Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('responds with a 200 and an updated payload when requesting with an XML', function testUpdatingABookingWithXML(done){
var xmlPayload = js2xmlparser.parse('booking', payload2)
request(server)
.post('/booking')
.send(payload)
.then(function(){
return request(server)
.post('/auth')
.send({'username': 'admin', 'password': 'password123'})
})
.then(function(res){
request(server)
.put('/booking/1')
.set('Cookie', 'token=' + res.body.token)
.set('Content-type', 'text/xml')
.set('Accept', 'application/json')
.send(xmlPayload)
}
obj_full_props.qHyperCubeDef.qMeasures[index].parsedData = parsed_msr;
});
}
var data = {
obj_full_props,
qsLoadTimeObject: sheet_object_loading_time
};
var options = {
useCDATA: true
};
var xml_sheet_object = js2xmlparser.parse("sheetObject", data, options);
//Storing XML with the object's data
fs.writeFile("AppStructures/"+config_app.appname+"_SheetObject_"+first_sheet+"_"+first_object+"_"+conn_data.user_directory + "_" + conn_data.user_name+".xml", xml_sheet_object, function(err) {
if (err) {
if(logging.log_mode || logging.log_mode_full) log.warning("Unable to store AppStructures/"+config_app.appname+"_SheetObject_"+first_sheet+"_"+first_object+"_"+conn_data.user_directory + "_" + conn_data.user_name+".xml: " + err, logging.log_file);
throw err;
}else{
if(logging.log_mode || logging.log_mode_full) log.info("Stored AppStructures/"+config_app.appname+"_SheetObject_"+first_sheet+"_"+first_object+"_"+conn_data.user_directory + "_" + conn_data.user_name+".xml", logging.log_file);
if(!logging.silent_mode) console.log(' │ '+config_app.appname+'_SheetObject_'+first_sheet+'_'+first_object+'_'+conn_data.user_directory + '_' + conn_data.user_name+'.xml file saved');
if(!logging.silent_mode) console.log(' │ ');
if(!logging.silent_mode) console.log(" │ Updating the remaining objects list for this sheet");
if(!logging.silent_mode) console.log(" │ This is the objects list length: "+objects_list.length);}
//Checking if all the objects were processed
if(objects_list.length>0){
if(logging.log_mode || logging.log_mode_full) log.info(objects_list.length + " remaining objects. Updating remaining list.", logging.log_file);
var tradingRequest = async function () {
var devId = utils.DEV_ID;
var ruName = utils.RU_NAME;
eBay.setDevName(devId);
const obj = {
'@': {
'xmlns': 'urn:ebay:apis:eBLBaseComponents'
},
'ErrorLanguage': 'en_US',
'WarningLevel': 'High',
'RuName': ruName
};
var content = js2xmlparser.parse('GetSessionIDRequest', obj, {declaration: {encoding: 'UTF-8'}});
try {
var response = await eBay.trading.getSessionID({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};
loading_time=received_time-start_time;
if(logging.log_mode || logging.log_mode_full) log.info("Received connections list", logging.log_file);
if(logging.log_mode_full) log.debug("Preparing data for DocumentsConnections_* XML storage", logging.log_file);
//Setting up data and options for XML file storage
var data = {
document_connections,
qsLoadingTime: loading_time
};
var options = {
useCDATA: true
}
var xml_doc_connections = js2xmlparser.parse("documentsConnections", data, options);
//Storing XML with Connections List
fs.writeFile('AppStructures/DocumentsConnections_'+conn_data.user_directory + '_' + conn_data.user_name+'.xml', xml_doc_connections, function(err) {
if (err){
if(logging.log_mode || logging.log_mode_full) log.warning("Unable to store AppStructures/DocumentsConnections_" + conn_data.user_directory + "_" + conn_data.user_name + ".xml: " + err, logging.log_file);
throw err;
}
else{
if(logging.log_mode || logging.log_mode_full) log.info("Stored AppStructures/DocumentsConnections_" + conn_data.user_directory + "_" + conn_data.user_name + ".xml", logging.log_file);
if(!logging.silent_mode) console.log('DocumentsConnections.xml file saved');
resolve("Checkpoint: Connections List is loaded");
}
});
});
})
}
}
}
}
}
}
}
}
}
noti_message['m2m:rqp']['@'] = {
"xmlns:m2m": "http://www.onem2m.org/xml/protocols",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
};
var xmlString = js2xmlparser.parse("m2m:rqp", noti_message['m2m:rqp']);
callback(xmlString);
}
catch (e) {
console.log('[make_xml_noti_message] xml parsing error');
callback(e.message);
return "";
}
}
}).then(function(data){
//Setting up options for XML file storage
var options = {
useCDATA: true
};
//Storing XML with the measure's data
var xml_library_measures = js2xmlparser.parse("libraryMeasures", data, options);
fs.writeFile("AppStructures/"+config_app.appname+"_LibraryMeasures_"+first_measure+"_"+conn_data.user_directory + "_" + conn_data.user_name+".xml", xml_library_measures, function(err) {
if (err) {
if(logging.log_mode || logging.log_mode_full) log.warning("Unable to store AppStructures/"+config_app.appname+"_LibraryMeasures_"+first_measure+"_"+conn_data.user_directory + "_" + conn_data.user_name+".xml: " + err, logging.log_file);
throw err;
}else{
if(logging.log_mode || logging.log_mode_full) log.info("Stored AppStructures/"+config_app.appname+"_LibraryMeasures_"+first_measure+"_"+conn_data.user_directory + "_" + conn_data.user_name+".xml", logging.log_file);
if(!logging.silent_mode) console.log(' '+config_app.appname+'_LibraryMeasures_'+first_measure+'_'+conn_data.user_directory + '_' + conn_data.user_name+'.xml file saved');
if(!logging.silent_mode) console.log();
if(!logging.silent_mode) console.log(" Updating the remaining measures list");
if(!logging.silent_mode) console.log(" This is the measures list length: "+measures_list.length);
}
//Checking if all library measures were processed
if(measures_list.length>0){
if(logging.log_mode || logging.log_mode_full) log.info(measures_list.length + " remaining measures. Updating remaining list.", logging.log_file);
getMeasuresDetails(measures_list);
downloadTableAsXML(dataFullStatus = false) {
if (dataFullStatus === false && JSON.stringify(this.state.data) !== "[]") {
try {
let result = js2xmlparser.parse(this.state.table, this.state.data);
let fileName = this.createFileName();
this.downloadFile(result, fileName, "text/plain");
} catch (err) {
console.error(err);
}
} else if (dataFullStatus === true) {
if (JSON.stringify(this.state.dataFull) !== "[]") {
try {
let result = js2xmlparser.parse(
this.state.table,
this.state.dataFull
);
let fileName = this.createFileName(true);
this.downloadFile(result, fileName, "text/plain");
} catch (err) {
console.error(err);
}
}
}
}
orderSignature() {
const xmlObj = {
'@': {
xmlns: 'http://www.ebics.org/S001',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'http://www.ebics.org/S001 http://www.ebics.org/S001/ebics_signature.xsd',
},
OrderSignatureData: {
SignatureVersion: 'A006',
SignatureValue: this.signatureValue(),
PartnerID: this._partnerId,
UserID: this._userId,
},
};
return js2xmlparser.parse('UserSignatureData', xmlObj, this._xmlOptions);
}
getXML($scope) {
const config = {};
Object.assign(config, $scope.currentConfig);
$scope.JSONContent = false;
if ($scope.XMLContent) {
$scope.XMLContent = false;
} else {
try {
const cleaned = objectWithoutProperties(config);
$scope.XMLContent = XMLBeautifier(
js2xmlparser.parse('configuration', cleaned)
);
} catch (error) {
$scope.XMLContent = false;
}
}
if (!$scope.$$phase) $scope.$digest();
}
const orderSignature = (ebicsAccount, document, key, xmlOptions) => {
const xmlObj = {
'@': {
xmlns: 'http://www.ebics.org/S001',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'http://www.ebics.org/S001 http://www.ebics.org/S001/ebics_signature.xsd',
},
OrderSignatureData: {
SignatureVersion: 'A006',
SignatureValue: signatureValue(document, key),
PartnerID: ebicsAccount.partnerId,
UserID: ebicsAccount.userId,
},
};
return js2xmlparser.parse('UserSignatureData', xmlObj, xmlOptions);
};
const encryptedOrderSignature = (ebicsAccount, document, transactionKey, key, xmlOptions) => {