Permalink
Browse files

[cfid-392] sync client changes to additional info the other way round

[Fixes #40892293] [cfid-392] updates via API to client autoapprove attribute disappear.

Change-Id: I7d82d9b4403c9eee13bf552012644c7d48697caf
  • Loading branch information...
1 parent f6a4503 commit 534b1b6613e5af89b15924085725b3c7ca153e69 @dsyer dsyer committed Dec 11, 2012
@@ -465,8 +465,8 @@ private ClientDetails syncWithExisting(ClientDetails existing, ClientDetails inp
details.setScope(existing.getScope());
}
- Map<String, Object> additionalInformation = new HashMap<String, Object>(input.getAdditionalInformation());
- additionalInformation.putAll(existing.getAdditionalInformation());
+ Map<String, Object> additionalInformation = new HashMap<String, Object>(existing.getAdditionalInformation());
+ additionalInformation.putAll(input.getAdditionalInformation());
for (String key : Collections.unmodifiableSet(additionalInformation.keySet())) {
if (additionalInformation.get(key)==null) {
additionalInformation.remove(key);
@@ -137,15 +137,18 @@ public void testUpdateClient() throws Exception {
client.setResourceIds(Collections.singleton("foo"));
client.setClientSecret(null);
client.setAuthorities(AuthorityUtils.commaSeparatedStringToAuthorityList("some.crap"));
+ client.setAdditionalInformation(Collections.<String,Object>singletonMap("foo", Arrays.asList("rab")));
ResponseEntity<Void> result = serverRunning.getRestTemplate().exchange(serverRunning.getUrl("/oauth/clients/{client}"),
HttpMethod.PUT, new HttpEntity<BaseClientDetails>(client, headers), Void.class, client.getClientId());
assertEquals(HttpStatus.OK, result.getStatusCode());
ResponseEntity<String> response = serverRunning.getForString("/oauth/clients/" + client.getClientId(), headers);
assertEquals(HttpStatus.OK, response.getStatusCode());
- assertTrue(response.getBody().contains(client.getClientId()));
- assertTrue(response.getBody().contains("some.crap"));
+ String body = response.getBody();
+ assertTrue(body.contains(client.getClientId()));
+ assertTrue(body.contains("some.crap"));
+ assertTrue("Wrong body: " + body, body.contains("\"foo\":[\"rab\"]"));
}
@@ -193,6 +196,7 @@ public void testCreateExistingClientFails() throws Exception {
private BaseClientDetails createClient(String grantTypes) throws Exception {
BaseClientDetails client = new BaseClientDetails(new RandomValueStringGenerator().generate(), "", "foo,bar", grantTypes, "uaa.none");
client.setClientSecret("secret");
+ client.setAdditionalInformation(Collections.<String,Object>singletonMap("foo", Arrays.asList("bar")));
ResponseEntity<Void> result = serverRunning.getRestTemplate().exchange(serverRunning.getUrl("/oauth/clients"),
HttpMethod.POST, new HttpEntity<BaseClientDetails>(client, headers), Void.class);
assertEquals(HttpStatus.CREATED, result.getStatusCode());

0 comments on commit 534b1b6

Please sign in to comment.