xref: /PHP-8.1/ext/soap/tests/bug69137.phpt (revision 7f2f0c00)
1--TEST--
2SOAP Bug #69137 - Peer verification fails when using a proxy with SoapClient
3--EXTENSIONS--
4soap
5--SKIPIF--
6<?php
7if (getenv("SKIP_ONLINE_TESTS")) { die("skip test requiring internet connection"); }
8if (!getenv('http_proxy')) { die("skip test unless an HTTP/HTTPS proxy server is specified in http_proxy environment variable"); }
9?>
10--INI--
11soap.wsdl_cache_enabled=1
12--FILE--
13<?php
14
15class IpLookup
16{
17    public $licenseKey;
18    public $ipAddress;
19}
20
21list ($proxyHost, $proxyPort) = explode(':', str_replace('http://', '', $_ENV['http_proxy']));
22
23// Prime the WSDL cache because that request sets peer_name on the HTTP context
24// and masks the SOAP bug.
25$testServiceWsdl = 'https://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl';
26$client = new SoapClient($testServiceWsdl);
27unset($client);
28
29$parameters = [
30    'proxy_host' => $proxyHost,
31    'proxy_port' => $proxyPort,
32    'trace' => 1,
33];
34$client = new SoapClient($testServiceWsdl, $parameters);
35
36$lookup = new IpLookup();
37$lookup->licenseKey = 0;
38$lookup->ipAddress = '72.52.91.14';
39
40$result = $client->ResolveIP($lookup);
41
42if ($result && is_object($result) && $result->ResolveIPResult && is_object($result->ResolveIPResult)) {
43    print "successful lookup";
44}
45?>
46--EXPECT--
47successful lookup
48