use of org.olat.user.restapi.ManagedUserVO in project openolat by klemens.
the class UserMgmtTest method testGetManagedUser.
@Test
public void testGetManagedUser() throws IOException, URISyntaxException {
String externalId = UUID.randomUUID().toString();
Identity managedId = JunitTestHelper.createAndPersistIdentityAsRndUser("managed-1");
dbInstance.commitAndCloseSession();
securityManager.setExternalId(managedId, externalId);
dbInstance.commitAndCloseSession();
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("users").path("managed").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<ManagedUserVO> managedUsers = parseManagedUserArray(response.getEntity().getContent());
boolean found = false;
for (ManagedUserVO managedUser : managedUsers) {
if (managedUser.getKey().equals(managedId.getKey())) {
found = true;
Assert.assertEquals(externalId, managedUser.getExternalId());
}
Assert.assertNotNull(managedUser.getExternalId());
}
Assert.assertTrue(found);
conn.shutdown();
}
use of org.olat.user.restapi.ManagedUserVO in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method testGetManagedUser.
@Test
public void testGetManagedUser() throws IOException, URISyntaxException {
String externalId = UUID.randomUUID().toString();
Identity managedId = JunitTestHelper.createAndPersistIdentityAsRndUser("managed-1");
dbInstance.commitAndCloseSession();
securityManager.setExternalId(managedId, externalId);
dbInstance.commitAndCloseSession();
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("users").path("managed").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<ManagedUserVO> managedUsers = parseManagedUserArray(response.getEntity().getContent());
boolean found = false;
for (ManagedUserVO managedUser : managedUsers) {
if (managedUser.getKey().equals(managedId.getKey())) {
found = true;
Assert.assertEquals(externalId, managedUser.getExternalId());
}
Assert.assertNotNull(managedUser.getExternalId());
}
Assert.assertTrue(found);
conn.shutdown();
}
Aggregations