Search in sources :

Example 1 with DeviceCredentialsFilter

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

the class DeviceCredentialsEntityTest method shouldListDeviceCredentialsWithType.

@Test
public void shouldListDeviceCredentialsWithType() throws Exception {
    DeviceCredentialsFilter filter = new DeviceCredentialsFilter().withType("public_key");
    Request<List<DeviceCredentials>> request = api.deviceCredentials().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_DEVICE_CREDENTIALS_LIST, 200);
    List<DeviceCredentials> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/device-credentials"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("type", "public_key"));
    assertThat(response, is(notNullValue()));
    assertThat(response, hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) DeviceCredentialsFilter(com.auth0.client.mgmt.filter.DeviceCredentialsFilter) List(java.util.List) DeviceCredentials(com.auth0.json.mgmt.DeviceCredentials) Test(org.junit.Test)

Example 2 with DeviceCredentialsFilter

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

the class DeviceCredentialsEntityTest method shouldListDeviceCredentialsWithClientId.

@Test
public void shouldListDeviceCredentialsWithClientId() throws Exception {
    DeviceCredentialsFilter filter = new DeviceCredentialsFilter().withClientId("client_23");
    Request<List<DeviceCredentials>> request = api.deviceCredentials().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_DEVICE_CREDENTIALS_LIST, 200);
    List<DeviceCredentials> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/device-credentials"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("client_id", "client_23"));
    assertThat(response, is(notNullValue()));
    assertThat(response, hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) DeviceCredentialsFilter(com.auth0.client.mgmt.filter.DeviceCredentialsFilter) List(java.util.List) DeviceCredentials(com.auth0.json.mgmt.DeviceCredentials) Test(org.junit.Test)

Example 3 with DeviceCredentialsFilter

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

the class DeviceCredentialsEntityTest method shouldListDeviceCredentialsWithUserId.

@Test
public void shouldListDeviceCredentialsWithUserId() throws Exception {
    DeviceCredentialsFilter filter = new DeviceCredentialsFilter().withUserId("user_23");
    Request<List<DeviceCredentials>> request = api.deviceCredentials().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_DEVICE_CREDENTIALS_LIST, 200);
    List<DeviceCredentials> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/device-credentials"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("user_id", "user_23"));
    assertThat(response, is(notNullValue()));
    assertThat(response, hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) DeviceCredentialsFilter(com.auth0.client.mgmt.filter.DeviceCredentialsFilter) List(java.util.List) DeviceCredentials(com.auth0.json.mgmt.DeviceCredentials) Test(org.junit.Test)

Example 4 with DeviceCredentialsFilter

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

the class DeviceCredentialsEntityTest method shouldListDeviceCredentialsWithFields.

@Test
public void shouldListDeviceCredentialsWithFields() throws Exception {
    DeviceCredentialsFilter filter = new DeviceCredentialsFilter().withFields("some,random,fields", true);
    Request<List<DeviceCredentials>> request = api.deviceCredentials().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_DEVICE_CREDENTIALS_LIST, 200);
    List<DeviceCredentials> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/device-credentials"));
    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) DeviceCredentialsFilter(com.auth0.client.mgmt.filter.DeviceCredentialsFilter) List(java.util.List) DeviceCredentials(com.auth0.json.mgmt.DeviceCredentials) Test(org.junit.Test)

Aggregations

DeviceCredentialsFilter (com.auth0.client.mgmt.filter.DeviceCredentialsFilter)4 DeviceCredentials (com.auth0.json.mgmt.DeviceCredentials)4 List (java.util.List)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)4 Test (org.junit.Test)4