Search in sources :

Example 6 with Connection

use of com.auth0.json.mgmt.Connection in project auth0-java by auth0.

the class ConnectionsEntityTest method shouldListConnectionsWithFields.

@Test
public void shouldListConnectionsWithFields() throws Exception {
    ConnectionFilter filter = new ConnectionFilter().withFields("some,random,fields", true);
    @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("fields", "some,random,fields"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    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 Connection

use of com.auth0.json.mgmt.Connection in project auth0-java by auth0.

the class ConnectionsEntityTest method shouldThrowOnUpdateConnectionWithNullId.

@Test
public void shouldThrowOnUpdateConnectionWithNullId() {
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("'connection id' cannot be null!");
    api.connections().update(null, new Connection("my-connection", "auth0"));
}
Also used : Connection(com.auth0.json.mgmt.Connection) Test(org.junit.Test)

Example 8 with Connection

use of com.auth0.json.mgmt.Connection in project auth0-java by auth0.

the class ConnectionsEntityTest method shouldListConnectionsWithName.

@Test
public void shouldListConnectionsWithName() throws Exception {
    ConnectionFilter filter = new ConnectionFilter().withName("my-connection");
    @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("name", "my-connection"));
    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 9 with Connection

use of com.auth0.json.mgmt.Connection in project auth0-java by auth0.

the class ConnectionsEntityTest method shouldNotListConnectionsWithTotals.

@Test
public void shouldNotListConnectionsWithTotals() throws Exception {
    ConnectionFilter filter = new ConnectionFilter().withTotals(true);
    @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, not(hasQueryParameter("include_totals")));
    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 10 with Connection

use of com.auth0.json.mgmt.Connection in project auth0-java by auth0.

the class ConnectionsEntityTest method shouldListConnections.

@Test
public void shouldListConnections() throws Exception {
    @SuppressWarnings("deprecation") Request<List<Connection>> request = api.connections().list(null);
    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(response, is(notNullValue()));
    assertThat(response, hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Connection(com.auth0.json.mgmt.Connection) List(java.util.List) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)13 Connection (com.auth0.json.mgmt.Connection)10 List (java.util.List)9 IOException (java.io.IOException)6 ConnectionFilter (com.auth0.client.mgmt.filter.ConnectionFilter)5 Auth0Exception (com.auth0.exception.Auth0Exception)5 APIException (com.auth0.exception.APIException)4 RateLimitException (com.auth0.exception.RateLimitException)4 RecordedMultipartRequest (com.auth0.net.multipart.RecordedMultipartRequest)4 JsonParseException (com.fasterxml.jackson.core.JsonParseException)4 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)4 ExpectedException (org.junit.rules.ExpectedException)4 VoidRequest (com.auth0.net.VoidRequest)3 File (java.io.File)3 UsersImportOptions (com.auth0.client.mgmt.filter.UsersImportOptions)2 Job (com.auth0.json.mgmt.jobs.Job)2 User (com.auth0.json.mgmt.users.User)2 FilePart (com.auth0.net.multipart.FilePart)2 KeyValuePart (com.auth0.net.multipart.KeyValuePart)2