use of com.yahoo.athenz.auth.Authorizer in project athenz by yahoo.
the class X509CertRequestTest method testValidateDnsSuffixNotAuthorized.
@Test
public void testValidateDnsSuffixNotAuthorized() throws IOException {
Path path = Paths.get("src/test/resources/athenz.instanceid.csr");
String csr = new String(Files.readAllBytes(path));
X509CertRequest certReq = new X509CertRequest(csr);
assertNotNull(certReq);
Authorizer authorizer = Mockito.mock(Authorizer.class);
Principal provider = Mockito.mock(Principal.class);
Mockito.when(authorizer.access("launch", "sys.auth:dns.ostk.athenz.cloud", provider, (String) null)).thenReturn(false);
StringBuilder errorMsg = new StringBuilder(256);
assertFalse(certReq.validate(provider, "athenz", "production", "1001", authorizer, errorMsg));
assertTrue(errorMsg.toString().contains("not authorized to handle"));
}
Aggregations