@Test(dependsOnMethods = "requestClientAssociate2") public void requestClientRead() throws Exception { showTitle("requestClientRead"); RegisterRequest registerRequest = new RegisterRequest(registrationAccessToken1); RegisterClient registerClient = new RegisterClient(registrationClientUri1); registerClient.setRequest(registerRequest); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getRegistrationClientUri()); assertNotNull(response.getClientSecretExpiresAt()); assertNotNull(response.getClaims().get(APPLICATION_TYPE.toString())); assertNotNull(response.getClaims().get(POLICY_URI.toString())); assertNotNull(response.getClaims().get(REQUEST_OBJECT_SIGNING_ALG.toString())); assertNotNull(response.getClaims().get(CONTACTS.toString())); assertNotNull(response.getClaims().get(SECTOR_IDENTIFIER_URI.toString())); assertNotNull(response.getClaims().get(SUBJECT_TYPE.toString())); assertNotNull(response.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString())); assertNotNull(response.getClaims().get(JWKS_URI.toString())); assertNotNull(response.getClaims().get(CLIENT_NAME.toString())); assertNotNull(response.getClaims().get(LOGO_URI.toString())); assertNotNull(response.getClaims().get(REQUEST_URIS.toString())); assertNotNull(response.getClaims().get("scopes")); }
@Test(dependsOnMethods = "requestClientAssociate2") public void requestClientUpdate() throws Exception { showTitle("requestClientUpdate"); final String logoUriNewValue = "http://www.gluu.org/test/yuriy/logo.png"; final String contact1NewValue = "*****@*****.**"; final String contact2NewValue = "*****@*****.**"; Calendar clientSecretExpiresAtCalendar = Calendar.getInstance(); clientSecretExpiresAtCalendar.add(Calendar.DAY_OF_YEAR, 1); Date clientSecretExpiresAt = clientSecretExpiresAtCalendar.getTime(); final RegisterRequest registerRequest = new RegisterRequest(registrationAccessToken1); registerRequest.setHttpMethod(HttpMethod.PUT); registerRequest.setContacts(Arrays.asList(contact1NewValue, contact2NewValue)); registerRequest.setLogoUri(logoUriNewValue); registerRequest.setClientSecretExpiresAt(clientSecretExpiresAt); final RegisterClient registerClient = new RegisterClient(registrationClientUri1); registerClient.setRequest(registerRequest); registerClient.setExecutor(clientExecutor(true)); final RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); // check whether info is really updated final String responseContacts = response.getClaims().get(CONTACTS.toString()); final String responseLogoUri = response.getClaims().get(LOGO_URI.toString()); assertTrue( responseContacts.contains(contact1NewValue) && responseContacts.contains(contact2NewValue)); assertNotNull(responseLogoUri.equals(logoUriNewValue)); long diff = response.getClientSecretExpiresAt().getTime() / 10000 - clientSecretExpiresAt.getTime() / 10000; // check after division on 1000 because of internal server conversion System.out.println( "Diff: " + diff + ", respTime: " + response.getClientSecretExpiresAt().getTime() + ", expAt: " + clientSecretExpiresAt.getTime()); assertTrue(Math.abs(diff) == 0); }