[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Adding unit test for empty dir-source values
commit 5ac628e7c8bd95c6c2cade6477aceef51a941b2e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sat Oct 6 12:26:10 2012 -0700
Adding unit test for empty dir-source values
Just realized that the nickname and hostname fields, which lack any
constraints, might also allow for empty values. I'm not really clear about this
so asking for clarification...
https://trac.torproject.org/7055
---
.../networkstatus/directory_authority.py | 34 ++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/test/unit/descriptor/networkstatus/directory_authority.py b/test/unit/descriptor/networkstatus/directory_authority.py
index cf16506..1405d12 100644
--- a/test/unit/descriptor/networkstatus/directory_authority.py
+++ b/test/unit/descriptor/networkstatus/directory_authority.py
@@ -4,6 +4,8 @@ Unit tests for the DirectoryAuthority of stem.descriptor.networkstatus.
import unittest
+import test.runner
+
from stem.descriptor.networkstatus import DirectoryAuthority
from test.mocking import get_directory_authority, get_key_certificate, AUTHORITY_HEADER
@@ -103,4 +105,36 @@ class TestDirectoryAuthority(unittest.TestCase):
authority = DirectoryAuthority(content, False)
self.assertEqual("turtles", authority.nickname)
+
+ 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)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits