blob: 23d0f769d7641e8161849c7599573483234ec3bb [file] [log] [blame]
[email protected]72921622013-07-17 17:22:481// 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 Cheng99f8570e2021-07-26 23:23:295#ifndef GOOGLE_APIS_COMMON_DUMMY_AUTH_SERVICE_H_
6#define GOOGLE_APIS_COMMON_DUMMY_AUTH_SERVICE_H_
[email protected]72921622013-07-17 17:22:487
8#include "base/compiler_specific.h"
Jiaming Cheng99f8570e2021-07-26 23:23:299#include "google_apis/common/auth_service_interface.h"
[email protected]72921622013-07-17 17:22:4810
11namespace google_apis {
12
13// Dummy implementation of AuthServiceInterface that always return a dummy
14// access token.
15class DummyAuthService : public AuthServiceInterface {
16 public:
[email protected]fedaeae2013-10-11 08:35:5417 // 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]72921622013-07-17 17:22:4820 DummyAuthService();
21
[email protected]fedaeae2013-10-11 08:35:5422 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]72921622013-07-17 17:22:4826 // AuthServiceInterface overrides.
dchengf93bb582014-10-21 16:11:5627 void AddObserver(AuthServiceObserver* observer) override;
28 void RemoveObserver(AuthServiceObserver* observer) override;
Anand K. Mistry8bd35f1f2020-01-15 03:27:1029 void StartAuthentication(AuthStatusCallback callback) override;
dchengf93bb582014-10-21 16:11:5630 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]72921622013-07-17 17:22:4835
36 private:
[email protected]fedaeae2013-10-11 08:35:5437 std::string access_token_;
38 std::string refresh_token_;
[email protected]72921622013-07-17 17:22:4839};
40
41} // namespace google_apis
42
Jiaming Cheng99f8570e2021-07-26 23:23:2943#endif // GOOGLE_APIS_COMMON_DUMMY_AUTH_SERVICE_H_