use of org.nhindirect.policy.PolicyExpression in project nhin-d by DirectProject.
the class TrustModel_isCertPolicyCompliantTest method testIsCertPolicyCompliant_missingRequiredField_assertFalse.
public void testIsCertPolicyCompliant_missingRequiredField_assertFalse() throws Exception {
final TrustModel model = new TrustModel();
final PolicyFilter filter = mock(PolicyFilter.class);
doThrow(new PolicyRequiredException("Just Passing Through")).when(filter).isCompliant((X509Certificate) any(), (PolicyExpression) any());
final PolicyResolver resolver = mock(PolicyResolver.class);
final PolicyExpression expression = mock(PolicyExpression.class);
when(resolver.getIncomingPolicy((InternetAddress) any())).thenReturn(Arrays.asList(expression));
model.setTrustPolicyResolver(resolver);
model.setPolicyFilter(filter);
final X509Certificate cert = mock(X509Certificate.class);
assertFalse(model.isCertPolicyCompliant(new InternetAddress("me@test.com"), cert));
}
use of org.nhindirect.policy.PolicyExpression in project nhin-d by DirectProject.
the class TrustModel_isCertPolicyCompliantTest method testIsCertPolicyCompliant_policyNotCompliant_assertFalse.
public void testIsCertPolicyCompliant_policyNotCompliant_assertFalse() throws Exception {
final TrustModel model = new TrustModel();
final PolicyFilter filter = mock(PolicyFilter.class);
when(filter.isCompliant((X509Certificate) any(), (PolicyExpression) any())).thenReturn(false);
final PolicyResolver resolver = mock(PolicyResolver.class);
final PolicyExpression expression = mock(PolicyExpression.class);
when(resolver.getIncomingPolicy((InternetAddress) any())).thenReturn(Arrays.asList(expression));
model.setTrustPolicyResolver(resolver);
model.setPolicyFilter(filter);
final X509Certificate cert = mock(X509Certificate.class);
assertFalse(model.isCertPolicyCompliant(new InternetAddress("me@test.com"), cert));
}
use of org.nhindirect.policy.PolicyExpression in project nhin-d by DirectProject.
the class DomainPolicyResolver_contstuctTest method testConstruct_differentForIncomingAndOutgoing_assertAttributes.
public void testConstruct_differentForIncomingAndOutgoing_assertAttributes() {
final PolicyExpression expression1 = mock(PolicyExpression.class);
final List<PolicyExpression> expressions1 = Arrays.asList(expression1);
final Map<String, Collection<PolicyExpression>> outgoingPolicies = new HashMap<String, Collection<PolicyExpression>>();
outgoingPolicies.put("testdomain.com", expressions1);
final PolicyExpression expression2 = mock(PolicyExpression.class);
final PolicyExpression expression3 = mock(PolicyExpression.class);
final List<PolicyExpression> expressions2 = Arrays.asList(expression2, expression3);
final Map<String, Collection<PolicyExpression>> incomingPolicies = new HashMap<String, Collection<PolicyExpression>>();
incomingPolicies.put("testdomain.com", expressions2);
final DomainPolicyResolver resolver = new DomainPolicyResolver(incomingPolicies, outgoingPolicies);
assertNotNull(resolver);
assertEquals(1, resolver.outgoingPolicies.size());
Collection<PolicyExpression> retrievedExpressions = resolver.outgoingPolicies.get("TESTDOMAIN.COM");
assertEquals(1, retrievedExpressions.size());
assertNotNull(retrievedExpressions);
assertEquals(1, resolver.incomingPolicies.size());
retrievedExpressions = resolver.incomingPolicies.get("TESTDOMAIN.COM");
assertEquals(2, retrievedExpressions.size());
assertNotNull(retrievedExpressions);
}
use of org.nhindirect.policy.PolicyExpression in project nhin-d by DirectProject.
the class DomainPolicyResolver_contstuctTest method testConstruct_sameForIncomingAndOutgoing_assertAttributes.
public void testConstruct_sameForIncomingAndOutgoing_assertAttributes() {
final PolicyExpression expression = mock(PolicyExpression.class);
final List<PolicyExpression> expressions = Arrays.asList(expression);
final Map<String, Collection<PolicyExpression>> policies = new HashMap<String, Collection<PolicyExpression>>();
policies.put("testdomain.com", expressions);
final DomainPolicyResolver resolver = new DomainPolicyResolver(policies);
assertNotNull(resolver);
assertEquals(1, resolver.incomingPolicies.size());
Collection<PolicyExpression> retrievedExpressions = resolver.incomingPolicies.get("TESTDOMAIN.COM");
assertNotNull(retrievedExpressions);
assertEquals(1, resolver.outgoingPolicies.size());
retrievedExpressions = resolver.outgoingPolicies.get("TESTDOMAIN.COM");
assertNotNull(retrievedExpressions);
}
use of org.nhindirect.policy.PolicyExpression in project nhin-d by DirectProject.
the class DomainPolicyResolver_getPolicyTest method testGetPolicy_outgoingPolicyDoesNotExist_assertEmpty.
public void testGetPolicy_outgoingPolicyDoesNotExist_assertEmpty() throws Exception {
final PolicyExpression expression = mock(PolicyExpression.class);
final List<PolicyExpression> expressions = Arrays.asList(expression);
final Map<String, Collection<PolicyExpression>> policies = new HashMap<String, Collection<PolicyExpression>>();
policies.put("testdomain.com", expressions);
final DomainPolicyResolver resolver = new DomainPolicyResolver(policies);
Collection<PolicyExpression> retrievedExpressions = resolver.getOutgoingPolicy(new InternetAddress("me@testdomainother.com"));
assertNotNull(retrievedExpressions);
assertEquals(0, retrievedExpressions.size());
}
Aggregations