[tor-commits] [stem/master] Dropping test for empty dir-source fields

atagar at torproject.org atagar at torproject.org
Sat Oct 13 18:35:45 UTC 2012


commit 98d8e4685bab0dd107f5dd6f185492d6f3a5c136
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Oct 8 08:36:47 2012 -0700

    Dropping test for empty dir-source fields
    
    Nick replied on 'https://trac.torproject.org/7055' saying that the fields can't
    be empty strings, so dropping the test. Also adding a validation check that the
    hostname isn't an empty string.
---
 stem/descriptor/networkstatus.py                   |    3 ++
 .../networkstatus/directory_authority.py           |   32 --------------------
 2 files changed, 3 insertions(+), 32 deletions(-)

diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py
index dea16f4..a2c13a2 100644
--- a/stem/descriptor/networkstatus.py
+++ b/stem/descriptor/networkstatus.py
@@ -801,6 +801,9 @@ class DirectoryAuthority(stem.descriptor.Descriptor):
             raise ValueError("Authority's nickname is invalid: %s" % dir_source_comp[0])
           elif not stem.util.tor_tools.is_valid_fingerprint(dir_source_comp[1]):
             raise ValueError("Authority's fingerprint is invalid: %s" % dir_source_comp[1])
+          elif not dir_source_comp[2]:
+            # https://trac.torproject.org/7055
+            raise ValueError("Authority's hostname can't be blank: %s" % line)
           elif not stem.util.connection.is_valid_ip_address(dir_source_comp[3]):
             raise ValueError("Authority's address isn't a valid IPv4 address: %s" % dir_source_comp[3])
           elif not stem.util.connection.is_valid_port(dir_source_comp[4], allow_zero = True):
diff --git a/test/unit/descriptor/networkstatus/directory_authority.py b/test/unit/descriptor/networkstatus/directory_authority.py
index b032b48..f01604f 100644
--- a/test/unit/descriptor/networkstatus/directory_authority.py
+++ b/test/unit/descriptor/networkstatus/directory_authority.py
@@ -125,38 +125,6 @@ class TestDirectoryAuthority(unittest.TestCase):
       self.assertEqual(None, authority.dir_port)
       self.assertEqual(None, authority.or_port)
   
-  def test_empty_values(self):
-    """
-    The 'dir-source' line has a couple string values where anything (without
-    spaces) would be valud. Check that we're ok with the value being an empty
-    string.
-    """
-    
-    # TODO: Test presently fails because a missing nickname makes us think that
-    # a field is missing. This is technically a bug caused by us ignoring an
-    # idiosyncrasy with how v3 documents are formatted. With all descriptor
-    # types *except* v3 documents a keyword and value is split by any amount
-    # of whitespace. With a v3 document it must be a single space.
-    #
-    # When we have an empty nickname the value starts with a space, causing our
-    # keyword/value regex to gobble the extra space (making the field
-    # disappear). Checking with Nick before investing any further effort into
-    # this...
-    # https://trac.torproject.org/7055
-    
-    test.runner.skip(self, "https://trac.torproject.org/7055")
-    return
-    
-    # drop the authority nickname
-    dir_source = AUTHORITY_HEADER[0][1].replace('turtles', '')
-    authority = get_directory_authority({"dir-source": dir_source})
-    self.assertEqual('', authority.nickname)
-    
-    # drop the hostname
-    dir_source = AUTHORITY_HEADER[0][1].replace('no.place.com', '')
-    authority = get_directory_authority({"dir-source": dir_source})
-    self.assertEqual('', authority.hostname)
-  
   def test_malformed_fingerprint(self):
     """
     Includes a malformed fingerprint on the 'dir-source' line.





More information about the tor-commits mailing list