use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.
the class OktaStateTest method validateDelete.
@Test
public void validateDelete() throws OktaRepository.EncryptionException {
TokenResponse tokenResponse = TestValues.getTokenResponse();
ProviderConfiguration providerConfiguration = TestValues.getProviderConfiguration(CUSTOM_URL);
mOktaState.save(tokenResponse);
mOktaState.save(providerConfiguration);
mOktaState.delete(tokenResponse);
assertNull(mOktaState.getTokenResponse());
assertNotNull(mOktaState.getProviderConfiguration());
}
use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.
the class HttpResponseTest method jsonOKResponse.
@Test
public void jsonOKResponse() throws Exception {
mServer.enqueue(new MockResponse().setResponseCode(HTTP_OK).addHeader(CONTENT_TYPE, JSON_CONTENT_TYPE).setBody(TOKEN_SUCCESS));
URL url = mServer.url("/").url();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Accept-Language", "en-US");
connection.setRequestProperty("Content-Length", TOKEN_SUCCESS.length() + "");
MockOktaHttpClient httpClient = new MockOktaHttpClient(connection);
InputStream inputStream;
try {
inputStream = connection.getInputStream();
} catch (IOException exception) {
inputStream = connection.getErrorStream();
}
HttpResponse response = new HttpResponse(HTTP_OK, httpClient.getHeaderFields(), httpClient.getContentLength(), inputStream, httpClient);
Map<String, List<String>> headers = response.getHeaders();
int contentLength = response.getContentLength();
int status = response.getStatusCode();
JSONObject jsonObject = response.asJson();
TokenResponse tokenResponse = new Gson().fromJson(jsonObject.toString(), TokenResponse.class);
assertNotNull(tokenResponse);
assertEquals(HTTP_OK, status);
assertNotNull(headers);
assertEquals(contentLength, TOKEN_SUCCESS.length());
}
use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.
the class RefreshTokenRequestTest method executeRequestSuccess.
@Test
public void executeRequestSuccess() throws AuthorizationException {
String jws = TestValues.getJwt(mEndPoint.getUrl(), CUSTOM_NONCE, mConfig.getClientId());
mEndPoint.enqueueTokenSuccess(jws);
TokenResponse response = mRequest.executeRequest(mHttpClient);
assertNotNull(response);
assertEquals(response.getIdToken(), jws);
}
use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.
the class AuthorizedRequestTest method setUp.
@Before
public void setUp() throws Exception {
mEndPoint = new MockEndPoint();
String url = mEndPoint.getUrl();
OIDCConfig config = TestValues.getConfigWithUrl(url);
mProviderConfig = TestValues.getProviderConfiguration(url);
mTokenResponse = new Gson().fromJson(JsonStrings.TOKEN_RESPONSE, TokenResponse.class);
mClientFactory = new HttpClientFactory();
mClientFactory.setClientType(mClientType);
mHttpClient = mClientFactory.build();
mRequest = HttpRequestBuilder.newAuthorizedRequest().uri(Uri.parse(mEndPoint.getUrl())).httpRequestMethod(ConnectionParameters.RequestMethod.POST).config(config).providerConfiguration(mProviderConfig).tokenResponse(mTokenResponse).createRequest();
}
use of com.okta.oidc.net.response.TokenResponse in project okta-oidc-android by okta.
the class TokenRequestTest method executeRequestSuccess.
@Test
public void executeRequestSuccess() throws AuthorizationException {
String jws = TestValues.getJwt(mEndPoint.getUrl(), CUSTOM_NONCE, mConfig.getClientId());
mEndPoint.enqueueTokenSuccess(jws);
TokenResponse response = mRequest.executeRequest(mHttpClient);
assertNotNull(response);
assertEquals(response.getIdToken(), jws);
}
Aggregations