Search in sources :

Example 1 with RulesConfig

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

the class RulesConfigsEntityTest method shouldUpdateRulesConfig.

@Test
public void shouldUpdateRulesConfig() throws Exception {
    Request<RulesConfig> request = api.rulesConfigs().update("1", new RulesConfig("my-value"));
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CONNECTION, 200);
    RulesConfig response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("PUT", "/api/v2/rules-configs/1"));
    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("value", "my-value"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) RulesConfig(com.auth0.json.mgmt.RulesConfig) Test(org.junit.Test)

Example 2 with RulesConfig

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

the class RulesConfigsEntityTest method shouldListRules.

@Test
public void shouldListRules() throws Exception {
    Request<List<RulesConfig>> request = api.rulesConfigs().list();
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_RULES_CONFIGS_LIST, 200);
    List<RulesConfig> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/rules-configs"));
    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) RulesConfig(com.auth0.json.mgmt.RulesConfig) List(java.util.List) Test(org.junit.Test)

Example 3 with RulesConfig

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

the class RulesConfigsEntityTest method shouldThrowOnUpdateRulesConfigWithNullKey.

@Test
public void shouldThrowOnUpdateRulesConfigWithNullKey() {
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("'rules config key' cannot be null!");
    api.rulesConfigs().update(null, new RulesConfig("my-value"));
}
Also used : RulesConfig(com.auth0.json.mgmt.RulesConfig) Test(org.junit.Test)

Aggregations

RulesConfig (com.auth0.json.mgmt.RulesConfig)3 Test (org.junit.Test)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 List (java.util.List)1