Skip to content

Commit

Permalink
feat(tests): add adblock configuration and test for ad block status
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed Nov 29, 2024
1 parent 533a2b1 commit 2a183a4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,30 @@
option family 'ipv4'
list ipaddr 'dhcp/ns_8d5d2cf4'
"""
adblock_db = """
config adblock 'global'
option adb_enabled '1'
option adb_debug '0'
option adb_forcedns '1'
option adb_safesearch '0'
option adb_dnsfilereset '0'
option adb_mail '0'
option adb_report '0'
option adb_backup '1'
option adb_fetchutil 'wget'
option adb_dns 'dnsmasq'
option ts_enabled '1'
list adb_zonelist 'lan'
list adb_portlist '53'
list adb_portlist '853'
option adb_srcarc '/etc/adblock/combined.sources.gz'
option adb_dnsinstance '0'
option adb_fetchparm '--compression=gzip --no-cache --no-cookies --max-redirect=0 --timeout=20 -O'
list adb_sources 'adaway'
list adb_sources 'adguard'
list adb_sources 'disconnect'
list adb_sources 'yoyo'
"""

def _setup_db(tmp_path):
# setup fake db
Expand Down Expand Up @@ -762,6 +786,8 @@ def _setup_db(tmp_path):
fp.write(netmap_db)
with tmp_path.joinpath('objects').open('w') as fp:
fp.write(objects_db)
with tmp_path.joinpath('adblock').open('w') as fp:
fp.write(adblock_db)
return EUci(confdir=tmp_path.as_posix())

def test_fact_hotspot(tmp_path):
Expand Down Expand Up @@ -930,3 +956,8 @@ def test_fact_firewall_stats(tmp_path):
assert result['objects']['rules']['forward'] == 1
assert result['objects']['rules']['input'] == 1
assert result['objects']['rules']['output'] == 1

def test_fact_ad_block(tmp_path):
u = _setup_db(tmp_path)
result = inventory.fact_ad_block(u)
assert result == {"enabled": True, "community": 0, "enterprise": 0}

0 comments on commit 2a183a4

Please sign in to comment.