public AuditLogService(RegisterAuditLogSettings settings, IOrganisationRepository organisationRepository, ILookupDataRepository lookupDataRepository, IOrganisationStatusManager organisationStatusManager)
 {
     _settings = settings;
     _organisationRepository    = organisationRepository;
     _lookupDataRepository      = lookupDataRepository;
     _organisationStatusManager = organisationStatusManager;
 }
Exemple #2
0
 public void Before_each_test()
 {
     _organisationRepository = new Mock <IOrganisationRepository>();
     _lookupRepository       = new Mock <ILookupDataRepository>();
     _settings = new RegisterAuditLogSettings();
     _organisationStatusManager = new Mock <IOrganisationStatusManager>();
 }
        public void Before_each_test()
        {
            _firstOrganisation = new Organisation
            {
                Id           = Guid.NewGuid(),
                ProviderType = new ProviderType {
                    Id = 1, Type = "Main "
                },
                LegalName        = "Legal Name",
                OrganisationType = new OrganisationType {
                    Id = 0, Type = "Unassigned"
                },
                TradingName      = "Trading Name",
                UKPRN            = 10002233,
                OrganisationData = new OrganisationData {
                    CompanyNumber = "1111222"
                }
            };

            _secondOrganisation = new Organisation
            {
                Id               = _firstOrganisation.Id,
                ProviderType     = _firstOrganisation.ProviderType,
                LegalName        = _firstOrganisation.LegalName,
                OrganisationType = _firstOrganisation.OrganisationType,
                TradingName      = _firstOrganisation.TradingName,
                UKPRN            = _firstOrganisation.UKPRN,
                OrganisationData = new OrganisationData
                {
                    CompanyNumber = _firstOrganisation.OrganisationData.CompanyNumber
                },
                UpdatedAt = DateTime.Now,
                UpdatedBy = "Test"
            };

            _settings = new RegisterAuditLogSettings
            {
                IgnoredFields = new List <string>
                {
                    "CreatedBy", "CreatedAt", "UpdatedBy", "UpdatedAt"
                },
                DisplayNames = new List <AuditLogDisplayName>
                {
                    new AuditLogDisplayName
                    {
                        FieldName = "LegalName", DisplayName = "Legal Name"
                    },
                    new AuditLogDisplayName
                    {
                        FieldName = "OrganisationData.CompanyNumber", DisplayName = "Company Number"
                    }
                }
            };
        }
Exemple #4
0
 public void Before_each_test()
 {
     _organisationRepository = new Mock <IOrganisationRepository>();
     _settings             = new RegisterAuditLogSettings();
     _lookupDataRepository = new Mock <ILookupDataRepository>();
     _lookupDataRepository.Setup(x => x.GetOrganisationTypes()).ReturnsAsync(
         new List <OrganisationType>
     {
         new OrganisationType {
             Id = 0, Type = "Unassigned", Status = "Live", CreatedBy = "test", CreatedAt = DateTime.Now
         },
         new OrganisationType {
             Id = 1, Type = "School", Status = "Live", CreatedBy = "test", CreatedAt = DateTime.Now
         },
         new OrganisationType {
             Id = 2, Type = "GFE College", Status = "Live", CreatedBy = "test", CreatedAt = DateTime.Now
         },
     }
         );
 }
 public void Before_each_test()
 {
     _organisationRepository = new Mock <IOrganisationRepository>();
     _lookupRepository       = new Mock <ILookupDataRepository>();
     _settings = new RegisterAuditLogSettings();
     _lookupRepository.Setup(x => x.GetOrganisationStatuses()).ReturnsAsync(
         new List <OrganisationStatus>
     {
         new OrganisationStatus {
             Id = OrganisationStatus.Removed, Status = "Removed", CreatedBy = "test", CreatedAt = DateTime.Now
         },
         new OrganisationStatus {
             Id = OrganisationStatus.Active, Status = "Active", CreatedBy = "test", CreatedAt = DateTime.Now
         },
         new OrganisationStatus {
             Id = OrganisationStatus.ActiveNotTakingOnApprentices, Status = "Active - not taking on apprentices", CreatedBy = "test", CreatedAt = DateTime.Now
         },
         new OrganisationStatus {
             Id = OrganisationStatus.Onboarding, Status = "Onboarding", CreatedBy = "test", CreatedAt = DateTime.Now
         }
     }
         );
 }
Exemple #6
0
 public void Before_each_test()
 {
     _organisationRepository = new Mock <IOrganisationRepository>();
     _settings = new RegisterAuditLogSettings();
 }
Exemple #7
0
        public void ConfigureServices(IServiceCollection services)
        {
            try
            {
                services.AddAuthentication(o => { o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; })
                .AddJwtBearer(o =>
                {
                    o.Authority = $"https://login.microsoftonline.com/{Configuration.ApiAuthentication.TenantId}";
                    o.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
                    {
                        RoleClaimType  = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role",
                        ValidAudiences = Configuration.ApiAuthentication.Audience.Split(',')
                    };
                    o.Events = new JwtBearerEvents()
                    {
                        OnTokenValidated = context => { return(Task.FromResult(0)); }
                    };
                });

                services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; });

                services.Configure <RequestLocalizationOptions>(options =>
                {
                    options.DefaultRequestCulture = new RequestCulture("en-GB");
                    options.SupportedCultures     = new List <CultureInfo> {
                        new CultureInfo("en-GB")
                    };
                    options.SupportedUICultures = new List <CultureInfo> {
                        new CultureInfo("en-GB")
                    };
                    options.RequestCultureProviders.Clear();
                });

                var auditLogSettings = new RegisterAuditLogSettings();
                ApplicationConfiguration.Bind("RegisterAuditLogSettings", auditLogSettings);
                services.AddSingleton(auditLogSettings);

                services.AddHealthChecks();
                IMvcBuilder mvcBuilder;
                if (_env.IsDevelopment())
                {
                    mvcBuilder = services.AddMvc(opt => { opt.Filters.Add(new AllowAnonymousFilter()); });
                }
                else
                {
                    mvcBuilder = services.AddMvc();
                }

                mvcBuilder
                .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix,
                                     opts => { opts.ResourcesPath = "Resources"; })
                .AddDataAnnotationsLocalization()
                .AddControllersAsServices()
                .AddFluentValidation(fvc => fvc.RegisterValidatorsFromAssemblyContaining <Startup>());

                services.AddSwaggerGen(c =>
                {
                    c.SwaggerDoc("v1", new Info {
                        Title = "SFA.DAS.RoATPService.Application.Api", Version = "v1"
                    });

                    if (_env.IsDevelopment())
                    {
                        var basePath = AppContext.BaseDirectory;
                        var xmlPath  = Path.Combine(basePath, "SFA.DAS.RoATPService.Application.Api.xml");
                        c.IncludeXmlComments(xmlPath);
                    }
                });

                ConfigureDependencyInjection(services);

                if (_env.IsDevelopment())
                {
                    // TestDataService.AddTestData(serviceProvider.GetService<AssessorDbContext>());
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error during Startup Configure Services");
                throw;
            }
        }