Search in sources :

Example 31 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class DefaultBundleRefreshProcessorImpl_refreshBundleTest method testRefreshBundle_validBundle_noCheckSum_needsRefreshed_assertUpdateCalled.

@SuppressWarnings("unchecked")
public void testRefreshBundle_validBundle_noCheckSum_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());
    processor.refreshBundle(bundle);
    verify(dao, times(1)).updateTrustBundleAnchors(eq(bundle.getId()), (Calendar) any(), (Collection<TrustBundleAnchor>) any(), (String) any());
}
Also used : TrustBundle(org.nhindirect.config.store.TrustBundle) File(java.io.File) TrustBundleAnchor(org.nhindirect.config.store.TrustBundleAnchor)

Example 32 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class DomainService_realDataTest method testDeleteDomainByName_associatedTrustBundle_assertDomainDeleted.

@SuppressWarnings("deprecation")
public void testDeleteDomainByName_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.removeDomain(domain.getDomainName());
    assertEquals(0, domainService.getDomainCount());
    boolean exceptionOccured = false;
    try {
        associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
    } catch (ConfigurationStoreException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) TrustBundle(org.nhindirect.config.store.TrustBundle) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Domain(org.nhindirect.config.store.Domain) File(java.io.File) TrustBundleDomainReltn(org.nhindirect.config.store.TrustBundleDomainReltn)

Example 33 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class TrustBundleServiceTest method testRefresTrustBundle.

public void testRefresTrustBundle() throws Exception {
    final TrustBundle bundle = new TrustBundle();
    impl.refreshTrustBundle(bundle.getId());
    verify(dao, times(1)).getTrustBundleById(bundle.getId());
    verify(template, never()).sendBody(bundle);
    when(dao.getTrustBundleById(bundle.getId())).thenReturn(bundle);
    impl.refreshTrustBundle(bundle.getId());
    verify(dao, times(2)).getTrustBundleById(bundle.getId());
    verify(template, times(1)).sendBody(bundle);
}
Also used : TrustBundle(org.nhindirect.config.store.TrustBundle)

Example 34 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class TrustBundleService_realDataTest method testAssociateDomainToBundle_incomingTrueOutgoingFalse_assertIncomingAndOutgoingFlags.

public void testAssociateDomainToBundle_incomingTrueOutgoingFalse_assertIncomingAndOutgoingFlags() 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, false);
    // assert the association
    Collection<TrustBundleDomainReltn> associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
    assertEquals(1, associatedBundel.size());
    TrustBundleDomainReltn reltn = associatedBundel.iterator().next();
    assertTrue(reltn.isIncoming());
    assertFalse(reltn.isOutgoing());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) TrustBundle(org.nhindirect.config.store.TrustBundle) Domain(org.nhindirect.config.store.Domain) File(java.io.File) TrustBundleDomainReltn(org.nhindirect.config.store.TrustBundleDomainReltn)

Example 35 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class TrustBundleService_realDataTest method testAssociateDomainToBundle_incomingAndOutgoingTrue_assertIncomingAndOutgoingFlags.

public void testAssociateDomainToBundle_incomingAndOutgoingTrue_assertIncomingAndOutgoingFlags() 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());
    TrustBundleDomainReltn reltn = associatedBundel.iterator().next();
    assertTrue(reltn.isIncoming());
    assertTrue(reltn.isOutgoing());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) TrustBundle(org.nhindirect.config.store.TrustBundle) Domain(org.nhindirect.config.store.Domain) File(java.io.File) TrustBundleDomainReltn(org.nhindirect.config.store.TrustBundleDomainReltn)

Aggregations

TrustBundle (org.nhindirect.config.store.TrustBundle)44 File (java.io.File)16 ConfigurationStoreException (org.nhindirect.config.store.ConfigurationStoreException)15 ApplicationContext (org.springframework.context.ApplicationContext)12 Transactional (org.springframework.transaction.annotation.Transactional)12 NoResultException (javax.persistence.NoResultException)11 TrustBundleAnchor (org.nhindirect.config.store.TrustBundleAnchor)10 Domain (org.nhindirect.config.store.Domain)9 Calendar (java.util.Calendar)8 TrustBundleDomainReltn (org.nhindirect.config.store.TrustBundleDomainReltn)7 X509Certificate (java.security.cert.X509Certificate)6 Query (javax.persistence.Query)6 TrustBundleDao (org.nhindirect.config.store.dao.TrustBundleDao)4 TrustBundleService (org.nhindirect.config.service.TrustBundleService)3 ArrayList (java.util.ArrayList)2 Address (org.nhindirect.config.store.Address)2 Anchor (org.nhindirect.config.store.Anchor)2 CertPolicy (org.nhindirect.config.store.CertPolicy)2 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)2 Certificate (org.nhindirect.config.store.Certificate)2