diff options
Diffstat (limited to 'tests/integration/test_accesslist.py')
| -rw-r--r-- | tests/integration/test_accesslist.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/integration/test_accesslist.py b/tests/integration/test_accesslist.py index b4e134e..41ff654 100644 --- a/tests/integration/test_accesslist.py +++ b/tests/integration/test_accesslist.py | |||
| @@ -37,12 +37,10 @@ class Blacklist(TrackerTestCase): | |||
| 37 | self.assertNotIn(b"failure reason", answer) | 37 | self.assertNotIn(b"failure reason", answer) |
| 38 | self.assertEqual(answer[b"complete"], 1) | 38 | self.assertEqual(answer[b"complete"], 1) |
| 39 | 39 | ||
| 40 | def test_the_block_holds_over_udp_but_the_answer_is_malformed(self): | 40 | def test_the_block_is_an_error_packet_over_udp(self): |
| 41 | """The UDP path has no spelling for "not authorized": the announce | 41 | """BEP 15 has an error action, which is what a refusal should use. |
| 42 | writes no body, so the tracker sends the eight byte header alone | 42 | It used to answer the announce header with no body behind it, a |
| 43 | where BEP 15 calls for at least twenty. Pinned rather than blessed — | 43 | packet too short for any client to read.""" |
| 44 | an error packet or silence would both be defensible, a short announce | ||
| 45 | is neither.""" | ||
| 46 | sock, connection_id = self.tracker.udp_connect() | 44 | sock, connection_id = self.tracker.udp_connect() |
| 47 | sock.close() | 45 | sock.close() |
| 48 | request = struct.pack( | 46 | request = struct.pack( |
| @@ -50,10 +48,10 @@ class Blacklist(TrackerTestCase): | |||
| 50 | ) | 48 | ) |
| 51 | answer = self.tracker.udp_raw(request) | 49 | answer = self.tracker.udp_raw(request) |
| 52 | self.assertIsNotNone(answer) | 50 | self.assertIsNotNone(answer) |
| 53 | self.assertEqual(len(answer), 8, "header only, no interval or counts") | 51 | action, transaction = struct.unpack(">II", answer[:8]) |
| 54 | action, transaction = struct.unpack(">II", answer) | 52 | self.assertEqual(action, 3, "action 3 is the error packet") |
| 55 | self.assertEqual(action, 1, "it still claims to be an announce") | ||
| 56 | self.assertEqual(transaction, 7) | 53 | self.assertEqual(transaction, 7) |
| 54 | self.assertIn(b"not authorized", answer[8:]) | ||
| 57 | 55 | ||
| 58 | def test_a_blocked_hash_is_not_stored_when_it_arrives_over_udp(self): | 56 | def test_a_blocked_hash_is_not_stored_when_it_arrives_over_udp(self): |
| 59 | sock, connection_id = self.tracker.udp_connect() | 57 | sock, connection_id = self.tracker.udp_connect() |
