#include <memory>
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/platform_browser_test.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/browser/cloud/user_policy_signin_service_base.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/device_management_service.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/policy/core/common/policy_switches.h"
#include "components/policy/core/common/policy_test_utils.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_test.h"
#include "net/base/net_errors.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"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/policy/core/user_cloud_policy_manager_ash.h"
#else
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#endif
BrowserThread;
_;
AnyNumber;
InvokeWithoutArgs;
Mock;
em;
namespace policy {
namespace {
bool ValidRequest(const std::string& method,
const GURL& url,
const std::string& data,
const std::string& expected_type,
em::DeviceManagementRequest* request_msg) { … }
void RespondWithBadResponse(const network::ResourceRequest& request,
network::TestURLLoaderFactory* factory) { … }
void RespondToRegisterWithSuccess(em::DeviceRegisterRequest::Type expected_type,
bool expect_reregister,
const network::ResourceRequest& request,
network::TestURLLoaderFactory* factory) { … }
}
class CloudPolicyManagerTest : public PlatformBrowserTest { … };
IN_PROC_BROWSER_TEST_F(CloudPolicyManagerTest, Register) { … }
IN_PROC_BROWSER_TEST_F(CloudPolicyManagerTest, RegisterFails) { … }
IN_PROC_BROWSER_TEST_F(CloudPolicyManagerTest, RegisterFailsWithRetries) { … }
IN_PROC_BROWSER_TEST_F(CloudPolicyManagerTest, RegisterWithRetry) { … }
}