| ... |
... |
@@ -47,12 +47,30 @@ class TestCircuitIsolation(MarionetteTestCase, TorBrowserMixin): |
|
47
|
47
|
).strip()
|
|
48
|
48
|
)
|
|
49
|
49
|
|
|
|
50
|
+ def extract_from_header(self, url):
|
|
|
51
|
+ # Navigate to the page to bypass CORS.
|
|
|
52
|
+ self.marionette.navigate(url)
|
|
|
53
|
+ # The IP checker service provided by TPA, return the caller IP address
|
|
|
54
|
+ # on the head of the response, inside the `X-Your-IP-Address` header.
|
|
|
55
|
+ return ip_address(
|
|
|
56
|
+ self.marionette.execute_async_script(
|
|
|
57
|
+ """
|
|
|
58
|
+ const [url, resolve] = arguments;
|
|
|
59
|
+
|
|
|
60
|
+ fetch(url).then(response =>
|
|
|
61
|
+ resolve(response.headers.get("X-Your-IP-Address"))
|
|
|
62
|
+ );
|
|
|
63
|
+ """,
|
|
|
64
|
+ script_args=[url],
|
|
|
65
|
+ )
|
|
|
66
|
+ )
|
|
|
67
|
+
|
|
50
|
68
|
def test_circuit_isolation(self):
|
|
51
|
69
|
self.bootstrap()
|
|
52
|
70
|
ips = [
|
|
53
|
71
|
self.extract_from_check_tpo(),
|
|
54
|
72
|
self.extract_generic("https://am.i.mullvad.net/ip"),
|
|
55
|
|
- self.extract_generic("https://v4.ident.me"),
|
|
|
73
|
+ self.extract_from_header("https://test.torproject.org"),
|
|
56
|
74
|
]
|
|
57
|
75
|
self.logger.info(f"Found the following IP addresses: {ips}")
|
|
58
|
76
|
unique_ips = set(ips)
|
| ... |
... |
@@ -63,11 +81,16 @@ class TestCircuitIsolation(MarionetteTestCase, TorBrowserMixin): |
|
63
|
81
|
"Some of the IP addresses we got are not unique.",
|
|
64
|
82
|
)
|
|
65
|
83
|
|
|
66
|
|
- # TODO: Renable the duplicate check once
|
|
67
|
|
- # https://gitlab.torproject.org/tpo/tpa/team/-/issues/42547 is resolved.
|
|
68
|
|
- # duplicate = self.extract_generic("https://test2.ifconfig.me/ip")
|
|
69
|
|
- # self.assertEqual(
|
|
70
|
|
- # ips[-1],
|
|
71
|
|
- # duplicate,
|
|
72
|
|
- # "Two IPs that were expected to be equal are different, we might be over isolating!",
|
|
73
|
|
- # ) |
|
|
84
|
+ duplicates = set(
|
|
|
85
|
+ self.extract_from_header("https://test-01.torproject.org"),
|
|
|
86
|
+ self.extract_from_header("https://test-02.torproject.org"),
|
|
|
87
|
+ self.extract_from_header("https://test.torproject.org"),
|
|
|
88
|
+ )
|
|
|
89
|
+ self.logger.info(
|
|
|
90
|
+ f"Found the following IP addresses, when checking for duplicates: {duplicates}"
|
|
|
91
|
+ )
|
|
|
92
|
+ self.assertEqual(
|
|
|
93
|
+ len(duplicates),
|
|
|
94
|
+ 1,
|
|
|
95
|
+ "IPs that were expected to be equal are different, we might be over isolating!",
|
|
|
96
|
+ ) |