public FilesControllerTests()
        {
            //TODO NInject or some other resolvers.
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupCodeServicesClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);

            _fileServicesClient = fileServicesClient;
            var lookupService   = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());

            _agencyIdentifierId = fileServices.Configuration.GetNonEmptyValue("Request:AgencyIdentifierId");
            _partId             = fileServices.Configuration.GetNonEmptyValue("Request:PartId");
            var claims = new[] {
                new Claim(CustomClaimTypes.JcParticipantId, _partId),
                new Claim(CustomClaimTypes.JcAgencyCode, _agencyIdentifierId),
            };
            var identity  = new ClaimsIdentity(claims, "Cookies");
            var principal = new ClaimsPrincipal(identity);

            var filesService = new FilesService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService(), principal);

            //TODO fake this.
            var vcCivilFileAccessHandler = new VcCivilFileAccessHandler(new ScvDbContext());

            _controller = new FilesController(fileServices.Configuration, fileServices.LogFactory.CreateLogger <FilesController>(), filesService, vcCivilFileAccessHandler);
            _controller.ControllerContext = HttpResponseTest.SetupMockControllerContext(fileServices.Configuration);
        }
        public CourtListControllerTests()
        {
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupCodeServicesClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);
            var lookupService         = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService       = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());

            var claims = new[] {
                new Claim(CustomClaimTypes.JcParticipantId, fileServices.Configuration.GetNonEmptyValue("Request:PartId")),
                new Claim(CustomClaimTypes.JcAgencyCode, fileServices.Configuration.GetNonEmptyValue("Request:AgencyIdentifierId")),
            };
            var identity  = new ClaimsIdentity(claims, "Cookies");
            var principal = new ClaimsPrincipal(identity);

            var courtListService = new CourtListService(fileServices.Configuration, fileServices.LogFactory.CreateLogger <CourtListService>(), fileServicesClient, new Mapper(), lookupService, locationService, new CachingService(), principal);

            _controller = new CourtListController(courtListService)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext(fileServices.Configuration)
            };
        }
Esempio n. 3
0
 public FilesService(IConfiguration configuration, FileServicesClient filesClient, IMapper mapper, LookupService lookupService, LocationService locationService, IAppCache cache)
 {
     _filesClient = filesClient;
     _filesClient.JsonSerializerSettings.ContractResolver = new SafeContractResolver {
         NamingStrategy = new CamelCaseNamingStrategy()
     };
     _cache = cache;
     _cache.DefaultCachePolicy.DefaultCacheDurationSeconds = int.Parse(configuration.GetNonEmptyValue("Caching:FileExpiryMinutes")) * 60;
     Civil    = new CivilFilesService(configuration, filesClient, mapper, lookupService, locationService, _cache);
     Criminal = new CriminalFilesService(configuration, filesClient, mapper, lookupService, locationService, _cache);
 }
 public CivilFilesService(IConfiguration configuration, FileServicesClient filesClient, IMapper mapper, LookupService lookupService, LocationService locationService, IAppCache cache)
 {
     _filesClient = filesClient;
     _filesClient.JsonSerializerSettings.ContractResolver = new SafeContractResolver {
         NamingStrategy = new CamelCaseNamingStrategy()
     };
     _lookupService             = lookupService;
     _locationService           = locationService;
     _mapper                    = mapper;
     _requestApplicationCode    = configuration.GetNonEmptyValue("Request:ApplicationCd");
     _requestAgencyIdentifierId = configuration.GetNonEmptyValue("Request:AgencyIdentifierId");
     _requestPartId             = configuration.GetNonEmptyValue("Request:PartId");
     _cache = cache;
 }
        public FilesControllerTests()
        {
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupServiceClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);
            var lookupService         = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService       = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());
            var filesService          = new FilesService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService());

            _controller = new FilesController(fileServices.Configuration, fileServices.LogFactory.CreateLogger <FilesController>(), filesService);
            _controller.ControllerContext = HttpResponseTest.SetupMockControllerContext();
        }
 public CriminalFilesService(IConfiguration configuration, FileServicesClient filesClient, IMapper mapper, LookupService lookupService, LocationService locationService, IAppCache cache,
                             ClaimsPrincipal user)
 {
     _filesClient = filesClient;
     _filesClient.JsonSerializerSettings.ContractResolver = new SafeContractResolver {
         NamingStrategy = new CamelCaseNamingStrategy()
     };
     _lookupService             = lookupService;
     _locationService           = locationService;
     _mapper                    = mapper;
     _applicationCode           = user.ApplicationCode();
     _requestAgencyIdentifierId = user.AgencyCode();
     _requestPartId             = user.ParticipantId();
     _cache = cache;
 }
