use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testGetTrustedRoles.
@Test
public void testGetTrustedRoles() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockResultSet.next()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false);
Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_NAME)).thenReturn("trole1").thenReturn("trole2").thenReturn("trole3");
Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_DOMAIN_ID)).thenReturn("101").thenReturn("102").thenReturn("103");
Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_ROLE)).thenReturn("role1").thenReturn("role1").thenReturn("role3");
Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_ASSERT_DOMAIN_ID)).thenReturn("101").thenReturn("101").thenReturn("103");
Map<String, List<String>> trustedRoles = jdbcConn.getTrustedRoles("getTrustedRoles");
assertEquals(2, trustedRoles.size());
List<String> roles = trustedRoles.get("101:role1");
assertEquals(2, roles.size());
assertEquals("101:trole1", roles.get(0));
assertEquals("102:trole2", roles.get(1));
roles = trustedRoles.get("103:role3");
assertEquals(1, roles.size());
assertEquals("103:trole3", roles.get(0));
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testPrepareRoleAssertionsStatementWithAction.
@Test
public void testPrepareRoleAssertionsStatementWithAction() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
jdbcConn.prepareRoleAssertionsStatement("create");
Mockito.verify(mockPrepStmt, times(1)).setString(Matchers.eq(1), Matchers.eq("create"));
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testListRoleMembersInvalidDomain.
@Test
public void testListRoleMembersInvalidDomain() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockResultSet.next()).thenReturn(// invalid domain
false);
try {
jdbcConn.listRoleMembers("my-domain", "role1");
fail();
} catch (Exception ex) {
assertTrue(true);
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testPrepareRolePrinciaplsStatementEmptyPrincipal.
@Test
public void testPrepareRolePrinciaplsStatementEmptyPrincipal() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
jdbcConn.prepareRolePrincipalsStatement("", "user", false);
jdbcConn.prepareRolePrincipalsStatement(null, "user", false);
Mockito.verify(mockPrepStmt, times(0)).setString(Matchers.isA(Integer.class), Matchers.isA(String.class));
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testGetDomainNotFound.
@Test
public void testGetDomainNotFound() throws Exception {
Mockito.when(mockResultSet.next()).thenReturn(false);
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Domain domain = jdbcConn.getDomain("my-domain");
assertNull(domain);
jdbcConn.close();
}
Aggregations