use of com.yahoo.athenz.zms.Role in project athenz by yahoo.
the class FileConnectionTest method testUpdateRole.
@Test
public void testUpdateRole() {
File fileDir = new File("/home/athenz/zms_store");
File quotaDir = new File("/home/athenz/zms_quota");
try (FileConnection fileconnection = new FileConnection(fileDir, quotaDir)) {
Role role = new Role();
try {
fileconnection.updateRole("domain1", role);
} catch (Exception ex) {
assertTrue(true);
}
}
}
use of com.yahoo.athenz.zms.Role in project athenz by yahoo.
the class ZMSUtilsTest method getRoles.
@DataProvider(name = "roles")
public static Object[][] getRoles() {
String domainName = "test_domain";
Role role1 = new Role();
String memberName = "member";
RoleMember roleMember = new RoleMember().setMemberName(memberName);
Role role2 = new Role();
role2.setMembers(Arrays.asList(memberName));
role2.setRoleMembers(Arrays.asList(roleMember));
Role role3 = new Role();
role3.setRoleMembers(Arrays.asList(roleMember));
Role role4 = new Role();
role4.setRoleMembers(Arrays.asList(roleMember));
role4.setTrust("trust");
Role role5 = new Role();
role5.setMembers(Arrays.asList(memberName));
role5.setTrust("trust");
Role role6 = new Role();
role6.setTrust("trust");
return new Object[][] { { domainName, role1, false }, { domainName, role2, true }, { domainName, role3, false }, { domainName, role4, true }, { domainName, role5, true }, { "trust", role6, true }, { "test_domain", role6, false } };
}
use of com.yahoo.athenz.zms.Role in project athenz by yahoo.
the class JDBCConnectionTest method testInsertRoleInvalidDomain.
@Test
public void testInsertRoleInvalidDomain() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Role role = new Role().setName("my-domain:role.role1");
// domain id failure
Mockito.when(mockResultSet.next()).thenReturn(false);
try {
jdbcConn.insertRole("my-domain", role);
fail();
} catch (Exception ex) {
assertTrue(true);
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.Role in project athenz by yahoo.
the class JDBCConnectionTest method testInsertRoleInvalidRoleDomain.
@Test
public void testInsertRoleInvalidRoleDomain() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Role role = new Role().setName("my-domain2:role.role1");
try {
jdbcConn.insertRole("my-domain", role);
fail();
} catch (Exception ex) {
assertTrue(true);
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.Role in project athenz by yahoo.
the class FileConnection method getAthenzDomain.
@Override
public AthenzDomain getAthenzDomain(String domainName) {
DomainStruct domainStruct = getDomainStruct(domainName);
if (domainStruct == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "domain not found", "getAthenzDomain");
}
AthenzDomain athenzDomain = new AthenzDomain(domainName);
athenzDomain.setDomain(getDomain(domainStruct));
if (domainStruct.getRoles() != null) {
athenzDomain.setRoles(new ArrayList<Role>(domainStruct.getRoles().values()));
}
if (domainStruct.getPolicies() != null) {
athenzDomain.setPolicies(new ArrayList<Policy>(domainStruct.getPolicies().values()));
}
if (domainStruct.getServices() != null) {
athenzDomain.setServices(new ArrayList<ServiceIdentity>(domainStruct.getServices().values()));
}
return athenzDomain;
}
Aggregations