summaryrefslogtreecommitdiffstats
path: root/net/adblock-fast/tests/01_pipeline/09_unbound_header
blob: dc73b1fff9835d173a7d041e1aace0389dcd015d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Test that unbound.adb_list mode prepends "server:" header line.

-- Testcase --
import adb from 'adblock-fast';
import { readfile } from 'fs';
let ti = adb._test_internals;

adb.env.load_config();
ti.set_cfg('dns', 'unbound.adb_list');
ti.set_cfg('dnsmasq_sanity_check', false);
ti.set_cfg('dnsmasq_validity_check', false);
ti.set_cfg('heartbeat_domain', null);
ti.set_cfg('config_update_enabled', false);
ti.set_cfg('update_config_sizes', false);
ti.env.dns_set_output_values('unbound.adb_list');
ti.append_urls();

let ok = ti.download_lists();
if (!ok) {
	print('download_lists failed\n');
} else {
	let content = readfile(ti.dns_output.file) || '';
	let lines = filter(split(content, '\n'), l => length(l) > 0);

	let results = [];

	// First line should be "server:"
	push(results, sprintf('first_line: %s', lines[0]));

	// Rest should be local-zone entries
	let lz_lines = filter(lines, l => match(l, /^local-zone: /));
	push(results, sprintf('local_zone_entries: %d', length(lz_lines)));

	// Spot-check format
	let test_domain = 'ad.doubleclick.test.example.com';
	let expected = 'local-zone: "' + test_domain + '." always_nxdomain';
	let has_entry = index(content, expected) >= 0;
	push(results, sprintf('correct_format: %s', has_entry ? 'YES' : 'NO'));

	print(join('\n', results) + '\n');
}
-- End --

-- Expect stdout --
first_line: server:
local_zone_entries: 162
correct_format: YES
-- End --