#include "chrome/browser/device_identity/device_oauth2_token_service.h"
#include <stdint.h>
#include <memory>
#include <set>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "build/chromeos_buildflags.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "google_apis/gaia/gaia_oauth_client.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/oauth2_access_token_manager_test_util.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
const char kRobotEmail[] = …;
const char kWrongRobotEmail[] = …;
}
class MockDeviceOAuth2TokenStore : public DeviceOAuth2TokenStore { … };
class DeviceOAuth2TokenServiceTest : public testing::Test { … };
void DeviceOAuth2TokenServiceTest::ReturnOAuthUrlFetchResults(
const std::string& url,
net::HttpStatusCode response_code,
const std::string& response_string) { … }
void DeviceOAuth2TokenServiceTest::PerformURLFetchesWithResults(
net::HttpStatusCode tokeninfo_access_token_status,
const std::string& tokeninfo_access_token_response,
net::HttpStatusCode tokeninfo_fetch_status,
const std::string& tokeninfo_fetch_response,
net::HttpStatusCode service_access_token_status,
const std::string& service_access_token_response) { … }
void DeviceOAuth2TokenServiceTest::PerformURLFetches() { … }
void DeviceOAuth2TokenServiceTest::AssertConsumerTokensAndErrors(
int num_tokens,
int num_errors) { … }
TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_Success) { … }
TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_SuccessAsyncLoad) { … }
TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_Cancel) { … }
TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_InitFailure) { … }
TEST_F(DeviceOAuth2TokenServiceTest,
RefreshTokenValidation_Failure_TokenInfoAccessTokenHttpError) { … }
TEST_F(DeviceOAuth2TokenServiceTest,
RefreshTokenValidation_Failure_TokenInfoAccessTokenInvalidResponse) { … }
TEST_F(DeviceOAuth2TokenServiceTest,
RefreshTokenValidation_Failure_InvalidScope) { … }
TEST_F(DeviceOAuth2TokenServiceTest,
RefreshTokenValidation_Failure_TokenInfoApiCallHttpError) { … }
TEST_F(DeviceOAuth2TokenServiceTest,
RefreshTokenValidation_Failure_TokenInfoApiCallInvalidResponse) { … }
TEST_F(DeviceOAuth2TokenServiceTest,
RefreshTokenValidation_Failure_CloudPrintAccessTokenHttpError) { … }
TEST_F(DeviceOAuth2TokenServiceTest,
RefreshTokenValidation_Failure_CloudPrintAccessTokenInvalidResponse) { … }
TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_Failure_BadOwner) { … }
TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_Retry) { … }