diff options
-rw-r--r-- | lib/rhbzpage.js | 6 | ||||
-rw-r--r-- | lib/xmlrpc.js | 2 | ||||
-rw-r--r-- | tests/test-xmlrpc.js | 32 |
3 files changed, 37 insertions, 3 deletions
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index b007982..f318528 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -4,6 +4,8 @@ // http://www.opensource.org/licenses/mit-license.php "use strict"; var utilMod = require("util"); +var xrpc = require("xmlrpc"); +var xhr = require("xhr"); // var TriagedDistro = 13; // var NumberOfFrames = 7; // var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; @@ -641,7 +643,7 @@ RHBugzillaPage.prototype.fillInChipMagic = function () { attURL = "https://bugzilla.redhat.com/attachment.cgi?id="+XorgLogAttID; that = this; - let req = new XMLHttpRequest(); + let req = new xhrMod.XMLHttpRequest(); req.open("GET",attURL,true); req.onreadystatechange = function (aEvt) { if (req.readyState == 4) { @@ -888,7 +890,7 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { email = false; } - let msg = new XMLRPCMessage("bugzilla.updateAttachMimeType"); + let msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType"); msg.addParameter( { 'attach_id' : id, 'mime_type' : type, diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js index 2b264e7..69bb77e 100644 --- a/lib/xmlrpc.js +++ b/lib/xmlrpc.js @@ -15,7 +15,7 @@ * */ -exports.XMLRPCMessage = function XMLRPCMessage(methodname) { +var XMLRPCMessage = exports.XMLRPCMessage = function XMLRPCMessage(methodname) { this.method = methodname || "system.listMethods"; this.params = []; return this; diff --git a/tests/test-xmlrpc.js b/tests/test-xmlrpc.js new file mode 100644 index 0000000..afb78c5 --- /dev/null +++ b/tests/test-xmlrpc.js @@ -0,0 +1,32 @@ +/*global exports: false, require: false */ +/*jslint plusplus: false */ +"use strict"; +var xrpc = require("xmlrpc"); +var xmlOut = "<?xml version=\"1.0\"?>\n" + + "<methodCall>\n<methodName>bugzilla.updateAttachMimeType</methodName>\n" + + "<params>\n<param>\n<value><struct>\n<member>\n<name>attach_id</name>\n" + + "<value><string>myId</string></value>\n</member>\n<member>\n" + + "<name>mime_type</name>\n<value><string>text/plain</string></value>\n</member>\n" + + "<member>\n<name>nomail</name>\n<value><string>billg@microsoft.com</string>" + + "</value>\n</member>\n</struct>\n</value>\n</param>\n<param>\n" + + "<value><string>me@example.com</string></value>\n</param>\n" + + "<param>\n<value><string>secret</string></value>\n</param>\n" + + "<param>\n<value><double>3.14</double></value>\n</param>\n" + + "<param>\n<value><boolean>1</boolean></value>\n</param>\n" + + "</params>\n</methodCall>"; + +// testing xrpc.XMLRPCMessage +exports.ensureGenerateXMLRPC = function (test) { + var msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType"); + msg.addParameter({ + 'attach_id' : "myId", + 'mime_type' : "text/plain", + 'nomail' : "billg@microsoft.com" + }); + msg.addParameter("me@example.com"); + msg.addParameter("secret"); + msg.addParameter(3.14); + msg.addParameter(true); + test.assertEqual(msg.xml(), xmlOut, + "generate XML-RPC message"); +}; |