summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-05 16:03:35 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-05 16:03:35 +0100
commit2a7bc3f8a7cd232cad0a858b4d810a2cac3193d8 (patch)
tree068ba4de5c5672bafea62f85a56fde788bbd23c6 /tests/integration
parent4e0b179014ced8c16c90bdfd6d82df625fea47e9 (diff)
Read the accesslist before any consumer consults it
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_accesslist.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/integration/test_accesslist.py b/tests/integration/test_accesslist.py
index 41ff654..1c84ccf 100644
--- a/tests/integration/test_accesslist.py
+++ b/tests/integration/test_accesslist.py
@@ -5,10 +5,11 @@ entry, and the file parser has to cope with the shapes an operator actually
5produces: an empty file, and a last line with no newline after it. 5produces: an empty file, and a last line with no newline after it.
6""" 6"""
7 7
8import os
8import struct 9import struct
9import unittest 10import unittest
10 11
11from harness import TrackerTestCase 12from harness import Tracker, TrackerTestCase
12 13
13BLOCKED = b"\xb1" * 20 14BLOCKED = b"\xb1" * 20
14ALLOWED = b"\xa1" * 20 15ALLOWED = b"\xa1" * 20
@@ -96,5 +97,26 @@ class MissingBlacklist(TrackerTestCase):
96 self.assertEqual(self.tracker.announce(BLOCKED, port=6881, left=0)[b"complete"], 1) 97 self.assertEqual(self.tracker.announce(BLOCKED, port=6881, left=0)[b"complete"], 1)
97 98
98 99
100class ListIsInPlaceBeforeTheStateFile(TrackerTestCase):
101 """The loader used to run in a thread of its own, so a state file read at
102 startup was checked against a list that was still empty."""
103
104 config = "access.blacklist {dir}/blacklist\n"
105 files = {"blacklist": listing(BLOCKED)}
106
107 def test_a_blacklisted_torrent_in_a_state_file_is_not_restored(self):
108 path = os.path.join(self.tracker.dir, "state")
109 with open(path, "w") as handle:
110 handle.write("%s:5:7\n%s:5:7\n" % (BLOCKED.hex(), ALLOWED.hex()))
111
112 restarted = Tracker(self.config, self.files, extra_args=["-l", path])
113 try:
114 self.assertNotIn(BLOCKED, restarted.scrape(BLOCKED)[b"files"], "the blacklist was not in place when the state file was read")
115 self.assertIn(ALLOWED, restarted.scrape(ALLOWED)[b"files"], "the state file was not read at all")
116 restarted.stop()
117 finally:
118 restarted._cleanup()
119
120
99if __name__ == "__main__": 121if __name__ == "__main__":
100 unittest.main() 122 unittest.main()