Search in sources :

Example 6 with TokenResponse

use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.

the class TokensTest method validateTokenInit_fromTokenResponse.

@Test
public void validateTokenInit_fromTokenResponse() {
    TokenResponse tokenResponse = TestValues.getTokenResponse();
    Tokens tokens = new Tokens(tokenResponse);
    assertNotNull(tokens);
    assertEquals(ACCESS_TOKEN, tokens.getAccessToken());
    assertEquals(REFRESH_TOKEN, tokens.getRefreshToken());
    assertEquals(ID_TOKEN, tokens.getIdToken());
    assertEquals(VALID_EXPIRES_IN, tokens.getExpiresIn());
    assertArrayEquals(VALID_SCOPES, tokens.getScope());
}
Also used : TokenResponse(com.okta.oidc.net.response.TokenResponse) Test(org.junit.Test)

Example 7 with TokenResponse

use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.

the class OktaStateTest method getTokenResponse.

@Test
public void getTokenResponse() throws OktaRepository.EncryptionException {
    TokenResponse tokenResponse = TestValues.getTokenResponse();
    mOktaState.save(tokenResponse);
    TokenResponse expected = mOktaState.getTokenResponse();
    assertNotNull(expected);
    assertEquals(tokenResponse.persist(), expected.persist());
}
Also used : TokenResponse(com.okta.oidc.net.response.TokenResponse) Test(org.junit.Test)

Example 8 with TokenResponse

use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.

the class HttpClientImplTest method setUp.

@Before
public void setUp() throws Exception {
    mEndPoint = new MockEndPoint();
    String url = mEndPoint.getUrl();
    OIDCConfig config = TestValues.getConfigWithUrl(url);
    ProviderConfiguration providerConfiguration = TestValues.getProviderConfiguration(url);
    TokenResponse tokenResponse = new Gson().fromJson(JsonStrings.TOKEN_RESPONSE, TokenResponse.class);
    mHttpClient = new HttpClientImpl();
    mRequest = HttpRequestBuilder.newAuthorizedRequest().uri(Uri.parse(mEndPoint.getUrl())).httpRequestMethod(ConnectionParameters.RequestMethod.POST).config(config).providerConfiguration(providerConfiguration).tokenResponse(tokenResponse).createRequest();
}
Also used : TokenResponse(com.okta.oidc.net.response.TokenResponse) MockEndPoint(com.okta.oidc.util.MockEndPoint) OIDCConfig(com.okta.oidc.OIDCConfig) Gson(com.google.gson.Gson) ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration) Before(org.junit.Before)

Example 9 with TokenResponse

use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.

the class RefreshTokenRequestTest method executeRequestFailure.

@Test
public void executeRequestFailure() throws AuthorizationException {
    mExpectedEx.expect(AuthorizationException.class);
    mEndPoint.enqueueReturnInvalidClient();
    TokenResponse response = mRequest.executeRequest(mHttpClient);
    assertNull(response);
}
Also used : TokenResponse(com.okta.oidc.net.response.TokenResponse) Test(org.junit.Test)

Example 10 with TokenResponse

use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.

the class TokenRequestTest method executeRequestFailure.

@Test
public void executeRequestFailure() throws AuthorizationException {
    mExpectedEx.expect(AuthorizationException.class);
    mEndPoint.enqueueReturnInvalidClient();
    TokenResponse response = mRequest.executeRequest(mHttpClient);
    assertNull(response);
}
Also used : TokenResponse(com.okta.oidc.net.response.TokenResponse) Test(org.junit.Test)

Aggregations

TokenResponse (com.okta.oidc.net.response.TokenResponse)25 Test (org.junit.Test)16 ProviderConfiguration (com.okta.oidc.net.request.ProviderConfiguration)7 AuthorizationException (com.okta.oidc.util.AuthorizationException)6 OktaRepository (com.okta.oidc.storage.OktaRepository)5 Gson (com.google.gson.Gson)4 Tokens (com.okta.oidc.Tokens)4 TokenRequest (com.okta.oidc.net.request.TokenRequest)4 AuthorizeResponse (com.okta.oidc.net.response.web.AuthorizeResponse)4 RefreshTokenRequest (com.okta.oidc.net.request.RefreshTokenRequest)3 AuthorizeRequest (com.okta.oidc.net.request.web.AuthorizeRequest)3 MockRequestCallback (com.okta.oidc.util.MockRequestCallback)3 IOException (java.io.IOException)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 JSONObject (org.json.JSONObject)3 OIDCConfig (com.okta.oidc.OIDCConfig)2 AuthorizedRequest (com.okta.oidc.net.request.AuthorizedRequest)2 RevokeTokenRequest (com.okta.oidc.net.request.RevokeTokenRequest)2 WebRequest (com.okta.oidc.net.request.web.WebRequest)2 UserInfo (com.okta.oidc.net.response.UserInfo)2