Search in sources :

Example 1 with DomainRoleMembersFetcher

use of com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher in project athenz by yahoo.

the class DomainRoleMembersFetcherTest method testNoDomain.

@Test
public void testNoDomain() {
    DBService dbsvc = Mockito.mock(DBService.class);
    DomainRoleMembersFetcher domainRoleMembersFetcher = new DomainRoleMembersFetcher(dbsvc, USER_DOMAIN_PREFIX);
    Set<String> domainRoleMembers = domainRoleMembersFetcher.getDomainRoleMembers("domain1", "domain1:role.admin");
    assertEquals(new HashSet<>(), domainRoleMembers);
}
Also used : DBService(com.yahoo.athenz.zms.DBService) DomainRoleMembersFetcher(com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher) Test(org.testng.annotations.Test)

Example 2 with DomainRoleMembersFetcher

use of com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher in project athenz by yahoo.

the class DomainRoleMembersFetcherTest method testNoDataStore.

@Test
public void testNoDataStore() {
    DomainRoleMembersFetcher domainRoleMembersFetcher = new DomainRoleMembersFetcher(null, USER_DOMAIN_PREFIX);
    Set<String> domainRoleMembers = domainRoleMembersFetcher.getDomainRoleMembers("domain1", "domain1:role.admin");
    assertEquals(new HashSet<>(), domainRoleMembers);
}
Also used : DomainRoleMembersFetcher(com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher) Test(org.testng.annotations.Test)

Example 3 with DomainRoleMembersFetcher

use of com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher in project athenz by yahoo.

the class DomainRoleMembersFetcherTest method testNoDataStore.

@Test
public void testNoDataStore() {
    DomainRoleMembersFetcher domainRoleMembersFetcher = new DomainRoleMembersFetcher(null, USER_DOMAIN_PREFIX);
    Set<String> domainRoleMembers = domainRoleMembersFetcher.getDomainRoleMembers("domain1", "domain1:role.admin");
    assertEquals(new HashSet<>(), domainRoleMembers);
}
Also used : DomainRoleMembersFetcher(com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher) Test(org.testng.annotations.Test)

Example 4 with DomainRoleMembersFetcher

use of com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher in project athenz by yahoo.

the class DomainRoleMembersFetcherTest method testGetDomainRoleMembers.

@Test
public void testGetDomainRoleMembers() {
    DBService dbsvc = Mockito.mock(DBService.class);
    String domainName = "domain1";
    AthenzDomain domainData = new AthenzDomain(domainName);
    Role adminRole = new Role();
    adminRole.setName(domainName + ":role.admin");
    RoleMember roleMember1 = new RoleMember();
    roleMember1.setMemberName("user.domain1rolemember1");
    RoleMember roleMember2 = new RoleMember();
    roleMember2.setMemberName("user.domain1rolemember2");
    adminRole.setRoleMembers(Arrays.asList(roleMember1, roleMember2));
    domainData.setRoles(Collections.singletonList(adminRole));
    Mockito.when(dbsvc.getRolesByDomain(eq("domain1"))).thenReturn(domainData.getRoles());
    DomainRoleMembersFetcher domainRoleMembersFetcher = new DomainRoleMembersFetcher(dbsvc, USER_DOMAIN_PREFIX);
    Set<String> domainRoleMembers = domainRoleMembersFetcher.getDomainRoleMembers("domain1", "domain1:role.admin");
    assertEquals(2, domainRoleMembers.size());
    assertTrue(domainRoleMembers.contains("user.domain1rolemember1"));
    assertTrue(domainRoleMembers.contains("user.domain1rolemember2"));
}
Also used : DBService(com.yahoo.athenz.zms.DBService) Role(com.yahoo.athenz.zms.Role) AthenzDomain(com.yahoo.athenz.zms.store.AthenzDomain) DomainRoleMembersFetcher(com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher) RoleMember(com.yahoo.athenz.zms.RoleMember) Test(org.testng.annotations.Test)

Example 5 with DomainRoleMembersFetcher

use of com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher in project athenz by yahoo.

the class DomainRoleMembersFetcherTest method testGetDomainRoleMembers.

@Test
public void testGetDomainRoleMembers() {
    DataStore dataStore = mock(DataStore.class);
    NotificationTestsCommon.mockDomainData(1, dataStore);
    DomainRoleMembersFetcher domainRoleMembersFetcher = new DomainRoleMembersFetcher(dataStore, USER_DOMAIN_PREFIX);
    Set<String> domainRoleMembers = domainRoleMembersFetcher.getDomainRoleMembers("domain1", "domain1:role.admin");
    assertEquals(2, domainRoleMembers.size());
    assertTrue(domainRoleMembers.contains("user.domain1rolemember1"));
    assertTrue(domainRoleMembers.contains("user.domain1rolemember2"));
}
Also used : DataStore(com.yahoo.athenz.zts.store.DataStore) DomainRoleMembersFetcher(com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher) Test(org.testng.annotations.Test)

Aggregations

DomainRoleMembersFetcher (com.yahoo.athenz.common.server.notification.DomainRoleMembersFetcher)6 Test (org.testng.annotations.Test)6 DBService (com.yahoo.athenz.zms.DBService)2 DataStore (com.yahoo.athenz.zts.store.DataStore)2 Role (com.yahoo.athenz.zms.Role)1 RoleMember (com.yahoo.athenz.zms.RoleMember)1 AthenzDomain (com.yahoo.athenz.zms.store.AthenzDomain)1