Beispiel #1
0
  def test_unrecognized_line(self):
    """
    Includes unrecognized content in the descriptor.
    """

    authority = DirectoryAuthority.create({'pepperjack': 'is oh so tasty!'})
    self.assertEqual(['pepperjack is oh so tasty!'], authority.get_unrecognized_lines())
Beispiel #2
0
  def test_legacy_dir_key(self):
    """
    Includes a 'legacy-dir-key' line with both valid and invalid content.
    """

    test_value = '65968CCB6BECB5AA88459C5A072624C6995B6B72'
    authority = DirectoryAuthority.create({'legacy-dir-key': test_value}, is_vote = True)
    self.assertEqual(test_value, authority.legacy_dir_key)

    # check that we'll fail if legacy-dir-key appears in a consensus
    content = DirectoryAuthority.content({'legacy-dir-key': test_value})
    self.assertRaises(ValueError, DirectoryAuthority, content, True)

    test_values = (
      '',
      'zzzzz',
      'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
    )

    for value in test_values:
      content = DirectoryAuthority.content({'legacy-dir-key': value})
      self.assertRaises(ValueError, DirectoryAuthority, content, True)

      authority = DirectoryAuthority(content, False)
      self.assertEqual(None, authority.legacy_dir_key)
Beispiel #3
0
  def test_blank_lines(self):
    """
    Includes blank lines, which should be ignored.
    """

    authority = DirectoryAuthority.create({'dir-source': DIR_SOURCE_LINE + '\n\n\n'})
    self.assertEqual('Mike Perry <email>', authority.contact)
Beispiel #4
0
  def test_unrecognized_line(self):
    """
    Includes unrecognized content in the descriptor.
    """

    authority = DirectoryAuthority.create({'pepperjack': 'is oh so tasty!'})
    self.assertEqual(['pepperjack is oh so tasty!'], authority.get_unrecognized_lines())
Beispiel #5
0
  def test_legacy_dir_key(self):
    """
    Includes a 'legacy-dir-key' line with both valid and invalid content.
    """

    test_value = '65968CCB6BECB5AA88459C5A072624C6995B6B72'
    authority = DirectoryAuthority.create({'legacy-dir-key': test_value}, is_vote = True)
    self.assertEqual(test_value, authority.legacy_dir_key)

    # check that we'll fail if legacy-dir-key appears in a consensus
    content = DirectoryAuthority.content({'legacy-dir-key': test_value})
    self.assertRaises(ValueError, DirectoryAuthority, content, True)

    test_values = (
      '',
      'zzzzz',
      'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
    )

    for value in test_values:
      content = DirectoryAuthority.content({'legacy-dir-key': value})
      self.assertRaises(ValueError, DirectoryAuthority, content, True)

      authority = DirectoryAuthority(content, False)
      self.assertEqual(None, authority.legacy_dir_key)
Beispiel #6
0
  def test_blank_lines(self):
    """
    Includes blank lines, which should be ignored.
    """

    authority = DirectoryAuthority.create({'dir-source': DIR_SOURCE_LINE + '\n\n\n'})
    self.assertEqual('Mike Perry <email>', authority.contact)
Beispiel #7
0
  def test_minimal_vote_authority(self):
    """
    Parses a minimal directory authority for a vote.
    """

    authority = DirectoryAuthority.create(is_vote = True)

    self.assertTrue(authority.nickname.startswith('Unnamed'))
    self.assertEqual(40, len(authority.fingerprint))
    self.assertEqual('no.place.com', authority.hostname)
    self.assertEqual(9030, authority.dir_port)
    self.assertEqual(9090, authority.or_port)
    self.assertEqual(False, authority.is_legacy)
    self.assertEqual('Mike Perry <email>', authority.contact)
    self.assertEqual(None, authority.vote_digest)
    self.assertEqual(None, authority.legacy_dir_key)
    self.assertEqual([], authority.get_unrecognized_lines())
Beispiel #8
0
  def test_minimal_vote_authority(self):
    """
    Parses a minimal directory authority for a vote.
    """

    authority = DirectoryAuthority.create(is_vote = True)

    self.assertTrue(authority.nickname.startswith('Unnamed'))
    self.assertEqual(40, len(authority.fingerprint))
    self.assertEqual('no.place.com', authority.hostname)
    self.assertEqual(9030, authority.dir_port)
    self.assertEqual(9090, authority.or_port)
    self.assertEqual(False, authority.is_legacy)
    self.assertEqual('Mike Perry <email>', authority.contact)
    self.assertEqual(None, authority.vote_digest)
    self.assertEqual(None, authority.legacy_dir_key)
    self.assertEqual([], authority.get_unrecognized_lines())