Search in sources :

Example 1 with ManagedUserVO

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();
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) Identity(org.olat.core.id.Identity) ManagedUserVO(org.olat.user.restapi.ManagedUserVO) URI(java.net.URI) Test(org.junit.Test)

Example 2 with ManagedUserVO

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();
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) Identity(org.olat.core.id.Identity) ManagedUserVO(org.olat.user.restapi.ManagedUserVO) URI(java.net.URI) Test(org.junit.Test)

Aggregations

URI (java.net.URI)2 HttpResponse (org.apache.http.HttpResponse)2 HttpGet (org.apache.http.client.methods.HttpGet)2 Test (org.junit.Test)2 Identity (org.olat.core.id.Identity)2 ManagedUserVO (org.olat.user.restapi.ManagedUserVO)2