use of org.simbasecurity.dwclient.gateway.representations.SimbaRoleR in project simba-os by cegeka.
the class SimbaManagerRestGatewayTest method unassignRoleFromUser_WhenUsernameDoesNotExist_ThrowsIllegalArgumentException.
@Test
public void unassignRoleFromUser_WhenUsernameDoesNotExist_ThrowsIllegalArgumentException() throws Exception {
String username = "ivar";
String rolename = "role name";
logInWithValidUser();
when(simbaUserServiceMock.findUserByName(anyString(), eq(username))).thenThrow(new IllegalArgumentException());
when(simbaRoleServiceMock.findRoleByName(anyString(), eq(rolename))).thenReturn(new SimbaRoleR());
expectedException.expect(IllegalArgumentException.class);
simbaManagerRestGateway.unassignRoleFromUser(rolename, username);
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaRoleR in project simba-os by cegeka.
the class SimbaManagerRestGatewayTest method unassignRoleFromUser_RemovesLookedUpSimbaRoleFromLookedUpSimbaUser.
@Test
public void unassignRoleFromUser_RemovesLookedUpSimbaRoleFromLookedUpSimbaUser() throws Exception {
String username = "herp";
String rolename = "derp";
String ssoToken = logInWithValidUser();
SimbaRoleR simbaRole = new SimbaRoleR();
SimbaUserR simbaUser = new SimbaUserR("simbauser");
when(simbaRoleServiceMock.findRoleByName(ssoToken, rolename)).thenReturn(simbaRole);
when(simbaUserServiceMock.findUserByName(ssoToken, username)).thenReturn(simbaUser);
simbaManagerRestGateway.unassignRoleFromUser(rolename, username);
verify(simbaGatewayMock, times(1)).login(APP_USER, APP_PASSWORD);
verify(simbaRoleServiceMock, times(1)).findRoleByName(ssoToken, rolename);
verify(simbaUserServiceMock, times(1)).findUserByName(ssoToken, username);
verify(simbaRoleServiceMock, times(1)).removeRoleFromUser(ssoToken, simbaRole, simbaUser);
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaRoleR in project simba-os by cegeka.
the class SimbaRoleServiceTest method addRoleToUser_WhenUserIsNull_ThrowsIllegalArgumentException.
@Test
public void addRoleToUser_WhenUserIsNull_ThrowsIllegalArgumentException() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("User cannot be null.");
simbaRoleService.addRoleToUser(getValidSSOToken(), new SimbaRoleR(), null);
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaRoleR in project simba-os by cegeka.
the class SimbaRoleServiceTest method addRoleToUser_WhenBothRoleAndUserExist_UserHasRole.
@Test
public void addRoleToUser_WhenBothRoleAndUserExist_UserHasRole() throws Exception {
String anExistingRolename = "simba-manager";
SimbaRoleR simbaRole = simbaRoleService.findRoleByName(getValidSSOToken(), anExistingRolename);
SimbaUserR user = simbaUserService.findUserByName(getValidSSOToken(), DUMMY_TEST_USER);
simbaRoleService.addRoleToUser(getValidSSOToken(), simbaRole, user);
simbaDatabaseRule.assertUserRoleExistsAndCleanUp(DUMMY_TEST_USER, anExistingRolename);
}
Aggregations