public AppFixture() { _webAppFactory = new WebApplicationFactory <Startup>().WithWebHostBuilder(builder => { builder.UseEnvironment("IntegrationTesting"); builder.ConfigureAppConfiguration(configBuilder => { var config = configBuilder.Build(); var azureAdOptions = config.GetSection("AzureAd").Get <AzureAdOptions>(); var appAuthentication = config.GetSection("AppAuthenticationSetting").Get <AppAuthenticationSettings>(); var userAuthentication = config.GetSection("UserAuthenticationSettings").Get <UserAuthenticationSettings>(); var userAdmin = config.GetSection("UserAdmin").Get <UserAuthenticationSettingsDetails>(); var userRegular = config.GetSection("UserRegular").Get <UserAuthenticationSettingsDetails>(); var userNotInDatabase = config.GetSection("UserNotInDatabase").Get <UserAuthenticationSettingsDetails>(); var userNoRoles = config.GetSection("UserNoRoles").Get <UserAuthenticationSettingsDetails>(); var wrongRolesScopesComb = config.GetSection("WrongRolesScopesComb").Get <UserAuthenticationSettingsWrongRolesScopesComb>(); Settings = new IntegrationTestSettings { Authority = $@"{azureAdOptions.Authority}/v2.0", ApplicationIdUri = azureAdOptions.ApplicationIdUri, AppAuthentication = appAuthentication, UserAuthentication = userAuthentication, UserAdmin = userAdmin, UserRegular = userRegular, UserNotInDatabase = userNotInDatabase, UserNoRoles = userNoRoles, WrongRolesScopesComb = wrongRolesScopesComb }; }); }); Client = _webAppFactory.CreateDefaultClient(); }
public AccessTokenProvider(IntegrationTestSettings settings) { _settings = settings; _confidentialClientApp = ConfidentialClientApplicationBuilder .Create(settings.AppAuthentication.ClientId) .WithClientSecret(settings.AppAuthentication.ClientSecret) .WithAuthority(settings.Authority) .Build(); _client = new HttpClient(); }