Esempio n. 7
0
        public CourtListService(IConfiguration configuration, FileServicesClient filesClient, IMapper mapper, LookupService lookupService, LocationService locationService, IAppCache cache)
        {
            _filesClient = filesClient;
            _filesClient.JsonSerializerSettings.ContractResolver = new SafeContractResolver {
                NamingStrategy = new CamelCaseNamingStrategy()
            };
            _cache = cache;
            _cache.DefaultCachePolicy.DefaultCacheDurationSeconds = int.Parse(configuration.GetNonEmptyValue("Caching:FileExpiryMinutes")) * 60;
            _mapper = mapper;

            _lookupService             = lookupService;
            _locationService           = locationService;
            _requestApplicationCode    = configuration.GetNonEmptyValue("Request:ApplicationCd");
            _requestAgencyIdentifierId = configuration.GetNonEmptyValue("Request:AgencyIdentifierId");
            _requestPartId             = configuration.GetNonEmptyValue("Request:PartId");
        }
        public CourtListControllerTests()
        {
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupServiceClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);
            var lookupService         = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService       = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());
            var courtListService      = new CourtListService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService());

            _controller = new CourtListController(courtListService)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext()
            };
        }
Esempio n. 9
0
        public CourtListService(IConfiguration configuration, ILogger <CourtListService> logger, FileServicesClient filesClient, IMapper mapper, LookupService lookupService, LocationService locationService, IAppCache cache, ClaimsPrincipal user)
        {
            _logger      = logger;
            _filesClient = filesClient;
            _filesClient.JsonSerializerSettings.ContractResolver = new SafeContractResolver {
                NamingStrategy = new CamelCaseNamingStrategy()
            };
            _cache = cache;
            _cache.DefaultCachePolicy.DefaultCacheDurationSeconds = int.Parse(configuration.GetNonEmptyValue("Caching:FileExpiryMinutes")) * 60;
            _mapper = mapper;

            _lookupService             = lookupService;
            _locationService           = locationService;
            _applicationCode           = user.ApplicationCode();
            _requestAgencyIdentifierId = user.AgencyCode();
            _requestPartId             = user.ParticipantId();
        }
