Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7240)

Unified Diff: chrome/browser/signin/token_service_unittest.cc

Issue 9301003: Change X-Auto-Login implementation to use OAuth token. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/signin/token_service_unittest.h ('k') | chrome/browser/signin/ubertoken_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/token_service_unittest.cc
diff --git a/chrome/browser/signin/token_service_unittest.cc b/chrome/browser/signin/token_service_unittest.cc
index 2c8b26438386029e941ec629baccc41a04f5ff3f..6bf25efef02e5cf9e426addc3956c1c6a7fdd5b6 100644
--- a/chrome/browser/signin/token_service_unittest.cc
+++ b/chrome/browser/signin/token_service_unittest.cc
@@ -73,13 +73,14 @@ void TokenServiceTestHarness::SetUp() {
profile_.reset(new TestingProfile());
profile_->CreateWebDataService(false);
WaitForDBLoadCompletion();
+ service_ = profile_->GetTokenService();
success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE,
- content::Source<TokenService>(&service_));
+ content::Source<TokenService>(service_));
failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED,
- content::Source<TokenService>(&service_));
+ content::Source<TokenService>(service_));
- service_.Initialize("test", profile_.get());
+ service_->Initialize("test", profile_.get());
}
void TokenServiceTestHarness::TearDown() {
@@ -112,8 +113,8 @@ class TokenServiceTest : public TokenServiceTestHarness {
public:
virtual void SetUp() {
TokenServiceTestHarness::SetUp();
- service_.UpdateCredentials(credentials_);
- service_.UpdateOAuthCredentials(oauth_token_, oauth_secret_);
+ service_->UpdateCredentials(credentials_);
+ service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_);
}
protected:
void TestLoadSingleToken(
@@ -123,7 +124,7 @@ class TokenServiceTest : public TokenServiceTestHarness {
std::string token = service + "_token";
(*db_tokens)[service] = token;
size_t prev_success_size = success_tracker_.size();
- service_.LoadTokensIntoMemory(*db_tokens, memory_tokens);
+ service_->LoadTokensIntoMemory(*db_tokens, memory_tokens);
// Check notification.
EXPECT_EQ(prev_success_size + 1, success_tracker_.size());
@@ -137,23 +138,23 @@ class TokenServiceTest : public TokenServiceTestHarness {
};
TEST_F(TokenServiceTest, SanityCheck) {
- EXPECT_TRUE(service_.HasLsid());
- EXPECT_EQ(service_.GetLsid(), "lsid");
- EXPECT_FALSE(service_.HasTokenForService("nonexistent service"));
- EXPECT_TRUE(service_.HasOAuthCredentials());
- EXPECT_EQ(service_.GetOAuthToken(), "oauth");
- EXPECT_EQ(service_.GetOAuthSecret(), "secret");
+ EXPECT_TRUE(service_->HasLsid());
+ EXPECT_EQ(service_->GetLsid(), "lsid");
+ EXPECT_FALSE(service_->HasTokenForService("nonexistent service"));
+ EXPECT_TRUE(service_->HasOAuthCredentials());
+ EXPECT_EQ(service_->GetOAuthToken(), "oauth");
+ EXPECT_EQ(service_->GetOAuthSecret(), "secret");
}
TEST_F(TokenServiceTest, NoToken) {
- EXPECT_FALSE(service_.HasTokenForService("nonexistent service"));
- EXPECT_EQ(service_.GetTokenForService("nonexistent service"), std::string());
+ EXPECT_FALSE(service_->HasTokenForService("nonexistent service"));
+ EXPECT_EQ(service_->GetTokenForService("nonexistent service"), std::string());
}
TEST_F(TokenServiceTest, NotificationSuccess) {
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
EXPECT_EQ(1U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
@@ -166,7 +167,7 @@ TEST_F(TokenServiceTest, NotificationSuccess) {
TEST_F(TokenServiceTest, NotificationOAuthLoginTokenSuccess) {
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
- service_.OnOAuthLoginTokenSuccess("rt1", "at1", 3600);
+ service_->OnOAuthLoginTokenSuccess("rt1", "at1", 3600);
EXPECT_EQ(1U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
@@ -180,7 +181,7 @@ TEST_F(TokenServiceTest, NotificationOAuthLoginTokenSuccess) {
TEST_F(TokenServiceTest, NotificationSuccessOAuth) {
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
- service_.OnOAuthWrapBridgeSuccess(
+ service_->OnOAuthWrapBridgeSuccess(
GaiaConstants::kSyncServiceOAuth, "token", "3600");
EXPECT_EQ(1U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
@@ -195,7 +196,7 @@ TEST_F(TokenServiceTest, NotificationFailed) {
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
- service_.OnIssueAuthTokenFailure(GaiaConstants::kSyncService, error);
+ service_->OnIssueAuthTokenFailure(GaiaConstants::kSyncService, error);
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(1U, failure_tracker_.size());
@@ -210,7 +211,7 @@ TEST_F(TokenServiceTest, NotificationOAuthLoginTokenFailed) {
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
- service_.OnOAuthLoginTokenFailure(error);
+ service_->OnOAuthLoginTokenFailure(error);
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(1U, failure_tracker_.size());
@@ -226,7 +227,7 @@ TEST_F(TokenServiceTest, NotificationFailedOAuth) {
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(0U, failure_tracker_.size());
GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
- service_.OnOAuthWrapBridgeFailure(GaiaConstants::kSyncServiceOAuth, error);
+ service_->OnOAuthWrapBridgeFailure(GaiaConstants::kSyncServiceOAuth, error);
EXPECT_EQ(0U, success_tracker_.size());
EXPECT_EQ(1U, failure_tracker_.size());
@@ -238,120 +239,122 @@ TEST_F(TokenServiceTest, NotificationFailedOAuth) {
}
TEST_F(TokenServiceTest, OnTokenSuccessUpdate) {
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token");
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token2");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token2");
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token2");
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService),
+ "token2");
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "");
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "");
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "");
}
TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) {
std::string service = GaiaConstants::kGaiaOAuth2LoginRefreshToken;
- service_.OnOAuthLoginTokenSuccess("rt1", "at1", 3600);
- EXPECT_TRUE(service_.HasOAuthLoginToken());
- EXPECT_EQ(service_.GetOAuth2LoginRefreshToken(), "rt1");
+ service_->OnOAuthLoginTokenSuccess("rt1", "at1", 3600);
+ EXPECT_TRUE(service_->HasOAuthLoginToken());
+ EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt1");
- service_.OnOAuthLoginTokenSuccess("rt2", "at2", 3600);
- EXPECT_TRUE(service_.HasOAuthLoginToken());
- EXPECT_EQ(service_.GetOAuth2LoginRefreshToken(), "rt2");
+ service_->OnOAuthLoginTokenSuccess("rt2", "at2", 3600);
+ EXPECT_TRUE(service_->HasOAuthLoginToken());
+ EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt2");
- service_.OnOAuthLoginTokenSuccess("rt3", "at3", 3600);
- EXPECT_TRUE(service_.HasOAuthLoginToken());
- EXPECT_EQ(service_.GetOAuth2LoginRefreshToken(), "rt3");
+ service_->OnOAuthLoginTokenSuccess("rt3", "at3", 3600);
+ EXPECT_TRUE(service_->HasOAuthLoginToken());
+ EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt3");
}
TEST_F(TokenServiceTest, OnTokenSuccess) {
// Don't "start fetching", just go ahead and issue the callback.
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
// Gaia returns the entire result as the token so while this is a shared
// result with ClientLogin, it doesn't matter, we should still get it back.
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token");
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
// Try the OAuth service.
- service_.OnOAuthWrapBridgeSuccess(
+ service_->OnOAuthWrapBridgeSuccess(
GaiaConstants::kSyncServiceOAuth, "token2", "3600");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncServiceOAuth),
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth),
"token2");
// First didn't change.
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token");
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
}
TEST_F(TokenServiceTest, ResetSimple) {
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_TRUE(service_.HasLsid());
- service_.OnOAuthGetAccessTokenSuccess("token2", "secret");
- service_.OnOAuthWrapBridgeSuccess(
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_TRUE(service_->HasLsid());
+ service_->OnOAuthGetAccessTokenSuccess("token2", "secret");
+ service_->OnOAuthWrapBridgeSuccess(
GaiaConstants::kSyncServiceOAuth, "token3", "4321");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_TRUE(service_.HasOAuthCredentials());
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_TRUE(service_->HasOAuthCredentials());
- service_.ResetCredentialsInMemory();
+ service_->ResetCredentialsInMemory();
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_FALSE(service_.HasLsid());
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasOAuthCredentials());
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_FALSE(service_->HasLsid());
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasOAuthCredentials());
}
TEST_F(TokenServiceTest, ResetComplex) {
TestURLFetcherFactory factory;
- service_.StartFetchingTokens();
+ service_->StartFetchingTokens();
// You have to call delegates by hand with the test fetcher,
// Let's pretend only one returned.
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "eraseme");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService),
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "eraseme");
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService),
"eraseme");
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
- service_.OnOAuthWrapBridgeSuccess(
+ service_->OnOAuthWrapBridgeSuccess(
GaiaConstants::kSyncServiceOAuth, "erasemetoo", "1234");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService),
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService),
"eraseme");
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncServiceOAuth),
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth),
"erasemetoo");
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
- service_.ResetCredentialsInMemory();
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
- EXPECT_FALSE(service_.HasLsid());
- EXPECT_FALSE(service_.HasOAuthCredentials());
+ service_->ResetCredentialsInMemory();
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
+ EXPECT_FALSE(service_->HasLsid());
+ EXPECT_FALSE(service_->HasOAuthCredentials());
// Now start using it again.
- service_.UpdateCredentials(credentials_);
- EXPECT_TRUE(service_.HasLsid());
- service_.StartFetchingTokens();
- service_.UpdateOAuthCredentials(oauth_token_, oauth_secret_);
- EXPECT_TRUE(service_.HasOAuthCredentials());
- service_.StartFetchingOAuthTokens();
-
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
- service_.OnOAuthWrapBridgeSuccess(
+ service_->UpdateCredentials(credentials_);
+ EXPECT_TRUE(service_->HasLsid());
+ service_->StartFetchingTokens();
+ service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_);
+ EXPECT_TRUE(service_->HasOAuthCredentials());
+ service_->StartFetchingOAuthTokens();
+
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
+ service_->OnOAuthWrapBridgeSuccess(
GaiaConstants::kSyncServiceOAuth, "token2", "3600");
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kTalkService, "token3");
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kTalkService, "token3");
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token");
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncServiceOAuth),
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth),
"token2");
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kTalkService), "token3");
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kTalkService),
+ "token3");
}
TEST_F(TokenServiceTest, FullIntegration) {
@@ -360,22 +363,23 @@ TEST_F(TokenServiceTest, FullIntegration) {
{
MockFactory<MockFetcher> factory;
factory.set_results(result);
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
- service_.StartFetchingTokens();
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_FALSE(service_->HasTokenForService(
+ GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
+ service_->StartFetchingTokens();
}
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kTalkService));
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kTalkService));
// Gaia returns the entire result as the token so while this is a shared
// result with ClientLogin, it doesn't matter, we should still get it back.
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), result);
- EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kTalkService), result);
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), result);
+ EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kTalkService), result);
- service_.ResetCredentialsInMemory();
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
+ service_->ResetCredentialsInMemory();
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
}
TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) {
@@ -383,7 +387,7 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) {
std::map<std::string, std::string> db_tokens;
std::map<std::string, std::string> memory_tokens;
- service_.LoadTokensIntoMemory(db_tokens, &memory_tokens);
+ service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
EXPECT_TRUE(db_tokens.empty());
EXPECT_TRUE(memory_tokens.empty());
EXPECT_EQ(0U, success_tracker_.size());
@@ -412,11 +416,11 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) {
db_tokens["ignore"] = "token";
- service_.LoadTokensIntoMemory(db_tokens, &memory_tokens);
+ service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
EXPECT_TRUE(memory_tokens.empty());
db_tokens[GaiaConstants::kSyncService] = "pepper";
- service_.LoadTokensIntoMemory(db_tokens, &memory_tokens);
+ service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncService));
EXPECT_EQ(memory_tokens[GaiaConstants::kSyncService], "pepper");
EXPECT_EQ(1U, success_tracker_.size());
@@ -426,7 +430,7 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) {
// the disk as well, but an older token.
db_tokens[GaiaConstants::kSyncService] = "ignoreme";
db_tokens[GaiaConstants::kSyncServiceOAuth] = "tomato";
- service_.LoadTokensIntoMemory(db_tokens, &memory_tokens);
+ service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
EXPECT_EQ(2U, memory_tokens.size());
EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncServiceOAuth));
@@ -437,78 +441,78 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) {
}
TEST_F(TokenServiceTest, WebDBLoadIntegration) {
- service_.LoadTokensFromDB();
+ service_->LoadTokensFromDB();
WaitForDBLoadCompletion();
EXPECT_EQ(0U, success_tracker_.size());
// Should result in DB write.
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
EXPECT_EQ(1U, success_tracker_.size());
- service_.OnOAuthGetAccessTokenSuccess("token1", "secret");
- service_.OnOAuthWrapBridgeSuccess(
+ service_->OnOAuthGetAccessTokenSuccess("token1", "secret");
+ service_->OnOAuthWrapBridgeSuccess(
GaiaConstants::kSyncServiceOAuth, "token2", "3600");
EXPECT_EQ(2U, success_tracker_.size());
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
// Clean slate.
- service_.ResetCredentialsInMemory();
+ service_->ResetCredentialsInMemory();
success_tracker_.Reset();
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- service_.LoadTokensFromDB();
+ service_->LoadTokensFromDB();
WaitForDBLoadCompletion();
EXPECT_EQ(2U, success_tracker_.size());
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
- EXPECT_TRUE(service_.HasLsid());
- EXPECT_TRUE(service_.HasOAuthCredentials());
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
+ EXPECT_TRUE(service_->HasLsid());
+ EXPECT_TRUE(service_->HasOAuthCredentials());
}
TEST_F(TokenServiceTest, MultipleLoadResetIntegration) {
// Should result in DB write.
- service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
- service_.ResetCredentialsInMemory();
+ service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
+ service_->ResetCredentialsInMemory();
success_tracker_.Reset();
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_FALSE(service_.HasLsid());
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_FALSE(service_->HasLsid());
- service_.OnOAuthGetAccessTokenSuccess("token2", "secret");
- service_.OnOAuthWrapBridgeSuccess(
+ service_->OnOAuthGetAccessTokenSuccess("token2", "secret");
+ service_->OnOAuthWrapBridgeSuccess(
GaiaConstants::kSyncServiceOAuth, "token3", "3600");
- service_.ResetCredentialsInMemory();
+ service_->ResetCredentialsInMemory();
success_tracker_.Reset();
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasOAuthCredentials());
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasOAuthCredentials());
- service_.LoadTokensFromDB();
+ service_->LoadTokensFromDB();
WaitForDBLoadCompletion();
- service_.LoadTokensFromDB(); // Should do nothing.
+ service_->LoadTokensFromDB(); // Should do nothing.
WaitForDBLoadCompletion();
EXPECT_EQ(2U, success_tracker_.size());
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
- EXPECT_TRUE(service_.HasLsid());
- EXPECT_TRUE(service_.HasOAuthCredentials());
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
+ EXPECT_TRUE(service_->HasLsid());
+ EXPECT_TRUE(service_->HasOAuthCredentials());
// Reset it one more time so there's no surprises.
- service_.ResetCredentialsInMemory();
+ service_->ResetCredentialsInMemory();
success_tracker_.Reset();
- service_.LoadTokensFromDB();
+ service_->LoadTokensFromDB();
WaitForDBLoadCompletion();
EXPECT_EQ(2U, success_tracker_.size());
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService));
- EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth));
- EXPECT_TRUE(service_.HasLsid());
- EXPECT_TRUE(service_.HasOAuthCredentials());
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
+ EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
+ EXPECT_TRUE(service_->HasLsid());
+ EXPECT_TRUE(service_->HasOAuthCredentials());
}
#ifndef NDEBUG
@@ -519,15 +523,15 @@ class TokenServiceCommandLineTest : public TokenServiceTestHarness {
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kSetToken, "my_service:my_value");
TokenServiceTestHarness::SetUp();
- service_.UpdateCredentials(credentials_);
- service_.UpdateOAuthCredentials(oauth_token_, oauth_secret_);
+ service_->UpdateCredentials(credentials_);
+ service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_);
*CommandLine::ForCurrentProcess() = original_cl;
}
};
TEST_F(TokenServiceCommandLineTest, TestValueOverride) {
- EXPECT_TRUE(service_.HasTokenForService("my_service"));
- EXPECT_EQ("my_value", service_.GetTokenForService("my_service"));
+ EXPECT_TRUE(service_->HasTokenForService("my_service"));
+ EXPECT_EQ("my_value", service_->GetTokenForService("my_service"));
}
#endif // ifndef NDEBUG
« no previous file with comments | « chrome/browser/signin/token_service_unittest.h ('k') | chrome/browser/signin/ubertoken_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698