use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class TrustBundleServiceTest method testAddTrustBundle.
public void testAddTrustBundle() throws Exception {
final TrustBundle bundle = new TrustBundle();
impl.addTrustBundle(bundle);
verify(dao, times(1)).addTrustBundle(bundle);
}
use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class DomainService_realDataTest method testDeleteDomainById_associatedTrustBundle_assertDomainDeleted.
public void testDeleteDomainById_associatedTrustBundle_assertDomainDeleted() throws Exception {
File bundleLocation = new File("./src/test/resources/bundles/signedbundle.p7b");
final ApplicationContext ctx = ConfigServiceRunner.getSpringApplicationContext();
// add a bundle
TrustBundleService trustService = (TrustBundleService) ctx.getBean("trustBundleSvc");
final TrustBundle bundle = new TrustBundle();
bundle.setBundleName("Test Bundle");
bundle.setBundleURL(filePrefix + bundleLocation.getAbsolutePath());
trustService.addTrustBundle(bundle);
// add a domain
DomainService domainService = (DomainService) ctx.getBean("domainSvc");
Domain domain = new Domain();
domain.setDomainName("Test Domain");
domain.setStatus(EntityStatus.ENABLED);
domainService.addDomain(domain);
//associate domain to bundle
trustService.associateTrustBundleToDomain(domain.getId(), bundle.getId(), true, true);
// assert the association
Collection<TrustBundleDomainReltn> associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
assertEquals(1, associatedBundel.size());
// now delete the domain
domainService.removeDomainById(domain.getId());
assertEquals(0, domainService.getDomainCount());
boolean exceptionOccured = false;
try {
associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class DefaultBundleRefreshProcessorImpl_convertRawBundleToAnchorCollectionTest method testConvertRawBundleToAnchorCollection_getFromSignedBundle_invalidSigner_assertNoAnchors.
public void testConvertRawBundleToAnchorCollection_getFromSignedBundle_invalidSigner_assertNoAnchors() throws Exception {
TrustBundleDao dao = mock(TrustBundleDao.class);
final X509Certificate signer = TestUtils.loadSigner("sm1.direct.com Root CA.der");
final byte[] rawBundle = TestUtils.loadBundle("signedbundle.p7m");
final DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
processor.setDao(dao);
final TrustBundle existingBundle = new TrustBundle();
existingBundle.setSigningCertificateData(signer.getEncoded());
final Calendar processAttempStart = Calendar.getInstance(Locale.getDefault());
Collection<X509Certificate> anchors = processor.convertRawBundleToAnchorCollection(rawBundle, existingBundle, processAttempStart);
assertNull(anchors);
}
use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class DefaultBundleRefreshProcessorImpl_refreshBundleTest method testRefreshBundle_validBundle_unmatchedChecksum_needsRefreshed_assertUpdateCalled.
@SuppressWarnings("unchecked")
public void testRefreshBundle_validBundle_unmatchedChecksum_needsRefreshed_assertUpdateCalled() throws Exception {
DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
processor.setDao(dao);
final TrustBundle bundle = new TrustBundle();
bundle.setBundleName("Junit Bundle");
File fl = new File("src/test/resources/bundles/signedbundle.p7b");
bundle.setBundleURL(filePrefix + fl.getAbsolutePath());
bundle.setCheckSum("12345");
processor.refreshBundle(bundle);
verify(dao, times(1)).updateTrustBundleAnchors(eq(bundle.getId()), (Calendar) any(), (Collection<TrustBundleAnchor>) any(), (String) any());
}
use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class DefaultBundleRefreshProcessorImpl_refreshBundleTest method testRefreshBundle_checkSumsMatch_assertUpdateNotCalled.
@SuppressWarnings("unchecked")
public void testRefreshBundle_checkSumsMatch_assertUpdateNotCalled() throws Exception {
DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
processor.setDao(dao);
final TrustBundle bundle = new TrustBundle();
File fl = new File("src/test/resources/bundles/signedbundle.p7b");
byte[] rawBundleByte = FileUtils.readFileToByteArray(fl);
bundle.setBundleName("Junit Bundle");
bundle.setBundleURL(filePrefix + fl.getAbsolutePath());
bundle.setCheckSum(BundleThumbprint.toThumbprint(rawBundleByte).toString());
processor.refreshBundle(bundle);
verify(dao, times(0)).updateTrustBundleAnchors(eq(bundle.getId()), (Calendar) any(), (Collection<TrustBundleAnchor>) any(), (String) any());
}
Aggregations