use of com.microsoft.identity.common.internal.cache.ICacheRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalOAuth2TokenCacheTest method loadTokensV1Compat.
@Test
public void loadTokensV1Compat() throws ClientException {
final ICacheRecord result = loadTestBundleIntoCache(defaultTestBundleV1);
assertEquals(defaultTestBundleV1.mGeneratedAccount, result.getAccount());
assertEquals(defaultTestBundleV1.mGeneratedAccessToken, result.getAccessToken());
assertEquals(defaultTestBundleV1.mGeneratedRefreshToken, result.getRefreshToken());
assertEquals(defaultTestBundleV1.mGeneratedIdToken, result.getV1IdToken());
final ICacheRecord secondaryLoad = mOauth2TokenCache.load(CLIENT_ID, TARGET, defaultTestBundleV1.mGeneratedAccount, BEARER_AUTHENTICATION_SCHEME);
assertEquals(result, secondaryLoad);
}
use of com.microsoft.identity.common.internal.cache.ICacheRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalOAuth2TokenCacheTest method removeAccessToken.
@Test
public void removeAccessToken() throws ClientException {
// Save an Account into the cache
final ICacheRecord result = mOauth2TokenCache.save(mockStrategy, mockRequest, mockResponse);
mOauth2TokenCache.removeCredential(result.getAccessToken());
final ICacheRecord secondaryLoad = mOauth2TokenCache.load(CLIENT_ID, TARGET, defaultTestBundleV2.mGeneratedAccount, BEARER_AUTHENTICATION_SCHEME);
assertEquals(defaultTestBundleV2.mGeneratedAccount, secondaryLoad.getAccount());
assertNull(secondaryLoad.getAccessToken());
assertEquals(defaultTestBundleV2.mGeneratedRefreshToken, secondaryLoad.getRefreshToken());
assertEquals(defaultTestBundleV2.mGeneratedIdToken, secondaryLoad.getIdToken());
}
use of com.microsoft.identity.common.internal.cache.ICacheRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalOAuth2TokenCacheTest method getAccountByLocalAccountIdWithAggregatedDataV1.
@Test
public void getAccountByLocalAccountIdWithAggregatedDataV1() throws ClientException {
// Save an Account into the cache
loadTestBundleIntoCache(defaultTestBundleV1);
final ICacheRecord resultRecord = mOauth2TokenCache.getAccountWithAggregatedAccountDataByLocalAccountId(ENVIRONMENT, CLIENT_ID, LOCAL_ACCOUNT_ID);
assertNotNull(resultRecord);
assertNotNull(resultRecord.getAccount());
assertNotNull(resultRecord.getV1IdToken());
assertNull(resultRecord.getIdToken());
assertNull(resultRecord.getAccessToken());
assertNull(resultRecord.getRefreshToken());
}
use of com.microsoft.identity.common.internal.cache.ICacheRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalOAuth2TokenCacheTest method getAccountByLocalAccountIdWithAggregatedData.
@Test
public void getAccountByLocalAccountIdWithAggregatedData() throws ClientException {
// Save an Account into the cache
mOauth2TokenCache.save(mockStrategy, mockRequest, mockResponse);
final ICacheRecord resultRecord = mOauth2TokenCache.getAccountWithAggregatedAccountDataByLocalAccountId(ENVIRONMENT, CLIENT_ID, LOCAL_ACCOUNT_ID);
assertNotNull(resultRecord);
assertNotNull(resultRecord.getAccount());
assertNotNull(resultRecord.getIdToken());
assertNull(resultRecord.getV1IdToken());
assertNull(resultRecord.getAccessToken());
assertNull(resultRecord.getRefreshToken());
}
use of com.microsoft.identity.common.internal.cache.ICacheRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalOAuth2TokenCacheTest method testFrtFallback.
@Test
public void testFrtFallback() throws ClientException {
// This test verifies changes in common/#893
// We will fallback on an FRT in the local cache for the current user if one is avail
final List<ICacheRecord> result = loadTestBundleIntoCacheWithAggregation(defaultTestBundleV2);
assertEquals(1, result.size());
final ICacheRecord entry = result.get(0);
assertNotNull(entry.getAccount());
assertNotNull(entry.getIdToken());
assertNotNull(entry.getAccessToken());
assertNotNull(entry.getRefreshToken());
// delete the existing RT and insert our FRT
accountCredentialCache.removeCredential(entry.getRefreshToken());
// Modify the existing RT to change the client_id and set a FoCI affiliation
final String fociRtClientId = UUID.randomUUID().toString();
final RefreshTokenRecord modifiedRT = entry.getRefreshToken();
modifiedRT.setFamilyId("1");
modifiedRT.setClientId(fociRtClientId);
accountCredentialCache.saveCredential(modifiedRT);
final ICacheRecord secondaryLoad = mOauth2TokenCache.load(entry.getAccessToken().getClientId(), TARGET, entry.getAccount(), BEARER_AUTHENTICATION_SCHEME);
assertNotNull(secondaryLoad.getRefreshToken());
assertEquals(fociRtClientId, secondaryLoad.getRefreshToken().getClientId());
}
Aggregations