Commit c30dd018 authored by pbond's avatar pbond Committed by Commit bot

Removed ONC check in ArcSettingsService.

Removed ONC proxy policy applied check when the default network is
changed.

If proxy settings are bundled to the specific network and another
network is connected on startup, these settings are not
transferred to ARC on startup and should be transferred only when the network
becomes a default netowork.

BUG=657361
TEST=browsertest

Review-Url: https://codereview.chromium.org/2436753002
Cr-Commit-Position: refs/heads/master@{#427058}
parent ae44722d
...@@ -485,14 +485,11 @@ void ArcSettingsServiceImpl::SendSettingsBroadcast( ...@@ -485,14 +485,11 @@ void ArcSettingsServiceImpl::SendSettingsBroadcast(
void ArcSettingsServiceImpl::DefaultNetworkChanged( void ArcSettingsServiceImpl::DefaultNetworkChanged(
const chromeos::NetworkState* network) { const chromeos::NetworkState* network) {
// kProxy pref and ONC policy have more priority than the default network // kProxy pref has more priority than the default network update.
// update. // If a default network is changed to the network with ONC policy with proxy
Profile* profile = ProfileManager::GetActiveUserProfile(); // settings, it should be translated here.
if (network && !IsPrefProxyConfigApplied() && if (network && !IsPrefProxyConfigApplied())
!chromeos::onc::HasPolicyForNetwork(
profile->GetPrefs(), g_browser_process->local_state(), *network)) {
SyncProxySettings(); SyncProxySettings();
}
} }
ArcSettingsService::ArcSettingsService(ArcBridgeService* bridge_service) ArcSettingsService::ArcSettingsService(ArcBridgeService* bridge_service)
......
...@@ -58,10 +58,121 @@ constexpr char kONCPolicy[] = ...@@ -58,10 +58,121 @@ constexpr char kONCPolicy[] =
" ]," " ],"
" \"Type\": \"UnencryptedConfiguration\"" " \"Type\": \"UnencryptedConfiguration\""
"}"; "}";
constexpr char kONCPacUrl[] = "http://domain.com/x";
constexpr char kDefaultServicePath[] = "stub_ethernet"; constexpr char kDeviceONCPolicy[] =
constexpr char kWifiServicePath[] = "stub_wifi"; "{"
" \"GlobalNetworkConfiguration\": {"
" \"AllowOnlyPolicyNetworksToAutoconnect\": false,"
" \"AllowOnlyPolicyNetworksToConnect\": false"
" },"
" \"NetworkConfigurations\": [ {"
" \"GUID\": \"{wifi1_guid}\","
" \"Name\": \"wifi1\","
" \"ProxySettings\": {"
" \"Manual\": {"
" \"FTPProxy\": {"
" \"Host\": \"proxy\","
" \"Port\": 5000"
" },"
" \"HTTPProxy\": {"
" \"Host\": \"proxy\","
" \"Port\": 5000"
" },"
" \"SOCKS\": {"
" \"Host\": \"proxy\","
" \"Port\": 5000"
" },"
" \"SecureHTTPProxy\": {"
" \"Host\": \"proxy\","
" \"Port\": 5000"
" }"
" },"
" \"Type\": \"Manual\""
" },"
" \"Type\": \"WiFi\","
" \"WiFi\": {"
" \"AutoConnect\": false,"
" \"HiddenSSID\": false,"
" \"SSID\": \"wifi1\","
" \"Security\": \"None\""
" }"
" } ]"
"}";
constexpr char kUserONCPolicy[] =
"{"
" \"NetworkConfigurations\": [ {"
" \"GUID\": \"{direct_guid}\","
" \"Name\": \"EAP-TTLS\","
" \"ProxySettings\": {"
" \"Type\": \"Direct\""
" },"
" \"Type\": \"WiFi\","
" \"WiFi\": {"
" \"AutoConnect\": false,"
" \"EAP\": {"
" \"Identity\": \"CrOS\","
" \"Inner\": \"Automatic\","
" \"Outer\": \"EAP-TTLS\","
" \"Password\": \"********\","
" \"Recommended\": ["
" \"AnonymousIdentity\","
" \"Identity\","
" \"Password\""
" ],"
" \"SaveCredentials\": true,"
" \"UseSystemCAs\": false"
" },"
" \"HiddenSSID\": false,"
" \"SSID\": \"direct_ssid\","
" \"Security\": \"WPA-EAP\""
" }"
" }, {"
" \"GUID\": \"{wifi0_guid}\","
" \"Name\": \"wifi0\","
" \"ProxySettings\": {"
" \"Manual\": {"
" \"FTPProxy\": {"
" \"Host\": \"proxy-n300\","
" \"Port\": 3000"
" },"
" \"HTTPProxy\": {"
" \"Host\": \"proxy-n300\","
" \"Port\": 3000"
" },"
" \"SOCKS\": {"
" \"Host\": \"proxy-n300\","
" \"Port\": 3000"
" },"
" \"SecureHTTPProxy\": {"
" \"Host\": \"proxy-n300\","
" \"Port\": 3000"
" }"
" },"
" \"Type\": \"Manual\""
" },"
" \"Type\": \"WiFi\","
" \"WiFi\": {"
" \"AutoConnect\": false,"
" \"HiddenSSID\": false,"
" \"SSID\": \"wifi0\","
" \"Security\": \"None\""
" }"
" } ]"
"}";
constexpr char kUserProfilePath[] = "user_profile"; constexpr char kUserProfilePath[] = "user_profile";
constexpr char kDefaultServicePath[] = "stub_ethernet";
constexpr char kWifi0ServicePath[] = "stub_wifi0";
constexpr char kWifi0Ssid[] = "wifi0";
constexpr char kWifi0Guid[] = "{wifi0_guid}";
constexpr char kWifi1ServicePath[] = "stub_wifi1";
constexpr char kWifi1Ssid[] = "wifi1";
constexpr char kWifi1Guid[] = "{wifi1_guid}";
constexpr char kONCPacUrl[] = "http://domain.com/x";
// Returns an amount of |broadcasts| matched with |proxy_settings|. // Returns an amount of |broadcasts| matched with |proxy_settings|.
int CountProxyBroadcasts( int CountProxyBroadcasts(
...@@ -129,6 +240,23 @@ class ArcSettingsServiceTest : public InProcessBrowserTest { ...@@ -129,6 +240,23 @@ class ArcSettingsServiceTest : public InProcessBrowserTest {
base::StringValue value(shill::kStateIdle); base::StringValue value(shill::kStateIdle);
service_test->SetServiceProperty(service_path, shill::kStateProperty, service_test->SetServiceProperty(service_path, shill::kStateProperty,
value); value);
RunUntilIdle();
}
void ConnectWifiNetworkService(const std::string& service_path,
const std::string& guid,
const std::string& ssid) {
chromeos::ShillServiceClient::TestInterface* service_test =
chromeos::DBusThreadManager::Get()
->GetShillServiceClient()
->GetTestInterface();
service_test->AddService(service_path, guid, ssid, shill::kTypeWifi,
shill::kStateOnline, true /* add_to_visible */);
service_test->SetServiceProperty(service_path, shill::kProfileProperty,
base::StringValue(kUserProfilePath));
RunUntilIdle();
} }
void SetProxyConfigForNetworkService( void SetProxyConfigForNetworkService(
...@@ -166,12 +294,6 @@ class ArcSettingsServiceTest : public InProcessBrowserTest { ...@@ -166,12 +294,6 @@ class ArcSettingsServiceTest : public InProcessBrowserTest {
service_test->SetServiceProperty(kDefaultServicePath, service_test->SetServiceProperty(kDefaultServicePath,
shill::kProfileProperty, shill::kProfileProperty,
base::StringValue(kUserProfilePath)); base::StringValue(kUserProfilePath));
service_test->AddService(kWifiServicePath, "stub_wifi_guid", "wifi0",
shill::kTypeWifi, shill::kStateOnline,
true /* add_to_visible */);
service_test->SetServiceProperty(kWifiServicePath, shill::kProfileProperty,
base::StringValue(kUserProfilePath));
} }
policy::MockConfigurationPolicyProvider provider_; policy::MockConfigurationPolicyProvider provider_;
...@@ -300,6 +422,7 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkProxyConfigTest) { ...@@ -300,6 +422,7 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkProxyConfigTest) {
} }
IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkDisconnectedTest) { IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkDisconnectedTest) {
ConnectWifiNetworkService(kWifi0ServicePath, kWifi0Guid, kWifi0Ssid);
fake_intent_helper_instance_->clear_broadcasts(); fake_intent_helper_instance_->clear_broadcasts();
// Set proxy confog for default network. // Set proxy confog for default network.
std::unique_ptr<base::DictionaryValue> default_proxy_config( std::unique_ptr<base::DictionaryValue> default_proxy_config(
...@@ -316,7 +439,7 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkDisconnectedTest) { ...@@ -316,7 +439,7 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkDisconnectedTest) {
base::MakeUnique<base::DictionaryValue>()); base::MakeUnique<base::DictionaryValue>());
wifi_proxy_config->SetString("mode", ProxyPrefs::kFixedServersProxyModeName); wifi_proxy_config->SetString("mode", ProxyPrefs::kFixedServersProxyModeName);
wifi_proxy_config->SetString("server", "wifi/proxy:8080"); wifi_proxy_config->SetString("server", "wifi/proxy:8080");
SetProxyConfigForNetworkService(kWifiServicePath, wifi_proxy_config.get()); SetProxyConfigForNetworkService(kWifi0ServicePath, wifi_proxy_config.get());
RunUntilIdle(); RunUntilIdle();
// Observe default network proxy config broadcast. // Observe default network proxy config broadcast.
...@@ -333,7 +456,6 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkDisconnectedTest) { ...@@ -333,7 +456,6 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, DefaultNetworkDisconnectedTest) {
// Disconnect default network. // Disconnect default network.
fake_intent_helper_instance_->clear_broadcasts(); fake_intent_helper_instance_->clear_broadcasts();
DisconnectNetworkService(kDefaultServicePath); DisconnectNetworkService(kDefaultServicePath);
RunUntilIdle();
// Observe WI-FI network proxy config broadcast. // Observe WI-FI network proxy config broadcast.
std::unique_ptr<base::DictionaryValue> expected_wifi_proxy_config( std::unique_ptr<base::DictionaryValue> expected_wifi_proxy_config(
...@@ -352,12 +474,57 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, NoNetworkConnectedTest) { ...@@ -352,12 +474,57 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, NoNetworkConnectedTest) {
// Disconnect all networks. // Disconnect all networks.
fake_intent_helper_instance_->clear_broadcasts(); fake_intent_helper_instance_->clear_broadcasts();
DisconnectNetworkService(kDefaultServicePath); DisconnectNetworkService(kDefaultServicePath);
DisconnectNetworkService(kWifiServicePath);
RunUntilIdle();
EXPECT_EQ( EXPECT_EQ(
CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(), nullptr), CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(), nullptr),
0); 0);
} }
IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, TwoONCProxyPolicyTest) {
// Connect to wifi1 with appliead device ONC policy.
ConnectWifiNetworkService(kWifi1ServicePath, kWifi1Guid, kWifi1Ssid);
// Disconnect default network.
DisconnectNetworkService(kDefaultServicePath);
fake_intent_helper_instance_->clear_broadcasts();
policy::PolicyMap policy;
policy.Set(policy::key::kOpenNetworkConfiguration,
policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
policy::POLICY_SOURCE_CLOUD,
base::MakeUnique<base::StringValue>(kUserONCPolicy), nullptr);
policy.Set(policy::key::kDeviceOpenNetworkConfiguration,
policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE,
policy::POLICY_SOURCE_CLOUD,
base::MakeUnique<base::StringValue>(kDeviceONCPolicy), nullptr);
UpdatePolicy(policy);
std::unique_ptr<base::DictionaryValue> expected_proxy_config(
base::MakeUnique<base::DictionaryValue>());
expected_proxy_config->SetString("mode",
ProxyPrefs::kFixedServersProxyModeName);
expected_proxy_config->SetString("host", "proxy");
expected_proxy_config->SetInteger("port", 5000);
EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(),
expected_proxy_config.get()),
1);
DisconnectNetworkService(kWifi1ServicePath);
fake_intent_helper_instance_->clear_broadcasts();
// Connect to wifi0 with appliead user ONC policy.
ConnectWifiNetworkService(kWifi0ServicePath, kWifi0Guid, kWifi0Ssid);
expected_proxy_config->SetString("mode",
ProxyPrefs::kFixedServersProxyModeName);
expected_proxy_config->SetString("host", "proxy-n300");
expected_proxy_config->SetInteger("port", 3000);
EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(),
expected_proxy_config.get()),
1);
}
} // namespace arc } // namespace arc
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