use of org.pentaho.platform.web.http.api.resources.services.UserRoleDaoService in project pentaho-platform by pentaho.
the class UserRoleDaoResourceTest method testUpdatePasswordNotAdmin.
@Test
public void testUpdatePasswordNotAdmin() throws Exception {
UserRoleDaoService mockService = mock(UserRoleDaoService.class);
doThrow(new SecurityException()).when(mockService).updatePassword(any(User.class));
UserRoleDaoResource resource = new UserRoleDaoResource(roleBindingDao, tenantManager, systemRoles, adminRole, mockService);
try {
resource.updatePassword(new UserChangePasswordDTO("name", "newPassword", "bogusPassword"));
} catch (WebApplicationException e) {
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), e.getResponse().getStatus());
}
}
use of org.pentaho.platform.web.http.api.resources.services.UserRoleDaoService in project pentaho-platform by pentaho.
the class UserRoleDaoResourceTest method testCreateUserDuplicate.
@Test
public void testCreateUserDuplicate() throws Exception {
UserRoleDaoService mockService = mock(UserRoleDaoService.class);
doThrow(new AlreadyExistsException("message")).when(mockService).createUser(any(User.class));
UserRoleDaoResource resource = new UserRoleDaoResource(roleBindingDao, tenantManager, systemRoles, adminRole, mockService);
try {
resource.createUser(new User("user", "duplicate"));
} catch (WebApplicationException e) {
assertEquals(Response.Status.PRECONDITION_FAILED.getStatusCode(), e.getResponse().getStatus());
}
}
use of org.pentaho.platform.web.http.api.resources.services.UserRoleDaoService in project pentaho-platform by pentaho.
the class UserRoleDaoResourceTest method testCreateRoleSecurityException.
@Test
public void testCreateRoleSecurityException() throws Exception {
UserRoleDaoService mockService = mock(UserRoleDaoService.class);
doThrow(new SecurityException()).when(mockService).createRole(anyString());
UserRoleDaoResource resource = new UserRoleDaoResource(roleBindingDao, tenantManager, systemRoles, adminRole, mockService);
try {
resource.createRole("anyRoleName");
} catch (WebApplicationException e) {
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), e.getResponse().getStatus());
}
}
Aggregations