Search in sources :

Example 41 with WebClient

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

the class TestAbstractRestService method test141GetUserAdministratorByNopasswordBadPassword.

@Test
public void test141GetUserAdministratorByNopasswordBadPassword() {
    final String TEST_NAME = "test140GetUserAdministratorByNopassword";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(USER_NOPASSWORD_USERNAME, "bad");
    client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value());
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 403);
    assertNoEmptyResponse(response);
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(1);
    getDummyAuditService().assertFailedLogin(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 42 with WebClient

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

the class TestAbstractRestService method test401AddUserTemplateOverwrite.

@Test
public void test401AddUserTemplateOverwrite() throws Exception {
    final String TEST_NAME = "test401AddUserTemplateOverwrite";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/objectTemplates");
    client.query("options", "overwrite");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(getRepoFile(USER_TEMPLATE_FILE));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus());
    String location = response.getHeaderString("Location");
    String expected = ENDPOINT_ADDRESS + "/objectTemplates/" + USER_TEMPLATE_OID;
    assertEquals("Unexpected location, expected: " + expected + " but was " + location, expected, location);
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(4);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
    getDummyAuditService().assertHasDelta(1, ChangeType.ADD, ObjectTemplateType.class);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 43 with WebClient

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

the class TestAbstractRestService method test002GetNonExistingUser.

@Test
public void test002GetNonExistingUser() {
    final String TEST_NAME = "test002GetNonExistingUser";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/12345");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 404);
    OperationResultType result = response.readEntity(OperationResultType.class);
    assertNotNull("Error response must contain operation result", result);
    LOGGER.info("Returned result: {}", result);
    assertEquals("Unexpected operation result status", OperationResultStatusType.FATAL_ERROR, result.getStatus());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 44 with WebClient

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

the class TestAbstractRestService method test016GetAuthBadPassword.

@Test
public void test016GetAuthBadPassword() {
    final String TEST_NAME = "test016GetAuthBadPassword";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(USER_ADMINISTRATOR_USERNAME, "forgot");
    client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value());
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 401);
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(1);
    getDummyAuditService().assertFailedLogin(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 45 with WebClient

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

the class TestAbstractRestService method test103AddUserBadTargetCollection.

@Test
public void test103AddUserBadTargetCollection() throws Exception {
    final String TEST_NAME = "test103AddUserBadTargetCollection";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/objectTemplates");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(getRepoFile(USER_DARTHADDER_FILE));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertStatus(response, 400);
    OperationResultType result = response.readEntity(OperationResultType.class);
    assertNotNull("Error response must contain operation result", result);
    LOGGER.info("Returned result: {}", result);
    assertEquals("Unexpected operation result status", OperationResultStatusType.FATAL_ERROR, result.getStatus());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Aggregations

WebClient (org.apache.cxf.jaxrs.client.WebClient)723 Test (org.junit.Test)400 Response (javax.ws.rs.core.Response)351 URL (java.net.URL)198 HashMap (java.util.HashMap)100 Book (org.apache.cxf.systest.jaxrs.security.Book)94 ArrayList (java.util.ArrayList)88 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)87 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)77 ClientAccessToken (org.apache.cxf.rs.security.oauth2.common.ClientAccessToken)60 Bus (org.apache.cxf.Bus)48 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)46 Test (org.testng.annotations.Test)46 Form (javax.ws.rs.core.Form)44 JwtToken (org.apache.cxf.rs.security.jose.jwt.JwtToken)42 JwtClaims (org.apache.cxf.rs.security.jose.jwt.JwtClaims)40 JwtAuthenticationClientFilter (org.apache.cxf.rs.security.jose.jaxrs.JwtAuthenticationClientFilter)32 InputStream (java.io.InputStream)28 ResponseProcessingException (javax.ws.rs.client.ResponseProcessingException)28 Document (org.w3c.dom.Document)27