예제 #1
0
    public void RevokeKey_CallsInternalManager()
    {
        // Arrange
        var            keyToRevoke            = new Guid("a11f35fc-1fed-4bd4-b727-056a63b70932");
        DateTimeOffset minRevocationDate      = DateTimeOffset.UtcNow;
        DateTimeOffset?actualRevocationDate   = null;
        var            mockInternalKeyManager = new Mock <IInternalXmlKeyManager>();

        mockInternalKeyManager
        .Setup(o => o.RevokeSingleKey(keyToRevoke, It.IsAny <DateTimeOffset>(), "Here's some reason text."))
        .Callback <Guid, DateTimeOffset, string>((innerKeyId, innerRevocationDate, innerReason) =>
        {
            actualRevocationDate = innerRevocationDate;
        });

        var options = Options.Create(new KeyManagementOptions()
        {
            AuthenticatedEncryptorConfiguration = new Mock <AlgorithmConfiguration>().Object,
            XmlRepository = new Mock <IXmlRepository>().Object,
            XmlEncryptor  = null
        });
        var keyManager = new XmlKeyManager(options, SimpleActivator.DefaultWithoutServices, NullLoggerFactory.Instance, mockInternalKeyManager.Object);

        // Act
        keyManager.RevokeKey(keyToRevoke, "Here's some reason text.");

        // Assert
        Assert.InRange(actualRevocationDate.Value, minRevocationDate, DateTimeOffset.UtcNow);
    }
예제 #2
0
 public void RevokeKey(Guid keyId, string reason = null)
 => _wrapped.RevokeKey(keyId, reason);