use of com.yahoo.athenz.zms.audit.MockAuditReferenceValidatorImpl in project athenz by yahoo.
the class DBServiceTest method testCheckRoleAuditEnabledFlagTrueRefValidationFail.
@Test
public void testCheckRoleAuditEnabledFlagTrueRefValidationFail() {
String domainName = "audit-test-domain-name";
String roleName = "testrole";
Role role = new Role().setAuditEnabled(true);
Mockito.doReturn(role).when(mockJdbcConn).getRole(domainName, roleName);
zms.dbService.auditReferenceValidator = new MockAuditReferenceValidatorImpl();
String caller = "testCheckRoleAuditEnabledFlagTrueRefValidationFail";
String principal = "testprincipal";
try {
zms.dbService.checkObjectAuditEnabled(mockJdbcConn, role.getAuditEnabled(), role.getName(), "auditref", caller, principal);
fail();
} catch (ResourceException ex) {
assertEquals(400, ex.getCode());
assertTrue(ex.getMessage().contains("Audit reference validation failed "));
}
zms.dbService.auditReferenceValidator = null;
}
Aggregations