[email protected] | 7292162 | 2013-07-17 17:22:48 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
Jiaming Cheng | 99f8570e | 2021-07-26 23:23:29 | [diff] [blame] | 5 | #ifndef GOOGLE_APIS_COMMON_DUMMY_AUTH_SERVICE_H_ |
6 | #define GOOGLE_APIS_COMMON_DUMMY_AUTH_SERVICE_H_ | ||||
[email protected] | 7292162 | 2013-07-17 17:22:48 | [diff] [blame] | 7 | |
8 | #include "base/compiler_specific.h" | ||||
Jiaming Cheng | 99f8570e | 2021-07-26 23:23:29 | [diff] [blame] | 9 | #include "google_apis/common/auth_service_interface.h" |
[email protected] | 7292162 | 2013-07-17 17:22:48 | [diff] [blame] | 10 | |
11 | namespace google_apis { | ||||
12 | |||||
13 | // Dummy implementation of AuthServiceInterface that always return a dummy | ||||
14 | // access token. | ||||
15 | class DummyAuthService : public AuthServiceInterface { | ||||
16 | public: | ||||
[email protected] | fedaeae | 2013-10-11 08:35:54 | [diff] [blame] | 17 | // The constructor presets non-empty tokens. When a test for checking auth |
18 | // failure case (i.e., empty tokens) is needed, explicitly clear them by the | ||||
19 | // Clear{Access, Refresh}Token methods. | ||||
[email protected] | 7292162 | 2013-07-17 17:22:48 | [diff] [blame] | 20 | DummyAuthService(); |
21 | |||||
[email protected] | fedaeae | 2013-10-11 08:35:54 | [diff] [blame] | 22 | void set_access_token(const std::string& token) { access_token_ = token; } |
23 | void set_refresh_token(const std::string& token) { refresh_token_ = token; } | ||||
24 | const std::string& refresh_token() const { return refresh_token_; } | ||||
25 | |||||
[email protected] | 7292162 | 2013-07-17 17:22:48 | [diff] [blame] | 26 | // AuthServiceInterface overrides. |
dcheng | f93bb58 | 2014-10-21 16:11:56 | [diff] [blame] | 27 | void AddObserver(AuthServiceObserver* observer) override; |
28 | void RemoveObserver(AuthServiceObserver* observer) override; | ||||
Anand K. Mistry | 8bd35f1f | 2020-01-15 03:27:10 | [diff] [blame] | 29 | void StartAuthentication(AuthStatusCallback callback) override; |
dcheng | f93bb58 | 2014-10-21 16:11:56 | [diff] [blame] | 30 | bool HasAccessToken() const override; |
31 | bool HasRefreshToken() const override; | ||||
32 | const std::string& access_token() const override; | ||||
33 | void ClearAccessToken() override; | ||||
34 | void ClearRefreshToken() override; | ||||
[email protected] | 7292162 | 2013-07-17 17:22:48 | [diff] [blame] | 35 | |
36 | private: | ||||
[email protected] | fedaeae | 2013-10-11 08:35:54 | [diff] [blame] | 37 | std::string access_token_; |
38 | std::string refresh_token_; | ||||
[email protected] | 7292162 | 2013-07-17 17:22:48 | [diff] [blame] | 39 | }; |
40 | |||||
41 | } // namespace google_apis | ||||
42 | |||||
Jiaming Cheng | 99f8570e | 2021-07-26 23:23:29 | [diff] [blame] | 43 | #endif // GOOGLE_APIS_COMMON_DUMMY_AUTH_SERVICE_H_ |