Search in sources :

Example 1 with EmailProvider

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

the class EmailProviderEntityTest method shouldGetEmailProvider.

@Test
public void shouldGetEmailProvider() throws Exception {
    Request<EmailProvider> request = api.emailProvider().get(null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMAIL_PROVIDER, 200);
    EmailProvider response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/emails/provider"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) EmailProvider(com.auth0.json.mgmt.emailproviders.EmailProvider) Test(org.junit.Test)

Example 2 with EmailProvider

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

the class EmailProviderEntityTest method shouldSetupEmailProvider.

@Test
public void shouldSetupEmailProvider() throws Exception {
    Request<EmailProvider> request = api.emailProvider().setup(new EmailProvider("provider"));
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMAIL_PROVIDER, 200);
    EmailProvider response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/emails/provider"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    Map<String, Object> body = bodyFromRequest(recordedRequest);
    assertThat(body.size(), is(1));
    assertThat(body, hasEntry("name", "provider"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) EmailProvider(com.auth0.json.mgmt.emailproviders.EmailProvider) Test(org.junit.Test)

Example 3 with EmailProvider

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

the class EmailProviderEntityTest method shouldGetEmailProviderWithFields.

@Test
public void shouldGetEmailProviderWithFields() throws Exception {
    FieldsFilter filter = new FieldsFilter().withFields("some,random,fields", true);
    Request<EmailProvider> request = api.emailProvider().get(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMAIL_PROVIDER, 200);
    EmailProvider response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/emails/provider"));
    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) EmailProvider(com.auth0.json.mgmt.emailproviders.EmailProvider) FieldsFilter(com.auth0.client.mgmt.filter.FieldsFilter) Test(org.junit.Test)

Example 4 with EmailProvider

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

the class EmailProviderEntityTest method shouldUpdateEmailProvider.

@Test
public void shouldUpdateEmailProvider() throws Exception {
    Request<EmailProvider> request = api.emailProvider().update(new EmailProvider("name"));
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMAIL_PROVIDER, 200);
    EmailProvider response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("PATCH", "/api/v2/emails/provider"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    Map<String, Object> body = bodyFromRequest(recordedRequest);
    assertThat(body.size(), is(1));
    assertThat(body, hasEntry("name", "name"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) EmailProvider(com.auth0.json.mgmt.emailproviders.EmailProvider) Test(org.junit.Test)

Aggregations

EmailProvider (com.auth0.json.mgmt.emailproviders.EmailProvider)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)4 Test (org.junit.Test)4 FieldsFilter (com.auth0.client.mgmt.filter.FieldsFilter)1