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);
}
Aggregations