public void OneTimeSetUp() { _testServer = new TestServer(); _httpClient = _testServer.CreateClient(); var secretsClient = new AmazonSecretsManagerClient(RegionEndpoint.USWest2); var secretResponse = secretsClient.GetSecretValueAsync(new GetSecretValueRequest { SecretId = TestUserSecretId }).Result; _testUserCreds = JsonConvert.DeserializeObject <TestUserCreds>(secretResponse.SecretString); _emailAdapter = new EmailAdapter(); _user = new AwsCognitoUser { FirstName = "test", LastName = "user", PhoneNumber = "+12223334444", UserName = _testUserCreds.TraceTestUserEmail, Password = _testUserCreds.TraceTestUserPassword }; var serviceProvider = _testServer.GetTestServiceProvider(); _authAdapter = serviceProvider.GetRequiredService <IAuthAdapter>(); _httpHandler = new HttpHandler(_clientConfig, _httpClient); _apiClient = new TraceApiClient(_httpHandler); }
public ListingController( IListingAdapter listingAdapter, IAuthAdapter authAdapter) { this.listingAdapter = listingAdapter; this.authAdapter = authAdapter; }
public void Setup() { _logger = Substitute.For <INpgLogger>(); _authAdapter = Substitute.For <IAuthAdapter>(); _userRepository = Substitute.For <IUserRepository>(); _accountsController = new AccountsController(_logger, _authAdapter, _userRepository); }
private OAuthAuthorization( IAuthAdapter adapter, ICredential initialCredential, UserInfo userInfo) { this.adapter = adapter; this.credential = new SwappableCredential(initialCredential, userInfo); }
/// <summary> /// Initializes a new instance of the <see cref="OrderController"/> class. /// </summary> /// <param name="orderAdapter">The order adapter.</param> public OrderController( IOrderAdapter orderAdapter, IPropertyAdapter propertyAdapter, IAuthAdapter authAdapter) { this.orderAdapter = orderAdapter; this.propertyAdapter = propertyAdapter; this.authAdapter = authAdapter; }
public SearchController( ISearchAdapter searchAdapter, IAuthAdapter authAdapter, IAccountAdapter accountAdapter) { this.searchAdapter = searchAdapter; this.authAdapter = authAdapter; this.accountAdapter = accountAdapter; }
/// <summary> /// Initializes a new instance of the <see cref="HomeController"/> class. /// </summary> public PropertyController( IAuthAdapter authAdapter, IPropertyFacade propertyFacade, IPropertyAdapter propertyAdapter) { this.authAdapter = authAdapter; this.propertyFacade = propertyFacade; this.propertyAdapter = propertyAdapter; }
private void AddAdapter(string providerName, IAuthAdapter adapter) { if (adapterDict.ContainsKey(providerName)) { adapterDict[providerName] = adapter; return; } adapterDict.Add(providerName, adapter); }
public PropertyController( IPropertyAdapter propertyAdapter, ISearchAdapter searchAdapter, IAuthAdapter authAdapter, IListingAdapter listingAdapter) { this.propertyAdapter = propertyAdapter; this.searchAdapter = searchAdapter; this.authAdapter = authAdapter; this.listingAdapter = listingAdapter; }
public void Setup() { _cognitoAdapterConfig = new AwsCognitoAdapterConfig { UserPoolId = "fake-userpool-id", ClientId = "fake-client-id" }; _awsCognitoClient = Substitute.For <IAmazonCognitoIdentityProvider>(); _cognitoAdapterHelper = Substitute.For <IAwsCognitoAdapterHelper>(); _authAdapter = new AwsCognitoAdapter(_awsCognitoClient, _cognitoAdapterConfig, _cognitoAdapterHelper); }
public void OneTimeSetUp() { _webAppFactory = new TestWebApplicationFactory(); _httpClient = _webAppFactory.CreateClient(); _testServiceProvider = _webAppFactory.GetTestServiceProvider(); _mockLogger = TestStartup.GetTestLogger(); _mockAuthAdapter = TestStartup.GetMockAuthAdapter(); _mockCognitoHelper = TestStartup.GetMockAuthHelper(); var createDbContext = _webAppFactory.GetRemindMeDatabaseContext(); createDbContext.ExecuteDatabaseMigration(); }
public bool CreateIDPAdapter(string providerName) { string authAdapterName = string.Format("{0}adapter", providerName); adapter = AdapterFactory.CreateAdapter <IAuthAdapter>(authAdapterName); if (adapter == null) { GamebaseLog.Warn(GamebaseStrings.AUTH_ADAPTER_NOT_FOUND, this, "CreateIDPAdapter"); return(false); } AddAdapter(providerName, adapter); return(true); }
public ListingController( IPropertyAdapter propertyAdapter, ISearchAdapter searchAdapter, IAuthAdapter authAdapter, IListingAdapter listingAdapter, IFeaturedAdapter featuredAdapter, IPropertyFacade propertyFacade) { this.propertyAdapter = propertyAdapter; this.searchAdapter = searchAdapter; this.authAdapter = authAdapter; this.listingAdapter = listingAdapter; this.featuredAdapter = featuredAdapter; this.propertyFacade = propertyFacade; }
public static async Task <OAuthAuthorization> CreateAuthorizationAsync( IAuthAdapter oauthAdapter, CancellationToken token) { TraceSources.Compute.TraceVerbose("Authorizing"); // Pop up browser window. var credential = await oauthAdapter.AuthorizeUsingBrowserAsync(token); var userInfo = await oauthAdapter.QueryUserInfoAsync( credential, token); return(new OAuthAuthorization( oauthAdapter, credential, userInfo)); }
public static async Task <OAuthAuthorization> TryLoadExistingAuthorizationAsync( IAuthAdapter oauthAdapter, CancellationToken token) { var existingTokenResponse = await oauthAdapter .GetStoredRefreshTokenAsync(token) .ConfigureAwait(false); if (oauthAdapter.IsRefreshTokenValid(existingTokenResponse)) { TraceSources.Common.TraceVerbose("Found existing credentials"); var scopesOfExistingTokenResponse = existingTokenResponse.Scope.Split(' '); if (!scopesOfExistingTokenResponse.ContainsAll(oauthAdapter.Scopes)) { TraceSources.Common.TraceVerbose( "Dropping existing credential as it lacks one or more scopes"); // The existing auth might be fine, but it lacks a scope. // Delete it so that it does not cause harm later. await oauthAdapter.DeleteStoredRefreshToken().ConfigureAwait(false); return(null); } else { var credential = oauthAdapter.AuthorizeUsingRefreshToken(existingTokenResponse); var userInfo = await oauthAdapter.QueryUserInfoAsync( credential, token).ConfigureAwait(false); return(new OAuthAuthorization( oauthAdapter, credential, userInfo)); } } else { return(null); } }
public override void ConfigureServices(IServiceCollection services) { base.ConfigureServices(services); var deployBucket = Configuration.GetSection("AWS").GetSection("S3")["DeployBucket"]; var testDbConnectionStringKey = Configuration.GetSection("AWS").GetSection("RDS")["AppDbConnectionStringKey"]; var provider = services.BuildServiceProvider(); var storageAdapter = provider.GetRequiredService <IStorageAdapter>(); _connectionString = storageAdapter.GetObjectAsync(deployBucket, testDbConnectionStringKey).Result; services .AddEntityFrameworkNpgsql() .AddDbContext <TestDatabaseContext>(options => options.UseNpgsql(_connectionString)); var mockLogger = Substitute.For <INpgLogger>(); services.AddSingleton(mockLogger); _mockLogger = mockLogger; var mockAuthAdapter = Substitute.For <IAuthAdapter>(); services.AddSingleton(mockAuthAdapter); _mockAuthAdapter = mockAuthAdapter; var mockCognitoHelper = Substitute.For <IAwsCognitoAdapterHelper>(); services.AddSingleton(mockCognitoHelper); _mockCognitoHelper = mockCognitoHelper; services.AddMvc() .AddApplicationPart(typeof(AccountsController).Assembly); _services = services; }
/// <summary> /// Initializes a new instance of the <see cref="PropertyAdapter"/> class. /// </summary> /// <param name="authAdapter">The auth adapter.</param> /// <param name="orderAdapter">The order adapter.</param> public PropertyAdapter(IAuthAdapter authAdapter, IOrderAdapter orderAdapter, IPropertyMailer mailer) { this.authAdapter = authAdapter; this.orderAdapter = orderAdapter; this.mailer = mailer; }
public UserController(IAppUserRepository userRepo, IAuthAdapter authAdapter) { _userRepo = userRepo; _authAdapter = authAdapter; }
public AuthController( IAuthAdapter authAdapter) { this.authAdapter = authAdapter; }
public AccountsController(INpgLogger logger, IAuthAdapter authAdapter, IUserRepository userRepository) { _logger = logger; _authAdapter = authAdapter; _userRepository = userRepository; }
public AuthServiceProvider(IAuthAdapter authAdapter) { this.AuthAdapter = authAdapter; }
public AccountController(IAppUserRepository userRepo, ILogger <AccountController> logger, IAuthAdapter authAdapter) { _logger = logger; _authAdapter = authAdapter; _userRepo = userRepo; }
public AccountsController(IAuthAdapter authAdapter) { _authAdapter = authAdapter; }