[tor-commits] [stem/master] Refactor existing "ignore 'unused' content" CertsCell test case into test data

atagar at torproject.org atagar at torproject.org
Thu Jul 12 18:53:11 UTC 2018


commit 3619331ad6545063df966bab5d855bdb463ed715
Author: Dave Rolek <dmr-x at riseup.net>
Date:   Wed Jul 11 18:54:29 2018 +0000

    Refactor existing "ignore 'unused' content" CertsCell test case into test data
    
    By refactoring this check into test data, and with the logic set up in
    previous commits, the commit also ensures more test coverage for this
    case.
    
    Also clean up the comments for context.
---
 test/unit/client/cell.py | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/test/unit/client/cell.py b/test/unit/client/cell.py
index 4caf13ba..2e5c498a 100644
--- a/test/unit/client/cell.py
+++ b/test/unit/client/cell.py
@@ -78,6 +78,7 @@ CERTS_CELLS = {
   b'\x00\x00\x81\x00\x01\x00': ([], b'', 2),
   b'\x00\x00\x81\x00\x04\x01\x01\x00\x00': ([Certificate(1, b'')], b'', 2),
   b'\x00\x00\x81\x00\x05\x01\x01\x00\x01\x08': ([Certificate(1, b'\x08')], b'', 2),
+  b'\x00\x00\x81\x00\x07\x01\x01\x00\x01\x08\x06\x04': ([Certificate(1, '\x08')], b'\x06\x04', 2),
 }
 
 AUTH_CHALLENGE_CELLS = {
@@ -321,11 +322,7 @@ class TestCell(unittest.TestCase):
       self.assertEqual(unused, cell.unused)
       self.assertEqual(cell_bytes, cell.pack(link_protocol))
 
-    # extra bytes after the last certificate should be ignored
-
-    self.assertEqual([Certificate(1, '\x08')], Cell.pop(b'\x00\x00\x81\x00\x07\x01\x01\x00\x01\x08\x06\x04', 2)[0].certificates)
-
-    # ... but truncated or missing certificates should error
+    # truncated or missing certificates should error
 
     self.assertRaisesRegexp(ValueError, 'CERTS cell should have a certificate with 3 bytes, but only had 1 remaining', Cell.pop, b'\x00\x00\x81\x00\x05\x01\x01\x00\x03\x08', 2)
     self.assertRaisesRegexp(ValueError, 'CERTS cell indicates it should have 2 certificates, but only contained 1', Cell.pop, b'\x00\x00\x81\x00\x05\x02\x01\x00\x01\x08', 2)





More information about the tor-commits mailing list