Search in sources :

Example 6 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project midpoint by Evolveum.

the class TestRestServiceProxyAuthentication method test004getUserSelfByHead.

/**
	 * user head is a super user and has also rest authorization so he can perform any action
	 */
@Test
public void test004getUserSelfByHead() {
    final String TEST_NAME = "test004getUserSelfByHead";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(null);
    client.path("/self");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 200);
    UserType userType = response.readEntity(UserType.class);
    assertNotNull("Returned entity in body must not be null.", userType);
    LOGGER.info("Returned entity: {}", userType.asPrismObject().debugDump());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 7 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project midpoint by Evolveum.

the class TestRestServiceProxyAuthentication method test002getUserSelfByEgoist.

@Test
public void test002getUserSelfByEgoist() {
    final String TEST_NAME = "test002getUserSelfByEgoist";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(USER_EGOIST_OID);
    client.path("/self/");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 200);
    UserType userType = response.readEntity(UserType.class);
    assertNotNull("Returned entity in body must not be null.", userType);
    LOGGER.info("Returned entity: {}", userType.asPrismObject().debugDump());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 8 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project midpoint by Evolveum.

the class TestAbstractRestService method test511validateValueExplicitConflict.

@Test
public void test511validateValueExplicitConflict() throws Exception {
    final String TEST_NAME = "test511validateValueExplicitConflict";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/" + USER_DARTHADDER_OID + "/validate");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT_CONFLICT));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    traceResponse(response);
    assertEquals("Expected 409 but got " + response.getStatus(), 409, response.getStatus());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 9 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project midpoint by Evolveum.

the class TestAbstractRestService method test506generateHonorificPrefixNameExecute.

@Test
public void test506generateHonorificPrefixNameExecute() throws Exception {
    final String TEST_NAME = "test506generateHonorificPrefixNameExecute";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/" + USER_DARTHADDER_OID + "/generate");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_HONORIFIC_PREFIX_EXECUTE));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    traceResponse(response);
    assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(4);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
    getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class);
//UserType user = loadObject(UserType.class, USER_DARTHADDER_OID);
//TODO assert changed items
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 10 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project midpoint by Evolveum.

the class TestAbstractRestService method test600modifySecurityQuestionAnswer.

@Test
public void test600modifySecurityQuestionAnswer() throws Exception {
    final String TEST_NAME = "test600modifySecurityQuestionAnswer";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/" + USER_DARTHADDER_OID);
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    traceResponse(response);
    assertEquals("Expected 204 but got " + response.getStatus(), 204, response.getStatus());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(4);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
    getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class);
    TestUtil.displayWhen(TEST_NAME);
    response = client.get();
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus());
    UserType userDarthadder = response.readEntity(UserType.class);
    CredentialsType credentials = userDarthadder.getCredentials();
    assertNotNull("No credentials in user. Something is wrong.", credentials);
    SecurityQuestionsCredentialsType securityQuestions = credentials.getSecurityQuestions();
    assertNotNull("No security questions defined for user. Something is wrong.", securityQuestions);
    List<SecurityQuestionAnswerType> secQuestionAnswers = securityQuestions.getQuestionAnswer();
    assertEquals("Expected just one question-answer couple, but found " + secQuestionAnswers.size(), 1, secQuestionAnswers.size());
    SecurityQuestionAnswerType secQuestionAnswer = secQuestionAnswers.iterator().next();
    String decrypted = getPrismContext().getDefaultProtector().decryptString(secQuestionAnswer.getQuestionAnswer());
    assertEquals("Unexpected answer " + decrypted + ". Expected 'newAnswer'.", "newAnswer", decrypted);
}
Also used : Response(javax.ws.rs.core.Response) SecurityQuestionsCredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsType) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) SecurityQuestionsCredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsType) WebClient(org.apache.cxf.jaxrs.client.WebClient) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SecurityQuestionAnswerType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType) Test(org.testng.annotations.Test)

Aggregations

WebClient (org.apache.cxf.jaxrs.client.WebClient)107 Response (javax.ws.rs.core.Response)82 Test (org.testng.annotations.Test)46 Test (org.junit.Test)35 SourceResponse (ddf.catalog.operation.SourceResponse)16 Matchers.containsString (org.hamcrest.Matchers.containsString)14 ResourceResponse (ddf.catalog.operation.ResourceResponse)12 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 SecureCxfClientFactory (org.codice.ddf.cxf.SecureCxfClientFactory)11 QueryImpl (ddf.catalog.operation.impl.QueryImpl)10 Filter (org.opengis.filter.Filter)10 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)9 Metacard (ddf.catalog.data.Metacard)8 Subject (ddf.security.Subject)8 InputStream (java.io.InputStream)7 Result (ddf.catalog.data.Result)5 IOException (java.io.IOException)5 MalformedURLException (java.net.MalformedURLException)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)4