Search in sources :

Example 1 with UserAuthority

use of com.yahoo.athenz.auth.impl.UserAuthority in project athenz by yahoo.

the class SimplePrincipalTest method testSimplePrincipalNullRole.

@Test
public void testSimplePrincipalNullRole() {
    UserAuthority userAuthority = new UserAuthority();
    userAuthority.initialize();
    assertNull(SimplePrincipal.create("user", fakeCreds, (List<String>) null, userAuthority));
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) UserAuthority(com.yahoo.athenz.auth.impl.UserAuthority) Test(org.testng.annotations.Test)

Example 2 with UserAuthority

use of com.yahoo.athenz.auth.impl.UserAuthority in project athenz by yahoo.

the class SimplePrincipalTest method testSimplePrincipalEmptyRole.

@Test
public void testSimplePrincipalEmptyRole() {
    List<String> roles = new ArrayList<>();
    UserAuthority userAuthority = new UserAuthority();
    userAuthority.initialize();
    assertNull(SimplePrincipal.create("user", fakeCreds, roles, userAuthority));
    roles.add("newrole");
    SimplePrincipal p = (SimplePrincipal) SimplePrincipal.create("user", fakeCreds, roles, userAuthority);
    assertEquals(p.getRoles().size(), 1);
    assertTrue(p.getRoles().contains("newrole"));
}
Also used : ArrayList(java.util.ArrayList) UserAuthority(com.yahoo.athenz.auth.impl.UserAuthority) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Test(org.testng.annotations.Test)

Example 3 with UserAuthority

use of com.yahoo.athenz.auth.impl.UserAuthority in project athenz by yahoo.

the class SimplePrincipalTest method testSimplePrincipal.

@Test
public void testSimplePrincipal() {
    String testApplicationId = "test_app_id";
    SimplePrincipal p = (SimplePrincipal) SimplePrincipal.create("user", "jdoe", fakeCreds, null);
    assertNotNull(p);
    p.setUnsignedCreds(fakeUnsignedCreds);
    p.setApplicationId(testApplicationId);
    assertEquals(p.getName(), "jdoe");
    assertEquals(p.getDomain(), "user");
    assertEquals(p.getCredentials(), fakeCreds);
    assertEquals(p.getUnsignedCredentials(), fakeUnsignedCreds);
    assertEquals(p.getApplicationId(), testApplicationId);
    UserAuthority userAuthority = new UserAuthority();
    userAuthority.initialize();
    p = (SimplePrincipal) SimplePrincipal.create("user", "jdoe", fakeCreds, userAuthority);
    assertNotNull(p);
}
Also used : UserAuthority(com.yahoo.athenz.auth.impl.UserAuthority) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Test(org.testng.annotations.Test)

Aggregations

UserAuthority (com.yahoo.athenz.auth.impl.UserAuthority)3 Test (org.testng.annotations.Test)3 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)2 ArrayList (java.util.ArrayList)2 List (java.util.List)1