Commit 69ff4ab3 authored by Andreea Costinas's avatar Andreea Costinas Committed by Commit Bot

system-proxy: Call SetAuthenticationDetails

This CL replaces the deprecated SetSystemTrafficCredentials dbus method
with SetAuthenticationDetails wich allows setting additional information
like kerberos availability.

BUG=chromium:1042641
TEST=updated unit tests

Change-Id: I3267d473a1a4350c07b004480d27d7c4e78fdad4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199259
Commit-Queue: Andreea-Elena Costinas <acostinas@google.com>
Reviewed-by: default avatarOmar Morsi <omorsi@google.com>
Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774661}
parent b1651f06
......@@ -83,13 +83,16 @@ void SystemProxyManager::OnSystemProxySettingsPolicyChanged() {
return;
}
system_proxy::SetSystemTrafficCredentialsRequest request;
request.set_system_services_username(*username);
request.set_system_services_password(*password);
system_proxy::Credentials credentials;
credentials.set_username(*username);
credentials.set_password(*password);
chromeos::SystemProxyClient::Get()->SetSystemTrafficCredentials(
request,
base::BindOnce(&SystemProxyManager::OnSetSystemTrafficCredentials,
system_proxy::SetAuthenticationDetailsRequest request;
request.set_traffic_type(system_proxy::TrafficOrigin::SYSTEM);
*request.mutable_credentials() = credentials;
chromeos::SystemProxyClient::Get()->SetAuthenticationDetails(
request, base::BindOnce(&SystemProxyManager::OnSetAuthenticationDetails,
weak_factory_.GetWeakPtr()));
}
......@@ -99,8 +102,8 @@ void SystemProxyManager::SetSystemServicesProxyUrlForTest(
system_services_address_ = local_proxy_url;
}
void SystemProxyManager::OnSetSystemTrafficCredentials(
const system_proxy::SetSystemTrafficCredentialsResponse& response) {
void SystemProxyManager::OnSetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsResponse& response) {
if (response.has_error_message()) {
NET_LOG(ERROR)
<< "Failed to set system traffic credentials for system proxy: "
......
......@@ -12,7 +12,7 @@
#include "chromeos/dbus/system_proxy/system_proxy_service.pb.h"
namespace system_proxy {
class SetSystemTrafficCredentialsResponse;
class SetAuthenticationDetailsResponse;
class ShutDownResponse;
} // namespace system_proxy
......@@ -42,8 +42,8 @@ class SystemProxyManager {
void SetSystemServicesProxyUrlForTest(const std::string& local_proxy_url);
private:
void OnSetSystemTrafficCredentials(
const system_proxy::SetSystemTrafficCredentialsResponse& response);
void OnSetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsResponse& response);
void OnDaemonShutDown(const system_proxy::ShutDownResponse& response);
// Once a trusted set of policies is established, this function calls
......
......@@ -48,24 +48,21 @@ class SystemProxyManagerTest : public testing::Test {
// Verifies that System-proxy is configured with the system traffic credentials
// set by |kSystemProxySettings| policy.
TEST_F(SystemProxyManagerTest, SetSystemTrafficCredentials) {
TEST_F(SystemProxyManagerTest, SetAuthenticationDetails) {
SystemProxyManager system_proxy_manager(chromeos::CrosSettings::Get());
EXPECT_EQ(0,
client_test_interface()->GetSetSystemTrafficCredentialsCallCount());
EXPECT_EQ(0, client_test_interface()->GetSetAuthenticationDetailsCallCount());
SetPolicy(true /* system_proxy_enabled */, "" /* system_services_username */,
"" /* system_services_password */);
task_environment_.RunUntilIdle();
// Don't send empty credentials.
EXPECT_EQ(0,
client_test_interface()->GetSetSystemTrafficCredentialsCallCount());
EXPECT_EQ(0, client_test_interface()->GetSetAuthenticationDetailsCallCount());
SetPolicy(true /* system_proxy_enabled */,
"test" /* system_services_username */,
"test" /* system_services_password */);
task_environment_.RunUntilIdle();
EXPECT_EQ(1,
client_test_interface()->GetSetSystemTrafficCredentialsCallCount());
EXPECT_EQ(1, client_test_interface()->GetSetAuthenticationDetailsCallCount());
}
// Verifies requests to shut down are sent to System-proxy according to the
......
......@@ -14,11 +14,11 @@ FakeSystemProxyClient::FakeSystemProxyClient() = default;
FakeSystemProxyClient::~FakeSystemProxyClient() = default;
void FakeSystemProxyClient::SetSystemTrafficCredentials(
const system_proxy::SetSystemTrafficCredentialsRequest& request,
SetSystemTrafficCredentialsCallback callback) {
void FakeSystemProxyClient::SetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsRequest& request,
SetAuthenticationDetailsCallback callback) {
++set_credentials_call_count_;
system_proxy::SetSystemTrafficCredentialsResponse response;
system_proxy::SetAuthenticationDetailsResponse response;
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), response));
}
......@@ -41,7 +41,7 @@ SystemProxyClient::TestInterface* FakeSystemProxyClient::GetTestInterface() {
return this;
}
int FakeSystemProxyClient::GetSetSystemTrafficCredentialsCallCount() const {
int FakeSystemProxyClient::GetSetAuthenticationDetailsCallCount() const {
return set_credentials_call_count_;
}
......
......@@ -21,16 +21,16 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeSystemProxyClient
~FakeSystemProxyClient() override;
// SystemProxyClient implementation.
void SetSystemTrafficCredentials(
const system_proxy::SetSystemTrafficCredentialsRequest& request,
SetSystemTrafficCredentialsCallback callback) override;
void SetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsRequest& request,
SetAuthenticationDetailsCallback callback) override;
void ShutDownDaemon(ShutDownDaemonCallback callback) override;
void ConnectToWorkerActiveSignal(WorkerActiveCallback callback) override;
SystemProxyClient::TestInterface* GetTestInterface() override;
// SystemProxyClient::TestInterface implementation.
int GetSetSystemTrafficCredentialsCallCount() const override;
int GetSetAuthenticationDetailsCallCount() const override;
int GetShutDownCallCount() const override;
private:
......
......@@ -59,10 +59,10 @@ class SystemProxyClientImpl : public SystemProxyClient {
~SystemProxyClientImpl() override = default;
// SystemProxyClient overrides:
void SetSystemTrafficCredentials(
const system_proxy::SetSystemTrafficCredentialsRequest& request,
SetSystemTrafficCredentialsCallback callback) override {
CallProtoMethodWithRequest(system_proxy::kSetSystemTrafficCredentialsMethod,
void SetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsRequest& request,
SetAuthenticationDetailsCallback callback) override {
CallProtoMethodWithRequest(system_proxy::kSetAuthenticationDetailsMethod,
request, std::move(callback));
}
......
......@@ -21,8 +21,8 @@ namespace chromeos {
// initializes the DBusThreadManager instance.
class COMPONENT_EXPORT(SYSTEM_PROXY) SystemProxyClient {
public:
using SetSystemTrafficCredentialsCallback = base::OnceCallback<void(
const system_proxy::SetSystemTrafficCredentialsResponse& response)>;
using SetAuthenticationDetailsCallback = base::OnceCallback<void(
const system_proxy::SetAuthenticationDetailsResponse& response)>;
using ShutDownDaemonCallback =
base::OnceCallback<void(const system_proxy::ShutDownResponse& response)>;
using WorkerActiveCallback = base::RepeatingCallback<void(
......@@ -32,8 +32,8 @@ class COMPONENT_EXPORT(SYSTEM_PROXY) SystemProxyClient {
// only implemented in the fake implementation.
class TestInterface {
public:
// Returns how many times |SetSystemTrafficCredentials| was called.
virtual int GetSetSystemTrafficCredentialsCallCount() const = 0;
// Returns how many times |SetAuthenticationDetails| was called.
virtual int GetSetAuthenticationDetailsCallCount() const = 0;
// Returns how many times |ShutDownDaemon| was called.
virtual int GetShutDownCallCount() const = 0;
......@@ -59,9 +59,9 @@ class COMPONENT_EXPORT(SYSTEM_PROXY) SystemProxyClient {
// SystemProxy daemon D-Bus method calls. See org.chromium.SystemProxy.xml and
// system_proxy_service.proto in Chromium OS code for the documentation of the
// methods and request/response messages.
virtual void SetSystemTrafficCredentials(
const system_proxy::SetSystemTrafficCredentialsRequest& request,
SetSystemTrafficCredentialsCallback callback) = 0;
virtual void SetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsRequest& request,
SetAuthenticationDetailsCallback callback) = 0;
// When receiving a shut-down call, System-proxy will schedule a shut-down
// task and reply. |callback| is called when the daemon starts to shut-down.
......
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