From e640c12e8f1cbc263f766035b0113ad132285e2a Mon Sep 17 00:00:00 2001 From: gggeek Date: Sat, 21 Mar 2015 17:28:26 +0000 Subject: [PATCH] Fix (hopefully) the Travis tests using https for localhost --- .travis.yml | 3 +-- tests/3LocalhostTest.php | 2 +- tests/4LocalhostMultiTest.php | 2 ++ tests/ci/travis/apache_vhost | 3 ++- tests/ci/travis/apache_vhost_hhvm | 3 ++- tests/parse_args.php | 8 +++++++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b446cc6..66de8b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/tests/3LocalhostTest.php b/tests/3LocalhostTest.php index 562dbb5..a773548 100644 --- a/tests/3LocalhostTest.php +++ b/tests/3LocalhostTest.php @@ -23,7 +23,7 @@ class LocalhostTest extends PHPUnit_Framework_TestCase // (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; diff --git a/tests/4LocalhostMultiTest.php b/tests/4LocalhostMultiTest.php index 15387f0..2b2ba67 100644 --- a/tests/4LocalhostMultiTest.php +++ b/tests/4LocalhostMultiTest.php @@ -154,6 +154,7 @@ class LocalhostMultiTest extends LocalhostTest $this->client->method = 'https'; $this->client->path = $this->args['HTTPSURI']; $this->client->setSSLVerifyPeer( !$this->args['HTTPSIGNOREPEER'] ); + $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST'] ); $this->_runtests(); } @@ -175,6 +176,7 @@ class LocalhostMultiTest extends LocalhostTest $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(); } diff --git a/tests/ci/travis/apache_vhost b/tests/ci/travis/apache_vhost index 1244894..87841d6 100644 --- a/tests/ci/travis/apache_vhost +++ b/tests/ci/travis/apache_vhost @@ -50,6 +50,7 @@ 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 @@ -64,4 +65,4 @@ - \ No newline at end of file + diff --git a/tests/ci/travis/apache_vhost_hhvm b/tests/ci/travis/apache_vhost_hhvm index f0ad9f4..63e57da 100644 --- a/tests/ci/travis/apache_vhost_hhvm +++ b/tests/ci/travis/apache_vhost_hhvm @@ -56,6 +56,7 @@ 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 @@ -70,4 +71,4 @@ - \ No newline at end of file + diff --git a/tests/parse_args.php b/tests/parse_args.php index e9f2e2e..0d21191 100644 --- a/tests/parse_args.php +++ b/tests/parse_args.php @@ -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 @@ -26,6 +28,7 @@ class argParser 'HTTPSSERVER' => 'gggeek.ssl.altervista.org', 'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php', 'HTTPSIGNOREPEER' => false, + 'HTTPSVERIFYHOST' => 2, 'PROXYSERVER' => null, 'NOPROXY' => false, 'LOCALPATH' => __DIR__, @@ -69,6 +72,9 @@ class argParser if (isset($HTTPSIGNOREPEER)) { $args['HTTPSIGNOREPEER'] = (bool)$HTTPSIGNOREPEER; } + if (isset($HTTPSVERIFYHOST)) { + $args['HTTPSVERIFYHOST'] = (int)$HTTPSVERIFYHOST; + } if (isset($PROXY)) { $arr = explode(':', $PROXY); $args['PROXYSERVER'] = $arr[0]; -- 2.43.0