Search in sources :

Example 6 with AccountDeletionRecord

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

the class MsalCppOAuth2TokenCacheTest method removeAccountWithHomeAccountIdTest.

@Test
public void removeAccountWithHomeAccountIdTest() throws ClientException {
    // Get the generated account
    final AccountRecord generatedAccount = mTestBundle.mGeneratedAccount;
    // Save it to the cache
    mCppCache.saveAccountRecord(generatedAccount);
    mCppCache.saveCredentials(null, mTestBundle.mGeneratedRefreshToken);
    // Call remove
    final AccountDeletionRecord deletionRecord = mCppCache.removeAccount(generatedAccount.getHomeAccountId(), "", "");
    // Check the receipt
    Assert.assertEquals(generatedAccount, deletionRecord.get(0));
    // Try to restore it
    final AccountRecord restoredAccount = mCppCache.getAccount(generatedAccount.getHomeAccountId(), generatedAccount.getEnvironment(), generatedAccount.getRealm());
    // Make sure it doesn't exist....
    Assert.assertNull(restoredAccount);
}
Also used : AccountDeletionRecord(com.microsoft.identity.common.internal.cache.AccountDeletionRecord) AccountRecord(com.microsoft.identity.common.internal.dto.AccountRecord) Test(org.junit.Test)

Example 7 with AccountDeletionRecord

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

the class MsalCppOAuth2TokenCacheTest method removeNonexistentAccountTest.

@Test
public void removeNonexistentAccountTest() throws ClientException {
    final AccountRecord generatedAccount = mTestBundle.mGeneratedAccount;
    final AccountDeletionRecord deletionRecord = mCppCache.removeAccount(generatedAccount.getHomeAccountId(), generatedAccount.getEnvironment(), generatedAccount.getRealm());
    Assert.assertTrue(deletionRecord.isEmpty());
}
Also used : AccountDeletionRecord(com.microsoft.identity.common.internal.cache.AccountDeletionRecord) AccountRecord(com.microsoft.identity.common.internal.dto.AccountRecord) Test(org.junit.Test)

Example 8 with AccountDeletionRecord

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

the class MsalCppOAuth2TokenCacheTest method removeNoMatchingAccount.

@Test
public void removeNoMatchingAccount() throws ClientException {
    // Get the generated account
    final AccountRecord generatedAccount = mTestBundle.mGeneratedAccount;
    // Save it to the cache
    mCppCache.saveAccountRecord(generatedAccount);
    mCppCache.saveCredentials(null, mTestBundle.mGeneratedRefreshToken);
    // Call remove with a different realm
    final AccountDeletionRecord deletionRecord = mCppCache.removeAccount(generatedAccount.getHomeAccountId(), generatedAccount.getEnvironment(), REALM2);
    // Check the receipt, should remove nothing
    Assert.assertEquals(0, deletionRecord.size());
}
Also used : AccountDeletionRecord(com.microsoft.identity.common.internal.cache.AccountDeletionRecord) AccountRecord(com.microsoft.identity.common.internal.dto.AccountRecord) Test(org.junit.Test)

Example 9 with AccountDeletionRecord

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

the class MsalCppOAuth2TokenCacheTest method removeAccountTest.

@Test
public void removeAccountTest() throws ClientException {
    // Get the generated account
    final AccountRecord generatedAccount = mTestBundle.mGeneratedAccount;
    // Save it to the cache
    mCppCache.saveAccountRecord(generatedAccount);
    mCppCache.saveCredentials(null, mTestBundle.mGeneratedRefreshToken);
    // Call remove
    final AccountDeletionRecord deletionRecord = mCppCache.removeAccount(generatedAccount.getHomeAccountId(), generatedAccount.getEnvironment(), generatedAccount.getRealm());
    // Check the receipt
    Assert.assertEquals(generatedAccount, deletionRecord.get(0));
    // Try to restore it
    final AccountRecord restoredAccount = mCppCache.getAccount(generatedAccount.getHomeAccountId(), generatedAccount.getEnvironment(), generatedAccount.getRealm());
    // Make sure it doesn't exist....
    Assert.assertNull(restoredAccount);
}
Also used : AccountDeletionRecord(com.microsoft.identity.common.internal.cache.AccountDeletionRecord) AccountRecord(com.microsoft.identity.common.internal.dto.AccountRecord) Test(org.junit.Test)

Aggregations

AccountDeletionRecord (com.microsoft.identity.common.internal.cache.AccountDeletionRecord)9 AccountRecord (com.microsoft.identity.common.internal.dto.AccountRecord)9 Test (org.junit.Test)9 BrokerApplicationMetadata (com.microsoft.identity.common.internal.cache.BrokerApplicationMetadata)1 BrokerOAuth2TokenCache (com.microsoft.identity.common.internal.cache.BrokerOAuth2TokenCache)1 ICacheRecord (com.microsoft.identity.common.internal.cache.ICacheRecord)1 MicrosoftFamilyOAuth2TokenCache (com.microsoft.identity.common.internal.cache.MicrosoftFamilyOAuth2TokenCache)1 MsalOAuth2TokenCache (com.microsoft.identity.common.internal.cache.MsalOAuth2TokenCache)1 OAuth2TokenCache (com.microsoft.identity.common.internal.providers.oauth2.OAuth2TokenCache)1 ArrayList (java.util.ArrayList)1