use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testValidateCertReqDNSNamesSubdomain.
@Test
public void testValidateCertReqDNSNamesSubdomain() throws IOException {
Path path = Paths.get("src/test/resources/subdomain.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.validateCertReqDNSNames(certReq, "athenz.domain", "production");
assertTrue(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testVerifyCertificateRequest.
@Test
public void testVerifyCertificateRequest() throws IOException {
Path path = Paths.get("src/test/resources/athenz.instanceid.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.verifyCertificateRequest(certReq, "athenz", "production");
assertTrue(result);
result = ZTSUtils.verifyCertificateRequest(certReq, "athenz2", "production");
assertFalse(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testValidateCertReqCommonNameException.
@Test
public void testValidateCertReqCommonNameException() {
PKCS10CertificationRequest certReq = Mockito.mock(PKCS10CertificationRequest.class);
Mockito.when(certReq.getSubject()).thenThrow(new CryptoException());
assertFalse(ZTSUtils.validateCertReqCommonName(certReq, "athenz.syncer"));
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testValidateCertReqDNSNames.
@Test
public void testValidateCertReqDNSNames() throws IOException {
Path path = Paths.get("src/test/resources/athenz.instanceid.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.validateCertReqDNSNames(certReq, "athenz", "production");
assertTrue(result);
result = ZTSUtils.validateCertReqDNSNames(certReq, "athenz2", "production");
assertFalse(result);
result = ZTSUtils.validateCertReqDNSNames(certReq, "athenz2", "productio2");
assertFalse(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testValidateCertReqDNSNamesUnknown.
@Test
public void testValidateCertReqDNSNamesUnknown() throws IOException {
Path path = Paths.get("src/test/resources/invalid_dns.csr");
String csr = new String(Files.readAllBytes(path));
// includes www.athenz.io as dns name so it should be rejected
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.validateCertReqDNSNames(certReq, "athenz", "production");
assertFalse(result);
result = ZTSUtils.validateCertReqDNSNames(certReq, "athenz", "production");
assertFalse(result);
}
Aggregations