Search in sources :

Example 1 with IdServiceResponse

use of com.salesforce.androidsdk.auth.OAuth2.IdServiceResponse in project SalesforceMobileSDK-Android by forcedotcom.

the class OAuth2Test method testCallIdentityService.

/**
 * Testing callIdentityService. Call refresh token then call out to identity service and
 * check that username returned match the one in TestCredentials.
 *
 * @throws IOException See {@link IOException}.
 * @throws OAuthFailedException See {@link OAuthFailedException}.
 * @throws URISyntaxException See {@link URISyntaxException}.
 */
@Test
public void testCallIdentityService() throws IOException, OAuthFailedException, URISyntaxException {
    // Get an auth token using the refresh token
    TokenEndpointResponse refreshResponse = OAuth2.refreshAuthToken(httpAccess, new URI(TestCredentials.LOGIN_URL), TestCredentials.CLIENT_ID, TestCredentials.REFRESH_TOKEN, null);
    Assert.assertNotNull("Auth token should not be null", refreshResponse.authToken);
    // Now let's call the identity service
    IdServiceResponse id = OAuth2.callIdentityService(httpAccess, TestCredentials.INSTANCE_URL + "/id/" + TestCredentials.ORG_ID + "/" + TestCredentials.USER_ID, refreshResponse.authToken);
    Assert.assertEquals("Wrong username returned", TestCredentials.USERNAME, id.username);
    Assert.assertEquals("Wrong pinLength returned", -1, id.pinLength);
    Assert.assertEquals("Wrong screenLockTimeout returned", -1, id.screenLockTimeout);
    Assert.assertTrue("Wrong biometricUnlockAllowed returned", id.biometricUnlockAllowed);
}
Also used : IdServiceResponse(com.salesforce.androidsdk.auth.OAuth2.IdServiceResponse) TokenEndpointResponse(com.salesforce.androidsdk.auth.OAuth2.TokenEndpointResponse) URI(java.net.URI) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

SmallTest (androidx.test.filters.SmallTest)1 IdServiceResponse (com.salesforce.androidsdk.auth.OAuth2.IdServiceResponse)1 TokenEndpointResponse (com.salesforce.androidsdk.auth.OAuth2.TokenEndpointResponse)1 URI (java.net.URI)1 Test (org.junit.Test)1