Search in sources :

Example 6 with ConnectionFilter

use of com.auth0.client.mgmt.filter.ConnectionFilter in project auth0-java by auth0.

the class ConnectionsEntityTest method shouldListConnectionsWithStrategy.

@Test
public void shouldListConnectionsWithStrategy() throws Exception {
    ConnectionFilter filter = new ConnectionFilter().withStrategy("auth0");
    @SuppressWarnings("deprecation") Request<List<Connection>> request = api.connections().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CONNECTIONS_LIST, 200);
    List<Connection> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/connections"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("strategy", "auth0"));
    assertThat(response, is(notNullValue()));
    assertThat(response, hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ConnectionFilter(com.auth0.client.mgmt.filter.ConnectionFilter) Connection(com.auth0.json.mgmt.Connection) List(java.util.List) Test(org.junit.Test)

Example 7 with ConnectionFilter

use of com.auth0.client.mgmt.filter.ConnectionFilter in project auth0-java by auth0.

the class ConnectionsEntityTest method shouldGetConnectionWithFields.

@Test
public void shouldGetConnectionWithFields() throws Exception {
    ConnectionFilter filter = new ConnectionFilter().withFields("some,random,fields", true);
    Request<Connection> request = api.connections().get("1", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CONNECTION, 200);
    Connection response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/connections/1"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("fields", "some,random,fields"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ConnectionFilter(com.auth0.client.mgmt.filter.ConnectionFilter) Connection(com.auth0.json.mgmt.Connection) Test(org.junit.Test)

Aggregations

ConnectionFilter (com.auth0.client.mgmt.filter.ConnectionFilter)7 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 Test (org.junit.Test)7 Connection (com.auth0.json.mgmt.Connection)5 List (java.util.List)4 ConnectionsPage (com.auth0.json.mgmt.ConnectionsPage)2