use of org.olat.user.restapi.RolesVO in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method testUpdateRoles.
@Test
public void testUpdateRoles() throws IOException, URISyntaxException {
// create an author
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("author-" + UUID.randomUUID().toString());
dbInstance.commitAndCloseSession();
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
RolesVO roles = new RolesVO();
roles.setAuthor(true);
roles.setUserManager(true);
// get roles of author
URI request = UriBuilder.fromUri(getContextURI()).path("/users/" + author.getKey() + "/roles").build();
HttpPost method = conn.createPost(request, MediaType.APPLICATION_JSON);
conn.addJsonEntity(method, roles);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
RolesVO modRoles = conn.parse(response, RolesVO.class);
Assert.assertNotNull(modRoles);
// check the roles
Roles reloadRoles = securityManager.getRoles(author);
Assert.assertTrue(reloadRoles.isAuthor());
Assert.assertFalse(reloadRoles.isGroupManager());
Assert.assertFalse(reloadRoles.isGuestOnly());
Assert.assertFalse(reloadRoles.isInstitutionalResourceManager());
Assert.assertFalse(reloadRoles.isInvitee());
Assert.assertFalse(reloadRoles.isOLATAdmin());
Assert.assertFalse(reloadRoles.isPoolAdmin());
Assert.assertTrue(reloadRoles.isUserManager());
conn.shutdown();
}
use of org.olat.user.restapi.RolesVO in project openolat by klemens.
the class UserRestClient method createAuthor.
public UserVO createAuthor(String name) throws IOException, URISyntaxException {
RestConnection restConnection = new RestConnection(deploymentUrl);
assertTrue(restConnection.login(username, password));
UserVO user = createUser(restConnection, name, "Auth");
RolesVO roles = new RolesVO();
roles.setAuthor(true);
// update roles of author
URI request = getUsersURIBuilder().path(user.getKey().toString()).path("roles").build();
HttpPost method = restConnection.createPost(request, MediaType.APPLICATION_JSON);
restConnection.addJsonEntity(method, roles);
HttpResponse response = restConnection.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
restConnection.shutdown();
return user;
}
use of org.olat.user.restapi.RolesVO in project openolat by klemens.
the class UserMgmtTest method testGetRoles.
@Test
public void testGetRoles() throws IOException, URISyntaxException {
// create an author
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("author-" + UUID.randomUUID().toString());
dbInstance.commitAndCloseSession();
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// get roles of author
URI request = UriBuilder.fromUri(getContextURI()).path("/users/" + author.getKey() + "/roles").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
RolesVO roles = conn.parse(response, RolesVO.class);
Assert.assertNotNull(roles);
Assert.assertTrue(roles.isAuthor());
Assert.assertFalse(roles.isGroupManager());
Assert.assertFalse(roles.isGuestOnly());
Assert.assertFalse(roles.isInstitutionalResourceManager());
Assert.assertFalse(roles.isInvitee());
Assert.assertFalse(roles.isOlatAdmin());
Assert.assertFalse(roles.isUserManager());
conn.shutdown();
}
use of org.olat.user.restapi.RolesVO in project OpenOLAT by OpenOLAT.
the class UserRestClient method createAuthor.
public UserVO createAuthor(String name) throws IOException, URISyntaxException {
RestConnection restConnection = new RestConnection(deploymentUrl);
assertTrue(restConnection.login(username, password));
UserVO user = createUser(restConnection, name, "Auth");
RolesVO roles = new RolesVO();
roles.setAuthor(true);
// update roles of author
URI request = getUsersURIBuilder().path(user.getKey().toString()).path("roles").build();
HttpPost method = restConnection.createPost(request, MediaType.APPLICATION_JSON);
restConnection.addJsonEntity(method, roles);
HttpResponse response = restConnection.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
restConnection.shutdown();
return user;
}
use of org.olat.user.restapi.RolesVO in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method testGetRoles.
@Test
public void testGetRoles() throws IOException, URISyntaxException {
// create an author
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("author-" + UUID.randomUUID().toString());
dbInstance.commitAndCloseSession();
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// get roles of author
URI request = UriBuilder.fromUri(getContextURI()).path("/users/" + author.getKey() + "/roles").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
RolesVO roles = conn.parse(response, RolesVO.class);
Assert.assertNotNull(roles);
Assert.assertTrue(roles.isAuthor());
Assert.assertFalse(roles.isGroupManager());
Assert.assertFalse(roles.isGuestOnly());
Assert.assertFalse(roles.isInstitutionalResourceManager());
Assert.assertFalse(roles.isInvitee());
Assert.assertFalse(roles.isOlatAdmin());
Assert.assertFalse(roles.isUserManager());
conn.shutdown();
}
Aggregations