public void SetUp()
        {
            var hostname = Environment.GetEnvironmentVariable("keyvaultHostname");

            _client = new KeyClient(new Uri(hostname ?? throw new ArgumentException()), new DefaultAzureCredential());
            _storer = new KeyVaultKeyStorer(_client, _loggerFactory.CreateLogger <KeyVaultKeyStorer>());
        }
Ejemplo n.º 2
0
        public void DeleteKeyFromVault_Purge_CompletelyRemovedKey()
        {
            var storeLogger = _loggerFactory.CreateLogger <KeyVaultKeyStorer>();
            var storer      = new KeyVaultKeyStorer(_client, storeLogger);

            var deleteLogger = _loggerFactory.CreateLogger <KeyVaultKeyDeleter>();
            var deleter      = new KeyVaultKeyDeleter(_client, deleteLogger);

            storer.Store(_keyName, KeyType.Ec);

            deleter.Delete(new KeyVaultKeyDeleteEvent
            {
                Name  = _keyName,
                Purge = true
            });

            Action action = () => _client.GetKey(_keyName);

            action.Should().ThrowExactly <RequestFailedException>().Where(e =>
                                                                          e.Message.Contains($"A key with (name/id) {_keyName} was not found in this key vault.",
                                                                                             StringComparison.InvariantCultureIgnoreCase));
            action = () => _client.GetDeletedKey(_keyName);

            action.Should().ThrowExactly <RequestFailedException>();
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            var hostname = Environment.GetEnvironmentVariable("keyvaultHostname");

            KeyName = Guid.NewGuid().ToString();

            _client = new KeyClient(new Uri(hostname ?? throw new ArgumentException()), new DefaultAzureCredential());
            Key     = _client.CreateKey(KeyName, KeyType.Rsa, new CreateRsaKeyOptions(KeyName)).Value;
            _storer = new KeyVaultKeyStorer(_client, _loggerFactory.CreateLogger <KeyVaultKeyStorer>());

            _encryptor = new KeyVaultKeyEncryptor(_loggerFactory.CreateLogger <KeyVaultKeyEncryptor>(),
                                                  new CryptographyClientFactory(new DefaultAzureCredential()), _client);
        }
Ejemplo n.º 4
0
        public void DeleteKeyFromVault_NoPurge_ReturnsDeletedKey()
        {
            var storeLogger = _loggerFactory.CreateLogger <KeyVaultKeyStorer>();
            var storer      = new KeyVaultKeyStorer(_client, storeLogger);

            var deleteLogger = _loggerFactory.CreateLogger <KeyVaultKeyDeleter>();
            var deleter      = new KeyVaultKeyDeleter(_client, deleteLogger);

            storer.Store(_keyName, KeyType.Ec);

            deleter.Delete(new KeyVaultKeyDeleteEvent
            {
                Name  = _keyName,
                Purge = false
            });

            _client.GetDeletedKey(_keyName).Value.Should().NotBeNull();
        }
 public KeyVaultKeyStoreController(KeyVaultKeyStorer keyStorer, ILogger<KeyVaultKeyStoreController> logger)
 {
     _keyStorer = keyStorer;
     _logger = logger;
 }