Search in sources :

Example 11 with Authorizer

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"));
}
Also used : Path(java.nio.file.Path) Authorizer(com.yahoo.athenz.auth.Authorizer) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Aggregations

Authorizer (com.yahoo.athenz.auth.Authorizer)11 Test (org.testng.annotations.Test)11 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 Principal (com.yahoo.athenz.auth.Principal)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 AuthorityList (com.yahoo.athenz.common.server.rest.Http.AuthorityList)3 Authority (com.yahoo.athenz.auth.Authority)2 Path (java.nio.file.Path)2