tests
[plcapi.git] / tests / 4LocalhostMultiTest.php
index 61e9494..32fef36 100644 (file)
@@ -21,10 +21,10 @@ class LocalhostMultiTest extends LocalhostTest
      */
     public function getSingleHttpTestMethods()
     {
-        $unsafeMethods = array('testHttps', 'testCatchExceptions', 'testUtf8Method', 'testServerComments', 'testExoticCharsetsRequests',
-            'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3',
-            // @todo the following are currently not compatible w Digest Auth (most likely because of client copy) and should be fixed
-            'testcatchWarnings', 'testWrappedMethodAsSource', 'testTransferOfObjectViaWrapping');
+        $unsafeMethods = array(
+            'testCatchExceptions', 'testUtf8Method', 'testServerComments',
+            'testExoticCharsetsRequests', 'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3',
+        );
 
         $methods = array();
         foreach(get_class_methods('LocalhostTest') as $method)
@@ -101,7 +101,7 @@ class LocalhostMultiTest extends LocalhostTest
      */
     public function testProxy($method)
     {
-        if (!$this->args['PROXYSERVER'])
+        if ($this->args['PROXYSERVER'] == '')
         {
             $this->markTestSkipped('PROXY definition missing: cannot test proxy');
             return;
@@ -131,6 +131,26 @@ class LocalhostMultiTest extends LocalhostTest
         $this->$method();
     }
 
+    /**
+     * @dataProvider getSingleHttpTestMethods
+     * @param string $method
+     */
+    public function testHttp10Curl($method)
+    {
+        if(!function_exists('curl_init'))
+        {
+            $this->markTestSkipped('CURL missing: cannot test http 1.1');
+            return;
+        }
+
+        $this->method = 'http10'; // not an error the double assignment!
+        $this->client->method = 'http10';
+        $this->client->keepalive = false;
+        $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_ALWAYS);
+
+        $this->$method();
+    }
+
     /**
      * @dataProvider getSingleHttpTestMethods
      * @param string $method
@@ -207,6 +227,34 @@ class LocalhostMultiTest extends LocalhostTest
             $this->markTestSkipped('CURL missing: cannot test https functionality');
             return;
         }
+        else if ($this->args['HTTPSSERVER'] == '')
+        {
+            $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
+            return;
+        }
+
+        $this->client->server = $this->args['HTTPSSERVER'];
+        $this->method = 'https';
+        $this->client->method = 'https';
+        $this->client->path = $this->args['HTTPSURI'];
+        $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
+        $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
+        $this->client->setSSLVersion($this->args['SSLVERSION']);
+
+        $this->$method();
+    }
+
+    /**
+     * @dataProvider getSingleHttpTestMethods
+     * @param string $method
+     */
+    public function testHttpsSocket($method)
+    {
+        if ($this->args['HTTPSSERVER'] == '')
+        {
+            $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
+            return;
+        }
 
         $this->client->server = $this->args['HTTPSSERVER'];
         $this->method = 'https';
@@ -215,6 +263,7 @@ class LocalhostMultiTest extends LocalhostTest
         $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
         $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
         $this->client->setSSLVersion($this->args['SSLVERSION']);
+        $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_NEVER);
 
         $this->$method();
     }
@@ -227,14 +276,20 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('curl_init'))
         {
-            $this->markTestSkipped('CURL missing: cannot test https functionality');
+            $this->markTestSkipped('CURL missing: cannot test https w. proxy');
             return;
         }
         else if ($this->args['PROXYSERVER'] == '')
         {
-            $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1');
+            $this->markTestSkipped('PROXY definition missing: cannot test proxy w. https');
+            return;
+        }
+        else if ($this->args['HTTPSSERVER'] == '')
+        {
+            $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https w. proxy');
             return;
         }
+
         $this->client->server = $this->args['HTTPSSERVER'];
         $this->method = 'https';
         $this->client->method = 'https';
@@ -322,4 +377,23 @@ class LocalhostMultiTest extends LocalhostTest
 
         $this->$method();
     }
+
+    function testBasicAuth()
+    {
+        $this->client->setCredentials('test', 'test');
+        $this->client->path = $this->args['URI'].'?FORCE_AUTH=Basic';
+        $this->_runtests();
+    }
+
+    function testDigestAuth()
+    {
+        if(!function_exists('curl_init'))
+        {
+            $this->markTestSkipped('CURL missing: cannot test digest auth functionality');
+            return;
+        }
+        $this->client->setCredentials('test', 'test', CURLAUTH_DIGEST);
+        $this->client->path = $this->args['URI'].'?FORCE_AUTH=Digest';
+        $this->_runtests();
+    }
 }