Skip to content

Commit

Permalink
Add support for Connection realms (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames authored Jan 20, 2022
1 parent 5211476 commit e9e22ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/main/java/com/auth0/json/mgmt/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class Connection {
private String provisioningTicketUrl;
@JsonProperty("metadata")
private Map<String, String> metadata;
@JsonProperty("realms")
private List<String> realms;

public Connection() {
}
Expand Down Expand Up @@ -161,4 +163,24 @@ public Map<String, String> getMetadata() {
public void setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
}

/**
* Getter for the realms of this connection.
*
* @return the list of realms.
*/
@JsonProperty("realms")
public List<String> getRealms() {
return realms;
}

/**
* Setter for the realms of this connection.
*
* @param realms the list of realms.
*/
@JsonProperty("realms")
public void setRealms(List<String> realms) {
this.realms = realms;
}
}
7 changes: 5 additions & 2 deletions src/test/java/com/auth0/json/mgmt/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class ConnectionTest extends JsonTest<Connection> {

private static final String json = "{\"name\": \"my-connection\",\"display_name\": \"My cool connection!\",\"strategy\": \"auth0\",\"options\": {},\"enabled_clients\": [\"client1\",\"client2\"],\"metadata\": {\"key\": \"value\"}}";
private static final String json = "{\"name\": \"my-connection\",\"display_name\": \"My cool connection!\",\"strategy\": \"auth0\",\"options\": {},\"enabled_clients\": [\"client1\",\"client2\"],\"metadata\": {\"key\": \"value\"},\"realms\": [\"realm1\",\"realm2\"]}";
private static final String readOnlyJson = "{\"id\":\"connectionId\"}";

private static final String jsonAd = "{\"name\":\"my-ad-connection\",\"strategy\":\"ad\",\"provisioning_ticket_url\":\"https://demo.auth0.com/p/ad/ddQTRlVt\",\"options\":{},\"enabled_clients\":[\"client1\",\"client2\"]}";
Expand All @@ -24,6 +24,7 @@ public void shouldSerialize() throws Exception {
connection.setOptions(new HashMap<String, Object>());
connection.setEnabledClients(Arrays.asList("client1", "client2"));
connection.setMetadata(new HashMap<String, String>());
connection.setRealms(Arrays.asList("realm1", "realm2"));

String serialized = toJSON(connection);
assertThat(serialized, is(notNullValue()));
Expand All @@ -34,6 +35,7 @@ public void shouldSerialize() throws Exception {
assertThat(serialized, JsonMatcher.hasEntry("enabled_clients", Arrays.asList("client1", "client2")));
assertThat(serialized, JsonMatcher.hasEntry("provisioning_ticket_url", null));
assertThat(serialized, JsonMatcher.hasEntry("metadata", notNullValue()));
assertThat(serialized, JsonMatcher.hasEntry("realms", Arrays.asList("realm1", "realm2")));
}

@Test
Expand All @@ -48,6 +50,7 @@ public void shouldDeserialize() throws Exception {
assertThat(connection.getEnabledClients(), contains("client1", "client2"));
assertThat(connection.getProvisioningTicketUrl(), is(nullValue()));
assertThat(connection.getMetadata(), is(notNullValue()));
assertThat(connection.getRealms(), contains("realm1", "realm2"));
}

@Test
Expand All @@ -70,4 +73,4 @@ public void shouldIncludeReadOnlyValuesOnDeserialize() throws Exception {

assertThat(connection.getId(), is("connectionId"));
}
}
}

0 comments on commit e9e22ea

Please sign in to comment.