Search in sources :

Example 46 with WebClient

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

the class TestAbstractRestService method test017GetUnauthorizedUser.

@Test
public void test017GetUnauthorizedUser() {
    final String TEST_NAME = "test017GetUnauthorizedUser";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(USER_NOBODY_USERNAME, USER_NOBODY_PASSWORD);
    client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value());
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 403);
    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 47 with WebClient

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

the class TestAbstractRestService method test135AddUserNopasswordAsDarthAdder.

@Test
public void test135AddUserNopasswordAsDarthAdder() throws Exception {
    final String TEST_NAME = "test135AddUserNopasswordAsDarthAdder";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD);
    client.path("/users");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(getRepoFile(USER_NOPASSWORD_FILE));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertStatus(response, 201);
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(4);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
    getDummyAuditService().assertHasDelta(1, ChangeType.ADD, UserType.class);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 48 with WebClient

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

the class TestAbstractRestService method test001GetUserAdministrator.

@Test
public void test001GetUserAdministrator() {
    final String TEST_NAME = "test001GetUserAdministrator";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value());
    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 49 with WebClient

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

the class TestAbstractRestService method test140GetUserAdministratorByNopassword.

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

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

the class TestAbstractRestService method test514validateValueImplicitMultiConflict.

@Test
public void test514validateValueImplicitMultiConflict() throws Exception {
    final String TEST_NAME = "test514validateValueImplicitMultiConflict";
    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_MULTI_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)

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