use of org.orcid.api.common.WebDriverHelper in project ORCID-Source by ORCID.
the class BlackBoxBase method getFullAuthorizationCodeUrl.
public String getFullAuthorizationCodeUrl(String clientId, String clientRedirectUri, String scopes, String userId, String password, boolean longLife) throws InterruptedException {
WebDriverHelper webDriverHelper = new WebDriverHelper(getWebDriver(), getWebBaseUrl(), clientRedirectUri);
oauthHelper.setWebDriverHelper(webDriverHelper);
return oauthHelper.getFullAuthorizationCodeUrl(clientId, scopes, userId, password, longLife);
}
use of org.orcid.api.common.WebDriverHelper in project ORCID-Source by ORCID.
the class RefreshTokenTest method generateRefreshTokenInPublicAPITest.
@Test
public void generateRefreshTokenInPublicAPITest() throws InterruptedException, JSONException {
String clientId = getClient1ClientId();
String clientSecret = getClient1ClientSecret();
String redirectUri = getClient1RedirectUri();
String userId = getUser1OrcidId();
String userPassword = getUser1Password();
WebDriverHelper webDriverHelper = new WebDriverHelper(webDriver, this.getWebBaseUrl(), redirectUri);
oauthHelper.setWebDriverHelper(webDriverHelper);
String authorizationCode = oauthHelper.getAuthorizationCode(clientId, ScopePathType.PERSON_UPDATE.value(), userId, userPassword, true);
assertNotNull(authorizationCode);
assertFalse(PojoUtil.isEmpty(authorizationCode));
ClientResponse tokenResponse = oauthHelper.getClientResponse(clientId, clientSecret, null, redirectUri, authorizationCode);
assertEquals(200, tokenResponse.getStatus());
String body = tokenResponse.getEntity(String.class);
JSONObject jsonObject = new JSONObject(body);
String accessToken = (String) jsonObject.get("access_token");
assertNotNull(accessToken);
String refreshToken = (String) jsonObject.get("refresh_token");
assertNotNull(refreshToken);
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("client_id", clientId);
params.add("client_secret", clientSecret);
params.add("redirect_uri", redirectUri);
params.add("refresh_token", refreshToken);
params.add("grant_type", "refresh_token");
tokenResponse = oauthHelper.getOauthT1Client().obtainOauth2RefreshTokenPost("refresh_token", accessToken, params);
assertNotNull(tokenResponse);
assertEquals(200, tokenResponse.getStatus());
body = tokenResponse.getEntity(String.class);
jsonObject = new JSONObject(body);
String refreshedAccessToken = (String) jsonObject.get("access_token");
assertNotNull(refreshedAccessToken);
String refreshedRefreshToken = (String) jsonObject.get("refresh_token");
assertNotNull(refreshedRefreshToken);
assertFalse(refreshedAccessToken.equals(accessToken));
assertFalse(refreshedRefreshToken.equals(refreshToken));
}
Aggregations