use of com.okta.oidc.clients.web.SyncWebAuthClient in project okta-oidc-android by okta.
the class SyncSessionClientImplTest method setUp.
@Before
public void setUp() throws Exception {
mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
mEndPoint = new MockEndPoint();
String url = mEndPoint.getUrl();
mConfig = TestValues.getConfigWithUrl(url);
mGson = new Gson();
OktaStorage storage = new SharedPreferenceStorage(mContext);
mProviderConfig = TestValues.getProviderConfiguration(url);
mTokenResponse = TokenResponse.RESTORE.restore(TOKEN_RESPONSE);
mClientFactory = new HttpClientFactory();
mClientFactory.setClientType(mClientType);
mHttpClient = mClientFactory.build();
SyncWebAuthClient mSyncWebAuth = new Okta.SyncWebAuthBuilder().withConfig(mConfig).withOktaHttpClient(mHttpClient).withContext(mContext).withStorage(storage).withEncryptionManager(new EncryptionManagerStub()).create();
mSyncSessionClientImpl = (SyncSessionClientImpl) mSyncWebAuth.getSessionClient();
mOktaState = mSyncSessionClientImpl.getOktaState();
mOktaState.save(mProviderConfig);
}
use of com.okta.oidc.clients.web.SyncWebAuthClient in project okta-oidc-android by okta.
the class SyncSessionClientImplTest method userProfileRequestOAuth2.
@Test
public void userProfileRequestOAuth2() throws AuthorizationException, OktaRepository.EncryptionException {
mExpectedEx.expect(AuthorizationException.class);
// create sessionclient from oauth2 resource
OIDCConfig oauth2Config = TestValues.getConfigWithUrl(mEndPoint.getUrl() + "/oauth2/default/");
SyncWebAuthClient syncWebAuthClient = new Okta.SyncWebAuthBuilder().withConfig(oauth2Config).withOktaHttpClient(mHttpClient).withContext(mContext).withStorage(new SharedPreferenceStorage(mContext, "oauth2prefs")).withEncryptionManager(new EncryptionManagerStub()).create();
SyncSessionClientImpl sessionClient = (SyncSessionClientImpl) syncWebAuthClient.getSessionClient();
AuthorizedRequest request = sessionClient.userProfileRequest(mOktaState.getProviderConfiguration(), mOktaState.getTokenResponse());
request.executeRequest(mHttpClient);
}
use of com.okta.oidc.clients.web.SyncWebAuthClient in project okta-oidc-android by okta.
the class OktaTest method testSyncWebBuilder.
@Test
public void testSyncWebBuilder() {
Okta.SyncWebAuthBuilder builder = mock(Okta.SyncWebAuthBuilder.class);
SyncWebAuthClient otherClient = new Okta.SyncWebAuthBuilder().withConfig(mConfig).withStorage(mStorage).withContext(mContext).withOktaHttpClient(mHttpClient).withTabColor(tabColor).supportedBrowsers(supportBrowsers).withEncryptionManager(mEncryptionManager).create();
when(builder.create()).thenReturn(otherClient);
builder.withConfig(mConfig);
verify(builder).withConfig(mConfig);
builder.withStorage(mStorage);
verify(builder).withStorage(mStorage);
builder.withOktaHttpClient(mHttpClient);
verify(builder).withOktaHttpClient(mHttpClient);
builder.withContext(mContext);
verify(builder).withContext(mContext);
builder.withTabColor(tabColor);
verify(builder).withTabColor(tabColor);
builder.supportedBrowsers(supportBrowsers);
verify(builder).supportedBrowsers(supportBrowsers);
builder.withEncryptionManager(mEncryptionManager);
verify(builder).withEncryptionManager(mEncryptionManager);
Object client = builder.create();
verify(builder).create();
assertEquals(otherClient, client);
}
Aggregations