// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ResultsAndCertificationConfiguration = ConfigurationLoader.Load( _config[Constants.EnvironmentNameConfigKey], _config[Constants.ConfigurationStorageConnectionStringConfigKey], _config[Constants.VersionConfigKey], _config[Constants.ServiceNameConfigKey]); //services.AddControllersWithViews(); //services.AddRazorPages(); services.AddApplicationInsightsTelemetry(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAntiforgery(options => { options.Cookie.Name = "tlevels-rc-x-csrf"; options.FormFieldName = "_csrfToken"; options.HeaderName = "X-XSRF-TOKEN"; }); services.AddMvc(config => { if (!_env.IsDevelopment()) { var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); config.Filters.Add(new AuthorizeFilter(policy)); } config.Filters.Add <AutoValidateAntiforgeryTokenAttribute>(); // TODO: Need to add custom exception filter config.Filters.Add <CustomExceptionFilterAttribute>(); }).SetCompatibilityVersion(CompatibilityVersion.Version_3_0); //services.AddSession(options => //{ // options.IdleTimeout = TimeSpan.FromMinutes(5); // options.Cookie.HttpOnly = true; // options.Cookie.SecurePolicy = CookieSecurePolicy.Always; //}); services.AddSingleton(ResultsAndCertificationConfiguration); services.AddHttpClient <ITokenRefresher, TokenRefresher>(); services.AddTransient <ITokenService, TokenService>(); services.AddTransient <ITokenServiceClient, TokenServiceClient>(); services.AddHttpClient <IResultsAndCertificationInternalApiClient, ResultsAndCertificationInternalApiClient>(); services .AddTransient <CustomCookieAuthenticationEvents>() //.AddTransient<AccessTokenHttpMessageHandler>() .AddHttpContextAccessor(); //services.AddHttpContextAccessor(); services.AddWebAuthentication(ResultsAndCertificationConfiguration, _logger, _env); services.AddAuthorization(); }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new ProviderTlevels { Id = 1, DisplayName = "Test1", Ukprn = _ukprn, Tlevels = new List <ProviderTlevel> { new ProviderTlevel { TqAwardingOrganisationId = 1, TlProviderId = 1, TlevelTitle = "Tlevel Title1" }, new ProviderTlevel { TqAwardingOrganisationId = 1, TlProviderId = 1, TlevelTitle = "Tlevel Title2" } } }; }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new AddLearnerRecordResponse { Uln = 1234567891, Name = "Test User", IsSuccess = true }; _model = new AddLearnerRecordRequest { Ukprn = 58974561, Uln = 1234567891, HasLrsEnglishAndMaths = false, EnglishAndMathsStatus = EnglishAndMathsStatus.AchievedWithSend, IndustryPlacementStatus = IndustryPlacementStatus.Completed, PerformedBy = "Test User" }; }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new AssessmentDetails { ProfileId = 1, Uln = 1234567890, Firstname = "John", Lastname = "Smith", ProviderUkprn = 1234567, ProviderName = "Test Provider", PathwayLarId = "7654321", PathwayName = "Pathway", PathwayAssessmentSeries = "Summer 2021", PathwayAssessmentId = 1, SpecialismLarId = "2345678", SpecialismName = "Specialism1", SpecialismAssessmentSeries = "Autumn 2022", SpecialismAssessmentId = 25, Status = RegistrationPathwayStatus.Active }; }
public override void Setup() { _configuration = new ResultsAndCertificationConfiguration { OrdnanceSurveyApiSettings = new OrdnanceSurveyApiSettings { PlacesUri = "http://os.api.com", PlacesKey = "test" } }; _mockHttpResult = new PostcodeLookupResult { AddressResult = new List <AddressResult> { new AddressResult { DeliveryPointAddress = new DeliveryPointAddress { Uprn = "1234567895", FormattedAddress = "Test line 1, Test line 2, Test town, xx1 1xx", OrganisationName = "Test org name", SubBuildingName = "Sub building", BuildingName = "Test building name", BuildingNumber = "Test line 1", ThroughfareName = "Test line 2", Town = "Test town", Postcode = "xx1 1xx" } } } }; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ResultsAndCertificationConfiguration = ConfigurationLoader.Load( Configuration[Constants.EnvironmentNameConfigKey], Configuration[Constants.ConfigurationStorageConnectionStringConfigKey], Configuration[Constants.VersionConfigKey], Configuration[Constants.ServiceNameConfigKey]); services.AddApplicationInsightsTelemetry(); services.AddControllers(); services.Configure <ApiBehaviorOptions>(options => { //options.SuppressModelStateInvalidFilter = true; options.InvalidModelStateResponseFactory = actionContext => { return(new BadRequestObjectResult(new BadRequestResponse(actionContext.ModelState))); }; }); RegisterDependencies(services); if (!_env.IsDevelopment()) { services.AddMvc(config => { config.Filters.Add(new AuthorizeFilter()); }); services.AddApiAuthentication(ResultsAndCertificationConfiguration).AddApiAuthorization(); } }
public RegistrationController(ResultsAndCertificationConfiguration configuration, ICsvHelperService <RegistrationCsvRecord, Registration, ImportResponseRecord <Registration> > csvParserService, IRegistrationService registrationService, IBlobStorageService blobStorageService) { _configuration = configuration; _csvParserService = csvParserService; _registrationService = registrationService; _blobStorageService = blobStorageService; }
public override void Setup() { _pathwayComponentGrade = LookupCategory.PathwayComponentGrade; _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new List <LookupData> { new LookupData { Id = 1, Code = "C1", Value = "V1" }, new LookupData { Id = 2, Code = "C2", Value = "V2" }, new LookupData { Id = 3, Code = "C3", Value = "V3" }, }; }
public TlevelHomeController(IHttpContextAccessor contextAccessor, ITokenService tokenService, IResultsAndCertificationInternalApiClient internalApiClient, ResultsAndCertificationConfiguration config) { _httpContextAccessor = contextAccessor; _tokenService = tokenService; _internalApiClient = internalApiClient; _config = config; }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new RegistrationDetails { ProfileId = 1, Uln = 1234567890, Firstname = "John", Lastname = "Smith", DateofBirth = DateTime.UtcNow, ProviderName = "Test Provider (1234567)", PathwayName = "Pathway (7654321)", Specialisms = new List <SpecialismDetails> { new SpecialismDetails { Code = "2345678", Name = "Specialism1" }, new SpecialismDetails { Code = "55567", Name = "Specialism2" } }, AcademicYear = 2020, Status = RegistrationPathwayStatus.Active }; }
public override void Given() { SeedTlevelTestData(); SeedNotificationTestData(); CreateMapper(); _verifyTlevelDetailsModel = new VerifyTlevelDetails { TqAwardingOrganisationId = _tqAwardingOrganisation.Id, PathwayStatusId = (int)TlevelReviewStatus.Queried, Query = "test", QueriedUserEmail = "*****@*****.**" }; _resultsAndCertificationConfiguration = new ResultsAndCertificationConfiguration { TlevelQueriedSupportEmailAddress = "*****@*****.**" }; _notificationsClient = Substitute.For <IAsyncNotificationClient>(); _notificationLogger = Substitute.For <ILogger <NotificationService> >(); _notificationTemplateRepository = Substitute.For <ILogger <GenericRepository <NotificationTemplate> > >(); IRepository <NotificationTemplate> notificationTemplateRepository = new GenericRepository <NotificationTemplate>(_notificationTemplateRepository, DbContext); _notificationService = new NotificationService(notificationTemplateRepository, _notificationsClient, _notificationLogger); _logger = Substitute.For <ILogger <IRepository <TqAwardingOrganisation> > >(); _service = new AwardingOrganisationService(_resultsAndCertificationConfiguration, Repository, _notificationService, _mapper, _logger); }
public OrdnanceSurveyApiClient(HttpClient httpClient, ResultsAndCertificationConfiguration configuration) { _httpClient = httpClient; _configuration = configuration; _httpClient.DefaultRequestHeaders.Accept.Clear(); _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new AddResultResponse { IsSuccess = true, Uln = 1234567890, ProfileId = 11 }; _model = new AddResultRequest { AoUkprn = 1, ProfileId = 11, AssessmentId = 1, LookupId = 1, ComponentType = Common.Enum.ComponentType.Core, PerformedBy = "Test User" }; }
public override void Setup() { _logger = Substitute.For <ILogger <IPersonalLearningRecordServiceApiClient> >(); _learnerServiceR9Client = Substitute.For <ILearnerServiceR9Client>(); _registrationLearnerDetails = new RegisteredLearnerDetails { Uln = 1234567890, Firstname = "First 1", Lastname = "Last 1", DateofBirth = DateTime.UtcNow.AddYears(-30) }; _configuration = new ResultsAndCertificationConfiguration { LearningRecordServiceSettings = new LearningRecordServiceSettings { VendorId = 1, Ukprn = "9856741231", Username = "******", Password = "******" } }; _mockHttpResult = new GetLearnerLearningEventsResponse { FoundULN = _registrationLearnerDetails.Uln.ToString(), IncomingULN = _registrationLearnerDetails.Uln.ToString(), LearnerRecord = new LearningEvent[] { new LearningEvent { Grade = "Pass", SubjectCode = "100/2510/8" }, new LearningEvent { Grade = "Fail", SubjectCode = "100/2508/X" } } }; }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new List <PathwayDetails> { new PathwayDetails { Id = 1, Name = "Test", Code = "10000111" }, new PathwayDetails { Id = 2, Name = "Display", Code = "10000112" } }; }
public override void Given() { _resultsAndCertificationConfiguration = new ResultsAndCertificationConfiguration { DfeSignInSettings = new DfeSignInSettings { Timeout = 2 } }; _timeoutController = new TimeoutController(_resultsAndCertificationConfiguration, CacheService); var httpContext = new ClaimsIdentityBuilder <TimeoutController>(_timeoutController) .Add(CustomClaimTypes.UserId, Guid.NewGuid().ToString()) .Build() .HttpContext; HttpContextAccessor.HttpContext.Returns(httpContext); CacheKey = CacheKeyHelper.GetCacheKey(HttpContextAccessor.HttpContext.User.GetUserId(), CacheConstants.UserSessionActivityCacheKey); var routeData = new RouteData(); routeData.Values.Add("controller", "Timeout"); routeData.Values.Add("action", nameof(TimeoutController.GetActiveDurationAsync)); var controllerActionDescriptor = new ControllerActionDescriptor { ControllerName = "Timeout", ActionName = nameof(TimeoutController.GetActiveDurationAsync) }; var actionContext = new ActionContext(HttpContextAccessor.HttpContext, routeData, controllerActionDescriptor); _actionExecutingContext = new ActionExecutingContext(actionContext, new List <IFilterMetadata>(), new Dictionary <string, object>(), _timeoutController); }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = true; _model = new ManageRegistration { ProfileId = 1, AoUkprn = 1234567890, FirstName = "First", LastName = "Last", DateOfBirth = "07/01/1987".ToDateTime(), ProviderUkprn = 98765432, CoreCode = "7654321", SpecialismCodes = new List <string> { "23456789", "7654321" }, PerformedBy = "Test User" }; }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockApiResponse = new LearnerRecordDetails { ProfileId = _profileId, Uln = _uln, Name = "Test User", DateofBirth = DateTime.UtcNow.AddYears(30), ProviderName = "Barnsley College (123456789)", PathwayName = "Course name (5689745)", IsLearnerRegistered = true, IsLearnerRecordAdded = false, IsEnglishAndMathsAchieved = true, HasLrsEnglishAndMaths = true, IsSendLearner = false, IndustryPlacementId = 7, IndustryPlacementStatus = Common.Enum.IndustryPlacementStatus.CompletedWithSpecialConsideration }; }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = new BulkAssessmentResponse { IsSuccess = false, BlobUniqueReference = Guid.NewGuid(), ErrorFileSize = 1.5 }; _model = new BulkProcessRequest { AoUkprn = _ukprn, BlobFileName = "assessmenttfile.csv", BlobUniqueReference = Guid.NewGuid() }; }
public PersonalLearningRecordServiceApiClient(ILogger <IPersonalLearningRecordServiceApiClient> logger, ILearnerServiceR9Client learnerServiceR9Client, ResultsAndCertificationConfiguration configuration) { _logger = logger; _learnerServiceR9Client = learnerServiceR9Client; _configuration = configuration; }
public StatementOfAchievementController(IStatementOfAchievementLoader statementOfAchievementLoader, IProviderAddressLoader providerAddress, ICacheService cacheService, ResultsAndCertificationConfiguration configuration, ILogger <StatementOfAchievementController> logger) { _statementOfAchievementLoader = statementOfAchievementLoader; _providerAddress = providerAddress; _cacheService = cacheService; _configuration = configuration; _logger = logger; }
public TokenRefresher( HttpClient httpClient, ResultsAndCertificationConfiguration resultsAndCertificationConfiguration, ILogger <TokenRefresher> logger) { _httpClient = httpClient; _resultsAndCertificationConfiguration = resultsAndCertificationConfiguration; _logger = logger; }
public override void Configure(IFunctionsHostBuilder builder) { _configuration = ConfigurationLoader.Load( Environment.GetEnvironmentVariable(Constants.EnvironmentNameConfigKey), Environment.GetEnvironmentVariable(Constants.ConfigurationStorageConnectionStringConfigKey), Environment.GetEnvironmentVariable(Constants.VersionConfigKey), Environment.GetEnvironmentVariable(Constants.ServiceNameConfigKey)); RegisterDependencies(builder.Services); }
public TokenRefresher( HttpClient httpClient, //IDiscoveryCache discoveryCache, ResultsAndCertificationConfiguration resultsAndCertificationConfiguration, ILogger <TokenRefresher> logger) { _httpClient = httpClient; //_discoveryCache = discoveryCache; _resultsAndCertificationConfiguration = resultsAndCertificationConfiguration; _logger = logger; }
public override void Setup() { _tokenServiceClient = Substitute.For <ITokenServiceClient>(); _configuration = new ResultsAndCertificationConfiguration { ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings { Uri = "http://tlevel.api.com" } }; _mockHttpResult = true; }
//public static IServiceCollection AddRequiredMvcComponents(this IServiceCollection services) //{ // return services; //} public static IServiceCollection AddApiAuthentication(this IServiceCollection services, ResultsAndCertificationConfiguration configuration) { //// configure jwt authentication //var key = Encoding.ASCII.GetBytes(configuration.DfeSignInSettings.APISecret); //services.AddAuthentication(x => //{ // x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; // x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; //}) //.AddJwtBearer(x => //{ // x.RequireHttpsMetadata = false; // x.SaveToken = true; // x.TokenValidationParameters = new TokenValidationParameters // { // ValidIssuer = configuration.DfeSignInSettings.Issuer, // ValidAudience = configuration.DfeSignInSettings.Audience, // ValidateIssuerSigningKey = true, // IssuerSigningKey = new SymmetricSecurityKey(key), // ValidateIssuer = true, // ValidateAudience = true, // ValidateLifetime = true, // ClockSkew = TimeSpan.Zero // }; //}); services .AddAuthentication(auth => { auth.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; //auth.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) //.AddAuthentication("Bearer") .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, auth => { auth.Authority = configuration.DfeSignInSettings.Authority; //auth.RequireHttpsMetadata = false; auth.Audience = "TLevelsRC"; //configuration.DfeSignInSettings.Audience; //auth.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters //{ // ValidateIssuer = false, // //ValidateAudience = true, // ValidateIssuerSigningKey = true, // IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII // .GetBytes(configuration.DfeSignInSettings.APISecret)), // //RequireExpirationTime = false //}; }); return(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ResultsAndCertificationConfiguration = ResultsAndCertificationConfigurationLoader.Load( Configuration[Constants.EnvironmentNameConfigKey], Configuration[Constants.ConfigurationStorageConnectionStringConfigKey], Configuration[Constants.VersionConfigKey], Configuration[Constants.ServiceNameConfigKey]); services.AddSingleton(ResultsAndCertificationConfiguration); services.AddTransient <IAsyncNotificationClient, NotificationClient>(provider => new NotificationClient(ResultsAndCertificationConfiguration.NotificationApiKey)); services.AddTransient <INotificationService, NotificationService>(); services.AddControllersWithViews(); }
public TlevelHomeController(IHttpContextAccessor contextAccessor, ITokenService tokenService, IResultsAndCertificationInternalApiClient internalApiClient, ILearnerServiceApiClient learnerServiceApiClient, IPersonalLearningRecordApiClient personalLearningRecordApiClient, ResultsAndCertificationConfiguration config) { _httpContextAccessor = contextAccessor; _tokenService = tokenService; _internalApiClient = internalApiClient; _learnerServiceApiClient = learnerServiceApiClient; _personalLearningRecordApiClient = personalLearningRecordApiClient; _config = config; }
public AwardingOrganisationService( ResultsAndCertificationConfiguration resultsAndCertificationConfiguration, IRepository <TqAwardingOrganisation> _repository, INotificationService notificationService, IMapper mapper, ILogger <IRepository <TqAwardingOrganisation> > logger) { _resultsAndCertificationConfiguration = resultsAndCertificationConfiguration; _awardingOrganisationRepository = _repository; _notificationService = notificationService; _mapper = mapper; _logger = logger; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ResultsAndCertificationConfiguration = ConfigurationLoader.Load( Configuration[Constants.EnvironmentNameConfigKey], Configuration[Constants.ConfigurationStorageConnectionStringConfigKey], Configuration[Constants.VersionConfigKey], Configuration[Constants.ServiceNameConfigKey]); services.AddControllers(); services.AddMvc(config => { //config.Filters.Add<ValidateModelAttribute>(); }).SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .ConfigureApiBehaviorOptions(options => { //options.SuppressConsumesConstraintForFormFileParameters = true; //options.SuppressInferBindingSourcesForParameters = true; //options.SuppressModelStateInvalidFilter = true; //options.SuppressMapClientErrors = true; }); services.Configure <ApiBehaviorOptions>(options => { //options.SuppressModelStateInvalidFilter = true; options.InvalidModelStateResponseFactory = actionContext => { return(new BadRequestObjectResult(new BadRequestResponse(actionContext.ModelState))); }; }); RegisterDependencies(services); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "ResultsAndCertification WebAPI", Version = "v1" }); //c.OperationFilter<SwaggerFileOperationFilter>(); //c.OperationFilter<FormFileSwaggerFilter>(); //// Set the comments path for the Swagger JSON and UI. //var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; //var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); //c.IncludeXmlComments(xmlPath); }); IdentityModelEventSource.ShowPII = true; services.AddApiAuthentication(ResultsAndCertificationConfiguration).AddApiAuthorization(); }