def test_bridge_ip_versions_line(self): """ Parses the 'bridge-ip-versions' line, which only appears in bridges. """ desc = BridgeExtraInfoDescriptor.create({'bridge-ip-versions': 'v4=16,v6=40'}) self.assertEqual({'v4': 16, 'v6': 40}, desc.ip_versions) desc = BridgeExtraInfoDescriptor.create({'bridge-ip-versions': ''}) self.assertEqual({}, desc.ip_versions) desc_text = BridgeExtraInfoDescriptor.content({'bridge-ip-versions': 'v4=24.5'}) self.assertRaises(ValueError, RelayExtraInfoDescriptor, desc_text, True)
def test_bridge_ip_transports_line(self): """ Parses the 'bridge-ip-transports' line, which only appears in bridges. """ desc = BridgeExtraInfoDescriptor.create({'bridge-ip-transports': '<OR>=16,<??>=40'}) self.assertEqual({'<OR>': 16, '<??>': 40}, desc.ip_transports) desc = BridgeExtraInfoDescriptor.create({'bridge-ip-transports': ''}) self.assertEqual({}, desc.ip_transports) desc_text = BridgeExtraInfoDescriptor.content({'bridge-ip-transports': '<OR>=24.5'}) self.assertRaises(ValueError, RelayExtraInfoDescriptor, desc_text, True)
def test_bridge_ip_transports_line(self): """ Parses the 'bridge-ip-transports' line, which only appears in bridges. """ desc = BridgeExtraInfoDescriptor.create({'bridge-ip-transports': '<OR>=16,<??>=40'}) self.assertEqual({'<OR>': 16, '<??>': 40}, desc.ip_transports) desc = BridgeExtraInfoDescriptor.create({'bridge-ip-transports': ''}) self.assertEqual({}, desc.ip_transports) desc_text = BridgeExtraInfoDescriptor.content({'bridge-ip-transports': '<OR>=24.5'}) self.assertRaises(ValueError, RelayExtraInfoDescriptor, desc_text, True)
def test_bridge_ip_versions_line(self): """ Parses the 'bridge-ip-versions' line, which only appears in bridges. """ desc = BridgeExtraInfoDescriptor.create({'bridge-ip-versions': 'v4=16,v6=40'}) self.assertEqual({'v4': 16, 'v6': 40}, desc.ip_versions) desc = BridgeExtraInfoDescriptor.create({'bridge-ip-versions': ''}) self.assertEqual({}, desc.ip_versions) desc_text = BridgeExtraInfoDescriptor.content({'bridge-ip-versions': 'v4=24.5'}) self.assertRaises(ValueError, RelayExtraInfoDescriptor, desc_text, True)
def test_transport_line(self): """ Basic exercise for both a bridge and relay's transport entry. """ desc = BridgeExtraInfoDescriptor.create({'transport': 'obfs3'}) self.assertEqual({'obfs3': (None, None, None)}, desc.transport) self.assertEqual([], desc.get_unrecognized_lines()) desc = RelayExtraInfoDescriptor.create({'transport': 'obfs2 83.212.96.201:33570'}) self.assertEqual({'obfs2': ('83.212.96.201', 33570, [])}, desc.transport) self.assertEqual([], desc.get_unrecognized_lines()) # multiple transport lines desc = BridgeExtraInfoDescriptor.create({'transport': 'obfs3\ntransport obfs4'}) self.assertEqual({'obfs3': (None, None, None), 'obfs4': (None, None, None)}, desc.transport) self.assertEqual([], desc.get_unrecognized_lines())
def test_transport_line(self): """ Basic exercise for both a bridge and relay's transport entry. """ desc = BridgeExtraInfoDescriptor.create({'transport': 'obfs3'}) self.assertEqual({'obfs3': (None, None, None)}, desc.transport) self.assertEqual([], desc.get_unrecognized_lines()) desc = RelayExtraInfoDescriptor.create({'transport': 'obfs2 83.212.96.201:33570'}) self.assertEqual({'obfs2': ('83.212.96.201', 33570, [])}, desc.transport) self.assertEqual([], desc.get_unrecognized_lines()) # multiple transport lines desc = BridgeExtraInfoDescriptor.create({'transport': 'obfs3\ntransport obfs4'}) self.assertEqual({'obfs3': (None, None, None), 'obfs4': (None, None, None)}, desc.transport) self.assertEqual([], desc.get_unrecognized_lines())
def test_minimal_bridge_descriptor(self): """ Basic sanity check that we can parse a descriptor with minimal attributes. """ desc = BridgeExtraInfoDescriptor.create() self.assertEqual('ec2bridgereaac65a3', desc.nickname) self.assertEqual([], desc.get_unrecognized_lines()) # check that we don't have crypto fields self.assertRaises(AttributeError, getattr, desc, 'signature')
def test_minimal_bridge_descriptor(self): """ Basic sanity check that we can parse a descriptor with minimal attributes. """ desc = BridgeExtraInfoDescriptor.create() self.assertEqual('ec2bridgereaac65a3', desc.nickname) self.assertEqual([], desc.get_unrecognized_lines()) # check that we don't have crypto fields self.assertRaises(AttributeError, getattr, desc, 'signature')