Ejemplo n.º 1
0
 /// <summary>
 /// Constructor for the EventService.
 /// </summary>
 /// <param name="context">A database ApplicationDbContext</param>
 /// <param name="applicationIdentityService">An instance of ApplicationIdentityService to retrieve users.</param>
 public EventService(
     EventDbContext context,
     IApplicationIdentityService applicationIdentityService)
 {
     _dbContext = context ?? throw new ArgumentNullException(nameof(context));
     _applicationIdentityService = applicationIdentityService ?? throw new ArgumentNullException(nameof(applicationIdentityService));
 }
Ejemplo n.º 2
0
 public ReportsController(
     IApplicationIdentityService applicationIdentityService,
     IProjectsService projectsService
     )
 {
     _projectsService            = projectsService ?? throw new ArgumentNullException(nameof(projectsService));
     _applicationIdentityService = applicationIdentityService ?? throw new ArgumentNullException(nameof(applicationIdentityService));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor for the PermissionService
 /// </summary>
 /// <param name="context">An ApplicationDbContext for data access</param>
 /// <param name="graphService">A GraphService instance for Microsoft Graph communication</param>
 /// <param name="eventService">An instance of the EventService for logging purposes</param>
 /// <param name="applicationIdentityService">An instance of the ApplicationIdentityService to resolve identities</param>
 public PermissionService(
     ApplicationDbContext context,
     IGraphService graphService,
     IEventService eventService,
     IApplicationIdentityService applicationIdentityService)
 {
     _dbContext = context ?? throw new ArgumentNullException(nameof(context));
     _applicationIdentityService = applicationIdentityService ?? throw new ArgumentNullException(nameof(applicationIdentityService));
     _graphService = graphService ?? throw new ArgumentNullException(nameof(graphService));
     _eventService = eventService ?? throw new ArgumentNullException(nameof(eventService));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor for the AssetService.
 /// </summary>
 /// <param name="context">A database <c>ApplicationDbContext</c></param>
 /// <param name="projectsService">An <c>IProjectsService</c> instance</param>
 public AssetService(ApplicationDbContext context,
                     IProjectsService projectsService,
                     IEncryptionService encryptionService,
                     IEventService eventService,
                     IApplicationIdentityService applicationIdentityService
                     )
 {
     _dbContext                  = context ?? throw new ArgumentNullException(nameof(context));
     _projectService             = projectsService ?? throw new ArgumentNullException(nameof(projectsService));
     _encryptionService          = encryptionService ?? throw new ArgumentNullException(nameof(encryptionService));
     _eventService               = eventService ?? throw new ArgumentNullException(nameof(eventService));
     _applicationIdentityService = applicationIdentityService ?? throw new ArgumentNullException(nameof(applicationIdentityService));
 }
 public AdminController(
     IPermissionService permissionService,
     IProjectsService projectsService,
     IApplicationIdentityService applicationIdentityService,
     IAssetService assetService,
     IConfiguration configuration
     )
 {
     _permissionService          = permissionService ?? throw new ArgumentNullException(nameof(permissionService));
     _projectsService            = projectsService ?? throw new ArgumentNullException(nameof(projectsService));
     _assetService               = assetService ?? throw new ArgumentNullException(nameof(assetService));
     _applicationIdentityService = applicationIdentityService ?? throw new ArgumentNullException(nameof(applicationIdentityService));
     _configuration              = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }
Ejemplo n.º 6
0
 public ProjectsController(
     IPermissionService permissionService,
     IProjectsService projectsService,
     IAssetService assetService,
     IGraphService graphService,
     IApplicationIdentityService applicationIdentityService
     )
 {
     _permissionService          = permissionService ?? throw new ArgumentNullException(nameof(permissionService));
     _projectsService            = projectsService ?? throw new ArgumentNullException(nameof(projectsService));
     _graphService               = graphService ?? throw new ArgumentNullException(nameof(graphService));
     _assetService               = assetService ?? throw new ArgumentNullException(nameof(assetService));
     _applicationIdentityService = applicationIdentityService ?? throw new ArgumentNullException(nameof(applicationIdentityService));
 }
        public IntegrationTestBase()
        {
            BuildTestConfiguration();
            _dbContext      = GetDbContext();
            _eventDbContext = GetEventDbContext();

            _testHttpContext                 = new DefaultHttpContext();
            _httpContextAccessor             = new HttpContextAccessor();
            _httpContextAccessor.HttpContext = _testHttpContext;
            _fakeHttpContextItems            = new Dictionary <object, object>();

            var memoryCache = new MemoryCache(new MemoryCacheOptions()
            {
            });
            var accessTokenRetriever = new TestAccessTokenRetriever();

            _graphService               = new MockGraphService();
            _encryptionService          = new EncryptionService();
            _applicationIdentityService = new ApplicationIdentityService(_dbContext, _graphService, _httpContextAccessor, _fakeHttpContextItems);
            _eventService               = new EventService(_eventDbContext, _applicationIdentityService);
            _permissionService          = new PermissionService(_dbContext, _graphService, _eventService, _applicationIdentityService);
            _projectsService            = new ProjectsService(_dbContext, _encryptionService, _eventService, _applicationIdentityService, _permissionService);
            _assetService               = new AssetService(_dbContext, _projectsService, _encryptionService, _eventService, _applicationIdentityService);

            _testUser = _applicationIdentityService.FindUserAsync(u => u.AzureAdObjectIdentifier == "TestAdObjectId11234567890").Result;
            if (_testUser == null)
            {
                _testUser = new ApplicationUser()
                {
                    DisplayName             = "Test User 123456789",
                    AzureAdObjectIdentifier = "TestAdObjectId11234567890",
                    TenantId              = "1234-12345-123",
                    AzureAdName           = "Test User Name",
                    AzureAdNameIdentifier = "123123kl21j3lk12j31",
                    Upn = "*****@*****.**",
                };

                _dbContext.ApplicationIdentities.Add(_testUser);
                _dbContext.SaveChanges();
                _testUser = _applicationIdentityService.FindUserAsync(u => u.AzureAdObjectIdentifier == "TestAdObjectId11234567890").Result;
            }
        }
Ejemplo n.º 8
0
        public ApplicationIdentityServiceTests()
        {
            BuildTestConfiguration();

            var memoryCache = new MemoryCache(new MemoryCacheOptions()
            {
            });
            var accessTokenRetriever = new TestAccessTokenRetriever();
            var telemetryService     = new MockTelemetryService();

            _graphService                    = new GraphService(memoryCache, _configuration, accessTokenRetriever, telemetryService);
            _testHttpContext                 = new DefaultHttpContext();
            _httpContextAccessor             = new HttpContextAccessor();
            _httpContextAccessor.HttpContext = _testHttpContext;

            var dbContextOptionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            dbContextOptionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            _dbContext = new ApplicationDbContext(dbContextOptionsBuilder.Options, false, true, false);

            _applicationIdentityService = new ApplicationIdentityService(_dbContext, _graphService, _httpContextAccessor);

            SetApplicationUser();
        }