Search in sources :

Example 1 with MockEndPoint

use of com.okta.oidc.util.MockEndPoint in project okta-oidc-android by okta.

the class SyncWebAuthClientTest method setUp.

@Before
public void setUp() throws Exception {
    mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    mEndPoint = new MockEndPoint();
    String url = mEndPoint.getUrl();
    mClientFactory = new HttpClientFactory();
    mClientFactory.setClientType(mClientType);
    mHttpClient = mClientFactory.build();
    mConfig = TestValues.getConfigWithUrl(url);
    mStorage = new SharedPreferenceStorage(mContext);
    mGson = new Gson();
    mProviderConfig = TestValues.getProviderConfiguration(url);
    mTokenResponse = TokenResponse.RESTORE.restore(TOKEN_RESPONSE);
    SyncWebAuthClient okta = new Okta.SyncWebAuthBuilder().withConfig(mConfig).withOktaHttpClient(mHttpClient).withContext(mContext).withStorage(mStorage).withEncryptionManager(new EncryptionManagerStub()).create();
    mSyncWebAuth = (SyncWebAuthClientImpl) okta;
    mOktaState = mSyncWebAuth.getOktaState();
    mOktaState.save(mProviderConfig);
}
Also used : SharedPreferenceStorage(com.okta.oidc.storage.SharedPreferenceStorage) MockEndPoint(com.okta.oidc.util.MockEndPoint) Gson(com.google.gson.Gson) EncryptionManagerStub(com.okta.oidc.util.EncryptionManagerStub) HttpClientFactory(com.okta.oidc.util.HttpClientFactory) Before(org.junit.Before)

Example 2 with MockEndPoint

use of com.okta.oidc.util.MockEndPoint in project okta-oidc-android by okta.

the class SessionClientImplTest method setUp.

@Before
public void setUp() throws Exception {
    mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    mEndPoint = new MockEndPoint();
    mGson = new Gson();
    mStorage = new SharedPreferenceStorage(mContext);
    String url = mEndPoint.getUrl();
    mClientFactory = new HttpClientFactory();
    mClientFactory.setClientType(mClientType);
    mConfig = TestValues.getConfigWithUrl(url);
    mProviderConfig = TestValues.getProviderConfiguration(url);
    mTokenResponse = TokenResponse.RESTORE.restore(TOKEN_RESPONSE);
    WebAuthClient okta = new Okta.WebAuthBuilder().withCallbackExecutor(mExecutor).withConfig(mConfig).withOktaHttpClient(mClientFactory.build()).withContext(mContext).withStorage(mStorage).withEncryptionManager(new EncryptionManagerStub()).create();
    mSessionClient = okta.getSessionClient();
    OktaState mOktaState = new OktaState(new OktaRepository(mStorage, mContext, new EncryptionManagerStub(), false, false));
    mOktaState.save(mTokenResponse);
    mOktaState.save(mProviderConfig);
}
Also used : SharedPreferenceStorage(com.okta.oidc.storage.SharedPreferenceStorage) OktaState(com.okta.oidc.OktaState) OktaRepository(com.okta.oidc.storage.OktaRepository) MockEndPoint(com.okta.oidc.util.MockEndPoint) Gson(com.google.gson.Gson) WebAuthClient(com.okta.oidc.clients.web.WebAuthClient) EncryptionManagerStub(com.okta.oidc.util.EncryptionManagerStub) Okta(com.okta.oidc.Okta) HttpClientFactory(com.okta.oidc.util.HttpClientFactory) Before(org.junit.Before)

Example 3 with MockEndPoint

use of com.okta.oidc.util.MockEndPoint in project okta-oidc-android by okta.

the class OktaTest method setUp.

@Before
public void setUp() throws Exception {
    mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    mStorage = new SharedPreferenceStorage(mContext);
    mHttpClient = new HttpClientImpl();
    mEncryptionManager = new EncryptionManagerStub();
    String url = new MockEndPoint().getUrl();
    mConfig = TestValues.getConfigWithUrl(url);
    tabColor = Color.BLACK;
    supportBrowsers = new String[] { "" };
}
Also used : SharedPreferenceStorage(com.okta.oidc.storage.SharedPreferenceStorage) MockEndPoint(com.okta.oidc.util.MockEndPoint) EncryptionManagerStub(com.okta.oidc.util.EncryptionManagerStub) HttpClientImpl(com.okta.oidc.net.HttpClientImpl) Before(org.junit.Before)

Example 4 with MockEndPoint

use of com.okta.oidc.util.MockEndPoint 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 5 with MockEndPoint

use of com.okta.oidc.util.MockEndPoint in project okta-oidc-android by okta.

the class ConfigurationRequestTest method setUp.

@Before
public void setUp() throws Exception {
    mEndPoint = new MockEndPoint();
    String url = mEndPoint.getUrl();
    OIDCConfig config = TestValues.getConfigWithUrl(url);
    mRequest = HttpRequestBuilder.newConfigurationRequest().config(config).createRequest();
    mClientFactory = new HttpClientFactory();
    mClientFactory.setClientType(mClientType);
    mHttpClient = mClientFactory.build();
    OIDCConfig configOAuth2 = TestValues.getConfigWithUrl(url + "/oauth2/default/" + WELL_KNOWN_OAUTH);
    mRequestOAuth2 = HttpRequestBuilder.newConfigurationRequest().config(configOAuth2).createRequest();
    mCallbackExecutor = Executors.newSingleThreadExecutor();
}
Also used : MockEndPoint(com.okta.oidc.util.MockEndPoint) OIDCConfig(com.okta.oidc.OIDCConfig) HttpClientFactory(com.okta.oidc.util.HttpClientFactory) Before(org.junit.Before)

Aggregations

MockEndPoint (com.okta.oidc.util.MockEndPoint)15 Before (org.junit.Before)15 HttpClientFactory (com.okta.oidc.util.HttpClientFactory)12 OIDCConfig (com.okta.oidc.OIDCConfig)6 Gson (com.google.gson.Gson)5 SharedPreferenceStorage (com.okta.oidc.storage.SharedPreferenceStorage)5 EncryptionManagerStub (com.okta.oidc.util.EncryptionManagerStub)5 TokenResponse (com.okta.oidc.net.response.TokenResponse)2 FragmentActivity (androidx.fragment.app.FragmentActivity)1 Okta (com.okta.oidc.Okta)1 OktaState (com.okta.oidc.OktaState)1 SyncWebAuthClient (com.okta.oidc.clients.web.SyncWebAuthClient)1 WebAuthClient (com.okta.oidc.clients.web.WebAuthClient)1 HttpClientImpl (com.okta.oidc.net.HttpClientImpl)1 OktaHttpClient (com.okta.oidc.net.OktaHttpClient)1 ProviderConfiguration (com.okta.oidc.net.request.ProviderConfiguration)1 OktaRepository (com.okta.oidc.storage.OktaRepository)1 OktaStorage (com.okta.oidc.storage.OktaStorage)1 AuthorizationException (com.okta.oidc.util.AuthorizationException)1