use of org.nhindirect.policy.x509.CertificatePolicyIndentifierExtensionField in project nhin-d by DirectProject.
the class CertificatePolicyIndentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_policyDoesNotExist_notRequired_assertValueEmpty.
public void testInjectRefereneValue_policyDoesNotExist_notRequired_assertValueEmpty() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("altNameOnly.der");
final CertificatePolicyIndentifierExtensionField field = new CertificatePolicyIndentifierExtensionField(false);
field.injectReferenceValue(cert);
assertTrue(field.getPolicyValue().getPolicyValue().isEmpty());
}
use of org.nhindirect.policy.x509.CertificatePolicyIndentifierExtensionField in project nhin-d by DirectProject.
the class CertificatePolicyIndentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_policyExists_assertValue.
public void testInjectRefereneValue_policyExists_assertValue() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("CernerDirectProviderCA.der");
final CertificatePolicyIndentifierExtensionField field = new CertificatePolicyIndentifierExtensionField(false);
field.injectReferenceValue(cert);
Collection<String> usages = field.getPolicyValue().getPolicyValue();
assertFalse(field.getPolicyValue().getPolicyValue().isEmpty());
assertTrue(usages.contains("2.16.840.1.113883.3.1313.0.1"));
}
use of org.nhindirect.policy.x509.CertificatePolicyIndentifierExtensionField in project nhin-d by DirectProject.
the class CertificatePolicyIndentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_policyDoesNotExist_required_assertException.
public void testInjectRefereneValue_policyDoesNotExist_required_assertException() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("altNameOnly.der");
final CertificatePolicyIndentifierExtensionField field = new CertificatePolicyIndentifierExtensionField(true);
boolean exceptionOccured = false;
try {
field.injectReferenceValue(cert);
} catch (PolicyRequiredException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.policy.x509.CertificatePolicyIndentifierExtensionField in project nhin-d by DirectProject.
the class CertificatePolicyIndentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_noInjection_getPolicyValue_assertException.
public void testInjectRefereneValue_noInjection_getPolicyValue_assertException() throws Exception {
final CertificatePolicyIndentifierExtensionField field = new CertificatePolicyIndentifierExtensionField(true);
boolean exceptionOccured = false;
try {
field.getPolicyValue();
} catch (IllegalStateException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations