예제 #1
0
        public void CreateConfig_ReturnsExpectedResult()
        {
            // Arrange

            // Act
            var result = CredStashConfig.Default();

            // Assert
            Assert.Equal("credential-store", result.TableName);
            Assert.Equal("name", result.KeyName);
        }
예제 #2
0
        public CredStashReaderBuilder WithCredStashConfig(CredStashConfig credStashConfig)
        {
            if (credStashConfig == null)
            {
                throw new ArgumentNullException("credStashConfig");
            }

            _credStashConfig = credStashConfig;

            return(this);
        }
예제 #3
0
        public CredentialStorage(CredStashConfig credStashConfig, IAmazonDynamoDB ddbClient)
        {
            if (credStashConfig == null)
            {
                throw new ArgumentNullException("credStashConfig");
            }
            if (ddbClient == null)
            {
                throw new ArgumentNullException("ddbClient");
            }

            _credStashConfig = credStashConfig;
            _ddbClient       = ddbClient;
        }
예제 #4
0
        public void Build_ReturnsExpectedResult()
        {
            // Arrange
            var ddbClient       = Substitute.For <IAmazonDynamoDB>();
            var kmsClient       = Substitute.For <IAmazonKeyManagementService>();
            var credStashConfig = new CredStashConfig("tableName", "keyName");

            // Act
            var reader = CredStashReaderBuilder.New()
                         .WithDynamoDbClient(ddbClient)
                         .WithKeyManagementServiceClient(kmsClient)
                         .WithCredStashConfig(credStashConfig)
                         .Build();

            // Assert
            Assert.NotNull(reader);
        }
예제 #5
0
        public ICredStashReader Build()
        {
            if (_dynamoDbClient == null)
            {
                _dynamoDbClient = new AmazonDynamoDBClient();
            }
            if (_keyManagementServiceClient == null)
            {
                _keyManagementServiceClient = new AmazonKeyManagementServiceClient();
            }
            if (_credStashConfig == null)
            {
                _credStashConfig = CredStashConfig.Default();
            }

            var credentialStorage = new CredentialStorage(_credStashConfig, _dynamoDbClient);
            var masterKeyStorage  = new MasterKeyStorage(_keyManagementServiceClient);

            return(new CredStashReader(credentialStorage, masterKeyStorage, new HmacSha256Verifier(), new AesCrypto()));
        }