tests
authorgggeek <giunta.gaetano@gmail.com>
Mon, 23 Jan 2023 13:50:00 +0000 (13:50 +0000)
committergggeek <giunta.gaetano@gmail.com>
Mon, 23 Jan 2023 13:50:00 +0000 (13:50 +0000)
.github/workflows/ci.yaml
demo/client/python/test.py
demo/server/server.php
src/Helper/XMLParser.php
tests/03ParsingTest.php
tests/09HTTPTest.php
tests/10DemofilesTest.php
tests/ci/Dockerfile

index d49b889..d192087 100644 (file)
@@ -67,6 +67,7 @@ jobs:
                 # @todo add env setup scripts for windows
                 run: |
                     chmod 755 ./tests/ci/setup/*.sh
+                    sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/install_packages.sh
                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_perl.sh
                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_apache.sh
                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_privoxy.sh
index d7954a9..0f47854 100644 (file)
@@ -3,7 +3,7 @@
 
 import xmlrpc.client
 import base64
-#import sys
+import sys
 
 server = xmlrpc.client.ServerProxy("http://localhost/demo/server/server.php")
 
@@ -29,3 +29,6 @@ except xmlrpc.client.Fault as err:
     print("A fault occurred")
     print("Fault code: %d" % err.faultCode)
     print("Fault string: %s" % err.faultString)
+
+    # let the test suite know that here was a fault
+    sys.exit(err.faultCode)
index 4ca667b..fb3827b 100644 (file)
@@ -85,6 +85,12 @@ if (defined('TESTMODE')) {
             }
         }
     }
+    if (isset($_GET['FORCE_REDIRECT'])) {
+        header('HTTP/1.0 302 Found');
+        unset($_GET['FORCE_REDIRECT']);
+        header('Location: ' . $_SERVER['REQUEST_URI'] . (count($_GET) ? '?' . http_build_query($_GET) : ''));
+        die();
+    }
 }
 
 $s->service();
index c406f7c..6375ff2 100644 (file)
@@ -570,12 +570,14 @@ class XMLParser
                 // NB: this simple checks helps a lot sanitizing input, i.e. no security problems around here
                 // Note the non-strict type check: it will allow ' 1 '
                 /// @todo feature-creep: use a flexible regexp, the same as we do with int, double and datetime.
-                ///       Note that using a regexp would also make this test less sensitive to phpunit shenanigans
+                ///       Note that using a regexp would also make this test less sensitive to phpunit shenanigans, and
+                ///       to changes in the way php compares strings (since 8.0, leading and trailing newlines are
+                ///       accepted when deciding if a string numeric...)
                 if ($this->_xh['ac'] == '1' || strcasecmp($this->_xh['ac'], 'true') === 0) {
                     $this->_xh['value'] = true;
                 } else {
                     // log if receiving something strange, even though we set the value to false anyway
-                    /// @todo to be consistent with the other types, we should use a value outside the good-value domain, e.g. NULL
+                    /// @todo to be consistent with the other types, we should return a value outside the good-value domain, e.g. NULL
                     if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') !== 0) {
                         $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in BOOLEAN value: ' . $this->_xh['ac']);
                         if ($this->current_parsing_options['xmlrpc_reject_invalid_values'])
index 74e3890..2510ab6 100644 (file)
@@ -389,7 +389,7 @@ aGk=
 <member>
 <name>bool</name>
 <value><boolean>
-1
+yes
 </boolean></value>
 </member>
 <member>
index d6dd932..2af8dec 100644 (file)
@@ -98,6 +98,24 @@ class HTTPTest extends ServerTest
         }
     }
 
+    /**
+     * @dataProvider getSingleHttpTestMethods
+     * @param string $method
+     */
+    public function testRedirects($method)
+    {
+        if (!function_exists('curl_init'))
+        {
+            $this->markTestSkipped('CURL missing: cannot test redirects');
+            return;
+        }
+
+        $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_ALWAYS);
+        $this->client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => true, CURLOPT_POSTREDIR => 3));
+
+        $this->$method();
+    }
+
     public function testAcceptCharset()
     {
         if (version_compare(PHP_VERSION, '5.6.0', '<'))
index fe8b228..05868ba 100644 (file)
@@ -4,6 +4,8 @@ include_once __DIR__ . '/WebTestCase.php';
 
 /**
  * Tests for php files in the 'demo' directory.
+ *
+ * @todo add execution of perl and python demos via usage of 'exec'
  */
 class DemoFilesTest extends PhpXmlRpc_WebTestCase
 {
index e34f156..43c9df8 100644 (file)
@@ -13,6 +13,7 @@ RUN mkdir -p /usr/share/man/man1 && \
   cd /root/setup && \
   ./install_packages.sh && \
   ./create_user.sh && \
+  ./setup_perl.sh && \
   ./setup_apache.sh && \
   ./setup_privoxy.sh && \
   ./setup_php.sh "${PHP_VERSION}" && \