@Test public void testCreateZoneWithNonUniqueSubdomain() { IdentityZone idZone1 = new IdentityZone(); String id1 = UUID.randomUUID().toString(); idZone1.setId(id1); idZone1.setSubdomain(id1 + "non-unique"); idZone1.setName("testCreateZone() " + id1); ResponseEntity<Void> response1 = client.exchange( serverRunning.getUrl("/identity-zones"), HttpMethod.POST, new HttpEntity<>(idZone1), new ParameterizedTypeReference<Void>() {}, id1); assertEquals(HttpStatus.CREATED, response1.getStatusCode()); IdentityZone idZone2 = new IdentityZone(); String id2 = UUID.randomUUID().toString(); idZone2.setId(id2); idZone2.setSubdomain(id1 + "non-unique"); idZone2.setName("testCreateZone() " + id2); ResponseEntity<Map<String, String>> response2 = client.exchange( serverRunning.getUrl("/identity-zones"), HttpMethod.POST, new HttpEntity<>(idZone2), new ParameterizedTypeReference<Map<String, String>>() {}, id2); assertEquals(HttpStatus.CONFLICT, response2.getStatusCode()); Assert.assertTrue( response2.getBody().get("error_description").toLowerCase().contains("subdomain")); }
@Test public void testCreateZoneWithClient() throws IOException { IdentityZone idZone = new IdentityZone(); String id = UUID.randomUUID().toString(); idZone.setId(id); idZone.setSubdomain(id); idZone.setName("testCreateZone() " + id); ResponseEntity<Void> response = client.exchange( serverRunning.getUrl("/identity-zones"), HttpMethod.POST, new HttpEntity<>(idZone), new ParameterizedTypeReference<Void>() {}, id); assertEquals(HttpStatus.CREATED, response.getStatusCode()); BaseClientDetails clientDetails = new BaseClientDetails("test123", null, "openid", "authorization_code", "uaa.resource"); clientDetails.setClientSecret("testSecret"); clientDetails.addAdditionalInformation( ClientConstants.ALLOWED_PROVIDERS, Collections.singleton(Origin.UAA)); ResponseEntity<Void> clientCreateResponse = client.exchange( serverRunning.getUrl("/identity-zones/" + id + "/clients"), HttpMethod.POST, new HttpEntity<>(clientDetails), new ParameterizedTypeReference<Void>() {}, id); assertEquals(HttpStatus.CREATED, clientCreateResponse.getStatusCode()); ResponseEntity<Void> clientDeleteResponse = client.exchange( serverRunning.getUrl( "/identity-zones/" + id + "/clients/" + clientDetails.getClientId()), HttpMethod.DELETE, null, new ParameterizedTypeReference<Void>() {}, id); assertEquals(HttpStatus.OK, clientDeleteResponse.getStatusCode()); }