use of com.yahoo.athenz.zts.cert.impl.SelfCertSigner in project athenz by yahoo.
the class ZTSImplTest method testGetRoleTokenCert.
@Test
public void testGetRoleTokenCert() throws Exception {
// this csr is for sports:role.readers role
RoleCertificateRequest req = new RoleCertificateRequest().setCsr(ROLE_CERT_CORETECH_REQUEST).setExpiryTime(Long.valueOf(3600));
SignedDomain signedDomain = createSignedDomain("coretech", "weather", "storage", true);
store.processDomain(signedDomain, false);
File caCert = new File("src/test/resources/valid_cn_x509.cert");
X509Certificate caCertificate = Crypto.loadX509Certificate(caCert);
File caKey = new File("src/test/resources/private_encrypted.key");
PrivateKey caPrivateKey = Crypto.loadPrivateKey(caKey, "athenz");
CertSigner certSigner = new SelfCertSigner(caPrivateKey, caCertificate);
CloudStore cloudStore = new MockCloudStore(certSigner);
store.setCloudStore(cloudStore);
zts.cloudStore = cloudStore;
Principal principal = SimplePrincipal.create("user_domain", "user1", "v=U1;d=user_domain;n=user;s=signature", 0, null);
ResourceContext context = createResourceContext(principal);
RoleToken roleToken = zts.postRoleCertificateRequest(context, "coretech", "readers", req);
assertNotNull(roleToken);
assertEquals(roleToken.getExpiryTime(), TimeUnit.SECONDS.convert(30, TimeUnit.DAYS));
}
Aggregations