test_token_storage.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2019 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. #ifndef REMOTING_TEST_TEST_TOKEN_STORAGE_H_
  5. #define REMOTING_TEST_TEST_TOKEN_STORAGE_H_
  6. #include <memory>
  7. #include <string>
  8. #include "remoting/test/test_device_id_provider.h"
  9. namespace base {
  10. class FilePath;
  11. }
  12. namespace remoting {
  13. namespace test {
  14. // Used to store and retrieve tokens for test. This interface is provided to
  15. // allow for stubbing out the storage mechanism for testing.
  16. class TestTokenStorage : public TestDeviceIdProvider::TokenStorage {
  17. public:
  18. TestTokenStorage() = default;
  19. ~TestTokenStorage() override = default;
  20. virtual std::string FetchRefreshToken() = 0;
  21. virtual bool StoreRefreshToken(const std::string& refresh_token) = 0;
  22. virtual std::string FetchUserEmail() = 0;
  23. virtual bool StoreUserEmail(const std::string& user_email) = 0;
  24. virtual std::string FetchAccessToken() = 0;
  25. virtual bool StoreAccessToken(const std::string& access_token) = 0;
  26. // Returns a TestTokenStorage which reads/writes to a user specific token
  27. // file on the local disk.
  28. static std::unique_ptr<TestTokenStorage> OnDisk(
  29. const std::string& user_name,
  30. const base::FilePath& tokens_file_path);
  31. };
  32. } // namespace test
  33. } // namespace remoting
  34. #endif // REMOTING_TEST_TEST_TOKEN_STORAGE_H_