public void testInjectRefereneValue_keyUsageDoesNotExist_notRequired_assertValue0() { var cert = new X509Certificate2(@"resources/certs/altNameOnly.der"); var field = new KeyUsageExtensionField(false); field.InjectReferenceValue(cert); field.GetPolicyValue().GetPolicyValue().Should().Be(0); }
public void TestInjectRefereneValue_NoInjection_GetPolicyValue_AssertException() { var field = new KeyUsageExtensionField(true); Action action = () => field.GetPolicyValue(); action.ShouldThrow <InvalidOperationException>(); }
public void testInjectRefereneValue_keyUsageDoesNotExist_required_assertException() { var cert = new X509Certificate2(@"resources/certs/altNameOnly.der"); var field = new KeyUsageExtensionField(true); Action action = () => field.InjectReferenceValue(cert); action.ShouldThrow<PolicyRequiredException>(); }
public void testInjectRefereneValue_keyUsageDoesNotExist_required_assertException() { var cert = new X509Certificate2(@"resources/certs/altNameOnly.der"); var field = new KeyUsageExtensionField(true); Action action = () => field.InjectReferenceValue(cert); action.ShouldThrow <PolicyRequiredException>(); }
public void testInjectRefereneValue_keyUsageExists_assertValue() { var cert = new X509Certificate2(@"resources/certs/[email protected]"); var field = new KeyUsageExtensionField(false); field.InjectReferenceValue(cert); var value = field.GetPolicyValue().GetPolicyValue(); (value & (int)KeyUsageBit.KeyEncipherment).Should().NotBe(0); (value & (int)KeyUsageBit.NonRepudiation).Should().NotBe(0); (value & (int)KeyUsageBit.DigitalSignature).Should().NotBe(0); }
public void CachingVerifyDisabledNullCacheSettings() { var policyIndex = new CertPolicyIndexStub(); var policyExpression = new KeyUsageExtensionField(false); var emailAddress = new MailAddress(Email); policyIndex.Add(emailAddress.Host, policyExpression); var resolver = new PolicyResolver(policyIndex, null); var source = resolver.GetIncomingPolicy(emailAddress); Assert.Null(resolver.Cache); Assert.True(source.Count > 0); }
private PolicyResolver CreateResolver(CacheSettings cacheSettings) { var policyIndex = new CertPolicyIndexStub(); var policyExpression = new KeyUsageExtensionField(false); var emailAddress = new MailAddress(Email); policyIndex.Add(emailAddress.Host, policyExpression); return(new PolicyResolver( policyIndex, new CacheSettings() { Name = cacheSettings.Name ?? TestCacheName, Cache = cacheSettings.Cache, NegativeCache = cacheSettings.NegativeCache, CacheTTLSeconds = cacheSettings.CacheTTLSeconds })); }
public void TestSerialize_SimpleExpression_ValidateExpression() { LiteralPolicyExpression<int> expr = new LiteralPolicyExpression<int>(new PolicyValue<int>((int) KeyUsageBit.DataEncipherment)); XMLLexiconPolicyParser parser = new XMLLexiconPolicyParser(expr); KeyUsageExtensionField extensionField = new KeyUsageExtensionField(true); List<IPolicyExpression> operands = new List<IPolicyExpression>(); operands.Add(expr); operands.Add(extensionField); IOperationPolicyExpression oper = new OperationPolicyExpression( PolicyOperator<int, int, bool>.EQUALS, operands); string xml = parser.Serialize(oper); Console.WriteLine(xml); }
public void TestSerialize_SimpleExpression_ValidateExpression() { LiteralPolicyExpression <int> expr = new LiteralPolicyExpression <int>(new PolicyValue <int>((int)KeyUsageBit.DataEncipherment)); XMLLexiconPolicyParser parser = new XMLLexiconPolicyParser(expr); KeyUsageExtensionField extensionField = new KeyUsageExtensionField(true); List <IPolicyExpression> operands = new List <IPolicyExpression>(); operands.Add(expr); operands.Add(extensionField); IOperationPolicyExpression oper = new OperationPolicyExpression( PolicyOperator <int, int, bool> .EQUALS, operands); string xml = parser.Serialize(oper); Console.WriteLine(xml); }
public void TestInjectRefereneValue_NoInjection_GetPolicyValue_AssertException() { var field = new KeyUsageExtensionField(true); Action action = () => field.GetPolicyValue(); action.ShouldThrow<InvalidOperationException>(); }