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

    desc = HiddenServiceDescriptor.create({'pepperjack': 'is oh so tasty!'})
    self.assertEqual(['pepperjack is oh so tasty!'], desc.get_unrecognized_lines())
  def test_unrecognized_line(self):
    """
    Includes unrecognized content in the descriptor.
    """

    desc = HiddenServiceDescriptor.create({'pepperjack': 'is oh so tasty!'})
    self.assertEqual(['pepperjack is oh so tasty!'], desc.get_unrecognized_lines())
Example #3
0
  def test_introduction_points_when_empty(self):
    """
    It's valid to advertise zero introduciton points. I'm not clear if this
    would mean an empty protocol-versions field or that it's omitted but either
    are valid according to the spec.
    """

    missing_field_desc = HiddenServiceDescriptor.create(exclude = ('introduction-points',))

    self.assertEqual(None, missing_field_desc.introduction_points_encoded)
    self.assertEqual([], missing_field_desc.introduction_points_auth)
    self.assertEqual(None, missing_field_desc.introduction_points_content)
    self.assertEqual([], missing_field_desc.introduction_points())

    empty_field_desc = HiddenServiceDescriptor.create({'introduction-points': MESSAGE_BLOCK % ''})

    self.assertEqual((MESSAGE_BLOCK % '').strip(), empty_field_desc.introduction_points_encoded)
    self.assertEqual([], empty_field_desc.introduction_points_auth)
    self.assertEqual(b'', empty_field_desc.introduction_points_content)
    self.assertEqual([], empty_field_desc.introduction_points())
  def test_introduction_points_when_empty(self):
    """
    It's valid to advertise zero introduciton points. I'm not clear if this
    would mean an empty protocol-versions field or that it's omitted but either
    are valid according to the spec.
    """

    missing_field_desc = HiddenServiceDescriptor.create(exclude = ('introduction-points',))

    self.assertEqual(None, missing_field_desc.introduction_points_encoded)
    self.assertEqual([], missing_field_desc.introduction_points_auth)
    self.assertEqual(None, missing_field_desc.introduction_points_content)
    self.assertEqual([], missing_field_desc.introduction_points())

    empty_field_desc = HiddenServiceDescriptor.create({'introduction-points': MESSAGE_BLOCK % ''})

    self.assertEqual((MESSAGE_BLOCK % '').strip(), empty_field_desc.introduction_points_encoded)
    self.assertEqual([], empty_field_desc.introduction_points_auth)
    self.assertEqual(b'', empty_field_desc.introduction_points_content)
    self.assertEqual([], empty_field_desc.introduction_points())
  def test_minimal_hidden_service_descriptor(self):
    """
    Basic sanity check that we can parse a hidden service descriptor with minimal attributes.
    """

    desc = HiddenServiceDescriptor.create()

    self.assertEqual('y3olqqblqw2gbh6phimfuiroechjjafa', desc.descriptor_id)
    self.assertEqual(2, desc.version)
    self.assertEqual('e24kgecavwsznj7gpbktqsiwgvngsf4e', desc.secret_id_part)
    self.assertEqual([2, 3], desc.protocol_versions)
    self.assertEqual('-----BEGIN MESSAGE-----\n-----END MESSAGE-----', desc.introduction_points_encoded)
    self.assertEqual([], desc.introduction_points_auth)
    self.assertEqual(b'', desc.introduction_points_content)
    self.assertEqual([], desc.introduction_points())
Example #6
0
  def test_minimal_hidden_service_descriptor(self):
    """
    Basic sanity check that we can parse a hidden service descriptor with minimal attributes.
    """

    desc = HiddenServiceDescriptor.create()

    self.assertEqual('y3olqqblqw2gbh6phimfuiroechjjafa', desc.descriptor_id)
    self.assertEqual(2, desc.version)
    self.assertEqual('e24kgecavwsznj7gpbktqsiwgvngsf4e', desc.secret_id_part)
    self.assertEqual([2, 3], desc.protocol_versions)
    self.assertEqual('-----BEGIN MESSAGE-----\n-----END MESSAGE-----', desc.introduction_points_encoded)
    self.assertEqual([], desc.introduction_points_auth)
    self.assertEqual(b'', desc.introduction_points_content)
    self.assertEqual([], desc.introduction_points())
    self.assertEqual('@type hidden-service-descriptor 1.0', str(desc.type_annotation()))
Example #7
0
 def test_from_str(self):
   sig = HiddenServiceDescriptor.create()
   self.assertEqual(sig, HiddenServiceDescriptor.from_str(str(sig)))