commit 525f2f9cee559fb8b77cb8daf46c68737487c63b Author: Damian Johnson atagar@torproject.org Date: Sun May 19 14:59:41 2013 -0700
Using a real descriptor for test_non_ascii_descriptor
Our test_non_ascii_descriptor test used an altered descriptor with katakana (Japanese characters) in its contact line. When we use doctored descriptors we can no longer exercise _validate_content since the signature won't match. Replacing the example descriptor with the one that's causing issues in #8755. --- test/integ/descriptor/data/non-ascii_descriptor | 34 +++++++++++------------ test/integ/descriptor/server_descriptor.py | 30 ++++++++++---------- 2 files changed, 31 insertions(+), 33 deletions(-)
diff --git a/test/integ/descriptor/data/non-ascii_descriptor b/test/integ/descriptor/data/non-ascii_descriptor index eb3e31a..da1d8a5 100644 --- a/test/integ/descriptor/data/non-ascii_descriptor +++ b/test/integ/descriptor/data/non-ascii_descriptor @@ -1,30 +1,30 @@ @type server-descriptor 1.0 -router torrelay389752132 130.243.230.116 9001 0 0 -platform Tor 0.2.2.35 (git-4f42b0a93422f70e) on Linux x86_64 +router Coruscant 88.182.161.122 9001 0 9030 +platform Tor 0.2.3.25 on Linux opt protocols Link 1 2 Circuit 1 -published 2012-03-21 16:28:14 -opt fingerprint 5D47 E91A 1F74 21A4 E325 5F4D 04E5 34E9 A214 07BB -uptime 3103848 -bandwidth 81920 102400 84275 -opt extra-info-digest 51E9FD0DA7C235D8C0250BAFB6E1ABB5F1EF9F04 +published 2013-05-18 11:16:19 +opt fingerprint 0B98 2154 5C48 E496 AEED 9ECC 0DB5 06C4 9FF8 158D +uptime 259738 +bandwidth 102400 204800 122818 +opt extra-info-digest 56403D838DE152421CD401B8E57DAD4483A3D56B onion-key -----BEGIN RSA PUBLIC KEY----- -MIGJAoGBAKTHzdEAocB7JhpB5iDaNYgHujJ+0mtoahZOAqgZ5BWVjw8fwt0UXEtO -BRPzNigNyAP1UWKHvgelBy49wvuC9twoBejCCYjcu9z2RmbBvYcyZRzphvHJqBpW -k3Rx75up+wsuBzhfwSYr7W+T+WkDQvz49RFPpns6Ef0qFpQ1TlHxAgMBAAE= +MIGJAoGBAK+rjPilZJVzvWn6slOpak4eUab+VXiGNkRAIKgGAqbpex7lNMcZeXbu +8uYhiDUdjRaHQUbBjLaj6nAjtlHUl3NCbIpo2p03KEcxfAGi3k6dUMBJ7aIYb8lL +SDK95huLBpyyNPikeDIiTKS1HNtmrai/iVtUiJS2I4fs3lP1TxevAgMBAAE= -----END RSA PUBLIC KEY----- signing-key -----BEGIN RSA PUBLIC KEY----- -MIGJAoGBALRHQWXGjGLNROY8At3dMnrcSxw4PF/9oLYuqCsXNAq0Gju+EBA5qfM4 -AMpeOk+7ZsZ6AsjdBPAPaOf7hm+z6Kr3Am/gC43dci+iuNHf2wYLR8TnW/C5Q6ZQ -iXpSAGrOHnIptyPHa0j9ayM4WmHWrPBKnC0QA91CGrxnnNc6DHehAgMBAAE= +MIGJAoGBANGDDMHoCtTeL4UTEGip4T+37jd4lEjBgla7lgL8W1gtVTX/uMMo+HGE +m1sD/FgBI3w8w7zpZlJgYeB/94YPUrw11iAEYAooJVmGDmel2g6CFofDs7KmrzqR +1FQDIWeY9sQd4+L+jWMquqcA3FyzuZz28gi56hIombjkfr0RwCsNAgMBAAE= -----END RSA PUBLIC KEY----- opt hidden-service-dir -contact 2048R/F171EC1F Johan Blåbäck こんにちは +contact 1024D/04D2E818 Lénaïc Huard <lenaic dot huard AT laposte dot net> reject *:* router-signature -----BEGIN SIGNATURE----- -WqBgiomhJ+XewpbOGg1r+6KXlAkdxHRhgCB/D980yJVzXWbOCrRhwyyAH9Lx+yrK -1EFXAtfQBBx2hmsw8CSYuUT6ckjXyUBAKEdABC25yRdi+fN3NfSQd56U9MvArjo9 -Y8oz244gH4BSVp4CScL8dK0EUsUrAxjs+OU7bnV5saA= +hk4jKRtI0LbjYWdGhjTuev9Hk9AilyBmBtK9nfpBPyamQZDZVirEUuP7PdtxM2U9 +EdCg+KnkrLoKoxh18YumBD2HvwHa2J1VZtezWkwxGB+HPkECTU/byl+dn6ZRncY7 +r0IrVeGUnlK/UaWpswx6amH7FEKXmBZYHxTxyuwwybQ= -----END SIGNATURE----- diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py index 43c9d4d..7779951 100644 --- a/test/integ/descriptor/server_descriptor.py +++ b/test/integ/descriptor/server_descriptor.py @@ -192,36 +192,34 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4= Parses a descriptor with non-ascii content. """
- test.mocking.mock_method(stem.descriptor.server_descriptor.RelayDescriptor, '_validate_content', test.mocking.no_op()) - descriptor_file = open(get_resource("non-ascii_descriptor"), 'rb')
- expected_contact = b"2048R/F171EC1F Johan Bl\xc3\xa5b\xc3\xa4ck \xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf" + expected_contact = b"1024D/04D2E818 L\xc3\xa9na\xc3\xafc Huard <lenaic dot huard AT laposte dot net>"
desc = next(stem.descriptor.parse_file(descriptor_file, "server-descriptor 1.0")) - self.assertEquals("torrelay389752132", desc.nickname) - self.assertEquals("5D47E91A1F7421A4E3255F4D04E534E9A21407BB", desc.fingerprint) - self.assertEquals("130.243.230.116", desc.address) + self.assertEquals("Coruscant", desc.nickname) + self.assertEquals("0B9821545C48E496AEED9ECC0DB506C49FF8158D", desc.fingerprint) + self.assertEquals("88.182.161.122", desc.address) self.assertEquals(9001, desc.or_port) self.assertEquals(None, desc.socks_port) - self.assertEquals(None, desc.dir_port) - self.assertEquals(b"Tor 0.2.2.35 (git-4f42b0a93422f70e) on Linux x86_64", desc.platform) - self.assertEquals(stem.version.Version("0.2.2.35"), desc.tor_version) - self.assertEquals("Linux x86_64", desc.operating_system) - self.assertEquals(3103848, desc.uptime) - self.assertEquals(datetime.datetime(2012, 3, 21, 16, 28, 14), desc.published) + self.assertEquals(9030, desc.dir_port) + self.assertEquals(b"Tor 0.2.3.25 on Linux", desc.platform) + self.assertEquals(stem.version.Version("0.2.3.25"), desc.tor_version) + self.assertEquals("Linux", desc.operating_system) + self.assertEquals(259738, desc.uptime) + self.assertEquals(datetime.datetime(2013, 5, 18, 11, 16, 19), desc.published) self.assertEquals(expected_contact, desc.contact) self.assertEquals(["1", "2"], desc.link_protocols) self.assertEquals(["1"], desc.circuit_protocols) self.assertEquals(False, desc.hibernating) self.assertEquals(False, desc.allow_single_hop_exits) self.assertEquals(False, desc.extra_info_cache) - self.assertEquals("51E9FD0DA7C235D8C0250BAFB6E1ABB5F1EF9F04", desc.extra_info_digest) + self.assertEquals("56403D838DE152421CD401B8E57DAD4483A3D56B", desc.extra_info_digest) self.assertEquals(["2"], desc.hidden_service_dir) self.assertEquals(set(), desc.family) - self.assertEquals(81920, desc.average_bandwidth) - self.assertEquals(102400, desc.burst_bandwidth) - self.assertEquals(84275, desc.observed_bandwidth) + self.assertEquals(102400, desc.average_bandwidth) + self.assertEquals(204800, desc.burst_bandwidth) + self.assertEquals(122818, desc.observed_bandwidth) self.assertEquals(stem.exit_policy.ExitPolicy("reject *:*"), desc.exit_policy) self.assertEquals([], desc.get_unrecognized_lines())
tor-commits@lists.torproject.org