use of org.simbasecurity.dwclient.gateway.representations.SimbaUserR in project simba-os by cegeka.
the class SimbaManagerRestGatewayTest method unassignRoleFromUser_WhenRolenameDoesNotExist_ThrowsIllegalArgumentException.
@Test
public void unassignRoleFromUser_WhenRolenameDoesNotExist_ThrowsIllegalArgumentException() throws Exception {
String username = "ivar";
String rolename = "role name";
logInWithValidUser();
when(simbaUserServiceMock.findUserByName(anyString(), eq(username))).thenReturn(new SimbaUserR(username));
when(simbaRoleServiceMock.findRoleByName(anyString(), eq(rolename))).thenThrow(new IllegalArgumentException());
expectedException.expect(IllegalArgumentException.class);
simbaManagerRestGateway.unassignRoleFromUser(rolename, username);
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaUserR in project simba-os by cegeka.
the class SimbaManagerRestGateway method assignRoleToUser.
public void assignRoleToUser(String rolename, String username) throws SimbaUnavailableException {
checkUsernameNotNull(username);
checkRolenameNotNull(rolename);
String appUserSSOToken = loginWithAppUser();
SimbaRoleR simbaRole = simbaRoleService.findRoleByName(appUserSSOToken, rolename);
SimbaUserR simbaUser = simbaUserService.findUserByName(appUserSSOToken, username);
simbaRoleService.addRoleToUser(appUserSSOToken, simbaRole, simbaUser);
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaUserR in project simba-os by cegeka.
the class SimbaManagerRestGateway method unassignRoleFromUser.
public void unassignRoleFromUser(String rolename, String username) throws SimbaUnavailableException {
checkUsernameNotNull(username);
checkRolenameNotNull(rolename);
String appUserSSOToken = loginWithAppUser();
SimbaRoleR simbaRole = simbaRoleService.findRoleByName(appUserSSOToken, rolename);
SimbaUserR simbaUser = simbaUserService.findUserByName(appUserSSOToken, username);
simbaRoleService.removeRoleFromUser(appUserSSOToken, simbaRole, simbaUser);
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaUserR 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.SimbaUserR in project simba-os by cegeka.
the class SimbaRoleServiceTest method addRoleToUser_WhenRoleIsNull_ThrowsIllegalArgumentException.
@Test
public void addRoleToUser_WhenRoleIsNull_ThrowsIllegalArgumentException() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Role cannot be null.");
simbaRoleService.addRoleToUser(getValidSSOToken(), null, new SimbaUserR());
}
Aggregations