Esempio n. 10
0
        public FilesService(IConfiguration configuration,
                            FileServicesClient filesClient,
                            IMapper mapper,
                            LookupService lookupService,
                            LocationService locationService,
                            IAppCache cache,
                            ClaimsPrincipal claimsPrincipal)
        {
            _filesClient = filesClient;
            _filesClient.JsonSerializerSettings.ContractResolver = new SafeContractResolver {
                NamingStrategy = new CamelCaseNamingStrategy()
            };
            _cache = cache;
            _cache.DefaultCachePolicy.DefaultCacheDurationSeconds = int.Parse(configuration.GetNonEmptyValue("Caching:FileExpiryMinutes")) * 60;
            Civil    = new CivilFilesService(configuration, filesClient, mapper, lookupService, locationService, _cache, claimsPrincipal);
            Criminal = new CriminalFilesService(configuration, filesClient, mapper, lookupService, locationService, _cache, claimsPrincipal);

            _applicationCode           = configuration.GetNonEmptyValue("Request:ApplicationCd");
            _requestAgencyIdentifierId = claimsPrincipal.AgencyCode();
            _requestPartId             = claimsPrincipal.ParticipantId();
        }
        public async Task FileServiceCorsTest()
        {
            // Create resource group
            var rgName = await CreateResourceGroupAsync();

            string accountName = Recording.GenerateAssetName("sto");

            // Create storage account
            StorageAccount account = await CreateStorageAccountAsync(rgName, accountName);

            VerifyAccountProperties(account, true);

            // implement case
            Response <FileServiceProperties> properties1 = await FileServicesClient.GetServicePropertiesAsync(rgName, accountName);

            Assert.AreEqual(0, properties1.Value.Cors.CorsRulesValue.Count());

            properties1.Value.Cors = new CorsRules
            {
                CorsRulesValue =
                {
                    new CorsRule(allowedOrigins: new string[]                     { "http://www.contoso.com", "http://www.fabrikam.com"    },
                                 allowedMethods: new CorsRuleAllowedMethodsItem[] { "GET",                    "HEAD", "POST", "OPTIONS", "MERGE", "PUT"},
                                 maxAgeInSeconds: 100,
                                 exposedHeaders: new string[]                     { "x-ms-meta-*" },
                                 allowedHeaders: new string[]                     { "x-ms-meta-abc",          "x-ms-meta-data*", "x-ms-meta-target*"}),

                    new CorsRule(allowedOrigins: new string[]                     { "*" },
                                 allowedMethods: new CorsRuleAllowedMethodsItem[] { "GET" },
                                 maxAgeInSeconds: 2,
                                 exposedHeaders: new string[]                     { "*" },
                                 allowedHeaders: new string[]                     { "*" }),

                    new CorsRule(allowedOrigins: new string[]                     { "http://www.abc23.com",   "https://www.fabrikam.com/*" },
                                 allowedMethods: new CorsRuleAllowedMethodsItem[] { "GET",                    "PUT", "CONNECT"             },
                                 maxAgeInSeconds: 2000,
                                 exposedHeaders: new string[]                     { "x-ms-meta-abc",          "x-ms-meta-data*", "x -ms-meta-target*"},
                                 allowedHeaders: new string[]                     { "x-ms-meta-12345675754564*" })
                }
            };

            Response <FileServiceProperties> properties3 = await FileServicesClient.SetServicePropertiesAsync(rgName, accountName, properties1.Value);

            //Validate CORS Rules
            Assert.AreEqual(properties1.Value.Cors.CorsRulesValue.Count, properties3.Value.Cors.CorsRulesValue.Count);
            for (int i = 0; i < properties1.Value.Cors.CorsRulesValue.Count; i++)
            {
                CorsRule putRule = properties1.Value.Cors.CorsRulesValue[i];
                CorsRule getRule = properties3.Value.Cors.CorsRulesValue[i];

                Assert.AreEqual(putRule.AllowedHeaders, getRule.AllowedHeaders);
                Assert.AreEqual(putRule.AllowedMethods, getRule.AllowedMethods);
                Assert.AreEqual(putRule.AllowedOrigins, getRule.AllowedOrigins);
                Assert.AreEqual(putRule.ExposedHeaders, getRule.ExposedHeaders);
                Assert.AreEqual(putRule.MaxAgeInSeconds, getRule.MaxAgeInSeconds);
            }

            Response <FileServiceProperties> properties4 = await FileServicesClient.GetServicePropertiesAsync(rgName, accountName);

            //Validate CORS Rules
            Assert.AreEqual(properties1.Value.Cors.CorsRulesValue.Count, properties4.Value.Cors.CorsRulesValue.Count);
            for (int i = 0; i < properties1.Value.Cors.CorsRulesValue.Count; i++)
            {
                CorsRule putRule = properties1.Value.Cors.CorsRulesValue[i];
                CorsRule getRule = properties4.Value.Cors.CorsRulesValue[i];

                Assert.AreEqual(putRule.AllowedHeaders, getRule.AllowedHeaders);
                Assert.AreEqual(putRule.AllowedMethods, getRule.AllowedMethods);
                Assert.AreEqual(putRule.AllowedOrigins, getRule.AllowedOrigins);
                Assert.AreEqual(putRule.ExposedHeaders, getRule.ExposedHeaders);
                Assert.AreEqual(putRule.MaxAgeInSeconds, getRule.MaxAgeInSeconds);
            }
        }