Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[OpenWrt] Fixed empty dns and dns-search bug
- Loading branch information
Showing
with
23 additions
and
6 deletions.
-
+4
−6
netjsonconfig/backends/openwrt/renderers.py
-
+19
−0
tests/openwrt/test_network.py
|
@@ -165,14 +165,12 @@ def _get_ip_rules(self): |
|
|
def __get_dns_servers(self): |
|
|
dns = self.config.get('dns_servers', None) |
|
|
if dns: |
|
|
dns = ' '.join(dns) |
|
|
return dns |
|
|
return ' '.join(dns) |
|
|
|
|
|
def __get_dns_search(self): |
|
|
dns = self.config.get('dns_search', None) |
|
|
if dns: |
|
|
dns = ' '.join(dns) |
|
|
return dns |
|
|
dns_search = self.config.get('dns_search', None) |
|
|
if dns_search: |
|
|
return ' '.join(dns_search) |
|
|
|
|
|
def _get_switches(self): |
|
|
uci_switches = [] |
|
|
|
@@ -827,5 +827,24 @@ def test_ula_prefix(self): |
|
|
|
|
|
config globals 'globals' |
|
|
option ula_prefix 'fd8e:f40a:6701::/48' |
|
|
""") |
|
|
self.assertEqual(o.render(), expected) |
|
|
|
|
|
def test_empty_dns(self): |
|
|
o = OpenWrt({ |
|
|
"interfaces": [ |
|
|
{ |
|
|
"name": "eth0", |
|
|
"type": "ethernet" |
|
|
} |
|
|
], |
|
|
"dns_servers": [], |
|
|
"dns_search": [] |
|
|
}) |
|
|
expected = self._tabs("""package network |
|
|
|
|
|
config interface 'eth0' |
|
|
option ifname 'eth0' |
|
|
option proto 'none' |
|
|
""") |
|
|
self.assertEqual(o.render(), expected) |