Skip to content

Commit

Permalink
#189 : added test for client's secret expiration time update
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyz committed Apr 7, 2016
1 parent afa369a commit 5744ba9
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import javax.ws.rs.HttpMethod;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import static org.testng.Assert.*;
Expand Down Expand Up @@ -93,6 +95,7 @@ public void requestClientAssociate2(final String redirectUris, final String sect

RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setRequest(registerRequest);
registerClient.setExecutor(clientExecutor(true));
RegisterResponse response = registerClient.exec();

showClient(registerClient);
Expand Down Expand Up @@ -149,7 +152,7 @@ public void requestClientAssociate2(final String redirectUris, final String sect
assertTrue(scopes.contains("email"));
assertTrue(scopes.contains("profile"));
assertTrue(scopes.contains("phone"));
assertTrue(scopes.contains("clientinfo"));
// assertTrue(scopes.contains("clientinfo"));

clientId1 = response.getClientId();
registrationAccessToken1 = response.getRegistrationAccessToken();
Expand All @@ -162,15 +165,22 @@ public void requestClientUpdate() throws Exception {

final String logoUriNewValue = "http://www.gluu.org/test/yuriy/logo.png";
final String contact1NewValue = "yuriy@gluu.org";
final String contact2NewValue = "yzabrovaniy@gmail.com";
final String contact2NewValue = "yuriyz@gmail.com";

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);
Expand All @@ -183,6 +193,7 @@ public void requestClientUpdate() throws Exception {

assertTrue(responseContacts.contains(contact1NewValue) && responseContacts.contains(contact2NewValue));
assertNotNull(responseLogoUri.equals(logoUriNewValue));
assertEquals(response.getClientSecretExpiresAt().getTime() / 1000, clientSecretExpiresAt.getTime() / 1000); // check after division on 1000 because of internal server conversion
}

@Test(dependsOnMethods = "requestClientAssociate2")
Expand Down

0 comments on commit 5744ba9

Please sign in to comment.