Search in sources :

Example 81 with WebClient

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

the class TestAbstractRestService method test512validateValueImplicitSingle.

@Test
public void test512validateValueImplicitSingle() throws Exception {
    final String TEST_NAME = "test512validateValueImplicitSingle";
    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_IMPLICIT_SINGLE));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertEquals("Expected 200 but got " + response.getStatus(), 200, 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 82 with WebClient

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

the class TestAbstractRestService method test005GetAuthBadUsernameEmptyPassword.

@Test
public void test005GetAuthBadUsernameEmptyPassword() {
    final String TEST_NAME = "test005GetAuthBadUsernameEmptyPassword";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient("NoSUCHuser", "");
    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 83 with WebClient

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

the class TestAbstractRestService method test200searchAllUsers.

@Test
public void test200searchAllUsers() {
    final String TEST_NAME = "test200searchAllUsers";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/search");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(new QueryType());
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertStatus(response, 200);
    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) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Example 84 with WebClient

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

the class TestAbstractRestService method test504checkGeneratedValue.

@Test
public void test504checkGeneratedValue() throws Exception {
    final String TEST_NAME = "test503generateValueExecute";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/" + USER_DARTHADDER_OID);
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus());
    UserType user = response.readEntity(UserType.class);
    assertNotNull("EmployeeNumber must not be null", user.getEmployeeNumber());
}
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 85 with WebClient

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

the class TestAbstractRestService method test003GetNoAuthHeaders.

@Test
public void test003GetNoAuthHeaders() {
    final String TEST_NAME = "test003GetNoAuthHeaders";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(null, null);
    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());
    // No records. There are no auth headers so this is not considered to be a login attempt
    getDummyAuditService().assertRecords(0);
}
Also used : Response(javax.ws.rs.core.Response) 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