assertTrue(userProp.privileges.contains("PRIVILEGE2"));
}
@Test
public void unassignPrivilegeToUserTest() {
SecurityAPI api = new SecurityAPI();
api.addPrivilege("privilege1", helper.loginAsSuperUser());
api.addPrivilege("privilege2", helper.loginAsSuperUser());
String email = "test@dummy1fkj.com";
api.addUser(email, helper.loginAsSuperUser());
api.assignPrivilegeToUser(email, "privilege1",
helper.loginAsSuperUser());
api.assignPrivilegeToUser(email, "privilege2",
helper.loginAsSuperUser());
APIResponse response = api.unassignPrivilegeToUser(email,
"privilege1", null);
assertTrue(response.statusCode == Status.ERROR_LOGIN_REQUIRED);
response = api.unassignPrivilegeToUser(email,
"privilege1", helper.loginAsInvalidUser());
assertTrue(response.statusCode == Status.ERROR_INVALID_USER);
response = api.unassignPrivilegeToUser(email,
"privilege1", helper.loginAsValidUser());
assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
response = api.unassignPrivilegeToUser(email,
"privilege1", helper.loginAsSuperUser());
System.out.println("status 1: " + response.statusCode);
UserProp userProp = (UserProp) api.getUser(email).object;
assertTrue(! userProp.privileges.contains("PRIVILEGE1"));
System.out.println("user prop: " + userProp);
assertTrue(response.statusCode == Status.SUCCESS);
//admin can unassign as well
response = api.unassignPrivilegeToUser(email,
"privilege2", helper.loginAsSuperUser());
assertTrue(response.statusCode == Status.SUCCESS);
userProp = (UserProp) api.getUser(email).object;
assertTrue(! userProp.privileges.contains("PRIVILEGE2"));
}