Search in sources :

Example 36 with Role

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);
        }
    }
}
Also used : Role(com.yahoo.athenz.zms.Role) File(java.io.File) Test(org.testng.annotations.Test)

Example 37 with Role

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 } };
}
Also used : Role(com.yahoo.athenz.zms.Role) RoleMember(com.yahoo.athenz.zms.RoleMember) DataProvider(org.testng.annotations.DataProvider)

Example 38 with Role

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();
}
Also used : Role(com.yahoo.athenz.zms.Role) PrincipalRole(com.yahoo.athenz.zms.PrincipalRole) JDBCConnection(com.yahoo.athenz.zms.store.jdbc.JDBCConnection) ResourceException(com.yahoo.athenz.zms.ResourceException) SQLException(java.sql.SQLException) Test(org.testng.annotations.Test)

Example 39 with Role

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();
}
Also used : Role(com.yahoo.athenz.zms.Role) PrincipalRole(com.yahoo.athenz.zms.PrincipalRole) JDBCConnection(com.yahoo.athenz.zms.store.jdbc.JDBCConnection) ResourceException(com.yahoo.athenz.zms.ResourceException) SQLException(java.sql.SQLException) Test(org.testng.annotations.Test)

Example 40 with Role

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;
}
Also used : Role(com.yahoo.athenz.zms.Role) PrincipalRole(com.yahoo.athenz.zms.PrincipalRole) Policy(com.yahoo.athenz.zms.Policy) AthenzDomain(com.yahoo.athenz.zms.store.AthenzDomain) ServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity)

Aggregations

Role (com.yahoo.athenz.zms.Role)94 Test (org.testng.annotations.Test)57 RoleMember (com.yahoo.athenz.zms.RoleMember)47 ArrayList (java.util.ArrayList)47 DomainData (com.yahoo.athenz.zms.DomainData)32 DataCache (com.yahoo.athenz.zts.cache.DataCache)31 PrincipalRole (com.yahoo.athenz.zms.PrincipalRole)27 Policy (com.yahoo.athenz.zms.Policy)22 SignedDomain (com.yahoo.athenz.zms.SignedDomain)22 Assertion (com.yahoo.athenz.zms.Assertion)20 MemberRole (com.yahoo.athenz.zts.cache.MemberRole)19 JDBCConnection (com.yahoo.athenz.zms.store.jdbc.JDBCConnection)14 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore)13 ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)12 ServiceIdentity (com.yahoo.athenz.zms.ServiceIdentity)11 SQLException (java.sql.SQLException)9 HashMap (java.util.HashMap)8 ResourceException (com.yahoo.athenz.zms.ResourceException)7 Domain (com.yahoo.athenz.zms.Domain)6 File (java.io.File)6