Commit 6aeac4b2 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Introduce ManagedProperties to cros_network_config

This CL:
* Adds ManagedProperties and its many subobjects to network_config.mojom
* Adds and implements CrosNetworkConfig.GetManagedProperties for
  retrieving managed properties.
* Uses GetManagedProperties in the chrome://network test UI.

Bug: 853953
Change-Id: I11cbef3ffcf814335c4b4cdafda31c0ef19ff4fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1680778
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681899}
parent ed78fae3
......@@ -333,16 +333,25 @@ const NetworkUI = (function() {
showDetail(detailCell, responseParams.result);
} else {
showDetailError(
detailCell, 'GetNetworkState(' + guid + ') failed');
detailCell, 'getNetworkState(' + guid + ') failed');
}
})
.catch((error) => {
showDetailError(detailCell, 'Mojo service failure: ' + error);
});
} else if (selectedId == 'managed') {
chrome.networkingPrivate.getManagedProperties(guid, function(properties) {
showDetail(detailCell, properties, chrome.runtime.lastError);
});
networkConfigProxy.getManagedProperties(guid)
.then((responseParams) => {
if (responseParams && responseParams.result) {
showDetail(detailCell, responseParams.result);
} else {
showDetailError(
detailCell, 'getManagedProperties(' + guid + ') failed');
}
})
.catch((error) => {
showDetailError(detailCell, 'Mojo service failure: ' + error);
});
} else {
chrome.networkingPrivate.getProperties(guid, function(properties) {
showDetail(detailCell, properties, chrome.runtime.lastError);
......@@ -367,7 +376,7 @@ const NetworkUI = (function() {
/**
* @param {!HTMLTableCellElement} detailCell
* @param {!networkUI.NetworkStateProperties|!networkUI.DeviceStateProperties|
* !chrome.networkingPrivate.ManagedProperties|
* !chromeos.networkConfig.mojom.ManagedProperties|
* !chrome.networkingPrivate.NetworkProperties} state
* @param {!Object=} error
*/
......
......@@ -5,7 +5,9 @@
#include "chromeos/network/managed_network_configuration_handler.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "chromeos/network/managed_network_configuration_handler_impl.h"
#include "chromeos/network/network_ui_data.h"
#include "chromeos/network/onc/onc_utils.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
......@@ -15,4 +17,18 @@ namespace chromeos {
ManagedNetworkConfigurationHandler::~ManagedNetworkConfigurationHandler() =
default;
// static
std::unique_ptr<ManagedNetworkConfigurationHandler>
ManagedNetworkConfigurationHandler::InitializeForTesting(
NetworkStateHandler* network_state_handler,
NetworkProfileHandler* network_profile_handler,
NetworkDeviceHandler* network_device_handler,
NetworkConfigurationHandler* network_configuration_handler) {
auto* handler = new ManagedNetworkConfigurationHandlerImpl();
handler->Init(network_state_handler, network_profile_handler,
network_configuration_handler, network_device_handler,
/*prohibitied_technologies_handler=*/nullptr);
return base::WrapUnique(handler);
}
} // namespace chromeos
......@@ -6,6 +6,7 @@
#define CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
#include <map>
#include <memory>
#include <string>
#include "base/callback.h"
......@@ -21,11 +22,15 @@ namespace base {
class DictionaryValue;
class ListValue;
class Value;
}
} // namespace base
namespace chromeos {
class NetworkConfigurationHandler;
class NetworkDeviceHandler;
class NetworkPolicyObserver;
class NetworkProfileHandler;
class NetworkStateHandler;
// The ManagedNetworkConfigurationHandler class is used to create and configure
// networks in ChromeOS using ONC and takes care of network policies.
......@@ -178,6 +183,13 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandler {
// Return the list of blacklisted WiFi networks (identified by HexSSIDs).
virtual std::vector<std::string> GetBlacklistedHexSSIDs() const = 0;
static std::unique_ptr<ManagedNetworkConfigurationHandler>
InitializeForTesting(
NetworkStateHandler* network_state_handler,
NetworkProfileHandler* network_profile_handler,
NetworkDeviceHandler* network_device_handler,
NetworkConfigurationHandler* network_configuration_handler);
private:
DISALLOW_ASSIGN(ManagedNetworkConfigurationHandler);
};
......
......@@ -88,7 +88,7 @@ const base::DictionaryValue* GetByGUID(const GuidToPolicyMap& policies,
const std::string& guid) {
auto it = policies.find(guid);
if (it == policies.end())
return NULL;
return nullptr;
return it->second.get();
}
......@@ -213,7 +213,9 @@ void ManagedNetworkConfigurationHandlerImpl::SendManagedProperties(
const NetworkState* network_state =
network_state_handler_->GetNetworkState(service_path);
const NetworkProfile* profile =
network_profile_handler_->GetProfileForPath(profile_path);
network_profile_handler_
? network_profile_handler_->GetProfileForPath(profile_path)
: nullptr;
if (!profile && !(network_state && network_state->IsNonProfileType())) {
// Visible but unsaved (not known) networks will not have a profile.
NET_LOG_DEBUG("No profile for service: " + profile_path, service_path);
......@@ -550,7 +552,7 @@ void ManagedNetworkConfigurationHandlerImpl::SetPolicy(
// |userhash| must be empty for device policies.
DCHECK(onc_source != ::onc::ONC_SOURCE_DEVICE_POLICY ||
userhash.empty());
Policies* policies = NULL;
Policies* policies = nullptr;
if (base::Contains(policies_by_user_, userhash)) {
policies = policies_by_user_[userhash].get();
} else {
......@@ -581,7 +583,7 @@ void ManagedNetworkConfigurationHandlerImpl::SetPolicy(
for (base::ListValue::const_iterator it = network_configs_onc.begin();
it != network_configs_onc.end(); ++it) {
const base::DictionaryValue* network = NULL;
const base::DictionaryValue* network = nullptr;
it->GetAsDictionary(&network);
DCHECK(network);
......@@ -796,7 +798,7 @@ ManagedNetworkConfigurationHandlerImpl::FindPolicyByGUID(
}
}
return NULL;
return nullptr;
}
const GuidToPolicyMap*
......@@ -804,7 +806,7 @@ ManagedNetworkConfigurationHandlerImpl::GetNetworkConfigsFromPolicy(
const std::string& userhash) const {
const Policies* policies = GetPoliciesForUser(userhash);
if (!policies)
return NULL;
return nullptr;
return &policies->per_network_config;
}
......@@ -814,7 +816,7 @@ ManagedNetworkConfigurationHandlerImpl::GetGlobalConfigFromPolicy(
const std::string& userhash) const {
const Policies* policies = GetPoliciesForUser(userhash);
if (!policies)
return NULL;
return nullptr;
return &policies->global_network_config;
}
......@@ -917,7 +919,7 @@ ManagedNetworkConfigurationHandlerImpl::GetPoliciesForUser(
const std::string& userhash) const {
UserToPoliciesMap::const_iterator it = policies_by_user_.find(userhash);
if (it == policies_by_user_.end())
return NULL;
return nullptr;
return it->second.get();
}
......@@ -929,14 +931,8 @@ ManagedNetworkConfigurationHandlerImpl::GetPoliciesForProfile(
return GetPoliciesForUser(profile.userhash);
}
ManagedNetworkConfigurationHandlerImpl::ManagedNetworkConfigurationHandlerImpl()
: network_state_handler_(NULL),
network_profile_handler_(NULL),
network_configuration_handler_(NULL),
network_device_handler_(NULL),
user_policy_applied_(false),
device_policy_applied_(false),
weak_ptr_factory_(this) {
ManagedNetworkConfigurationHandlerImpl::
ManagedNetworkConfigurationHandlerImpl() {
CHECK(base::ThreadTaskRunnerHandle::IsSet());
}
......@@ -956,7 +952,8 @@ void ManagedNetworkConfigurationHandlerImpl::Init(
network_profile_handler_ = network_profile_handler;
network_configuration_handler_ = network_configuration_handler;
network_device_handler_ = network_device_handler;
network_profile_handler_->AddObserver(this);
if (network_profile_handler_)
network_profile_handler_->AddObserver(this);
prohibited_technologies_handler_ = prohibited_technologies_handler;
}
......
......@@ -129,6 +129,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandlerImpl
private:
friend class AutoConnectHandlerTest;
friend class ClientCertResolverTest;
friend class ManagedNetworkConfigurationHandler;
friend class ManagedNetworkConfigurationHandlerTest;
friend class ManagedNetworkConfigurationHandlerMockTest;
friend class NetworkConnectionHandlerImplTest;
......@@ -148,7 +149,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandlerImpl
ManagedNetworkConfigurationHandlerImpl();
// Handlers may be NULL in tests so long as they do not execute any paths
// Handlers may be null in tests so long as they do not execute any paths
// that require the handlers.
void Init(NetworkStateHandler* network_state_handler,
NetworkProfileHandler* network_profile_handler,
......@@ -230,11 +231,11 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandlerImpl
UserToPoliciesMap policies_by_user_;
// Local references to the associated handler instances.
NetworkStateHandler* network_state_handler_;
NetworkProfileHandler* network_profile_handler_;
NetworkConfigurationHandler* network_configuration_handler_;
NetworkDeviceHandler* network_device_handler_;
ProhibitedTechnologiesHandler* prohibited_technologies_handler_;
NetworkStateHandler* network_state_handler_ = nullptr;
NetworkProfileHandler* network_profile_handler_ = nullptr;
NetworkConfigurationHandler* network_configuration_handler_ = nullptr;
NetworkDeviceHandler* network_device_handler_ = nullptr;
ProhibitedTechnologiesHandler* prohibited_technologies_handler_ = nullptr;
// Owns the currently running PolicyApplicators.
UserToPolicyApplicatorMap policy_applicators_;
......@@ -248,12 +249,12 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandlerImpl
base::ObserverList<NetworkPolicyObserver, true>::Unchecked observers_;
bool user_policy_applied_;
bool device_policy_applied_;
bool user_policy_applied_ = false;
bool device_policy_applied_ = false;
// For Shill client callbacks
base::WeakPtrFactory<ManagedNetworkConfigurationHandlerImpl>
weak_ptr_factory_;
weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandlerImpl);
};
......
......@@ -9,6 +9,7 @@
#include <algorithm>
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "chromeos/dbus/shill/shill_manager_client.h"
......@@ -219,4 +220,12 @@ NetworkProfileHandler::~NetworkProfileHandler() {
ShillManagerClient::Get()->RemovePropertyChangedObserver(this);
}
// static
std::unique_ptr<NetworkProfileHandler>
NetworkProfileHandler::InitializeForTesting() {
auto* handler = new NetworkProfileHandler();
handler->Init();
return base::WrapUnique(handler);
}
} // namespace chromeos
......@@ -59,6 +59,8 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkProfileHandler
static std::string GetSharedProfilePath();
static std::unique_ptr<NetworkProfileHandler> InitializeForTesting();
protected:
friend class AutoConnectHandlerTest;
friend class ClientCertResolverTest;
......
......@@ -14,6 +14,7 @@ static_library("network_config") {
deps = [
"//base",
"//chromeos/login/login_state",
"//chromeos/network",
"//chromeos/services/network_config/public/cpp",
"//chromeos/services/network_config/public/mojom",
......@@ -38,8 +39,10 @@ source_set("unit_tests") {
"//base",
"//base/test:test_support",
"//chromeos/dbus/shill:test_support",
"//chromeos/login/login_state",
"//chromeos/network:test_support",
"//chromeos/services/network_config/public/cpp:test_support",
"//components/onc",
"//services/network/public/mojom:mojom_ip_address",
"//testing/gtest",
]
......
......@@ -12,8 +12,13 @@
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h"
namespace base {
class DictionaryValue;
}
namespace chromeos {
class ManagedNetworkConfigurationHandler;
class NetworkDeviceHandler;
class NetworkStateHandler;
......@@ -22,8 +27,10 @@ namespace network_config {
class CrosNetworkConfig : public mojom::CrosNetworkConfig,
public NetworkStateHandlerObserver {
public:
CrosNetworkConfig(NetworkStateHandler* network_state_handler,
NetworkDeviceHandler* network_device_handler);
CrosNetworkConfig(
NetworkStateHandler* network_state_handler,
NetworkDeviceHandler* network_device_handler,
ManagedNetworkConfigurationHandler* network_configuration_handler);
~CrosNetworkConfig() override;
void BindRequest(mojom::CrosNetworkConfigRequest request);
......@@ -35,6 +42,8 @@ class CrosNetworkConfig : public mojom::CrosNetworkConfig,
void GetNetworkStateList(mojom::NetworkFilterPtr filter,
GetNetworkStateListCallback callback) override;
void GetDeviceStateList(GetDeviceStateListCallback callback) override;
void GetManagedProperties(const std::string& guid,
GetManagedPropertiesCallback callback) override;
void SetNetworkTypeEnabledState(
mojom::NetworkType type,
bool enabled,
......@@ -44,6 +53,14 @@ class CrosNetworkConfig : public mojom::CrosNetworkConfig,
void RequestNetworkScan(mojom::NetworkType type) override;
private:
void GetManagedPropertiesSuccess(int callback_id,
const std::string& service_path,
const base::DictionaryValue& properties);
void GetManagedPropertiesFailure(
std::string guid,
int callback_id,
const std::string& error_name,
std::unique_ptr<base::DictionaryValue> error_data);
void SetCellularSimStateSuccess(int callback_id);
void SetCellularSimStateFailure(
int callback_id,
......@@ -63,11 +80,15 @@ class CrosNetworkConfig : public mojom::CrosNetworkConfig,
NetworkStateHandler* network_state_handler_; // Unowned
NetworkDeviceHandler* network_device_handler_; // Unowned
ManagedNetworkConfigurationHandler*
network_configuration_handler_; // Unowned
mojo::InterfacePtrSet<mojom::CrosNetworkConfigObserver> observers_;
mojo::BindingSet<mojom::CrosNetworkConfig> bindings_;
int callback_id_ = 1;
base::flat_map<int, GetManagedPropertiesCallback>
get_managed_properties_callbacks_;
base::flat_map<int, SetCellularSimStateCallback>
set_cellular_sim_state_callbacks_;
int set_cellular_sim_state_callback_id_ = 1;
base::WeakPtrFactory<CrosNetworkConfig> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(CrosNetworkConfig);
......
......@@ -6,14 +6,22 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_task_environment.h"
#include "chromeos/dbus/shill/fake_shill_device_client.h"
#include "chromeos/login/login_state/login_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_device_handler.h"
#include "chromeos/network/network_profile_handler.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_state_test_helper.h"
#include "chromeos/network/network_type_pattern.h"
#include "chromeos/network/onc/onc_utils.h"
#include "chromeos/services/network_config/public/cpp/cros_network_config_test_observer.h"
#include "components/onc/onc_constants.h"
#include "net/base/ip_address.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
......@@ -31,14 +39,58 @@ const char* kCellularDevicePath = "/device/stub_cellular_device";
class CrosNetworkConfigTest : public testing::Test {
public:
CrosNetworkConfigTest() {
LoginState::Initialize();
network_profile_handler_ = NetworkProfileHandler::InitializeForTesting();
network_device_handler_ = NetworkDeviceHandler::InitializeForTesting(
helper_.network_state_handler());
network_configuration_handler_ =
base::WrapUnique<NetworkConfigurationHandler>(
NetworkConfigurationHandler::InitializeForTest(
helper_.network_state_handler(),
network_device_handler_.get()));
managed_network_configuration_handler_ =
ManagedNetworkConfigurationHandler::InitializeForTesting(
helper_.network_state_handler(), network_profile_handler_.get(),
network_device_handler_.get(),
network_configuration_handler_.get());
cros_network_config_ = std::make_unique<CrosNetworkConfig>(
helper_.network_state_handler(), network_device_handler_.get());
helper_.network_state_handler(), network_device_handler_.get(),
managed_network_configuration_handler_.get());
SetupPolicy();
SetupNetworks();
}
~CrosNetworkConfigTest() override { cros_network_config_.reset(); }
~CrosNetworkConfigTest() override {
cros_network_config_.reset();
managed_network_configuration_handler_.reset();
network_configuration_handler_.reset();
network_device_handler_.reset();
network_profile_handler_.reset();
LoginState::Shutdown();
}
void SetupPolicy() {
managed_network_configuration_handler_->SetPolicy(
::onc::ONC_SOURCE_DEVICE_POLICY,
/*userhash=*/std::string(),
/*network_configs_onc=*/base::ListValue(),
/*global_network_config=*/base::DictionaryValue());
const std::string user_policy_ssid = "wifi2";
base::Value wifi2_onc = base::Value::FromUniquePtrValue(
onc::ReadDictionaryFromJson(base::StringPrintf(
R"({"GUID": "wifi2_guid", "Type": "WiFi",
"WiFi": { "Passphrase": "fake", "SSID": "%s", "HexSSID": "%s",
"Security": "WPA-PSK"}})",
user_policy_ssid.c_str(),
base::HexEncode(user_policy_ssid.c_str(), user_policy_ssid.size())
.c_str())));
base::ListValue user_policy_onc;
user_policy_onc.GetList().push_back(std::move(wifi2_onc));
managed_network_configuration_handler_->SetPolicy(
::onc::ONC_SOURCE_USER_POLICY, helper().UserHash(), user_policy_onc,
/*global_network_config=*/base::DictionaryValue());
}
void SetupNetworks() {
// Wifi device exists by default, add Ethernet and Cellular.
......@@ -64,8 +116,8 @@ class CrosNetworkConfigTest : public testing::Test {
R"({"GUID": "wifi1_guid", "Type": "wifi", "State": "ready",
"Strength": 50})");
helper().ConfigureService(
R"({"GUID": "wifi2_guid", "Type": "wifi", "State": "idle",
"SecurityClass": "psk", "Strength": 100,
R"({"GUID": "wifi2_guid", "Type": "wifi", "SSID": "wifi2",
"State": "idle", "SecurityClass": "psk", "Strength": 100,
"Profile": "user_profile_path"})");
helper().ConfigureService(
R"({"GUID": "cellular_guid", "Type": "cellular", "State": "idle",
......@@ -150,6 +202,22 @@ class CrosNetworkConfigTest : public testing::Test {
return nullptr;
}
mojom::ManagedPropertiesPtr GetManagedProperties(const std::string& guid) {
mojom::ManagedPropertiesPtr result;
base::RunLoop run_loop;
cros_network_config()->GetManagedProperties(
guid, base::BindOnce(
[](mojom::ManagedPropertiesPtr* result,
base::OnceClosure quit_closure,
mojom::ManagedPropertiesPtr properties) {
*result = std::move(properties);
std::move(quit_closure).Run();
},
&result, run_loop.QuitClosure()));
run_loop.Run();
return result;
}
bool SetCellularSimState(const std::string& current_pin_or_puk,
base::Optional<std::string> new_pin,
bool require_pin) {
......@@ -177,7 +245,11 @@ class CrosNetworkConfigTest : public testing::Test {
private:
base::test::ScopedTaskEnvironment scoped_task_environment_;
NetworkStateTestHelper helper_{false /* use_default_devices_and_services */};
std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
std::unique_ptr<NetworkDeviceHandler> network_device_handler_;
std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_;
std::unique_ptr<ManagedNetworkConfigurationHandler>
managed_network_configuration_handler_;
std::unique_ptr<CrosNetworkConfig> cros_network_config_;
std::unique_ptr<CrosNetworkConfigTestObserver> observer_;
std::string wifi1_path_;
......@@ -212,7 +284,7 @@ TEST_F(CrosNetworkConfigTest, GetNetworkState) {
ASSERT_TRUE(network->wifi);
EXPECT_EQ(mojom::SecurityType::kWpaPsk, network->wifi->security);
EXPECT_EQ(100, network->wifi->signal_strength);
EXPECT_EQ(mojom::OncSource::kUser, network->source);
EXPECT_EQ(mojom::OncSource::kUserPolicy, network->source);
network = GetNetworkState("wifi3_guid");
ASSERT_TRUE(network);
......@@ -332,6 +404,62 @@ TEST_F(CrosNetworkConfigTest, GetDeviceStateList) {
EXPECT_EQ(mojom::DeviceStateType::kDisabled, devices[0]->device_state);
}
// Test a sampling of properties, ensuring that string property types are
// translated as strings and not enum values (See ManagedProperties definition
// in cros_network_config.mojom for details).
TEST_F(CrosNetworkConfigTest, GetManagedProperties) {
mojom::ManagedPropertiesPtr properties = GetManagedProperties("eth_guid");
ASSERT_TRUE(properties);
EXPECT_EQ("eth_guid", properties->guid);
EXPECT_EQ(mojom::NetworkType::kEthernet, properties->type);
EXPECT_EQ(mojom::ConnectionStateType::kOnline, properties->connection_state);
properties = GetManagedProperties("wifi1_guid");
ASSERT_TRUE(properties);
EXPECT_EQ("wifi1_guid", properties->guid);
EXPECT_EQ(mojom::NetworkType::kWiFi, properties->type);
EXPECT_EQ(mojom::ConnectionStateType::kConnected,
properties->connection_state);
ASSERT_TRUE(properties->wifi);
EXPECT_EQ(50, properties->wifi->signal_strength);
properties = GetManagedProperties("wifi2_guid");
ASSERT_TRUE(properties);
EXPECT_EQ("wifi2_guid", properties->guid);
EXPECT_EQ(mojom::NetworkType::kWiFi, properties->type);
EXPECT_EQ(mojom::ConnectionStateType::kNotConnected,
properties->connection_state);
ASSERT_TRUE(properties->wifi);
EXPECT_EQ(::onc::wifi::kWPA_PSK, properties->wifi->security->active_value);
EXPECT_EQ(mojom::OncSource::kUserPolicy,
properties->wifi->security->effective_source);
EXPECT_EQ(::onc::wifi::kWPA_PSK,
*properties->wifi->security->effective_value);
EXPECT_EQ(100, properties->wifi->signal_strength);
properties = GetManagedProperties("cellular_guid");
ASSERT_TRUE(properties);
EXPECT_EQ("cellular_guid", properties->guid);
EXPECT_EQ(mojom::NetworkType::kCellular, properties->type);
EXPECT_EQ(mojom::ConnectionStateType::kNotConnected,
properties->connection_state);
ASSERT_TRUE(properties->cellular);
EXPECT_EQ(0, properties->cellular->signal_strength);
EXPECT_EQ("LTE", properties->cellular->network_technology);
EXPECT_EQ(::onc::cellular::kActivated,
properties->cellular->activation_state);
properties = GetManagedProperties("vpn_guid");
ASSERT_TRUE(properties);
EXPECT_EQ("vpn_guid", properties->guid);
EXPECT_EQ(mojom::NetworkType::kVPN, properties->type);
EXPECT_EQ(mojom::ConnectionStateType::kConnecting,
properties->connection_state);
ASSERT_TRUE(properties->vpn);
EXPECT_EQ(::onc::vpn::kTypeL2TP_IPsec, properties->vpn->type->active_value);
EXPECT_EQ(mojom::OncSource::kNone, properties->vpn->type->effective_source);
}
TEST_F(CrosNetworkConfigTest, SetNetworkTypeEnabledState) {
std::vector<mojom::DeviceStatePropertiesPtr> devices = GetDeviceStateList();
ASSERT_EQ(3u, devices.size());
......@@ -502,7 +630,9 @@ TEST_F(CrosNetworkConfigTest, DeviceListChanged) {
helper().network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::WiFi(), false, network_handler::ErrorCallback());
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1, observer()->device_state_list_changed());
// This will trigger two device list updates. Once when wifi is disabled,
// and once when Device::available_managed_network_path_ changes.
EXPECT_EQ(2, observer()->device_state_list_changed());
}
TEST_F(CrosNetworkConfigTest, ActiveNetworksChanged) {
......
......@@ -18,7 +18,8 @@ NetworkConfigService::NetworkConfigService(
: service_binding_(this, std::move(request)),
cros_network_config_(std::make_unique<CrosNetworkConfig>(
NetworkHandler::Get()->network_state_handler(),
NetworkHandler::Get()->network_device_handler())) {}
NetworkHandler::Get()->network_device_handler(),
NetworkHandler::Get()->managed_network_configuration_handler())) {}
NetworkConfigService::~NetworkConfigService() = default;
......
......@@ -36,7 +36,8 @@ void CrosNetworkConfigTestHelper::SetupCrosNetworkConfig() {
network_state_helper_.network_state_handler());
cros_network_config_impl_ = std::make_unique<CrosNetworkConfig>(
network_state_helper_.network_state_handler(),
network_device_handler_.get());
network_device_handler_.get(),
/*network_configuration_handler=*/nullptr);
}
void CrosNetworkConfigTestHelper::SetupServiceInterface() {
......
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