use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testListRoleAuditLogsException.
@Test
public void testListRoleAuditLogsException() throws SQLException {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockResultSet.next()).thenReturn(// domain id success
true).thenReturn(// role id success
true);
Mockito.when(mockResultSet.getInt(1)).thenReturn(// domain id
5).thenReturn(// role id
7);
Mockito.when(mockPrepStmt.executeQuery()).thenReturn(mockResultSet).thenReturn(mockResultSet).thenThrow(new SQLException("failed operation", "state", 1001));
try {
jdbcConn.listRoleAuditLogs("my-domain", "role1");
fail();
} catch (ResourceException ex) {
assertEquals(500, ex.getCode());
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testListPrincipalsException.
@Test
public void testListPrincipalsException() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockPrepStmt.executeQuery()).thenThrow(new SQLException("failed operation", "state", 1001));
try {
jdbcConn.listPrincipals("user");
fail();
} catch (ResourceException ex) {
assertEquals(ex.getCode(), ResourceException.INTERNAL_SERVER_ERROR);
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testVerifyDomainProductIdUniquenessFail.
@Test
public void testVerifyDomainProductIdUniquenessFail() throws Exception {
Mockito.when(mockResultSet.next()).thenReturn(true).thenReturn(false);
Mockito.doReturn("iaas.athenz.ci").when(mockResultSet).getString(1);
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
try {
jdbcConn.verifyDomainProductIdUniqueness("iaas.athenz", Integer.valueOf(1001), "unitTest");
fail();
} catch (ResourceException ex) {
assertEquals(400, ex.getCode());
assertTrue(ex.getMessage().contains("iaas.athenz.ci"));
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testGetRoleException.
@Test
public void testGetRoleException() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockPrepStmt.executeQuery()).thenThrow(new SQLException("failed operation", "state", 1001));
try {
jdbcConn.getRole("my-domain", "role1");
fail();
} catch (ResourceException ex) {
assertEquals(500, ex.getCode());
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testUpdateQuotaInvalidDomain.
@Test
public void testUpdateQuotaInvalidDomain() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Quota quota = new Quota().setName("athenz").setAssertion(10).setEntity(11).setPolicy(12).setPublicKey(13).setRole(14).setRoleMember(15).setService(16).setServiceHost(17).setSubdomain(18);
Mockito.when(mockResultSet.next()).thenReturn(false);
try {
jdbcConn.updateQuota("athenz", quota);
fail();
} catch (ResourceException ex) {
assertEquals(404, ex.getCode());
}
jdbcConn.close();
}
Aggregations