use of org.simbasecurity.dwclient.gateway.representations.SimbaRoleR in project simba-os by cegeka.
the class SimbaManagerRestGatewayTest method isSimbaRestManagerAlive_WhenRoleServiceCallWasSuccessfulAndRoleDoesNotExist_ThenSimbaManagerIsAlive.
@Test
public void isSimbaRestManagerAlive_WhenRoleServiceCallWasSuccessfulAndRoleDoesNotExist_ThenSimbaManagerIsAlive() throws Exception {
String ssoToken = logInWithValidUser();
when(simbaRoleServiceMock.findRoleByName(ssoToken, APP_USER_ROLE)).thenReturn(new SimbaRoleR());
boolean actual = simbaManagerRestGateway.isSimbaRestManagerAlive();
assertThat(actual).isTrue();
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaRoleR in project simba-os by cegeka.
the class SimbaManagerRestGatewayTest method assignRoleToUser_AssignsLookedUpSimbaRoleToLookedUpSimbaUser.
@Test
public void assignRoleToUser_AssignsLookedUpSimbaRoleToLookedUpSimbaUser() 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.assignRoleToUser(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)).addRoleToUser(ssoToken, simbaRole, simbaUser);
}
use of org.simbasecurity.dwclient.gateway.representations.SimbaRoleR 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.SimbaRoleR 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.SimbaRoleR in project simba-os by cegeka.
the class SimbaManagerRestGatewayTest method assignRoleToUser_WhenUsernameDoesNotExist_ThrowsIllegalArgumentException.
@Test
public void assignRoleToUser_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.assignRoleToUser(rolename, username);
}
Aggregations