summaryrefslogtreecommitdiffstats
path: root/extensions/shell/browser/shell_oauth2_token_service_unittest.cc
blob: 649fd3abd54bc42f606bd1c753dd6ef2b7ad2ec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/shell/browser/shell_oauth2_token_service.h"

#include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/extensions_test.h"

namespace extensions {

class ShellOAuth2TokenServiceTest : public ExtensionsTest {
 public:
  ShellOAuth2TokenServiceTest() {}
  ~ShellOAuth2TokenServiceTest() override {}

 private:
  content::TestBrowserThreadBundle thread_bundle_;
};

// Verifies setting the refresh token makes it available.
TEST_F(ShellOAuth2TokenServiceTest, SetRefreshToken) {
  ShellOAuth2TokenService service(nullptr, "larry@google.com", "token123");

  // Only has a token for the account in the constructor.
  EXPECT_EQ("larry@google.com", service.AccountId());
  EXPECT_TRUE(service.RefreshTokenIsAvailable("larry@google.com"));
  EXPECT_FALSE(service.RefreshTokenIsAvailable("sergey@google.com"));

  service.SetRefreshToken("sergey@google.com", "token456");

  // The account and refresh token have updated.
  EXPECT_EQ("sergey@google.com", service.AccountId());
  EXPECT_FALSE(service.RefreshTokenIsAvailable("larry@google.com"));
  EXPECT_TRUE(service.RefreshTokenIsAvailable("sergey@google.com"));
}

}  // namespace extensions