Commit a6b22f4e authored by pneubeck@chromium.org's avatar pneubeck@chromium.org

Use Shill's Manager::ConfigureServiceForProfile for all network types.

ConfigureServiceForProfile was only used for WiFi as Shill didn't support other types before https://gerrit.chromium.org/gerrit/63651.

This change is helpful for Ethernet EAP policy as well, because Shill will automatically select the EthernetEAP service if the network type is EthernetEAP.

BUG=265592, 217524
R=stevenjb@chromium.org

Review URL: https://codereview.chromium.org/22689003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216988 0039d316-1c4b-4281-b951-d872f2087c98
parent 2992797d
...@@ -279,29 +279,20 @@ void NetworkConfigurationHandler::CreateConfiguration( ...@@ -279,29 +279,20 @@ void NetworkConfigurationHandler::CreateConfiguration(
NET_LOG_USER("CreateConfiguration", type); NET_LOG_USER("CreateConfiguration", type);
LogConfigProperties("Configure", type, properties); LogConfigProperties("Configure", type, properties);
// Shill supports ConfigureServiceForProfile only for network type WiFi. In std::string profile;
// all other cases, we have to rely on GetService for now. This is properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty,
// unproblematic for VPN (user profile only), but will lead to inconsistencies &profile);
// with WiMax, for example. DCHECK(!profile.empty());
if (type == flimflam::kTypeWifi) { manager->ConfigureServiceForProfile(
std::string profile; dbus::ObjectPath(profile),
properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, properties,
&profile); base::Bind(&NetworkConfigurationHandler::RunCreateNetworkCallback,
manager->ConfigureServiceForProfile( AsWeakPtr(),
dbus::ObjectPath(profile), callback),
properties, base::Bind(&network_handler::ShillErrorCallbackFunction,
base::Bind(&NetworkConfigurationHandler::RunCreateNetworkCallback, "Config.CreateConfiguration Failed",
AsWeakPtr(), callback), "",
base::Bind(&network_handler::ShillErrorCallbackFunction, error_callback));
"Config.CreateConfiguration Failed", "", error_callback));
} else {
manager->ConfigureService(
properties,
base::Bind(&NetworkConfigurationHandler::RunCreateNetworkCallback,
AsWeakPtr(), callback),
base::Bind(&network_handler::ShillErrorCallbackFunction,
"Config.CreateConfiguration Failed", "", error_callback));
}
} }
void NetworkConfigurationHandler::RemoveConfiguration( void NetworkConfigurationHandler::RemoveConfiguration(
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chromeos/dbus/mock_shill_manager_client.h" #include "chromeos/dbus/mock_shill_manager_client.h"
#include "chromeos/dbus/mock_shill_profile_client.h" #include "chromeos/dbus/mock_shill_profile_client.h"
#include "chromeos/dbus/mock_shill_service_client.h" #include "chromeos/dbus/mock_shill_service_client.h"
#include "chromeos/dbus/shill_profile_client_stub.h"
#include "chromeos/network/network_configuration_handler.h" #include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_state.h" #include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler.h"
...@@ -157,9 +158,11 @@ class NetworkConfigurationHandlerTest : public testing::Test { ...@@ -157,9 +158,11 @@ class NetworkConfigurationHandlerTest : public testing::Test {
callback.Run(result); callback.Run(result);
} }
void OnConfigureService(const base::DictionaryValue& properties, void OnConfigureService(
const ObjectPathCallback& callback, const dbus::ObjectPath& profile_path,
const ShillClientHelper::ErrorCallback& error_callback) { const base::DictionaryValue& properties,
const ObjectPathCallback& callback,
const ShillClientHelper::ErrorCallback& error_callback) {
callback.Run(dbus::ObjectPath("/service/2")); callback.Run(dbus::ObjectPath("/service/2"));
} }
...@@ -327,19 +330,21 @@ TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) { ...@@ -327,19 +330,21 @@ TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) {
} }
TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) { TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) {
std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n";
std::string networkName = "MyNetwork"; std::string networkName = "MyNetwork";
std::string key = "SSID"; std::string key = "SSID";
std::string profile = "profile path";
scoped_ptr<base::StringValue> networkNameValue( scoped_ptr<base::StringValue> networkNameValue(
base::Value::CreateStringValue(networkName)); base::Value::CreateStringValue(networkName));
base::DictionaryValue value; base::DictionaryValue value;
value.Set(key, base::Value::CreateStringValue(networkName)); value.SetWithoutPathExpansion(flimflam::kSSIDProperty,
base::Value::CreateStringValue(networkName));
EXPECT_CALL( value.SetWithoutPathExpansion(flimflam::kProfileProperty,
*mock_manager_client_, base::Value::CreateStringValue(profile));
ConfigureService(_, _, _)).WillOnce(
Invoke(this, EXPECT_CALL(*mock_manager_client_,
&NetworkConfigurationHandlerTest::OnConfigureService)); ConfigureServiceForProfile(dbus::ObjectPath(profile), _, _, _))
.WillOnce(
Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService));
network_configuration_handler_->CreateConfiguration( network_configuration_handler_->CreateConfiguration(
value, value,
base::Bind(&StringResultCallback, std::string("/service/2")), base::Bind(&StringResultCallback, std::string("/service/2")),
...@@ -586,6 +591,8 @@ TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) { ...@@ -586,6 +591,8 @@ TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) {
flimflam::kTypeProperty, flimflam::kTypeWifi); flimflam::kTypeProperty, flimflam::kTypeWifi);
properties.SetStringWithoutPathExpansion( properties.SetStringWithoutPathExpansion(
flimflam::kStateProperty, flimflam::kStateIdle); flimflam::kStateProperty, flimflam::kStateIdle);
properties.SetStringWithoutPathExpansion(
flimflam::kProfileProperty, ShillProfileClientStub::kSharedProfilePath);
network_configuration_handler_->CreateConfiguration( network_configuration_handler_->CreateConfiguration(
properties, properties,
...@@ -596,10 +603,16 @@ TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) { ...@@ -596,10 +603,16 @@ TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) {
message_loop_.RunUntilIdle(); message_loop_.RunUntilIdle();
EXPECT_FALSE(create_service_path_.empty()); EXPECT_FALSE(create_service_path_.empty());
std::string ssid; std::string ssid;
EXPECT_TRUE(GetServiceStringProperty( EXPECT_TRUE(GetServiceStringProperty(
create_service_path_, flimflam::kSSIDProperty, &ssid)); create_service_path_, flimflam::kSSIDProperty, &ssid));
std::string actual_profile;
EXPECT_EQ(service_path, ssid); EXPECT_EQ(service_path, ssid);
EXPECT_TRUE(GetServiceStringProperty(
create_service_path_, flimflam::kProfileProperty, &actual_profile));
EXPECT_EQ(ShillProfileClientStub::kSharedProfilePath, actual_profile);
} }
} // namespace chromeos } // namespace chromeos
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