]> git.kaiwu.me - njs.git/commitdiff
Tests: detection when "xml" module is disabled.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 30 Nov 2023 02:43:37 +0000 (18:43 -0800)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 30 Nov 2023 02:43:37 +0000 (18:43 -0800)
test/harness/compatXml.js
test/xml/external_entity_ignored.t.js
test/xml/saml_verify.t.js

index 465d95ea205b3a14ff61362be600093888eb172e..cf3642c24f47c8fa72c61b0efca44ecc740539f3 100644 (file)
@@ -4,5 +4,14 @@ if (typeof require == 'function'
     && typeof njs == 'object'
     && typeof njs.version == 'string')
 {
-    xml = require('xml');
+    try {
+        xml = require('xml');
+
+    } catch (e) {
+        // ignore
+    }
+}
+
+function has_xml() {
+    return xml;
 }
index 26ee2403050df095b61f9d0ecded3456c31fc738..57c91e7fd2ee013ac954b4bee7f16451a8053c67 100644 (file)
@@ -11,8 +11,7 @@ let data = `<?xml version="1.0"?>
 <root>&c;</root>
 `;
 
-if (has_njs()) {
-    const xml = require('xml');
+if (has_njs() && has_xml()) {
     let doc = xml.parse(data);
     assert.sameValue(doc.$root.$text, "");
 }
index ec15c513325d29f833923911118b343cd658d067..be6bae82245e218d7869c1e5d73fb225ddb7fc13 100644 (file)
@@ -280,7 +280,7 @@ function p(args, default_opts) {
 
 let saml_verify_tsuite = {
     name: "SAML verify",
-    skip: () => (!has_njs() || !has_fs() || !has_webcrypto()),
+    skip: () => (!has_njs() || !has_fs() || !has_webcrypto() || !has_xml()),
     T: verify,
     prepare_args: p,
     opts: {