Commit 06c7d0ce authored by Zach Trudo's avatar Zach Trudo Committed by Commit Bot

Add GetEncryptedReportUrl

CloudPolicyClient will be expanded to make use of a new server endpoint.
This change prepares DeviceManagementService for that eventuality.

Bug: chromium:1135951
Change-Id: I8b23d8dc112a8f583ddc249f01572cae9522d99b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2454278Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Commit-Queue: Zach Trudo <zatrudo@google.com>
Cr-Commit-Position: refs/heads/master@{#816213}
parent 7516f8dd
......@@ -86,7 +86,8 @@ void ChromeBrowserPolicyConnector::Init(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
std::unique_ptr<DeviceManagementService::Configuration> configuration(
new DeviceManagementServiceConfiguration(GetDeviceManagementUrl(),
GetRealtimeReportingUrl()));
GetRealtimeReportingUrl(),
GetEncryptedReportingUrl()));
std::unique_ptr<DeviceManagementService> device_management_service(
new DeviceManagementService(std::move(configuration)));
device_management_service->ScheduleInitialization(
......
......@@ -26,15 +26,18 @@
namespace policy {
DeviceManagementServiceConfiguration::DeviceManagementServiceConfiguration(
const std::string& server_url,
const std::string& reporting_server_url)
: server_url_(server_url), reporting_server_url_(reporting_server_url) {}
const std::string& dm_server_url,
const std::string& realtime_reporting_server_url,
const std::string& encrypted_reporting_server_url)
: dm_server_url_(dm_server_url),
realtime_reporting_server_url_(realtime_reporting_server_url),
encrypted_reporting_server_url_(encrypted_reporting_server_url) {}
DeviceManagementServiceConfiguration::~DeviceManagementServiceConfiguration() {
}
std::string DeviceManagementServiceConfiguration::GetDMServerUrl() {
return server_url_;
return dm_server_url_;
}
std::string DeviceManagementServiceConfiguration::GetAgentParameter() {
......@@ -79,8 +82,14 @@ std::string DeviceManagementServiceConfiguration::GetPlatformParameter() {
"%s|%s|%s", os_name.c_str(), os_hardware.c_str(), os_version.c_str());
}
std::string DeviceManagementServiceConfiguration::GetReportingServerUrl() {
return reporting_server_url_;
std::string
DeviceManagementServiceConfiguration::GetRealtimeReportingServerUrl() {
return realtime_reporting_server_url_;
}
std::string
DeviceManagementServiceConfiguration::GetEncryptedReportingServerUrl() {
return encrypted_reporting_server_url_;
}
std::string
......
......@@ -18,19 +18,23 @@ namespace policy {
class DeviceManagementServiceConfiguration
: public DeviceManagementService::Configuration {
public:
DeviceManagementServiceConfiguration(const std::string& server_url,
const std::string& reporting_server_url);
DeviceManagementServiceConfiguration(
const std::string& dm_server_url,
const std::string& realtime_reporting_server_url,
const std::string& encrypted_reporting_server_url);
~DeviceManagementServiceConfiguration() override;
std::string GetDMServerUrl() override;
std::string GetAgentParameter() override;
std::string GetPlatformParameter() override;
std::string GetReportingServerUrl() override;
std::string GetRealtimeReportingServerUrl() override;
std::string GetEncryptedReportingServerUrl() override;
std::string GetReportingConnectorServerUrl() override;
private:
const std::string server_url_;
const std::string reporting_server_url_;
const std::string dm_server_url_;
const std::string realtime_reporting_server_url_;
const std::string encrypted_reporting_server_url_;
DISALLOW_COPY_AND_ASSIGN(DeviceManagementServiceConfiguration);
};
......
......@@ -607,7 +607,8 @@ void CloudPolicyClient::UploadAppInstallReport(base::Value report,
CHECK(is_registered());
CancelAppInstallReportUpload();
app_install_report_request_job_ = CreateNewRealtimeReportingJob(
std::move(report), service()->configuration()->GetReportingServerUrl(),
std::move(report),
service()->configuration()->GetRealtimeReportingServerUrl(),
/* add_connector_url_params=*/false, std::move(callback));
DCHECK(app_install_report_request_job_);
}
......@@ -627,7 +628,8 @@ void CloudPolicyClient::UploadExtensionInstallReport(base::Value report,
CHECK(is_registered());
CancelExtensionInstallReportUpload();
extension_install_report_request_job_ = CreateNewRealtimeReportingJob(
std::move(report), service()->configuration()->GetReportingServerUrl(),
std::move(report),
service()->configuration()->GetRealtimeReportingServerUrl(),
/* add_connector_url_params=*/false, std::move(callback));
DCHECK(extension_install_report_request_job_);
}
......
......@@ -1557,7 +1557,7 @@ TEST_F(CloudPolicyClientTest, UploadRealtimeReport) {
TEST_F(CloudPolicyClientTest, RealtimeReportMerge) {
auto config = std::make_unique<RealtimeReportingJobConfiguration>(
client_.get(), DMAuth::FromDMToken(kDMToken),
service_.configuration()->GetReportingServerUrl(), false,
service_.configuration()->GetRealtimeReportingServerUrl(), false,
RealtimeReportingJobConfiguration::Callback());
// Add one report to the config.
......
......@@ -110,7 +110,10 @@ class POLICY_EXPORT DeviceManagementService {
virtual std::string GetPlatformParameter() = 0;
// Server at which to contact the real time reporting service.
virtual std::string GetReportingServerUrl() = 0;
virtual std::string GetRealtimeReportingServerUrl() = 0;
// Server endpoint for encrypted events.
virtual std::string GetEncryptedReportingServerUrl() = 0;
// Server at which to contact the real time reporting service for
// enterprise connectors.
......
......@@ -97,7 +97,13 @@ std::string MockDeviceManagementServiceConfiguration::GetPlatformParameter() {
return kPlatform;
}
std::string MockDeviceManagementServiceConfiguration::GetReportingServerUrl() {
std::string
MockDeviceManagementServiceConfiguration::GetRealtimeReportingServerUrl() {
return server_url_;
}
std::string
MockDeviceManagementServiceConfiguration::GetEncryptedReportingServerUrl() {
return server_url_;
}
......
......@@ -31,7 +31,8 @@ class MockDeviceManagementServiceConfiguration
std::string GetDMServerUrl() override;
std::string GetAgentParameter() override;
std::string GetPlatformParameter() override;
std::string GetReportingServerUrl() override;
std::string GetRealtimeReportingServerUrl() override;
std::string GetEncryptedReportingServerUrl() override;
std::string GetReportingConnectorServerUrl() override;
private:
......
......@@ -69,9 +69,10 @@ class RealtimeReportingJobConfigurationTest : public testing::Test {
#if defined(OS_CHROMEOS)
fake_serial_number_(&fake_statistics_provider_),
#endif
configuration_(&client_,
configuration_(
&client_,
DMAuth::FromDMToken(kDummyToken),
service_.configuration()->GetReportingServerUrl(),
service_.configuration()->GetRealtimeReportingServerUrl(),
false,
base::BindOnce(&MockCallbackObserver::OnURLLoadComplete,
base::Unretained(&callback_observer_))) {
......
......@@ -58,7 +58,8 @@ void BrowserPolicyConnectorIOS::Init(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
std::unique_ptr<policy::DeviceManagementService::Configuration> configuration(
new policy::DeviceManagementServiceConfigurationIOS(
GetDeviceManagementUrl(), GetRealtimeReportingUrl()));
GetDeviceManagementUrl(), GetRealtimeReportingUrl(),
GetEncryptedReportingUrl()));
std::unique_ptr<policy::DeviceManagementService> device_management_service(
new policy::DeviceManagementService(std::move(configuration)));
device_management_service->ScheduleInitialization(
......
......@@ -19,8 +19,9 @@ class DeviceManagementServiceConfigurationIOS
: public DeviceManagementService::Configuration {
public:
DeviceManagementServiceConfigurationIOS(
const std::string& server_url,
const std::string& reporting_server_url);
const std::string& dm_server_url,
const std::string& realtime_reporting_server_url,
const std::string& encrypted_reporting_server_url);
DeviceManagementServiceConfigurationIOS(
const DeviceManagementServiceConfigurationIOS&) = delete;
DeviceManagementServiceConfigurationIOS& operator=(
......@@ -31,12 +32,14 @@ class DeviceManagementServiceConfigurationIOS
std::string GetDMServerUrl() override;
std::string GetAgentParameter() override;
std::string GetPlatformParameter() override;
std::string GetReportingServerUrl() override;
std::string GetRealtimeReportingServerUrl() override;
std::string GetEncryptedReportingServerUrl() override;
std::string GetReportingConnectorServerUrl() override;
private:
const std::string server_url_;
const std::string reporting_server_url_;
const std::string dm_server_url_;
const std::string realtime_reporting_server_url_;
const std::string encrypted_reporting_server_url_;
};
} // namespace policy
......
......@@ -21,15 +21,18 @@ namespace policy {
DeviceManagementServiceConfigurationIOS::
DeviceManagementServiceConfigurationIOS(
const std::string& server_url,
const std::string& reporting_server_url)
: server_url_(server_url), reporting_server_url_(reporting_server_url) {}
const std::string& dm_server_url,
const std::string& realtime_reporting_server_url,
const std::string& encrypted_reporting_server_url)
: dm_server_url_(dm_server_url),
realtime_reporting_server_url_(realtime_reporting_server_url),
encrypted_reporting_server_url_(encrypted_reporting_server_url) {}
DeviceManagementServiceConfigurationIOS::
~DeviceManagementServiceConfigurationIOS() = default;
std::string DeviceManagementServiceConfigurationIOS::GetDMServerUrl() {
return server_url_;
return dm_server_url_;
}
std::string DeviceManagementServiceConfigurationIOS::GetAgentParameter() {
......@@ -56,8 +59,14 @@ std::string DeviceManagementServiceConfigurationIOS::GetPlatformParameter() {
os_version.c_str());
}
std::string DeviceManagementServiceConfigurationIOS::GetReportingServerUrl() {
return reporting_server_url_;
std::string
DeviceManagementServiceConfigurationIOS::GetRealtimeReportingServerUrl() {
return realtime_reporting_server_url_;
}
std::string
DeviceManagementServiceConfigurationIOS::GetEncryptedReportingServerUrl() {
return encrypted_reporting_server_url_;
}
std::string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment