def test_include_conf_dir(): dnsmasq1 = DnsmasqConf( context_wrap(DNSMASQ_CONF_MAIN_INCLUDE_CONF_DIR, path="/etc/dnsmasq.conf")) dnsmasq2 = DnsmasqConf( context_wrap(DNSMASQ_CONF_FILE_2, path="/etc/dnsmasq.d/1id-dns.conf")) result = DnsmasqConfTree([dnsmasq1, dnsmasq2]) assert len(result["dns-forward-max"]) == 2
def test_exclude_conf_dir(): dnsmasq1 = DnsmasqConf( context_wrap(DNSMASQ_CONF_MAIN_EXCLUDE_CONF_DIR, path="/etc/dnsmasq.conf")) dnsmasq2 = DnsmasqConf( context_wrap(DNSMASQ_CONF_FILE_1, path="/etc/dnsmasq.d/origin-dns.conf")) result = DnsmasqConfTree([dnsmasq1, dnsmasq2]) assert "txt-record" not in result assert len(result["server"]) == 2
def test_no_conf_dir(): # no conf-dir dnsmasq1 = DnsmasqConf( context_wrap(DNSMASQ_CONF_MAIN, path="/etc/dnsmasq.conf")) dnsmasq2 = DnsmasqConf( context_wrap(DNSMASQ_CONF_FILE_1, path="/etc/dnsmasq.d/origin-dns.conf")) result = DnsmasqConfTree([dnsmasq1, dnsmasq2]) assert "domain-needed" in result assert "log-queries" not in result assert len(result["server"]) == 2
def test_conf_dir(): dnsmasq1 = DnsmasqConf( context_wrap(DNSMASQ_CONF_MAIN_CONF_DIR, path="/etc/dnsmasq.conf")) dnsmasq2 = DnsmasqConf( context_wrap(DNSMASQ_CONF_FILE_1, path="/etc/dnsmasq.d/origin-dns.conf")) result = DnsmasqConfTree([dnsmasq1, dnsmasq2]) assert "txt-record" in result assert len(result["server"]) == 3 dnsmasq1 = DnsmasqConf( context_wrap(DNSMASQ_CONF_MAIN_CONF_DIR, path="/etc/dnsmasq.conf")) dnsmasq2 = DnsmasqConf( context_wrap(DNSMASQ_CONF_FILE_2, path="/etc/dnsmasq.d/dns-forward-max.conf")) result = DnsmasqConfTree([dnsmasq1, dnsmasq2]) assert len(result["dns-forward-max"]) == 2 assert result["dns-forward-max"][-1].value == 10000
def test_dnsmasq_conf(): result = DnsmasqConf( context_wrap(DNSMASQ_CONF_MAIN, path="/etc/dnsmasq.conf")) assert "no-resolv" in result assert result.find("port").value == 5353 assert len(result.find_all("server")) == 2 assert result.find_all("server")[0].value == '/in-addr.arpa/127.0.0.1' assert result.find("bind-dynamic").name == 'bind-dynamic' assert "# End of config" not in result
def test_dnsmasq_conf_file(): result = DnsmasqConf( context_wrap(DNSMASQ_CONF_FILE_1, path="/etc/dnsmasq.d/dns-origin.conf")) assert len(result["server"]) == 2 assert result["server"][-1].value == "/cluster.local/127.0.0.1"