1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
include_once __DIR__ . '/../lib/xmlrpc.inc'; |
4
|
|
|
|
5
|
|
|
include_once __DIR__ . '/parse_args.php'; |
6
|
|
|
|
7
|
|
|
include_once __DIR__ . '/PolyfillTestCase.php'; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Tests involving requests sent to non-existing servers |
11
|
|
|
*/ |
12
|
|
|
class InvalidHostTest extends PhpXmlRpc_PolyfillTestCase |
13
|
|
|
{ |
14
|
|
|
/** @var xmlrpc_client $client */ |
15
|
|
|
public $client = null; |
16
|
|
|
public $args = array(); |
17
|
|
|
|
18
|
|
|
public function set_up() |
19
|
|
|
{ |
20
|
|
|
$this->args = argParser::getArgs(); |
21
|
|
|
|
22
|
|
|
$this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['LOCALSERVER'], 80); |
23
|
|
|
$this->client->setDebug($this->args['DEBUG']); |
24
|
|
|
|
25
|
|
|
if ($this->args['DEBUG'] == 1) |
26
|
|
|
ob_start(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
protected function tear_down() |
30
|
|
|
{ |
31
|
|
|
if ($this->args['DEBUG'] != 1) |
32
|
|
|
return; |
33
|
|
|
$out = ob_get_clean(); |
34
|
|
|
$status = $this->getStatus(); |
35
|
|
|
if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR |
|
|
|
|
36
|
|
|
|| $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { |
37
|
|
|
echo $out; |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function test404() |
42
|
|
|
{ |
43
|
|
|
$m = new xmlrpcmsg('examples.echo', array( |
44
|
|
|
new xmlrpcval('hello', 'string'), |
45
|
|
|
)); |
46
|
|
|
$r = $this->client->send($m, 5); |
47
|
|
|
$this->assertEquals(5, $r->faultCode()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testSrvNotFound() |
51
|
|
|
{ |
52
|
|
|
$m = new xmlrpcmsg('examples.echo', array( |
53
|
|
|
new xmlrpcval('hello', 'string'), |
54
|
|
|
)); |
55
|
|
|
$this->client->server .= 'XXX'; |
56
|
|
|
$r = $this->client->send($m, 5); |
57
|
|
|
// make sure there's no freaking catchall DNS in effect |
58
|
|
|
$dnsinfo = dns_get_record($this->client->server); |
59
|
|
|
if ($dnsinfo) { |
|
|
|
|
60
|
|
|
$this->markTestSkipped('Seems like there is a catchall DNS in effect: host ' . $this->client->server . ' found'); |
61
|
|
|
} else { |
62
|
|
|
$this->assertEquals(5, $r->faultCode()); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testCurlKAErr() |
67
|
|
|
{ |
68
|
|
|
if (!function_exists('curl_init')) { |
69
|
|
|
$this->markTestSkipped('CURL missing: cannot test curl keepalive errors'); |
70
|
|
|
|
71
|
|
|
return; |
72
|
|
|
} |
73
|
|
|
$m = new xmlrpcmsg('examples.stringecho', array( |
74
|
|
|
new xmlrpcval('hello', 'string'), |
75
|
|
|
)); |
76
|
|
|
// test 2 calls w. keepalive: 1st time connection ko, second time ok |
77
|
|
|
$this->client->server .= 'XXX'; |
78
|
|
|
$this->client->keepalive = true; |
79
|
|
|
$r = $this->client->send($m, 5, 'http11'); |
80
|
|
|
// in case we have a "universal dns resolver" getting in the way, we might get a 302 instead of a 404 |
81
|
|
|
$this->assertTrue($r->faultCode() === 8 || $r->faultCode() == 5); |
82
|
|
|
|
83
|
|
|
// now test a successful connection |
84
|
|
|
$server = explode(':', $this->args['LOCALSERVER']); |
85
|
|
|
if (count($server) > 1) { |
86
|
|
|
$this->client->port = $server[1]; |
87
|
|
|
} |
88
|
|
|
$this->client->server = $server[0]; |
89
|
|
|
$this->client->path = $this->args['URI']; |
90
|
|
|
|
91
|
|
|
$r = $this->client->send($m, 5, 'http11'); |
92
|
|
|
$this->assertEquals(0, $r->faultCode()); |
93
|
|
|
$ro = $r->value(); |
94
|
|
|
is_object($ro) && $this->assertEquals('hello', $ro->scalarVal()); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths