public void IsAuthenticatedSuccessTest()
        {
            // Arrange
            IUserService userService = Substitute.For <IUserService>();

            userService.IsValidUser(Arg.Any <User>()).Returns(true);
            ISecretManagementService secretManagementService = Substitute.For <ISecretManagementService>();

            secretManagementService.GetKeyVaultSecret(Arg.Any <string>()).Returns(Task.FromResult("very_long_token_secret"));
            IOptions <TokenPayload> options = Options.Create(new TokenPayload {
                Secret            = string.Empty,
                Issuer            = string.Empty,
                Audience          = string.Empty,
                AccessExpiration  = 1,
                RefreshExpiration = 1
            });
            IAuthenticateService authenticateService = new AuthenticateService(userService, secretManagementService, options);
            User user = new User {
                Username = "******"
            };
            string token;

            // Act
            bool success = authenticateService.IsAuthenticated(user, out token);

            // Assert
            success.Should().Be(true);
        }
Exemple #2
0
 public AuthenticateService(
     IUserService userService,
     ISecretManagementService secretManagementService,
     IOptions <TokenPayload> tokenPayload)
 {
     _userService             = userService;
     _secretManagementService = secretManagementService;
     _tokenPayload            = tokenPayload.Value;
 }
 public GetStockLocationsFromVanessa(
     ISecretManagementService secretManagementService,
     IOptions <PersistenceAdapterSettings> adapterOptions,
     ILogger <GetStockLocationsFromVanessa> logger)
 {
     _secretManagementService = secretManagementService;
     _logger  = logger;
     _options = adapterOptions.Value;
     _logger.LogDebug("Query built.");
 }
        public void IsAuthenticatedFailureTest()
        {
            // Arrange
            IUserService userService = Substitute.For <IUserService>();

            userService.IsValidUser(Arg.Any <User>()).Returns(false);
            ISecretManagementService secretManagementService = Substitute.For <ISecretManagementService>();
            IOptions <TokenPayload>  options = Options.Create(new TokenPayload {
                Secret            = string.Empty,
                Issuer            = string.Empty,
                Audience          = string.Empty,
                AccessExpiration  = 1,
                RefreshExpiration = 1
            });
            IAuthenticateService authenticateService = new AuthenticateService(userService, secretManagementService, options);
            User   user = new User();
            string token;

            // Act
            bool success = authenticateService.IsAuthenticated(user, out token);

            // Assert
            success.Should().Be(false);
        }
Exemple #5
0
 public Startup(IConfiguration configuration, ISecretManagementService secretManagementService)
 {
     Configuration            = configuration;
     _secretManagementService = secretManagementService;
 }