Permalink
Browse files

[OpenWrt] Fixed empty dns and dns-search bug

  • Loading branch information...
nemesisdesign committed Mar 22, 2016
1 parent e008ef6 commit c70ab76e62c7735bd285ffdb263baf5d3b6b4e4a
Showing with 23 additions and 6 deletions.
  1. +4 −6 netjsonconfig/backends/openwrt/renderers.py
  2. +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)

0 comments on commit c70ab76

Please sign in to comment.