private void assertUserAllowed(UserGroupInformation ugi, AccessControlList acl) { assertTrue("User " + ugi + " is not granted the access-control!!", acl.isUserAllowed(ugi)); }
public void testWildCardAccessControlList() throws Exception { AccessControlList acl; acl = new AccessControlList("*"); assertTrue(acl.isAllAllowed()); acl = new AccessControlList(" * "); assertTrue(acl.isAllAllowed()); acl = new AccessControlList(" *"); assertTrue(acl.isAllAllowed()); acl = new AccessControlList("* "); assertTrue(acl.isAllAllowed()); }
public void testAclString() { AccessControlList acl; acl = new AccessControlList("*"); assertTrue(acl.toString().equals("All users are allowed")); validateGetAclString(acl); acl = new AccessControlList(" "); assertTrue(acl.toString().equals("No users are allowed")); acl = new AccessControlList("user1,user2"); assertTrue(acl.toString().equals("Users [user1, user2] are allowed")); validateGetAclString(acl); acl = new AccessControlList("user1,user2 ");// with space assertTrue(acl.toString().equals("Users [user1, user2] are allowed")); validateGetAclString(acl); acl = new AccessControlList(" group1,group2"); assertTrue(acl.toString().equals( "Members of the groups [group1, group2] are allowed")); validateGetAclString(acl); acl = new AccessControlList("user1,user2 group1,group2"); assertTrue(acl.toString().equals( "Users [user1, user2] and " + "members of the groups [group1, group2] are allowed")); validateGetAclString(acl); }
private void validateGetAclString(AccessControlList acl) { assertTrue(acl.toString().equals( new AccessControlList(acl.getAclString()).toString())); }
assertTrue(th instanceof IllegalArgumentException); assertTrue(th instanceof IllegalArgumentException); th = null; try { assertTrue(th instanceof IllegalArgumentException); th = null; try { assertTrue(th instanceof IllegalArgumentException);
/** * Tests adding user/group to an wild card acl. */ public void testAddRemoveToWildCardACL() { AccessControlList acl = new AccessControlList(" * "); assertTrue(acl.isAllAllowed()); UserGroupInformation drwho = UserGroupInformation.createUserForTesting("drwho@APACHE.ORG", new String[] { "aliens" }); UserGroupInformation drwho2 = UserGroupInformation.createUserForTesting("drwho2@APACHE.ORG", new String[] { "tardis" }); acl.addUser("drwho"); assertTrue(acl.isAllAllowed()); assertFalse(acl.getAclString().contains("drwho")); acl.addGroup("tardis"); assertTrue(acl.isAllAllowed()); assertFalse(acl.getAclString().contains("tardis")); acl.removeUser("drwho"); assertTrue(acl.isAllAllowed()); assertUserAllowed(drwho, acl); acl.removeGroup("tardis"); assertTrue(acl.isAllAllowed()); assertUserAllowed(drwho2, acl); }