Search in sources :

Example 16 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 17 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 18 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 19 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 20 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)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