Fix (hopefully) the Travis tests using https for localhost
authorgggeek <giunta.gaetano@gmail.com>
Sat, 21 Mar 2015 17:28:26 +0000 (17:28 +0000)
committergggeek <giunta.gaetano@gmail.com>
Sat, 21 Mar 2015 17:28:26 +0000 (17:28 +0000)
.travis.yml
tests/3LocalhostTest.php
tests/4LocalhostMultiTest.php
tests/ci/travis/apache_vhost
tests/ci/travis/apache_vhost_hhvm
tests/parse_args.php

index b446cc6..66de8b0 100644 (file)
@@ -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
index 562dbb5..a773548 100644 (file)
@@ -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;
index 15387f0..2b2ba67 100644 (file)
@@ -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();
     }
 
index 1244894..87841d6 100644 (file)
@@ -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
 
@@ -64,4 +65,4 @@
 
 </VirtualHost>
 
-</IfModule>
\ No newline at end of file
+</IfModule>
index f0ad9f4..63e57da 100644 (file)
@@ -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
 
@@ -70,4 +71,4 @@
 
 </VirtualHost>
 
-</IfModule>
\ No newline at end of file
+</IfModule>
index e9f2e2e..0d21191 100644 (file)
  * @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];