Search in sources :

Example 71 with InstanceCertManager

use of com.yahoo.athenz.zts.cert.InstanceCertManager in project athenz by yahoo.

the class ZTSImplTest method testGetCertificateAuthorityBundle.

@Test
public void testGetCertificateAuthorityBundle() {
    Principal principal = SimplePrincipal.create("user_domain", "user1", "v=U1;d=user_domain;n=user;s=signature", 0, null);
    ResourceContext context = createResourceContext(principal);
    ChangeLogStore structStore = new ZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", privateKey, "0");
    DataStore store = new DataStore(structStore, null, ztsMetric);
    ZTSImpl ztsImpl = new ZTSImpl(mockCloudStore, store);
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_BUNDLES_FNAME, "src/test/resources/ca-bundle-file.json");
    ztsImpl.instanceCertManager = new InstanceCertManager(null, null, null, true, null);
    CertificateAuthorityBundle bundle = ztsImpl.getCertificateAuthorityBundle(context, "athenz");
    assertNotNull(bundle);
    bundle = ztsImpl.getCertificateAuthorityBundle(context, "system");
    assertNotNull(bundle);
    bundle = ztsImpl.getCertificateAuthorityBundle(context, "ssh");
    assertNotNull(bundle);
    try {
        ztsImpl.getCertificateAuthorityBundle(context, "unknown");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.NOT_FOUND);
    }
    try {
        ztsImpl.getCertificateAuthorityBundle(context, "athenz test");
        fail();
    } catch (ResourceException ignored) {
    }
    System.clearProperty(ZTSConsts.ZTS_PROP_CERT_BUNDLES_FNAME);
}
Also used : InstanceCertManager(com.yahoo.athenz.zts.cert.InstanceCertManager) ZMSFileChangeLogStore(com.yahoo.athenz.common.server.store.impl.ZMSFileChangeLogStore) ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.MockZMSFileChangeLogStore) ZMSFileChangeLogStore(com.yahoo.athenz.common.server.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.MockZMSFileChangeLogStore) DataStore(com.yahoo.athenz.zts.store.DataStore) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Aggregations

InstanceCertManager (com.yahoo.athenz.zts.cert.InstanceCertManager)71 Test (org.testng.annotations.Test)69 DataStore (com.yahoo.athenz.zts.store.DataStore)61 ChangeLogStore (com.yahoo.athenz.common.server.store.ChangeLogStore)56 ZMSFileChangeLogStore (com.yahoo.athenz.common.server.store.impl.ZMSFileChangeLogStore)56 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.MockZMSFileChangeLogStore)56 Path (java.nio.file.Path)49 InstanceProvider (com.yahoo.athenz.instance.provider.InstanceProvider)39 InstanceConfirmation (com.yahoo.athenz.instance.provider.InstanceConfirmation)34 X509Certificate (java.security.cert.X509Certificate)30 X509CertRecord (com.yahoo.athenz.common.server.cert.X509CertRecord)23 HttpServletResponse (javax.servlet.http.HttpServletResponse)11 Response (javax.ws.rs.core.Response)11 Principal (com.yahoo.athenz.auth.Principal)10 HostnameResolver (com.yahoo.athenz.common.server.dns.HostnameResolver)7 JOSEException (com.nimbusds.jose.JOSEException)3 CertificateAuthority (com.yahoo.athenz.auth.impl.CertificateAuthority)3 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)3 DynamicConfigLong (com.yahoo.athenz.common.server.util.config.dynamic.DynamicConfigLong)3 WorkloadRecord (com.yahoo.athenz.common.server.workload.WorkloadRecord)3