public IActionResult Post(KeyVaultCertificateAddEvent @event) { _logger.LogInformation("Processing event: {Event}", @event.ToString()); var addedCertificate = _certificateAdder.Add(@event.Name, @event.Enabled, @event.Tags); return(Created("", addedCertificate)); }
public void Add_AddsCertificate() { _adder.Add(CertificateName); var certificate = _client.GetCertificate(CertificateName).Value; certificate.Should().NotBeNull(); certificate.Name.Should().Be(CertificateName); }
public void Delete_NoPurge_AddCertificateToDeletedCertificates() { var deleteLogger = _loggerFactory.CreateLogger <KeyVaultCertificateDeleter>(); var addLogger = _loggerFactory.CreateLogger <KeyVaultCertificateAdder>(); var adder = new KeyVaultCertificateAdder(_client, addLogger); adder.Add(_certificateName); var deleter = new KeyVaultCertificateDeleter(_client, deleteLogger); deleter.Delete(new KeyVaultCertificateDeleteEvent { Name = _certificateName }); _client.GetDeletedCertificate(_certificateName).Value.Should().NotBeNull(); }
public void Delete_Purge_CompletelyRemovedCertificate() { var deleteLogger = _loggerFactory.CreateLogger <KeyVaultCertificateDeleter>(); var addLogger = _loggerFactory.CreateLogger <KeyVaultCertificateAdder>(); var adder = new KeyVaultCertificateAdder(_client, addLogger); adder.Add(_certificateName); var deleter = new KeyVaultCertificateDeleter(_client, deleteLogger); deleter.Delete(new KeyVaultCertificateDeleteEvent { Name = _certificateName, Purge = true }); Action action = () => _client.GetCertificate(_certificateName); action.Should().ThrowExactly <RequestFailedException>().Where(e => e.Message.Contains($"A certificate with (name/id) {_certificateName} was not found in this key vault.", StringComparison.InvariantCultureIgnoreCase)); action = () => _client.GetDeletedCertificate(_certificateName); action.Should().ThrowExactly <RequestFailedException>(); }