#include "components/policy/core/common/cloud/device_management_service.h"
#include <stdint.h>
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/platform_browser_test.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/dm_auth.h"
#include "components/policy/core/common/cloud/mock_device_management_service.h"
#include "components/policy/proto/cloud_policy.pb.h"
#include "components/policy/test_support/embedded_policy_test_server.h"
#include "components/policy/test_support/policy_storage.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_test.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/base/upload_data_stream.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.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"
BrowserThread;
DoAll;
Invoke;
InvokeWithoutArgs;
_;
em;
namespace policy {
namespace {
const char kClientID[] = …;
const char kDMToken[] = …;
void ConstructResponse(const std::string& request_data,
std::string* response_data) { … }
void OnRequest(network::TestURLLoaderFactory* test_factory,
const network::ResourceRequest& request) { … }
}
class DeviceManagementServiceIntegrationTest
: public PlatformBrowserTest,
public testing::WithParamInterface<std::string (
DeviceManagementServiceIntegrationTest::*)(void)> { … };
IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, Registration) { … }
IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest,
ApiAuthCodeFetch) { … }
IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, PolicyFetch) { … }
#if BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, AutoEnrollment) {
base::RunLoop run_loop;
EXPECT_CALL(*this, OnJobDone(_, DM_STATUS_SUCCESS, _, _))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
em::DeviceManagementRequest request;
request.mutable_auto_enrollment_request()->set_remainder(0);
request.mutable_auto_enrollment_request()->set_modulus(1);
std::unique_ptr<DeviceManagementService::Job> job =
StartJob(DeviceManagementService::JobConfiguration::TYPE_AUTO_ENROLLMENT,
false, DMAuth::NoAuth(), "", request);
run_loop.Run();
}
#endif
INSTANTIATE_TEST_SUITE_P(…);
}