Skip to content

Commit

Permalink
Add metadata field to Connection object
Browse files Browse the repository at this point in the history
  • Loading branch information
Alison Tong authored and atongbc committed May 9, 2019
1 parent f71e79f commit 9117152
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/auth0/json/mgmt/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class Connection {
private List<String> enabledClients = null;
@JsonProperty("provisioning_ticket_url")
private String provisioningTicketUrl;
@JsonProperty("metadata")
private Map<String, String> metadata;

public Connection() {
}
Expand Down Expand Up @@ -118,4 +120,23 @@ public String getProvisioningTicketUrl() {
return provisioningTicketUrl;
}

/**
* Getter for the metadata of this connection.
*
* @return the map of metadata key-values.
*/
@JsonProperty("metadata")
public Map<String, String> getMetadata() {
return metadata;
}

/**
* Setter for the metadata of this connection.
*
* @param metadata the map of metadata key-values.
*/
@JsonProperty("metadata")
public void setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
}
}
6 changes: 5 additions & 1 deletion 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\",\"strategy\":\"auth0\",\"options\":{},\"enabled_clients\":[\"client1\",\"client2\"]}";
private static final String json = "{\"name\": \"my-connection\",\"strategy\": \"auth0\",\"options\": {},\"enabled_clients\": [\"client1\",\"client2\"],\"metadata\": {\"key\": \"value\"}}";
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 @@ -22,6 +22,7 @@ public void shouldSerialize() throws Exception {
Connection connection = new Connection("my-connection", "auth0");
connection.setOptions(new HashMap<String, Object>());
connection.setEnabledClients(Arrays.asList("client1", "client2"));
connection.setMetadata(new HashMap<String, String>());

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

@Test
Expand All @@ -42,6 +44,7 @@ public void shouldDeserialize() throws Exception {
assertThat(connection.getStrategy(), is("auth0"));
assertThat(connection.getEnabledClients(), contains("client1", "client2"));
assertThat(connection.getProvisioningTicketUrl(), is(nullValue()));
assertThat(connection.getMetadata(), is(notNullValue()));
}

@Test
Expand All @@ -54,6 +57,7 @@ public void shouldDeserializeAd() throws Exception {
assertThat(connection.getStrategy(), is("ad"));
assertThat(connection.getEnabledClients(), contains("client1", "client2"));
assertThat(connection.getProvisioningTicketUrl(), is("https://demo.auth0.com/p/ad/ddQTRlVt"));
assertThat(connection.getMetadata(), is(nullValue()));
}

@Test
Expand Down
5 changes: 4 additions & 1 deletion src/test/resources/mgmt/connection.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"enabled_clients": [
"avUAvH1pgnZGgAGlv8guZLPoaOnjVJsM",
"ScKKdrpyUwfkhOQP6KXItH32INgZf7Rb"
]
],
"metadata": {
"key": "value"
}
}
5 changes: 4 additions & 1 deletion src/test/resources/mgmt/connections_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"enabled_clients": [
"avUAvH1pgnZGgAGlv8guZLPoaOnjVJsM",
"ScKKdrpyUwfkhOQP6KXItH32INgZf7Rb"
]
],
"metadata": {
"key": "value"
}
},
{
"name": "My connection2",
Expand Down

0 comments on commit 9117152

Please sign in to comment.