Skip to content

Commit 767d61e

Browse files
authored
Merge pull request #147 from rrybalkin/support-client-description-field
Application (aka Client) description field support
2 parents 0e4e703 + fe8c354 commit 767d61e

2 files changed

Lines changed: 35 additions & 11 deletions

File tree

src/main/java/com/auth0/json/mgmt/client/Client.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class Client {
1818

1919
@JsonProperty("name")
2020
private String name;
21+
@JsonProperty("description")
22+
private String description;
2123
@JsonProperty("client_id")
2224
private String clientId;
2325
@JsonProperty("client_secret")
@@ -99,6 +101,26 @@ public void setName(String name) {
99101
this.name = name;
100102
}
101103

104+
/**
105+
* Getter for the description of the application.
106+
*
107+
* @return the description.
108+
*/
109+
@JsonProperty("description")
110+
public String getDescription() {
111+
return description;
112+
}
113+
114+
/**
115+
* Setter for the description of the application.
116+
*
117+
* @param description the description to use.
118+
*/
119+
@JsonProperty("description")
120+
public void setDescription(String description) {
121+
this.description = description;
122+
}
123+
102124
/**
103125
* Getter for the application's client id.
104126
*

src/test/java/com/auth0/json/mgmt/client/ClientTest.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.hamcrest.collection.IsMapContaining;
66
import org.junit.Test;
77

8-
import java.util.Arrays;
98
import java.util.Collections;
109
import java.util.List;
1110
import java.util.Map;
@@ -15,19 +14,20 @@
1514

1615
public class ClientTest extends JsonTest<Client> {
1716

18-
private static final String json = "{\"name\":\"name\",\"client_secret\":\"secret\",\"app_type\":\"type\",\"logo_uri\":\"uri\",\"oidc_conformant\":true,\"callbacks\":[\"value\"],\"allowed_origins\":[\"value\"],\"client_aliases\":[\"value\"],\"allowed_clients\":[\"value\"],\"allowed_logout_urls\":[\"value\"],\"jwt_configuration\":{\"lifetime_in_seconds\":100,\"scopes\":\"openid\",\"alg\":\"alg\"},\"encryption_key\":{\"pub\":\"pub\",\"cert\":\"cert\"},\"sso\":true,\"sso_disabled\":true,\"custom_login_page_on\":true,\"custom_login_page\":\"custom\",\"custom_login_page_preview\":\"preview\",\"form_template\":\"template\",\"addons\":{\"rms\":{},\"mscrm\":{},\"slack\":{},\"layer\":{}},\"token_endpoint_auth_method\":\"method\",\"client_metadata\":{\"key\":\"value\"},\"mobile\":{\"android\":{\"app_package_name\":\"pkg\",\"sha256_cert_fingerprints\":[\"256\"]},\"ios\":{\"team_id\":\"team\",\"app_bundle_identifier\":\"id\"}}}";
17+
private static final String json = "{\"name\":\"name\",\"description\":\"description\",\"client_secret\":\"secret\",\"app_type\":\"type\",\"logo_uri\":\"uri\",\"oidc_conformant\":true,\"callbacks\":[\"value\"],\"allowed_origins\":[\"value\"],\"client_aliases\":[\"value\"],\"allowed_clients\":[\"value\"],\"allowed_logout_urls\":[\"value\"],\"jwt_configuration\":{\"lifetime_in_seconds\":100,\"scopes\":\"openid\",\"alg\":\"alg\"},\"encryption_key\":{\"pub\":\"pub\",\"cert\":\"cert\"},\"sso\":true,\"sso_disabled\":true,\"custom_login_page_on\":true,\"custom_login_page\":\"custom\",\"custom_login_page_preview\":\"preview\",\"form_template\":\"template\",\"addons\":{\"rms\":{},\"mscrm\":{},\"slack\":{},\"layer\":{}},\"token_endpoint_auth_method\":\"method\",\"client_metadata\":{\"key\":\"value\"},\"mobile\":{\"android\":{\"app_package_name\":\"pkg\",\"sha256_cert_fingerprints\":[\"256\"]},\"ios\":{\"team_id\":\"team\",\"app_bundle_identifier\":\"id\"}}}";
1918
private static final String readOnlyJson = "{\"client_id\":\"clientId\",\"is_first_party\":true,\"is_heroku_app\":true,\"signing_keys\":[{\"cert\":\"ce\",\"pkcs7\":\"pk\",\"subject\":\"su\"}]}";
2019

2120
@Test
2221
public void shouldSerialize() throws Exception {
2322
Client client = new Client("ignored");
2423

2524
client.setName("name");
25+
client.setDescription("description");
2626
client.setClientSecret("secret");
2727
client.setAppType("type");
2828
client.setLogoUri("uri");
2929
client.setOIDCConformant(true);
30-
List<String> stringList = Arrays.asList("value");
30+
List<String> stringList = Collections.singletonList("value");
3131
client.setCallbacks(stringList);
3232
client.setAllowedOrigins(stringList);
3333
client.setClientAliases(stringList);
@@ -46,24 +46,25 @@ public void shouldSerialize() throws Exception {
4646
Addons addons = new Addons(new Addon(), new Addon(), new Addon(), new Addon());
4747
client.setAddons(addons);
4848
client.setTokenEndpointAuthMethod("method");
49-
Map<String, Object> metadata = Collections.singletonMap("key", (Object) "value");
49+
Map<String, Object> metadata = Collections.singletonMap("key", "value");
5050
client.setClientMetadata(metadata);
51-
Mobile mobile = new Mobile(new Android("pkg", Arrays.asList("256")), new IOS("team", "id"));
51+
Mobile mobile = new Mobile(new Android("pkg", Collections.singletonList("256")), new IOS("team", "id"));
5252
client.setMobile(mobile);
5353

5454
String serialized = toJSON(client);
5555
assertThat(serialized, is(notNullValue()));
5656

5757
assertThat(serialized, JsonMatcher.hasEntry("name", "name"));
58+
assertThat(serialized, JsonMatcher.hasEntry("description", "description"));
5859
assertThat(serialized, JsonMatcher.hasEntry("client_secret", "secret"));
5960
assertThat(serialized, JsonMatcher.hasEntry("app_type", "type"));
6061
assertThat(serialized, JsonMatcher.hasEntry("logo_uri", "uri"));
6162
assertThat(serialized, JsonMatcher.hasEntry("oidc_conformant", true));
62-
assertThat(serialized, JsonMatcher.hasEntry("callbacks", Arrays.asList("value")));
63-
assertThat(serialized, JsonMatcher.hasEntry("allowed_origins", Arrays.asList("value")));
64-
assertThat(serialized, JsonMatcher.hasEntry("client_aliases", Arrays.asList("value")));
65-
assertThat(serialized, JsonMatcher.hasEntry("allowed_clients", Arrays.asList("value")));
66-
assertThat(serialized, JsonMatcher.hasEntry("allowed_logout_urls", Arrays.asList("value")));
63+
assertThat(serialized, JsonMatcher.hasEntry("callbacks", Collections.singletonList("value")));
64+
assertThat(serialized, JsonMatcher.hasEntry("allowed_origins", Collections.singletonList("value")));
65+
assertThat(serialized, JsonMatcher.hasEntry("client_aliases", Collections.singletonList("value")));
66+
assertThat(serialized, JsonMatcher.hasEntry("allowed_clients", Collections.singletonList("value")));
67+
assertThat(serialized, JsonMatcher.hasEntry("allowed_logout_urls", Collections.singletonList("value")));
6768
assertThat(serialized, JsonMatcher.hasEntry("jwt_configuration", notNullValue()));
6869
assertThat(serialized, JsonMatcher.hasEntry("encryption_key", notNullValue()));
6970
assertThat(serialized, JsonMatcher.hasEntry("sso", true));
@@ -84,6 +85,7 @@ public void shouldDeserialize() throws Exception {
8485
assertThat(client, is(notNullValue()));
8586

8687
assertThat(client.getName(), is("name"));
88+
assertThat(client.getDescription(), is("description"));
8789
assertThat(client.getClientSecret(), is("secret"));
8890
assertThat(client.getAppType(), is("type"));
8991
assertThat(client.getLogoUri(), is("uri"));
@@ -109,7 +111,7 @@ public void shouldDeserialize() throws Exception {
109111

110112
assertThat(client.getAddons(), is(notNullValue()));
111113
assertThat(client.getTokenEndpointAuthMethod(), is("method"));
112-
assertThat(client.getClientMetadata(), IsMapContaining.hasEntry("key", (Object) "value"));
114+
assertThat(client.getClientMetadata(), IsMapContaining.hasEntry("key", "value"));
113115
assertThat(client.getMobile(), is(notNullValue()));
114116
}
115117

0 commit comments

Comments
 (0)