use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testInsertQuotaInvalidDomain.
@Test
public void testInsertQuotaInvalidDomain() 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.insertQuota("athenz", quota);
fail();
} catch (ResourceException ex) {
assertEquals(404, ex.getCode());
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testInsertServiceIdentityInvalidName.
@Test
public void testInsertServiceIdentityInvalidName() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
ServiceIdentity service = new ServiceIdentity().setName("service1");
Mockito.doReturn(1).when(mockPrepStmt).executeUpdate();
Mockito.when(mockResultSet.next()).thenReturn(true);
// return domain id
Mockito.when(mockResultSet.getInt(1)).thenReturn(5).thenReturn(// service id
4);
try {
jdbcConn.insertServiceIdentity("my-domain", service);
fail();
} catch (ResourceException ex) {
assertEquals(400, ex.getCode());
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testVerifyDomainAccountUniquenessFail.
@Test
public void testVerifyDomainAccountUniquenessFail() 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.verifyDomainAccountUniqueness("iaas.athenz", "12345", "unitTest");
fail();
} catch (ResourceException ex) {
assertEquals(400, ex.getCode());
assertTrue(ex.getMessage().contains("iaas.athenz.ci"));
}
jdbcConn.close();
}
Aggregations