|
3 | 3 | use lang\IllegalArgumentException; |
4 | 4 | use peer\URL; |
5 | 5 | use peer\http\HttpProxy; |
6 | | -use test\Assert; |
7 | | -use test\{Expect, Test, Values}; |
8 | | - |
9 | | -/** |
10 | | - * TestCase |
11 | | - * |
12 | | - * @see xp://peer.http.HttpProxy |
13 | | - */ |
| 6 | +use test\{Assert, Expect, Test, Values}; |
| 7 | + |
14 | 8 | class HttpProxyTest { |
15 | 9 |
|
16 | 10 | #[Test] |
@@ -102,34 +96,22 @@ public function exludes_also_work_localhost_special_case() { |
102 | 96 | Assert::true($proxy->excludes()->contains(new URL('http://127.0.0.1'))); |
103 | 97 | } |
104 | 98 |
|
105 | | - /** @return string */ |
106 | | - protected function exampleIp() { |
107 | | - static $resolved= null; |
108 | | - |
109 | | - if (!$resolved) { |
110 | | - if (!($resolved= dns_get_record('example.com', DNS_A))) { |
111 | | - $this->skip('Cannot resolve example.com (DNS_A)'); |
112 | | - } |
113 | | - } |
114 | | - return $resolved[0]['ip']; |
115 | | - } |
116 | | - |
117 | 99 | #[Test] |
118 | 100 | public function host_excludes_work_with_ips_in_urls() { |
119 | | - $proxy= new HttpProxy('proxy.example.com', 3128, ['example.com']); |
120 | | - Assert::true($proxy->excludes()->contains(new URL('http://'.$this->exampleIp()))); |
| 101 | + $proxy= new HttpProxy('proxy.example.com', 3128, ['localhost']); |
| 102 | + Assert::true($proxy->excludes()->contains(new URL('http://127.0.0.1'))); |
121 | 103 | } |
122 | 104 |
|
123 | 105 | #[Test] |
124 | 106 | public function ips_in_both_excludes_and_urls_work() { |
125 | | - $proxy= new HttpProxy('proxy.example.com', 3128, [$this->exampleIp()]); |
126 | | - Assert::true($proxy->excludes()->contains(new URL('http://'.$this->exampleIp()))); |
| 107 | + $proxy= new HttpProxy('proxy.example.com', 3128, ['127.0.0.1']); |
| 108 | + Assert::true($proxy->excludes()->contains(new URL('http://127.0.0.1'))); |
127 | 109 | } |
128 | 110 |
|
129 | 111 | #[Test] |
130 | 112 | public function ip_excludes_work_with_hosts_in_urls() { |
131 | | - $proxy= new HttpProxy('proxy.example.com', 3128, [$this->exampleIp()]); |
132 | | - Assert::true($proxy->excludes()->contains(new URL('http://example.com'))); |
| 113 | + $proxy= new HttpProxy('proxy.example.com', 3128, ['127.0.0.1']); |
| 114 | + Assert::true($proxy->excludes()->contains(new URL('http://localhost'))); |
133 | 115 | } |
134 | 116 |
|
135 | 117 | #[Test, Values([['https://192.168.2.6/', true], ['https://192.168.3.6/', false]])] |
|
0 commit comments