Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/com/auth0/json/mgmt/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Client {

@JsonProperty("name")
private String name;
@JsonProperty("description")
private String description;
@JsonProperty("client_id")
private String clientId;
@JsonProperty("client_secret")
Expand Down Expand Up @@ -99,6 +101,26 @@ public void setName(String name) {
this.name = name;
}

/**
* Getter for the description of the application.
*
* @return the description.
*/
@JsonProperty("description")
public String getDescription() {
return description;
}

/**
* Setter for the description of the application.
*
* @param description the description to use.
*/
@JsonProperty("description")
public void setDescription(String description) {
this.description = description;
}

/**
* Getter for the application's client id.
*
Expand Down
24 changes: 13 additions & 11 deletions src/test/java/com/auth0/json/mgmt/client/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.hamcrest.collection.IsMapContaining;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand All @@ -15,19 +14,20 @@

public class ClientTest extends JsonTest<Client> {

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\"}}}";
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\"}}}";
private static final String readOnlyJson = "{\"client_id\":\"clientId\",\"is_first_party\":true,\"is_heroku_app\":true,\"signing_keys\":[{\"cert\":\"ce\",\"pkcs7\":\"pk\",\"subject\":\"su\"}]}";

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

client.setName("name");
client.setDescription("description");
client.setClientSecret("secret");
client.setAppType("type");
client.setLogoUri("uri");
client.setOIDCConformant(true);
List<String> stringList = Arrays.asList("value");
List<String> stringList = Collections.singletonList("value");
client.setCallbacks(stringList);
client.setAllowedOrigins(stringList);
client.setClientAliases(stringList);
Expand All @@ -46,24 +46,25 @@ public void shouldSerialize() throws Exception {
Addons addons = new Addons(new Addon(), new Addon(), new Addon(), new Addon());
client.setAddons(addons);
client.setTokenEndpointAuthMethod("method");
Map<String, Object> metadata = Collections.singletonMap("key", (Object) "value");
Map<String, Object> metadata = Collections.singletonMap("key", "value");
client.setClientMetadata(metadata);
Mobile mobile = new Mobile(new Android("pkg", Arrays.asList("256")), new IOS("team", "id"));
Mobile mobile = new Mobile(new Android("pkg", Collections.singletonList("256")), new IOS("team", "id"));
client.setMobile(mobile);

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

assertThat(serialized, JsonMatcher.hasEntry("name", "name"));
assertThat(serialized, JsonMatcher.hasEntry("description", "description"));
assertThat(serialized, JsonMatcher.hasEntry("client_secret", "secret"));
assertThat(serialized, JsonMatcher.hasEntry("app_type", "type"));
assertThat(serialized, JsonMatcher.hasEntry("logo_uri", "uri"));
assertThat(serialized, JsonMatcher.hasEntry("oidc_conformant", true));
assertThat(serialized, JsonMatcher.hasEntry("callbacks", Arrays.asList("value")));
assertThat(serialized, JsonMatcher.hasEntry("allowed_origins", Arrays.asList("value")));
assertThat(serialized, JsonMatcher.hasEntry("client_aliases", Arrays.asList("value")));
assertThat(serialized, JsonMatcher.hasEntry("allowed_clients", Arrays.asList("value")));
assertThat(serialized, JsonMatcher.hasEntry("allowed_logout_urls", Arrays.asList("value")));
assertThat(serialized, JsonMatcher.hasEntry("callbacks", Collections.singletonList("value")));
assertThat(serialized, JsonMatcher.hasEntry("allowed_origins", Collections.singletonList("value")));
assertThat(serialized, JsonMatcher.hasEntry("client_aliases", Collections.singletonList("value")));
assertThat(serialized, JsonMatcher.hasEntry("allowed_clients", Collections.singletonList("value")));
assertThat(serialized, JsonMatcher.hasEntry("allowed_logout_urls", Collections.singletonList("value")));
assertThat(serialized, JsonMatcher.hasEntry("jwt_configuration", notNullValue()));
assertThat(serialized, JsonMatcher.hasEntry("encryption_key", notNullValue()));
assertThat(serialized, JsonMatcher.hasEntry("sso", true));
Expand All @@ -84,6 +85,7 @@ public void shouldDeserialize() throws Exception {
assertThat(client, is(notNullValue()));

assertThat(client.getName(), is("name"));
assertThat(client.getDescription(), is("description"));
assertThat(client.getClientSecret(), is("secret"));
assertThat(client.getAppType(), is("type"));
assertThat(client.getLogoUri(), is("uri"));
Expand All @@ -109,7 +111,7 @@ public void shouldDeserialize() throws Exception {

assertThat(client.getAddons(), is(notNullValue()));
assertThat(client.getTokenEndpointAuthMethod(), is("method"));
assertThat(client.getClientMetadata(), IsMapContaining.hasEntry("key", (Object) "value"));
assertThat(client.getClientMetadata(), IsMapContaining.hasEntry("key", "value"));
assertThat(client.getMobile(), is(notNullValue()));
}

Expand Down