Search in sources :

Example 1 with ICacheKeyValueDelegate

use of com.microsoft.identity.common.internal.cache.ICacheKeyValueDelegate in project microsoft-authentication-library-common-for-android by AzureAD.

the class MsalOAuth2TokenCacheTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    mockStrategy = Mockito.mock(MicrosoftStsOAuth2Strategy.class);
    mockRequest = Mockito.mock(MicrosoftStsAuthorizationRequest.class);
    mockResponse = Mockito.mock(MicrosoftStsTokenResponse.class);
    mockCredentialAdapter = Mockito.mock(IAccountCredentialAdapter.class);
    // Used by mocks
    defaultTestBundleV1 = new AccountCredentialTestBundle(MicrosoftAccount.AUTHORITY_TYPE_V1_V2, LOCAL_ACCOUNT_ID, USERNAME, HOME_ACCOUNT_ID, ENVIRONMENT, REALM, TARGET, CACHED_AT, EXPIRES_ON, SECRET, CLIENT_ID, SECRET, MOCK_ID_TOKEN_WITH_CLAIMS, null, SESSION_KEY, V1IdToken);
    defaultTestBundleV2 = new AccountCredentialTestBundle(MicrosoftAccount.AUTHORITY_TYPE_V1_V2, LOCAL_ACCOUNT_ID, USERNAME, HOME_ACCOUNT_ID, ENVIRONMENT, REALM, TARGET, CACHED_AT, EXPIRES_ON, SECRET, CLIENT_ID, SECRET, MOCK_ID_TOKEN_WITH_CLAIMS, null, SESSION_KEY, IdToken);
    // Mocks
    configureMocksForTestBundle(defaultTestBundleV2);
    // Context and related init
    final Context context = InstrumentationRegistry.getTargetContext();
    mSharedPreferencesFileManager = SharedPreferencesFileManager.getSharedPreferences(context, "test_prefs", new StorageHelper(context));
    final ICacheKeyValueDelegate keyValueDelegate = new CacheKeyValueDelegate();
    accountCredentialCache = new SharedPreferencesAccountCredentialCache(keyValueDelegate, mSharedPreferencesFileManager);
    mOauth2TokenCache = new MsalOAuth2TokenCache<>(context, accountCredentialCache, mockCredentialAdapter);
}
Also used : Context(android.content.Context) MicrosoftStsAuthorizationRequest(com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsAuthorizationRequest) IAccountCredentialAdapter(com.microsoft.identity.common.internal.cache.IAccountCredentialAdapter) SharedPreferencesAccountCredentialCache(com.microsoft.identity.common.internal.cache.SharedPreferencesAccountCredentialCache) MicrosoftStsOAuth2Strategy(com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy) StorageHelper(com.microsoft.identity.common.adal.internal.cache.StorageHelper) ICacheKeyValueDelegate(com.microsoft.identity.common.internal.cache.ICacheKeyValueDelegate) MicrosoftStsTokenResponse(com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsTokenResponse) CacheKeyValueDelegate(com.microsoft.identity.common.internal.cache.CacheKeyValueDelegate) ICacheKeyValueDelegate(com.microsoft.identity.common.internal.cache.ICacheKeyValueDelegate) Before(org.junit.Before)

Aggregations

Context (android.content.Context)1 StorageHelper (com.microsoft.identity.common.adal.internal.cache.StorageHelper)1 CacheKeyValueDelegate (com.microsoft.identity.common.internal.cache.CacheKeyValueDelegate)1 IAccountCredentialAdapter (com.microsoft.identity.common.internal.cache.IAccountCredentialAdapter)1 ICacheKeyValueDelegate (com.microsoft.identity.common.internal.cache.ICacheKeyValueDelegate)1 SharedPreferencesAccountCredentialCache (com.microsoft.identity.common.internal.cache.SharedPreferencesAccountCredentialCache)1 MicrosoftStsAuthorizationRequest (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsAuthorizationRequest)1 MicrosoftStsOAuth2Strategy (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy)1 MicrosoftStsTokenResponse (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsTokenResponse)1 Before (org.junit.Before)1