Commit 632c6589 authored by Pavol Marko's avatar Pavol Marko Committed by Commit Bot

onc_to_shill: Set defaults for {IPAddress,NameServers}ConfigType

In onc to shill translation, set IPAddressConfigType and
NameServersConfigType to "DHCP" in the resulting ONC data if no value is
provided by shill.
The default of "DHCP" is consistent with go/onc and with shill behavior.

This is important so that these values always have a value when policy
decoration happens (the shill -> onc translated ONC is an input to
policy_util::CreateManagedONC invoked in
ManagedNetworkConfigurationHandlerImpl).

The UI can then depend on these always having an ActiveValue, so
cros_network_config.mojom has been changed to set the corresponding
{ip_address,name_servers}_config_type fields as mandatory.

Bug: 1108922, 1109660, 1109670
Test: unit tests + manual on DuT (network settings)
Change-Id: I6111a3c7f6af64fac22ea33347dd17774bbda4c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530330Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Pavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827390}
parent ac8df9c9
...@@ -54,8 +54,10 @@ chrome.test.runTests([ ...@@ -54,8 +54,10 @@ chrome.test.runTests([
}, },
ConnectionState: 'NotConnected', ConnectionState: 'NotConnected',
GUID: 'stub_cellular1_guid', GUID: 'stub_cellular1_guid',
IPAddressConfigType: chrome.networking.onc.IPConfigType.DHCP,
Metered: true, Metered: true,
Name: 'cellular1', Name: 'cellular1',
NameServersConfigType: chrome.networking.onc.IPConfigType.DHCP,
Source: 'User', Source: 'User',
Type: 'Cellular', Type: 'Cellular',
}, result); }, result);
......
...@@ -541,6 +541,7 @@ var availableTests = [ ...@@ -541,6 +541,7 @@ var availableTests = [
}], }],
MacAddress: '00:11:22:AA:BB:CC', MacAddress: '00:11:22:AA:BB:CC',
Name: 'wifi1', Name: 'wifi1',
NameServersConfigType: chrome.networkingPrivate.IPConfigType.DHCP,
Source: 'User', Source: 'User',
StaticIPConfig: { StaticIPConfig: {
IPAddress: '1.2.3.4', IPAddress: '1.2.3.4',
...@@ -591,8 +592,10 @@ var availableTests = [ ...@@ -591,8 +592,10 @@ var availableTests = [
}, },
ConnectionState: ConnectionStateType.NOT_CONNECTED, ConnectionState: ConnectionStateType.NOT_CONNECTED,
GUID: kCellularGuid, GUID: kCellularGuid,
IPAddressConfigType: chrome.networkingPrivate.IPConfigType.DHCP,
Metered: true, Metered: true,
Name: 'cellular1', Name: 'cellular1',
NameServersConfigType: chrome.networkingPrivate.IPConfigType.DHCP,
Source: 'User', Source: 'User',
Type: NetworkType.CELLULAR, Type: NetworkType.CELLULAR,
}, result); }, result);
...@@ -633,7 +636,9 @@ var availableTests = [ ...@@ -633,7 +636,9 @@ var availableTests = [
Connectable: false, Connectable: false,
ConnectionState: ConnectionStateType.NOT_CONNECTED, ConnectionState: ConnectionStateType.NOT_CONNECTED,
GUID: guid, GUID: guid,
IPAddressConfigType: chrome.networkingPrivate.IPConfigType.DHCP,
Name: '', Name: '',
NameServersConfigType: chrome.networkingPrivate.IPConfigType.DHCP,
Priority: 0, Priority: 0,
Source: 'None', Source: 'None',
Type: NetworkType.CELLULAR, Type: NetworkType.CELLULAR,
...@@ -659,6 +664,14 @@ var availableTests = [ ...@@ -659,6 +664,14 @@ var availableTests = [
UserPolicy: 'Direct' UserPolicy: 'Direct'
} }
}, },
IPAddressConfigType: {
Active: 'DHCP',
Effective: 'UserPolicy'
},
NameServersConfigType: {
Active: 'DHCP',
Effective: 'UserPolicy'
},
Source: 'UserPolicy', Source: 'UserPolicy',
Type: NetworkType.WI_FI, Type: NetworkType.WI_FI,
WiFi: { WiFi: {
......
...@@ -194,6 +194,15 @@ std::unique_ptr<base::DictionaryValue> TranslateNetworkStateToONC( ...@@ -194,6 +194,15 @@ std::unique_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
std::unique_ptr<base::DictionaryValue> onc_dictionary = std::unique_ptr<base::DictionaryValue> onc_dictionary =
TranslateShillServiceToONCPart(*shill_dictionary, onc_source, TranslateShillServiceToONCPart(*shill_dictionary, onc_source,
&onc::kNetworkWithStateSignature, network); &onc::kNetworkWithStateSignature, network);
// Remove IPAddressConfigType/NameServersConfigType as these were
// historically not provided by TranslateNetworkStateToONC.
// The source shill properties for those ONC properties are not provided by
// NetworkState::GetStateProperties, however since CL:2530330 these are
// assumed to have defaults that are always enforced during ONC translation.
onc_dictionary->RemoveKey(::onc::network_config::kIPAddressConfigType);
onc_dictionary->RemoveKey(::onc::network_config::kNameServersConfigType);
return onc_dictionary; return onc_dictionary;
} }
......
...@@ -325,10 +325,12 @@ const OncFieldSignature network_configuration_fields[] = { ...@@ -325,10 +325,12 @@ const OncFieldSignature network_configuration_fields[] = {
{::onc::network_config::kCellular, &kCellularSignature}, {::onc::network_config::kCellular, &kCellularSignature},
{::onc::network_config::kEthernet, &kEthernetSignature}, {::onc::network_config::kEthernet, &kEthernetSignature},
{::onc::network_config::kGUID, &kStringSignature}, {::onc::network_config::kGUID, &kStringSignature},
{::onc::network_config::kIPAddressConfigType, &kStringSignature}, {::onc::network_config::kIPAddressConfigType, &kStringSignature,
[]() { return base::Value(::onc::network_config::kIPConfigTypeDHCP); }},
{::onc::network_config::kMetered, &kBoolSignature}, {::onc::network_config::kMetered, &kBoolSignature},
{::onc::network_config::kName, &kStringSignature}, {::onc::network_config::kName, &kStringSignature},
{::onc::network_config::kNameServersConfigType, &kStringSignature}, {::onc::network_config::kNameServersConfigType, &kStringSignature,
[]() { return base::Value(::onc::network_config::kIPConfigTypeDHCP); }},
{::onc::network_config::kPriority, &kIntegerSignature}, {::onc::network_config::kPriority, &kIntegerSignature},
{::onc::network_config::kProxySettings, &kProxySettingsSignature}, {::onc::network_config::kProxySettings, &kProxySettingsSignature},
{::onc::kRecommended, &kRecommendedSignature}, {::onc::kRecommended, &kRecommendedSignature},
......
...@@ -13,11 +13,20 @@ ...@@ -13,11 +13,20 @@
namespace chromeos { namespace chromeos {
namespace onc { namespace onc {
// Generates a default value for a field.
// This is used so that static global base::Values can be avoided (which would
// have a non-trivial destructor and are thus prohibited).
using DefaultValueSetterFunc = base::Value (*)();
struct OncValueSignature; struct OncValueSignature;
struct OncFieldSignature { struct OncFieldSignature {
const char* onc_field_name; const char* onc_field_name;
const OncValueSignature* value_signature; const OncValueSignature* value_signature;
// If this is non-null, it will be called if the field doesn't have a value
// after shill->onc translation and the returned value will be assigned to the
// field.
DefaultValueSetterFunc default_value_setter = nullptr;
}; };
struct COMPONENT_EXPORT(CHROMEOS_NETWORK) OncValueSignature { struct COMPONENT_EXPORT(CHROMEOS_NETWORK) OncValueSignature {
......
...@@ -167,6 +167,13 @@ class ShillToONCTranslator { ...@@ -167,6 +167,13 @@ class ShillToONCTranslator {
// entry from |shill_dictionary_| to |onc_object_| if it exists. // entry from |shill_dictionary_| to |onc_object_| if it exists.
void CopyProperty(const OncFieldSignature* field_signature); void CopyProperty(const OncFieldSignature* field_signature);
// Applies defaults to fields according to |onc_signature_|.
void SetDefaultsAccordingToSignature();
// Applies defaults to fields according to |value_signature|.
void SetDefaultsAccordingToSignature(
const OncValueSignature* value_signature);
// If existent, translates the entry at |shill_property_name| in // If existent, translates the entry at |shill_property_name| in
// |shill_dictionary_| using |table|. It is an error if no matching table // |shill_dictionary_| using |table|. It is an error if no matching table
// entry is found. Writes the result as entry at |onc_field_name| in // entry is found. Writes the result as entry at |onc_field_name| in
...@@ -224,6 +231,9 @@ ShillToONCTranslator::CreateTranslatedONCObject() { ...@@ -224,6 +231,9 @@ ShillToONCTranslator::CreateTranslatedONCObject() {
} else { } else {
CopyPropertiesAccordingToSignature(); CopyPropertiesAccordingToSignature();
} }
SetDefaultsAccordingToSignature();
return base::DictionaryValue::From(std::move(onc_object_)); return base::DictionaryValue::From(std::move(onc_object_));
} }
...@@ -841,6 +851,27 @@ void ShillToONCTranslator::CopyProperty( ...@@ -841,6 +851,27 @@ void ShillToONCTranslator::CopyProperty(
onc_object_->SetKey(field_signature->onc_field_name, shill_value->Clone()); onc_object_->SetKey(field_signature->onc_field_name, shill_value->Clone());
} }
void ShillToONCTranslator::SetDefaultsAccordingToSignature() {
SetDefaultsAccordingToSignature(onc_signature_);
}
void ShillToONCTranslator::SetDefaultsAccordingToSignature(
const OncValueSignature* value_signature) {
if (value_signature->base_signature)
SetDefaultsAccordingToSignature(value_signature->base_signature);
if (!value_signature->fields)
return;
for (const OncFieldSignature* field_signature = value_signature->fields;
field_signature->onc_field_name != nullptr; ++field_signature) {
if (!field_signature->default_value_setter)
continue;
if (onc_object_->FindKey(field_signature->onc_field_name))
continue;
onc_object_->SetKey(field_signature->onc_field_name,
field_signature->default_value_setter());
}
}
void ShillToONCTranslator::TranslateWithTableAndSet( void ShillToONCTranslator::TranslateWithTableAndSet(
const std::string& shill_property_name, const std::string& shill_property_name,
const StringTranslationEntry table[], const StringTranslationEntry table[],
......
...@@ -153,7 +153,7 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -153,7 +153,7 @@ INSTANTIATE_TEST_SUITE_P(
std::make_pair("shill_cellular_with_state.json", std::make_pair("shill_cellular_with_state.json",
"translation_of_shill_cellular_with_state.onc"), "translation_of_shill_cellular_with_state.onc"),
std::make_pair("shill_output_third_party_vpn.json", std::make_pair("shill_output_third_party_vpn.json",
"third_party_vpn.onc"), "translation_of_shill_output_third_party_vpn.onc"),
std::make_pair( std::make_pair(
"shill_wifi_eap_ttls_with_password_variable.json", "shill_wifi_eap_ttls_with_password_variable.json",
"translation_of_shill_wifi_eap_ttls_with_password_variable.onc"), "translation_of_shill_wifi_eap_ttls_with_password_variable.onc"),
......
...@@ -1244,12 +1244,12 @@ mojom::ManagedPropertiesPtr ManagedPropertiesToMojo( ...@@ -1244,12 +1244,12 @@ mojom::ManagedPropertiesPtr ManagedPropertiesToMojo(
result->saved_ip_config = GetIPConfig(saved_ip_config); result->saved_ip_config = GetIPConfig(saved_ip_config);
// Managed properties // Managed properties
result->ip_address_config_type = result->ip_address_config_type = GetRequiredManagedString(
GetManagedString(properties, ::onc::network_config::kIPAddressConfigType); properties, ::onc::network_config::kIPAddressConfigType);
result->metered = result->metered =
GetManagedBoolean(properties, ::onc::network_config::kMetered); GetManagedBoolean(properties, ::onc::network_config::kMetered);
result->name = GetManagedString(properties, ::onc::network_config::kName); result->name = GetManagedString(properties, ::onc::network_config::kName);
result->name_servers_config_type = GetManagedString( result->name_servers_config_type = GetRequiredManagedString(
properties, ::onc::network_config::kNameServersConfigType); properties, ::onc::network_config::kNameServersConfigType);
result->priority = result->priority =
GetManagedInt32(properties, ::onc::network_config::kPriority); GetManagedInt32(properties, ::onc::network_config::kPriority);
......
...@@ -570,11 +570,11 @@ struct ManagedProperties { ...@@ -570,11 +570,11 @@ struct ManagedProperties {
bool connectable = false; bool connectable = false;
string? error_state; string? error_state;
string guid; string guid;
ManagedString? ip_address_config_type; ManagedString ip_address_config_type;
array<IPConfigProperties>? ip_configs; array<IPConfigProperties>? ip_configs;
ManagedBoolean? metered; ManagedBoolean? metered;
ManagedString? name; ManagedString? name;
ManagedString? name_servers_config_type; ManagedString name_servers_config_type;
ManagedInt32? priority; ManagedInt32? priority;
ManagedProxySettings? proxy_settings; ManagedProxySettings? proxy_settings;
PortalState portal_state = kUnknown; PortalState portal_state = kUnknown;
......
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
"Name": { "Name": {
"Active": "wifi2" "Active": "wifi2"
}, },
"IPAddressConfigType": {
"Active": "DHCP"
},
"NameServersConfigType": {
"Active": "DHCP"
},
"Source": "User", "Source": "User",
"Type": "WiFi", "Type": "WiFi",
"WiFi": { "WiFi": {
......
{ {
"Type": "Tether", "Type": "Tether",
"Name": "Tether Network", "Name": "Tether Network",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"Tether": { "Tether": {
"BatteryPercentage": 85, "BatteryPercentage": 85,
"Carrier": "Project Fi", "Carrier": "Project Fi",
......
...@@ -52,5 +52,7 @@ ...@@ -52,5 +52,7 @@
}, },
"Scanning": false "Scanning": false
}, },
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"Source":"Device" "Source":"Device"
} }
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
} }
}, },
"GUID":"guid", "GUID":"guid",
"IPAddressConfigType":"DHCP",
"Name":"", "Name":"",
"NameServersConfigType":"DHCP",
"Type":"Ethernet" "Type":"Ethernet"
} }
{ "GUID": "guid", { "GUID": "guid",
"Type": "VPN", "Type": "VPN",
"Name": "MyL2TPVPN", "Name": "MyL2TPVPN",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"VPN": { "VPN": {
"Type": "L2TP-IPsec", "Type": "L2TP-IPsec",
"Host": "some.host.org", "Host": "some.host.org",
......
{ {
"GUID": "{a3860e83-f03d-4cb1-bafa-b22c9e746950}", "GUID": "{a3860e83-f03d-4cb1-bafa-b22c9e746950}",
"IPAddressConfigType":"DHCP",
"Name": "my vpn", "Name": "my vpn",
"NameServersConfigType":"DHCP",
"Type": "VPN", "Type": "VPN",
"VPN": { "VPN": {
"AutoConnect": true, "AutoConnect": true,
......
{ {
"GUID": "{84391467-dd8b-4c66-9b52-860583038351}", "GUID": "{84391467-dd8b-4c66-9b52-860583038351}",
"IPAddressConfigType":"DHCP",
"Name": "TestOpenVPN", "Name": "TestOpenVPN",
"NameServersConfigType":"DHCP",
"Type": "VPN", "Type": "VPN",
"VPN": { "VPN": {
"Host": "terminus.muc", "Host": "terminus.muc",
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"GUID": "{a3860e83-f03d-4cb1-bafa-b22c9e746950}", "GUID": "{a3860e83-f03d-4cb1-bafa-b22c9e746950}",
"Name": "my vpn", "Name": "my vpn",
"Type": "VPN", "Type": "VPN",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"VPN": { "VPN": {
"AutoConnect": true, "AutoConnect": true,
"Host": "vpn.my.domain.com", "Host": "vpn.my.domain.com",
......
{ {
// "GUID" missing because it was missing in the Shill dict. // "GUID" missing because it was missing in the Shill dict.
"Name": "my vpn", "Name": "my vpn",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"Type": "VPN", "Type": "VPN",
"VPN": { "VPN": {
"Host": "vpn.my.domain.com", "Host": "vpn.my.domain.com",
......
{
"GUID": "guid",
"IPAddressConfigType":"DHCP",
"Name": "third-party VPN",
"NameServersConfigType":"DHCP",
"Type": "VPN",
"VPN": {
"Type": "ThirdPartyVPN",
"ThirdPartyVPN": {
"ExtensionID": "deadbeefdeadbeefdeadbeefdeadbeef",
}
}
}
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"GUID": "{84391467-dd8b-4c66-9b52-860583038351}", "GUID": "{84391467-dd8b-4c66-9b52-860583038351}",
"Name": "TestIpsecVPN", "Name": "TestIpsecVPN",
"Type": "VPN", "Type": "VPN",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"VPN": { "VPN": {
"Host": "terminus.muc", "Host": "terminus.muc",
"IPsec": { "IPsec": {
......
{ {
"GUID":"{77db0089-0bc8-4358-929c-123xcv}", "GUID":"{77db0089-0bc8-4358-929c-123xcv}",
"Name":"", "Name":"",
"IPAddressConfigType":"DHCP",
"ProxySettings": { "ProxySettings": {
"Type": "PAC", "Type": "PAC",
"PAC": "https://proxycfg.my.domain.com/proxy.dat" "PAC": "https://proxycfg.my.domain.com/proxy.dat"
}, },
"NameServersConfigType":"DHCP",
"Type":"WiFi", "Type":"WiFi",
"WiFi":{ "WiFi":{
"EAP": { "EAP": {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"GUID": "{77db0089-0bc8-4358-929c-123xcv}", "GUID": "{77db0089-0bc8-4358-929c-123xcv}",
"Type": "WiFi", "Type": "WiFi",
"Name": "", "Name": "",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"WiFi": { "WiFi": {
"Security": "WPA-EAP", "Security": "WPA-EAP",
"EAP": { "EAP": {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"GUID": "{77db0089-0bc8-4358-929c-123xcv}", "GUID": "{77db0089-0bc8-4358-929c-123xcv}",
"Type": "WiFi", "Type": "WiFi",
"Name": "", "Name": "",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"WiFi": { "WiFi": {
"Security": "WPA-EAP", "Security": "WPA-EAP",
"EAP": { "EAP": {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"GUID": "{77db0089-0bc8-4358-929c-123xcv}", "GUID": "{77db0089-0bc8-4358-929c-123xcv}",
"Type": "WiFi", "Type": "WiFi",
"Name": "", "Name": "",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"WiFi": { "WiFi": {
"Security": "WPA-EAP", "Security": "WPA-EAP",
"EAP": { "EAP": {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"GUID": "{77db0089-0bc8-4358-929c-123xcv}", "GUID": "{77db0089-0bc8-4358-929c-123xcv}",
"Type": "WiFi", "Type": "WiFi",
"Name": "", "Name": "",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"WiFi": { "WiFi": {
"Security": "WPA-EAP", "Security": "WPA-EAP",
"EAP": { "EAP": {
......
{ {
"GUID":"{64c4f86b-cf6a-4e4a-8eff-456def}", "GUID":"{64c4f86b-cf6a-4e4a-8eff-456def}",
"IPAddressConfigType":"DHCP",
"Name":"OpenWrt", "Name":"OpenWrt",
"NameServersConfigType":"DHCP",
"Type":"WiFi", "Type":"WiFi",
"WiFi":{ "WiFi":{
// Hex of the SSID field // Hex of the SSID field
......
{ {
"IPAddressConfigType":"DHCP",
"Name": "", "Name": "",
"NameServersConfigType":"DHCP",
"ProxySettings": { "ProxySettings": {
"Type": "Manual", "Type": "Manual",
"Manual": { "Manual": {
......
{ {
"Name": "", "Name": "",
"IPAddressConfigType":"DHCP",
"ProxySettings": { "ProxySettings": {
"Type": "PAC", "Type": "PAC",
"PAC": "http://pac.foo.com/script.pac" "PAC": "http://pac.foo.com/script.pac"
}, },
"NameServersConfigType":"DHCP",
"Type": "WiFi", "Type": "WiFi",
"WiFi": { "WiFi": {
"Security": "None" "Security": "None"
......
{ {
"GUID":"{77db0089-0bc8-4358-929c-123xcv}", "GUID":"{77db0089-0bc8-4358-929c-123xcv}",
"IPAddressConfigType":"DHCP",
"Name":"", "Name":"",
"NameServersConfigType":"DHCP",
"ProxySettings": { "ProxySettings": {
"Type": "PAC", "Type": "PAC",
"PAC": "https://proxycfg.my.domain.com/proxy.dat" "PAC": "https://proxycfg.my.domain.com/proxy.dat"
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
"Connectable": true, "Connectable": true,
"GUID": "{64c4f86b-cf6a-4e4a-8eff-456def}", "GUID": "{64c4f86b-cf6a-4e4a-8eff-456def}",
"Name": "OpenWrt", "Name": "OpenWrt",
"IPAddressConfigType":"DHCP",
"NameServersConfigType":"DHCP",
"Priority": 1, "Priority": 1,
"Type": "WiFi", "Type": "WiFi",
"WiFi": { "WiFi": {
......
...@@ -1093,8 +1093,10 @@ TEST_F(NetworkingPrivateApiTest, GetCellularProperties) { ...@@ -1093,8 +1093,10 @@ TEST_F(NetworkingPrivateApiTest, GetCellularProperties) {
.Build()) .Build())
.Set("ConnectionState", "Connected") .Set("ConnectionState", "Connected")
.Set("GUID", "cellular_guid") .Set("GUID", "cellular_guid")
.Set("IPAddressConfigType", "DHCP")
.Set("Metered", true) .Set("Metered", true)
.Set("Name", "cellular") .Set("Name", "cellular")
.Set("NameServersConfigType", "DHCP")
.Set("Source", "User") .Set("Source", "User")
.Set("Type", "Cellular") .Set("Type", "Cellular")
.Build(); .Build();
...@@ -1153,8 +1155,10 @@ TEST_F(NetworkingPrivateApiTest, GetCellularPropertiesFromWebUi) { ...@@ -1153,8 +1155,10 @@ TEST_F(NetworkingPrivateApiTest, GetCellularPropertiesFromWebUi) {
.Build()) .Build())
.Set("ConnectionState", "Connected") .Set("ConnectionState", "Connected")
.Set("GUID", "cellular_guid") .Set("GUID", "cellular_guid")
.Set("IPAddressConfigType", "DHCP")
.Set("Metered", true) .Set("Metered", true)
.Set("Name", "cellular") .Set("Name", "cellular")
.Set("NameServersConfigType", "DHCP")
.Set("Source", "User") .Set("Source", "User")
.Set("Type", "Cellular") .Set("Type", "Cellular")
.Build(); .Build();
......
...@@ -163,11 +163,8 @@ Polymer({ ...@@ -163,11 +163,8 @@ Polymer({
} }
// Update the 'automatic' property. // Update the 'automatic' property.
if (properties.ipAddressConfigType) { const ipConfigType = OncMojo.getActiveValue(properties.ipAddressConfigType);
const ipConfigType = this.automatic_ = ipConfigType !== 'Static';
OncMojo.getActiveValue(properties.ipAddressConfigType);
this.automatic_ = ipConfigType !== 'Static';
}
if (properties.ipConfigs || properties.staticIpConfig) { if (properties.ipConfigs || properties.staticIpConfig) {
// Update the 'ipConfig' property. // Update the 'ipConfig' property.
......
...@@ -130,11 +130,8 @@ Polymer({ ...@@ -130,11 +130,8 @@ Polymer({
} }
// Update the 'nameserversType' property. // Update the 'nameserversType' property.
let configType; const configType =
if (this.managedProperties.nameServersConfigType) { OncMojo.getActiveValue(this.managedProperties.nameServersConfigType);
configType =
OncMojo.getActiveValue(this.managedProperties.nameServersConfigType);
}
let type; let type;
if (configType === 'Static') { if (configType === 'Static') {
if (this.isGoogleNameservers_(nameservers)) { if (this.isGoogleNameservers_(nameservers)) {
...@@ -186,8 +183,7 @@ Polymer({ ...@@ -186,8 +183,7 @@ Polymer({
if (!managedProperties) { if (!managedProperties) {
return false; return false;
} }
if (managedProperties.nameServersConfigType && if (this.isNetworkPolicyEnforced(managedProperties.nameServersConfigType)) {
this.isNetworkPolicyEnforced(managedProperties.nameServersConfigType)) {
return false; return false;
} }
if (managedProperties.staticIpConfig && if (managedProperties.staticIpConfig &&
...@@ -212,8 +208,7 @@ Polymer({ ...@@ -212,8 +208,7 @@ Polymer({
if (nameserversType !== 'custom') { if (nameserversType !== 'custom') {
return false; return false;
} }
if (managedProperties.nameServersConfigType && if (this.isNetworkPolicyEnforced(managedProperties.nameServersConfigType)) {
this.isNetworkPolicyEnforced(managedProperties.nameServersConfigType)) {
return false; return false;
} }
if (managedProperties.staticIpConfig && if (managedProperties.staticIpConfig &&
......
...@@ -717,6 +717,8 @@ ...@@ -717,6 +717,8 @@
connectable: false, connectable: false,
guid: guid, guid: guid,
name: OncMojo.createManagedString(name), name: OncMojo.createManagedString(name),
ipAddressConfigType: OncMojo.createManagedString('DHCP'),
nameServersConfigType: OncMojo.createManagedString('DHCP'),
portalState: mojom.PortalState.kUnknown, portalState: mojom.PortalState.kUnknown,
}; };
switch (type) { switch (type) {
......
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