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