3 include_once __DIR__ . '/../lib/xmlrpc.inc';
4 include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc';
6 include_once __DIR__ . '/parse_args.php';
8 include_once __DIR__ . '/5ServerTest.php';
11 * Tests which stress http features of the library.
12 * Each of these tests iterates over (almost) all the 'localhost' tests
14 class HTTPTest extends ServerTest
17 * Returns all test methods from the base class, except the ones which failed already
19 * @todo (re)introduce skipping of tests which failed when executed individually even if test runs happen as separate processes
20 * @todo reintroduce skipping of tests within the loop
22 public function getSingleHttpTestMethods()
24 $unsafeMethods = array(
25 'testCatchExceptions', 'testUtf8Method', 'testServerComments',
26 'testExoticCharsetsRequests', 'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3',
27 'testWrapInexistentUrl',
31 foreach(get_class_methods('ServerTest') as $method)
33 if (strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))
35 if (!isset(self::$failed_tests[$method])) {
36 $methods[$method] = array($method);
45 * @dataProvider getSingleHttpTestMethods
46 * @param string $method
48 public function testDeflate($method)
50 if (!function_exists('gzdeflate'))
52 $this->markTestSkipped('Zlib missing: cannot test deflate functionality');
56 $this->client->accepted_compression = array('deflate');
57 $this->client->request_compression = 'deflate';
63 * @dataProvider getSingleHttpTestMethods
64 * @param string $method
66 public function testGzip($method)
68 if (!function_exists('gzdeflate'))
70 $this->markTestSkipped('Zlib missing: cannot test gzip functionality');
74 $this->client->accepted_compression = array('gzip');
75 $this->client->request_compression = 'gzip';
80 public function testKeepAlives()
82 if (!function_exists('curl_init'))
84 $this->markTestSkipped('CURL missing: cannot test http 1.1');
88 $this->method = 'http11';
89 $this->client->method = 'http11';
90 $this->client->keepalive = true;
92 // to successfully test keepalive, we have to reuse the same client for all tests, we can not recreate one on setup/teardown...
93 foreach ($this->getSingleHttpTestMethods() as $methods) {
94 $method = $methods[0];
100 * @dataProvider getSingleHttpTestMethods
101 * @param string $method
103 public function testProxy($method)
105 if ($this->args['PROXYSERVER'] == '')
107 $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy');
111 $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
117 * @dataProvider getSingleHttpTestMethods
118 * @param string $method
120 public function testHttp11($method)
122 if (!function_exists('curl_init'))
124 $this->markTestSkipped('CURL missing: cannot test http 1.1');
128 $this->method = 'http11'; // not an error the double assignment!
129 $this->client->method = 'http11';
130 $this->client->keepalive = false;
136 * @dataProvider getSingleHttpTestMethods
137 * @param string $method
139 public function testHttp10Curl($method)
141 if (!function_exists('curl_init'))
143 $this->markTestSkipped('CURL missing: cannot test http 1.1');
147 $this->method = 'http10'; // not an error the double assignment!
148 $this->client->method = 'http10';
149 $this->client->keepalive = false;
150 $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_ALWAYS);
156 * @dataProvider getSingleHttpTestMethods
157 * @param string $method
159 public function testHttp11Gzip($method)
161 if (!function_exists('curl_init'))
163 $this->markTestSkipped('CURL missing: cannot test http 1.1');
166 $this->method = 'http11'; // not an error the double assignment!
167 $this->client->method = 'http11';
168 $this->client->keepalive = false;
169 $this->client->accepted_compression = array('gzip');
170 $this->client->request_compression = 'gzip';
176 * @dataProvider getSingleHttpTestMethods
177 * @param string $method
179 public function testHttp11Deflate($method)
181 if (!function_exists('curl_init'))
183 $this->markTestSkipped('CURL missing: cannot test http 1.1');
186 $this->method = 'http11'; // not an error the double assignment!
187 $this->client->method = 'http11';
188 $this->client->keepalive = false;
189 $this->client->accepted_compression = array('deflate');
190 $this->client->request_compression = 'deflate';
196 * @dataProvider getSingleHttpTestMethods
197 * @param string $method
199 public function testHttp11Proxy($method)
201 if (!function_exists('curl_init'))
203 $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy');
206 else if ($this->args['PROXYSERVER'] == '')
208 $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. http 1.1');
212 $this->method = 'http11'; // not an error the double assignment!
213 $this->client->method = 'http11';
214 $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
215 $this->client->keepalive = false;
221 * @dataProvider getSingleHttpTestMethods
222 * @param string $method
224 public function testHttps($method)
226 if (!function_exists('curl_init'))
228 $this->markTestSkipped('CURL missing: cannot test https functionality');
231 else if ($this->args['HTTPSSERVER'] == '')
233 $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
237 $this->client->server = $this->args['HTTPSSERVER'];
238 $this->method = 'https';
239 $this->client->method = 'https';
240 $this->client->path = $this->args['HTTPSURI'];
241 $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
242 $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
243 $this->client->setSSLVersion($this->args['SSLVERSION']);
249 * @dataProvider getSingleHttpTestMethods
250 * @param string $method
252 public function testHttpsSocket($method)
254 if ($this->args['HTTPSSERVER'] == '')
256 $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
260 $this->client->server = $this->args['HTTPSSERVER'];
261 $this->method = 'https';
262 $this->client->method = 'https';
263 $this->client->path = $this->args['HTTPSURI'];
264 $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
265 $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
266 $this->client->setSSLVersion($this->args['SSLVERSION']);
267 $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_NEVER);
273 * @dataProvider getSingleHttpTestMethods
274 * @param string $method
276 public function testHttpsProxy($method)
278 if (!function_exists('curl_init'))
280 $this->markTestSkipped('CURL missing: cannot test https w. proxy');
283 else if ($this->args['PROXYSERVER'] == '')
285 $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. https');
288 else if ($this->args['HTTPSSERVER'] == '')
290 $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https w. proxy');
294 $this->client->server = $this->args['HTTPSSERVER'];
295 $this->method = 'https';
296 $this->client->method = 'https';
297 $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
298 $this->client->path = $this->args['HTTPSURI'];
299 $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
300 $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
301 $this->client->setSSLVersion($this->args['SSLVERSION']);
307 * @dataProvider getSingleHttpTestMethods
308 * @param string $method
310 public function testUTF8Responses($method)
312 $this->addQueryParams(array('RESPONSE_ENCODING' => 'UTF-8'));
318 * @dataProvider getSingleHttpTestMethods
319 * @param string $method
321 public function testUTF8Requests($method)
323 $this->client->request_charset_encoding = 'UTF-8';
329 * @dataProvider getSingleHttpTestMethods
330 * @param string $method
332 public function testISOResponses($method)
334 $this->addQueryParams(array('RESPONSE_ENCODING' => 'ISO-8859-1'));
340 * @dataProvider getSingleHttpTestMethods
341 * @param string $method
343 public function testISORequests($method)
345 $this->client->request_charset_encoding = 'ISO-8859-1';
351 * @dataProvider getSingleHttpTestMethods
352 * @param string $method
354 public function testBasicAuth($method)
356 $this->client->setCredentials('test', 'test');
357 $this->addQueryParams(array('FORCE_AUTH' => 'Basic'));
363 * @dataProvider getSingleHttpTestMethods
364 * @param string $method
366 public function testDigestAuth($method)
368 if (!function_exists('curl_init'))
370 $this->markTestSkipped('CURL missing: cannot test digest auth functionality');
374 $this->client->setCredentials('test', 'test', CURLAUTH_DIGEST);
375 $this->addQueryParams(array('FORCE_AUTH' => 'Digest'));
376 $this->method = 'http11';
377 $this->client->method = 'http11';