From f3e1141f3e72b70d287a1c7443d3c4b8725cc6ff Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Wed, 24 Jan 2018 00:33:27 +0000 Subject: [PATCH] VPN: Do not share configured VPNs VPN configurations were never shared in the non Settings based UI. We should preserve that behavior in the new UI. (The current behavior is completely wrong and always shares VPN configurations even when they require certificates). TBR=stevenjb@chromium.org (cherry picked from commit b08867e4e0e133862c0a16b08b2b7990ac45a59e) Bug: 798924 Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation Change-Id: I4470a77b8f4f36e0f46aba5505eafd96fb0ca799 Reviewed-on: https://chromium-review.googlesource.com/876933 Commit-Queue: Steven Bennetts Reviewed-by: Kevin Cernekee Reviewed-by: Toni Barzic Cr-Original-Commit-Position: refs/heads/master@{#531008} Reviewed-on: https://chromium-review.googlesource.com/882551 Reviewed-by: Steven Bennetts Cr-Commit-Position: refs/branch-heads/3325@{#52} Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369} --- .../cr_components/network_config_test.js | 31 +++++++++++++------ .../chromeos/network/network_config.js | 5 +++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/chrome/test/data/webui/cr_components/network_config_test.js b/chrome/test/data/webui/cr_components/network_config_test.js index 977e9d18ba2f7..5f7ddbeb5051b 100644 --- a/chrome/test/data/webui/cr_components/network_config_test.js +++ b/chrome/test/data/webui/cr_components/network_config_test.js @@ -28,6 +28,9 @@ suite('network-config', function() { networkConfig = document.createElement('network-config'); networkConfig.networkingPrivate = api_; networkConfig.networkProperties = networkProperties; + } + + function initNetworkConfig() { document.body.appendChild(networkConfig); networkConfig.init(); Polymer.dom.flush(); @@ -44,6 +47,7 @@ suite('network-config', function() { setup(function() { api_.resetForTest(); setNetworkConfig({GUID: '', Name: '', Type: 'WiFi'}); + initNetworkConfig(); }); teardown(function() { @@ -69,6 +73,7 @@ suite('network-config', function() { }; api_.addNetworksForTest([network]); setNetworkConfig({GUID: 'someguid', Name: '', Type: 'WiFi'}); + initNetworkConfig(); }); teardown(function() { @@ -116,10 +121,11 @@ suite('network-config', function() { } test('New Config: Login or guest', function() { - setNetworkConfig({GUID: '', Name: '', Type: 'WiFi'}); - setLoginOrGuest(); // Insecure networks are always shared so test a secure config. - networkConfig.security_ = 'WEP-PSK'; + setNetworkConfig( + {GUID: '', Name: '', Type: 'WiFi', WiFi: {Security: 'WEP-PSK'}}); + setLoginOrGuest(); + initNetworkConfig(); return flushAsync().then(() => { let share = networkConfig.$$('#share'); assertTrue(!!share); @@ -129,10 +135,11 @@ suite('network-config', function() { }); test('New Config: Kiosk', function() { - setNetworkConfig({GUID: '', Name: '', Type: 'WiFi'}); - setKiosk(); // Insecure networks are always shared so test a secure config. - networkConfig.security_ = 'WEP-PSK'; + setNetworkConfig( + {GUID: '', Name: '', Type: 'WiFi', WiFi: {Security: 'WEP-PSK'}}); + setKiosk(); + initNetworkConfig(); return flushAsync().then(() => { let share = networkConfig.$$('#share'); assertTrue(!!share); @@ -142,8 +149,10 @@ suite('network-config', function() { }); test('New Config: Authenticated, Not secure', function() { - setNetworkConfig({GUID: '', Name: '', Type: 'WiFi'}); + setNetworkConfig( + {GUID: '', Name: '', Type: 'WiFi', WiFi: {Security: 'None'}}); setAuthenticated(); + initNetworkConfig(); return flushAsync().then(() => { let share = networkConfig.$$('#share'); assertTrue(!!share); @@ -153,9 +162,10 @@ suite('network-config', function() { }); test('New Config: Authenticated, Secure', function() { - setNetworkConfig({GUID: '', Name: '', Type: 'WiFi'}); + setNetworkConfig( + {GUID: '', Name: '', Type: 'WiFi', WiFi: {Security: 'WEP-PSK'}}); setAuthenticated(); - networkConfig.security_ = 'WEP-PSK'; + initNetworkConfig(); return flushAsync().then(() => { let share = networkConfig.$$('#share'); assertTrue(!!share); @@ -176,6 +186,7 @@ suite('network-config', function() { api_.addNetworksForTest([network]); setNetworkConfig({GUID: 'someguid', Name: '', Type: 'WiFi'}); setAuthenticated(); + initNetworkConfig(); return flushAsync().then(() => { assertFalse(!!networkConfig.$$('#share')); }); @@ -190,6 +201,7 @@ suite('network-config', function() { }; api_.addNetworksForTest([ethernet]); setNetworkConfig({GUID: 'ethernetguid', Name: '', Type: 'Ethernet'}); + initNetworkConfig(); return flushAsync().then(() => { assertEquals('ethernetguid', networkConfig.guid); assertEquals('None', networkConfig.security_); @@ -216,6 +228,7 @@ suite('network-config', function() { }; api_.addNetworksForTest([ethernet, ethernetEap]); setNetworkConfig({GUID: 'ethernetguid', Name: '', Type: 'Ethernet'}); + initNetworkConfig(); return flushAsync().then(() => { assertEquals('eapguid', networkConfig.guid); assertEquals('WPA-EAP', networkConfig.security_); diff --git a/ui/webui/resources/cr_components/chromeos/network/network_config.js b/ui/webui/resources/cr_components/chromeos/network/network_config.js index 19296b0cc80c2..73c4662890e96 100644 --- a/ui/webui/resources/cr_components/chromeos/network/network_config.js +++ b/ui/webui/resources/cr_components/chromeos/network/network_config.js @@ -348,6 +348,7 @@ Polymer({ } this.onCertificateListsChanged_(); this.updateIsConfigured_(); + this.setShareNetwork_(); requestAnimationFrame(() => { var e = this.$$( 'network-config-input:not([disabled]),' + @@ -542,6 +543,10 @@ Polymer({ source == CrOnc.Source.DEVICE || source == CrOnc.Source.DEVICE_POLICY; return; } + if (!this.shareIsVisible_()) { + this.shareNetwork_ = false; + return; + } if (this.shareAllowEnable) { // New insecure WiFi networks are always shared. if (this.networkProperties.Type == CrOnc.Type.WI_FI &&