Skip to content

Commit

Permalink
Fix (hopefully) the Travis tests using https for localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Mar 21, 2015
1 parent 4cb5edd commit e640c12
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -27,12 +27,11 @@ before_script:

script:
# to have code coverage: --coverage-clover=coverage.clover
phpunit tests LOCALSERVER=localhost URI=/demo/server/server.php HTTPSSERVER=localhost HTTPSURI=/demo/server/server.php PROXY=localhost:8080 HTTPSIGNOREPEER=1
phpunit tests LOCALSERVER=localhost URI=/demo/server/server.php HTTPSSERVER=localhost HTTPSURI=/demo/server/server.php PROXY=localhost:8080 HTTPSVERIFYHOST=0

after_failure:
- cat apache_error.log
- cat apache_access.log
- cat /etc/ssl/certs/ssl-cert-snakeoil.pem

after_script:
# # upload code-coverage to Scrutinizer
Expand Down
2 changes: 1 addition & 1 deletion tests/3LocalhostTest.php
Expand Up @@ -23,7 +23,7 @@ public static function fail($message = '')
// (but only if not called from subclass objects / multitests)
if (function_exists('debug_backtrace') && strtolower(get_called_class()) == 'localhosttests') {
global $failed_tests;
$trace = debug_backtrace();
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
for ($i = 0; $i < count($trace); $i++) {
if (strpos($trace[$i]['function'], 'test') === 0) {
self::$failed_tests[$trace[$i]['function']] = true;
Expand Down
2 changes: 2 additions & 0 deletions tests/4LocalhostMultiTest.php
Expand Up @@ -154,6 +154,7 @@ function testHttps()
$this->client->method = 'https';
$this->client->path = $this->args['HTTPSURI'];
$this->client->setSSLVerifyPeer( !$this->args['HTTPSIGNOREPEER'] );
$this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST'] );
$this->_runtests();
}

Expand All @@ -175,6 +176,7 @@ function testHttpsProxy()
$this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
$this->client->path = $this->args['HTTPSURI'];
$this->client->setSSLVerifyPeer( !$this->args['HTTPSIGNOREPEER'] );
$this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST'] );
$this->_runtests();
}

Expand Down
3 changes: 2 additions & 1 deletion tests/ci/travis/apache_vhost
Expand Up @@ -50,6 +50,7 @@
</IfModule>

SSLEngine on
# This cert is bundled by default in Ubuntu
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Expand All @@ -64,4 +65,4 @@

</VirtualHost>

</IfModule>
</IfModule>
3 changes: 2 additions & 1 deletion tests/ci/travis/apache_vhost_hhvm
Expand Up @@ -56,6 +56,7 @@
</IfModule>

SSLEngine on
# This cert is bundled by default in Ubuntu
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Expand All @@ -70,4 +71,4 @@

</VirtualHost>

</IfModule>
</IfModule>
8 changes: 7 additions & 1 deletion tests/parse_args.php
Expand Up @@ -10,8 +10,10 @@
* @param string HTTPSSURI
* @param string PROXY
* @param string NOPROXY
* @param bool HTTPSIGNOREPEER
* @param int HTTPSVERIFYHOST
*
* @copyright (C) 2007-20014 G. Giunta
* @copyright (C) 2007-2015 G. Giunta
* @license code licensed under the BSD License: see file license.txt
**/
class argParser
Expand All @@ -26,6 +28,7 @@ public static function getArgs()
'HTTPSSERVER' => 'gggeek.ssl.altervista.org',
'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php',
'HTTPSIGNOREPEER' => false,
'HTTPSVERIFYHOST' => 2,
'PROXYSERVER' => null,
'NOPROXY' => false,
'LOCALPATH' => __DIR__,
Expand Down Expand Up @@ -69,6 +72,9 @@ public static function getArgs()
if (isset($HTTPSIGNOREPEER)) {
$args['HTTPSIGNOREPEER'] = (bool)$HTTPSIGNOREPEER;
}
if (isset($HTTPSVERIFYHOST)) {
$args['HTTPSVERIFYHOST'] = (int)$HTTPSVERIFYHOST;
}
if (isset($PROXY)) {
$arr = explode(':', $PROXY);
$args['PROXYSERVER'] = $arr[0];
Expand Down

0 comments on commit e640c12

Please sign in to comment.