fake_test_token_storage.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2015 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_FAKE_TEST_TOKEN_STORAGE_H_
  5. #define REMOTING_TEST_FAKE_TEST_TOKEN_STORAGE_H_
  6. #include <string>
  7. #include "remoting/test/test_token_storage.h"
  8. namespace remoting {
  9. namespace test {
  10. // Stubs out the file API and returns fake data so we can remove
  11. // file system dependencies when testing the TestDriverEnvironment.
  12. class FakeTestTokenStorage : public TestTokenStorage {
  13. public:
  14. FakeTestTokenStorage();
  15. FakeTestTokenStorage(const FakeTestTokenStorage&) = delete;
  16. FakeTestTokenStorage& operator=(const FakeTestTokenStorage&) = delete;
  17. ~FakeTestTokenStorage() override;
  18. // TestTokenStorage interface.
  19. std::string FetchRefreshToken() override;
  20. bool StoreRefreshToken(const std::string& refresh_token) override;
  21. std::string FetchUserEmail() override;
  22. bool StoreUserEmail(const std::string& user_email) override;
  23. std::string FetchAccessToken() override;
  24. bool StoreAccessToken(const std::string& access_token) override;
  25. std::string FetchDeviceId() override;
  26. bool StoreDeviceId(const std::string& device_id) override;
  27. bool refresh_token_write_attempted() const {
  28. return refresh_token_write_attempted_;
  29. }
  30. const std::string& stored_refresh_token_value() const {
  31. return stored_refresh_token_value_;
  32. }
  33. void set_refresh_token_value(const std::string& new_token_value) {
  34. refresh_token_value_ = new_token_value;
  35. }
  36. void set_refresh_token_write_succeeded(bool write_succeeded) {
  37. refresh_token_write_succeeded_ = write_succeeded;
  38. }
  39. private:
  40. // Control members used to return specific data to the caller.
  41. std::string refresh_token_value_;
  42. bool refresh_token_write_succeeded_;
  43. // Verification members to observe the value of the data being written.
  44. bool refresh_token_write_attempted_;
  45. std::string stored_refresh_token_value_;
  46. };
  47. } // namespace test
  48. } // namespace remoting
  49. #endif // REMOTING_TEST_FAKE_TEST_TOKEN_STORAGE_H_