public void RevokeAllKeys() { // Arrange XElement elementStoredInRepository = null; string friendlyNameStoredInRepository = null; var mockXmlRepository = new Mock <IXmlRepository>(); mockXmlRepository .Setup(o => o.StoreElement(It.IsAny <XElement>(), It.IsAny <string>())) .Callback <XElement, string>((el, friendlyName) => { elementStoredInRepository = el; friendlyNameStoredInRepository = friendlyName; }); var options = Options.Create(new KeyManagementOptions() { AuthenticatedEncryptorConfiguration = new Mock <AlgorithmConfiguration>().Object, XmlRepository = mockXmlRepository.Object, XmlEncryptor = null }); var keyManager = new XmlKeyManager(options, SimpleActivator.DefaultWithoutServices, NullLoggerFactory.Instance); var revocationDate = XmlConvert.ToDateTimeOffset("2015-03-01T19:13:19.7573854-08:00"); // Act & assert // The cancellation token should not already be fired var firstCancellationToken = keyManager.GetCacheExpirationToken(); Assert.False(firstCancellationToken.IsCancellationRequested); // After the call to RevokeAllKeys, the first CT should be fired, // and we should've gotten a new CT. keyManager.RevokeAllKeys(revocationDate, "Here's some reason text."); var secondCancellationToken = keyManager.GetCacheExpirationToken(); Assert.True(firstCancellationToken.IsCancellationRequested); Assert.False(secondCancellationToken.IsCancellationRequested); // Was the correct element stored in the repository? const string expectedRepositoryXml = @" <revocation version='1'> <revocationDate>2015-03-01T19:13:19.7573854-08:00</revocationDate> <!--All keys created before the revocation date are revoked.--> <key id='*' /> <reason>Here's some reason text.</reason> </revocation>"; XmlAssert.Equal(expectedRepositoryXml, elementStoredInRepository); Assert.Equal("revocation-20150302T0313197573854Z", friendlyNameStoredInRepository); }
public void RevokeAllKeys(DateTimeOffset revocationDate, string reason = null) => _wrapped.RevokeAllKeys(revocationDate, reason);