feat: Created a mini nodeJS server with NewMan for testing without PostMan GUI.

This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
Simon Priet
2021-09-08 14:01:19 +02:00
parent 5fbd7c88fa
commit e69a613a37
5610 changed files with 740417 additions and 3 deletions

21
node_modules/node-oauth1/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,21 @@
language: node_js
os:
- linux
- windows
node_js:
- '6'
- '8'
jobs:
include:
- name: 'Coverage'
node_js: stable
os: linux
script:
- npm run test-unit
- bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F unit
notifications:
slack:
secure: PuYBCkRXgUKxoFMyTZdYcxplpgW+T/hxq54gsFOcAxN079i7PTD/GmGIgKM1RviCocvroUst5bW3ULk3haYUb8gQSCyAeHzRl00DaoOXshTRjFzJyU6m5wbT/R45dh6ZO2BT6uwlVU95KznieCC+yjlbppPOis8bwxra08ODnsA1L7OeI7fVlKjyh+lPA4qnmuYpNtMfTO5mmHroHBS5nWoB1WctWuZQGSfDYLUr/XrhKkJOBbv7FI7setTroIRF4Rs9nIFEF3mzTuUK5VV6lQAZRzNHKmgD9DmGVeaB5Y4fWEznocV1d6cInsjMr4EyMYziyOFnnPZAk8GZapMDwD0/5E9L5+Q8uXhFhVHYurpZnP+wylqZmnfb4UaFcP96BBaavhfF/ai+LWlLbHiL5b1HX4dlauNfHdq1W1YCILI2Atfr+36rqu3102S6HHkOssoTw09ftLfQHuF6CNYnVE5cS40pupwFZj3o0h9yQnCFDPxlq2ls+hon+PKL9wCHL5MlG+jQZDDL8eZC8F9CoZUyVIxNhoh0fnZ+t4bIlGW5eB8f8oMCxcnjocxZpichfAsmuaPh/e2KfdoF/B7ce6+Tb3/YXqo5QVTsJ1Vzi4I7c3jx1Q0DAyZODsBKyE0y7NfmeVNap0WIgajiJBoKji8Fjw+tDfa3hSb4yyPSG6w=

13
node_modules/node-oauth1/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# node-oauth1
This is an implementation of OAuth-1.0a signatures, originally by Netflix, Inc.
# Installation
Install using
```
$ npm install node-oauth1
```
# License
Apache-2.0

24
node_modules/node-oauth1/codecov.yml generated vendored Normal file
View File

@@ -0,0 +1,24 @@
coverage:
range: 40..100 # green if 100+, red if 70-
status:
patch:
# coverage status for pull request diff
default:
target: 100 # any patch should be 100% covered
threshold: 1% # allow a little drop
project:
# coverage status for whole project
default:
target: auto # use coverage of base commit as target
threshold: 1% # allow a little drop
# coverage status for unit tests
unit:
flags: unit
target: 40
parsers:
javascript:
enable_partials: yes # use partial line coverage

622
node_modules/node-oauth1/index.js generated vendored Normal file
View File

@@ -0,0 +1,622 @@
/* jshint ignore:start */
/*
* Copyright 2008 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Here's some JavaScript software for implementing OAuth.
This isn't as useful as you might hope. OAuth is based around
allowing tools and websites to talk to each other. However,
JavaScript running in web browsers is hampered by security
restrictions that prevent code running on one website from
accessing data stored or served on another.
Before you start hacking, make sure you understand the limitations
posed by cross-domain XMLHttpRequest.
On the bright side, some platforms use JavaScript as their
language, but enable the programmer to access other web sites.
Examples include Google Gadgets, and Microsoft Vista Sidebar.
For those platforms, this library should come in handy.
*/
// The HMAC-SHA1 signature method calls b64_hmac_sha1, defined by
// http://pajhome.org.uk/crypt/md5/sha1.js
/* An OAuth message is represented as an object like this:
{method: "GET", action: "http://server.com/path", parameters: ...}
The parameters may be either a map {name: value, name2: value2}
or an Array of name-value pairs [[name, value], [name2, value2]].
The latter representation is more powerful: it supports parameters
in a specific sequence, or several parameters with the same name;
for example [["a", 1], ["b", 2], ["a", 3]].
Parameter names and values are NOT percent-encoded in an object.
They must be encoded before transmission and decoded after reception.
For example, this message object:
{method: "GET", action: "http://server/path", parameters: {p: "x y"}}
... can be transmitted as an HTTP request that begins:
GET /path?p=x%20y HTTP/1.0
(This isn't a valid OAuth request, since it lacks a signature etc.)
Note that the object "x y" is transmitted as x%20y. To encode
parameters, you can call OAuth.addToURL, OAuth.formEncode or
OAuth.getAuthorization.
This message object model harmonizes with the browser object model for
input elements of an form, whose value property isn't percent encoded.
The browser encodes each value before transmitting it. For example,
see consumer.setInputs in example/consumer.js.
*/
/* This script needs to know what time it is. By default, it uses the local
clock (new Date), which is apt to be inaccurate in browsers. To do
better, you can load this script from a URL whose query string contains
an oauth_timestamp parameter, whose value is a current Unix timestamp.
For example, when generating the enclosing document using PHP:
<script src="oauth.js?oauth_timestamp=<?=time()?>" ...
Another option is to call OAuth.correctTimestamp with a Unix timestamp.
*/
var crypto = require('crypto');
var OAuth;
if (OAuth == null) OAuth = {};
OAuth.setProperties = function setProperties(into, from) {
if (into != null && from != null) {
for (var key in from) {
into[key] = from[key];
}
}
return into;
}
OAuth.setProperties(OAuth, // utility functions
{
percentEncode: function percentEncode(s) {
if (s == null) {
return "";
}
if (s instanceof Array) {
var e = "";
for (var i = 0; i < s.length; ++s) {
if (e != "") e += '&';
e += OAuth.percentEncode(s[i]);
}
return e;
}
s = encodeURIComponent(s);
// Now replace the values which encodeURIComponent doesn't do
// encodeURIComponent ignores: - _ . ! ~ * ' ( )
// OAuth dictates the only ones you can ignore are: - _ . ~
// Source: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent
s = s.replace(/\!/g, "%21");
s = s.replace(/\*/g, "%2A");
s = s.replace(/\'/g, "%27");
s = s.replace(/\(/g, "%28");
s = s.replace(/\)/g, "%29");
return s;
}
,
decodePercent: function decodePercent(s) {
if (s != null) {
// Handle application/x-www-form-urlencoded, which is defined by
// http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
s = s.replace(/\+/g, " ");
}
return decodeURIComponent(s);
}
,
/** Convert the given parameters to an Array of name-value pairs. */
getParameterList: function getParameterList(parameters) {
if (parameters == null) {
return [];
}
if (typeof parameters != "object") {
return OAuth.decodeForm(parameters + "");
}
if (parameters instanceof Array) {
return parameters;
}
var list = [];
for (var p in parameters) {
list.push([p, parameters[p]]);
}
return list;
}
,
/** Convert the given parameters to a map from name to value. */
getParameterMap: function getParameterMap(parameters) {
if (parameters == null) {
return {};
}
if (typeof parameters != "object") {
return OAuth.getParameterMap(OAuth.decodeForm(parameters + ""));
}
if (parameters instanceof Array) {
var map = {};
for (var p = 0; p < parameters.length; ++p) {
var key = parameters[p][0];
if (map[key] === undefined) { // first value wins
map[key] = parameters[p][1];
}
}
return map;
}
return parameters;
}
,
getParameter: function getParameter(parameters, name) {
if (parameters instanceof Array) {
for (var p = 0; p < parameters.length; ++p) {
if (parameters[p][0] == name) {
return parameters[p][1]; // first value wins
}
}
} else {
return OAuth.getParameterMap(parameters)[name];
}
return null;
}
,
formEncode: function formEncode(parameters) {
var form = "";
var list = OAuth.getParameterList(parameters);
for (var p = 0; p < list.length; ++p) {
var value = list[p][1];
if (value == null) value = "";
if (form != "") form += '&';
form += OAuth.percentEncode(list[p][0])
+ '=' + OAuth.percentEncode(value);
}
return form;
}
,
decodeForm: function decodeForm(form) {
var list = [];
var nvps = form.split('&');
for (var n = 0; n < nvps.length; ++n) {
var nvp = nvps[n];
if (nvp == "") {
continue;
}
var equals = nvp.indexOf('=');
var name;
var value;
if (equals < 0) {
name = OAuth.decodePercent(nvp);
value = null;
} else {
name = OAuth.decodePercent(nvp.substring(0, equals));
value = OAuth.decodePercent(nvp.substring(equals + 1));
}
list.push([name, value]);
}
return list;
}
,
setParameter: function setParameter(message, name, value) {
var parameters = message.parameters;
if (parameters instanceof Array) {
for (var p = 0; p < parameters.length; ++p) {
if (parameters[p][0] == name) {
if (value === undefined) {
parameters.splice(p, 1);
} else {
parameters[p][1] = value;
value = undefined;
}
}
}
if (value !== undefined) {
parameters.push([name, value]);
}
} else {
parameters = OAuth.getParameterMap(parameters);
parameters[name] = value;
message.parameters = parameters;
}
}
,
setParameters: function setParameters(message, parameters) {
var list = OAuth.getParameterList(parameters);
for (var i = 0; i < list.length; ++i) {
OAuth.setParameter(message, list[i][0], list[i][1]);
}
}
,
/** Fill in parameters to help construct a request message.
This function doesn't fill in every parameter.
The accessor object should be like:
{consumerKey:'foo', consumerSecret:'bar', accessorSecret:'nurn', token:'krelm', tokenSecret:'blah'}
The accessorSecret property is optional.
*/
completeRequest: function completeRequest(message, accessor) {
if (message.method == null) {
message.method = "GET";
}
var map = OAuth.getParameterMap(message.parameters);
if (map.oauth_consumer_key == null) {
OAuth.setParameter(message, "oauth_consumer_key", accessor.consumerKey || "");
}
if (map.oauth_token == null && accessor.token != null) {
OAuth.setParameter(message, "oauth_token", accessor.token);
}
if (map.oauth_version == null) {
OAuth.setParameter(message, "oauth_version", "1.0");
}
if (map.oauth_timestamp == null) {
OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
}
if (map.oauth_nonce == null) {
OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
}
OAuth.SignatureMethod.sign(message, accessor);
}
,
setTimestampAndNonce: function setTimestampAndNonce(message) {
OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
}
,
addToURL: function addToURL(url, parameters) {
var newURL = url;
if (parameters != null) {
var toAdd = OAuth.formEncode(parameters);
if (toAdd.length > 0) {
var q = url.indexOf('?');
if (q < 0) newURL += '?';
else newURL += '&';
newURL += toAdd;
}
}
return newURL;
}
,
/** Construct the value of the Authorization header for an HTTP request. */
getAuthorizationHeader: function getAuthorizationHeader(realm, parameters, disableParamsEncoding) {
var header = 'OAuth ',
headerParams = [];
if (realm && realm.trim()) {
!disableParamsEncoding && (realm = OAuth.percentEncode(realm));
headerParams.push(`realm="${realm}"`);
}
var list = OAuth.getParameterList(parameters);
for (var p = 0; p < list.length; ++p) {
var parameter = list[p];
var name = parameter[0];
var value = parameter[1];
// Skip adding params with no value
if (!value) { continue; }
if (typeof value.toString === 'function') {
value = value.toString().trim();
}
if (!disableParamsEncoding) {
name = OAuth.percentEncode(name);
value = OAuth.percentEncode(value);
}
if (name.indexOf('oauth_') == 0) {
headerParams.push(`${name}="${value}"`);
}
}
return header + headerParams.join(',');
}
,
/** Correct the time using a parameter from the URL from which the last script was loaded. */
correctTimestampFromSrc: function correctTimestampFromSrc(parameterName) {
parameterName = parameterName || "oauth_timestamp";
var scripts = document.getElementsByTagName('script');
if (scripts == null || !scripts.length) return;
var src = scripts[scripts.length - 1].src;
if (!src) return;
var q = src.indexOf("?");
if (q < 0) return;
parameters = OAuth.getParameterMap(OAuth.decodeForm(src.substring(q + 1)));
var t = parameters[parameterName];
if (t == null) return;
OAuth.correctTimestamp(t);
}
,
/** Generate timestamps starting with the given value. */
correctTimestamp: function correctTimestamp(timestamp) {
OAuth.timeCorrectionMsec = (timestamp * 1000) - (new Date()).getTime();
}
,
/** The difference between the correct time and my clock. */
timeCorrectionMsec: 0
,
timestamp: function timestamp() {
var t = (new Date()).getTime() + OAuth.timeCorrectionMsec;
return Math.floor(t / 1000);
}
,
nonce: function nonce(length) {
var chars = OAuth.nonce.CHARS;
var result = "";
for (var i = 0; i < length; ++i) {
var rnum = Math.floor(Math.random() * chars.length);
result += chars.substring(rnum, rnum + 1);
}
return result;
}
});
OAuth.nonce.CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
/** Define a constructor function,
without causing trouble to anyone who was using it as a namespace.
That is, if parent[name] already existed and had properties,
copy those properties into the new constructor.
*/
OAuth.declareClass = function declareClass(parent, name, newConstructor) {
var previous = parent[name];
parent[name] = newConstructor;
if (newConstructor != null && previous != null) {
for (var key in previous) {
if (key != "prototype") {
newConstructor[key] = previous[key];
}
}
}
return newConstructor;
}
/** An abstract algorithm for signing messages. */
OAuth.declareClass(OAuth, "SignatureMethod", function OAuthSignatureMethod() {
});
OAuth.setProperties(OAuth.SignatureMethod.prototype, // instance members
{
/** Add a signature to the message. */
sign: function sign(message) {
var baseString = OAuth.SignatureMethod.getBaseString(message);
var signature = this.getSignature(baseString);
OAuth.setParameter(message, "oauth_signature", signature);
return signature; // just in case someone's interested
}
,
/** Set the key string for signing. */
initialize: function initialize(name, accessor) {
if (name.startsWith("RSA")) {
this.key = accessor.privateKey;
return;
}
var consumerSecret;
if (accessor.accessorSecret != null
&& name.length > 9
&& name.substring(name.length - 9) == "-Accessor") {
consumerSecret = accessor.accessorSecret;
} else {
consumerSecret = accessor.consumerSecret;
}
this.key = OAuth.percentEncode(consumerSecret)
+ "&" + OAuth.percentEncode(accessor.tokenSecret);
}
});
/* SignatureMethod expects an accessor object to be like this:
{tokenSecret: "lakjsdflkj...", consumerSecret: "QOUEWRI..", accessorSecret: "xcmvzc..."}
The accessorSecret property is optional.
*/
// Class members:
OAuth.setProperties(OAuth.SignatureMethod, // class members
{
sign: function sign(message, accessor) {
var name = OAuth.getParameterMap(message.parameters).oauth_signature_method;
if (name == null || name == "") {
name = "HMAC-SHA1";
OAuth.setParameter(message, "oauth_signature_method", name);
}
return OAuth.SignatureMethod.newMethod(name, accessor).sign(message);
}
,
/** Instantiate a SignatureMethod for the given method name. */
newMethod: function newMethod(name, accessor) {
var impl = OAuth.SignatureMethod.REGISTERED[name];
if (impl != null) {
var method = new impl();
method.initialize(name, accessor);
return method;
}
var err = new Error("Unsupported signature method");
var acceptable = "";
for (var r in OAuth.SignatureMethod.REGISTERED) {
if (acceptable != "") acceptable += '&';
acceptable += OAuth.percentEncode(r);
}
err.oauth_acceptable_signature_methods = acceptable;
throw err;
}
,
/** A map from signature method name to constructor. */
REGISTERED: {}
,
/** Subsequently, the given constructor will be used for the named methods.
The constructor will be called with no parameters.
The resulting object should usually implement getSignature(baseString).
You can easily define such a constructor by calling makeSubclass, below.
*/
registerMethodClass: function registerMethodClass(names, classConstructor) {
for (var n = 0; n < names.length; ++n) {
OAuth.SignatureMethod.REGISTERED[names[n]] = classConstructor;
}
}
,
/** Create a subclass of OAuth.SignatureMethod, with the given getSignature function. */
makeSubclass: function makeSubclass(getSignatureFunction) {
var superClass = OAuth.SignatureMethod;
var subClass = function () {
superClass.call(this);
};
subClass.prototype = new superClass();
// Delete instance variables from prototype:
// delete subclass.prototype... There aren't any.
subClass.prototype.getSignature = getSignatureFunction;
subClass.prototype.constructor = subClass;
return subClass;
}
,
getBaseString: function getBaseString(message) {
var URL = message.action;
var q = URL.indexOf('?');
var parameters;
if (q < 0) {
parameters = message.parameters;
} else {
// Combine the URL query string with the other parameters:
parameters = OAuth.decodeForm(URL.substring(q + 1));
var toAdd = OAuth.getParameterList(message.parameters);
for (var a = 0; a < toAdd.length; ++a) {
parameters.push(toAdd[a]);
}
}
return OAuth.percentEncode(message.method.toUpperCase())
+ '&' + OAuth.percentEncode(OAuth.SignatureMethod.normalizeUrl(URL))
+ '&' + OAuth.percentEncode(OAuth.SignatureMethod.normalizeParameters(parameters));
}
,
normalizeUrl: function normalizeUrl(url) {
var uri = OAuth.SignatureMethod.parseUri(url);
var scheme = uri.protocol.toLowerCase();
var authority = uri.authority.toLowerCase();
var dropPort = (scheme == "http" && uri.port == 80)
|| (scheme == "https" && uri.port == 443);
if (dropPort) {
// find the last : in the authority
var index = authority.lastIndexOf(":");
if (index >= 0) {
authority = authority.substring(0, index);
}
}
var path = uri.path;
if (!path) {
path = "/"; // conforms to RFC 2616 section 3.2.2
}
// we know that there is no query and no fragment here.
return scheme + "://" + authority + path;
}
,
parseUri: function parseUri(str) {
/* This function was adapted from parseUri 1.2.1
http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
*/
var o = {
key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
parser: { strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/ }
};
var m = o.parser.strict.exec(str);
var uri = {};
var i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
return uri;
}
,
normalizeParameters: function normalizeParameters(parameters) {
if (parameters == null) {
return "";
}
var list = OAuth.getParameterList(parameters);
var sortable = [];
for (var p = 0; p < list.length; ++p) {
var nvp = list[p];
if (nvp[0] != "oauth_signature") {
sortable.push([OAuth.percentEncode(nvp[0])
+ " " // because it comes before any character that can appear in a percentEncoded string.
+ OAuth.percentEncode(nvp[1])
, nvp]);
}
}
sortable.sort(function (a, b) {
if (a[0] < b[0]) return -1;
if (a[0] > b[0]) return 1;
return 0;
});
var sorted = [];
for (var s = 0; s < sortable.length; ++s) {
sorted.push(sortable[s][1]);
}
return OAuth.formEncode(sorted);
}
});
OAuth.SignatureMethod.registerMethodClass(["PLAINTEXT", "PLAINTEXT-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return this.key;
}
));
OAuth.SignatureMethod.registerMethodClass(["HMAC-SHA1", "HMAC-SHA1-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return crypto.createHmac('sha1', this.key).update(baseString).digest('base64');
}
));
OAuth.SignatureMethod.registerMethodClass(["HMAC-SHA256", "HMAC-SHA256-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return crypto.createHmac('sha256', this.key).update(baseString).digest('base64');
}
));
OAuth.SignatureMethod.registerMethodClass(["HMAC-SHA512", "HMAC-SHA512-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return crypto.createHmac('sha512', this.key).update(baseString).digest('base64');
}
));
OAuth.SignatureMethod.registerMethodClass(["RSA-SHA1", "RSA-SHA1-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return crypto.createSign('RSA-SHA1').update(baseString).sign(this.key, 'base64');
}
));
OAuth.SignatureMethod.registerMethodClass(["RSA-SHA256", "RSA-SHA256-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return crypto.createSign('RSA-SHA256').update(baseString).sign(this.key, 'base64');
}
));
OAuth.SignatureMethod.registerMethodClass(["RSA-SHA512", "RSA-SHA512-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return crypto.createSign('RSA-SHA512').update(baseString).sign(this.key, 'base64');
}
));
try {
OAuth.correctTimestampFromSrc();
} catch (e) {
}
module.exports = OAuth;
/* jshint ignore:end */

25
node_modules/node-oauth1/npm/test-browser.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env node
// ---------------------------------------------------------------------------------------------------------------------
// This script is intended to execute all unit tests in the Chrome Browser.
// ---------------------------------------------------------------------------------------------------------------------
/* eslint-env node, es6 */
require('shelljs/global');
var chalk = require('chalk'),
path = require('path'),
KARMA_CONFIG_PATH = path.join(__dirname, '..', 'test', 'karma.conf');
module.exports = function (exit) {
console.log(chalk.yellow.bold('Running unit tests within browser...'));
var KarmaServer = require('karma').Server;
(new KarmaServer({ // eslint-disable no-new
cmd: 'start',
configFile: KARMA_CONFIG_PATH
}, exit)).start();
};
// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(exit);

64
node_modules/node-oauth1/npm/test-unit.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/env node
/* eslint-env node, es6 */
// ---------------------------------------------------------------------------------------------------------------------
// This script is intended to execute all unit tests.
// ---------------------------------------------------------------------------------------------------------------------
// set directories and files for test and coverage report
var path = require('path'),
NYC = require('nyc'),
sh = require('shelljs'),
chalk = require('chalk'),
recursive = require('recursive-readdir'),
COV_REPORT_PATH = '.coverage',
SPEC_SOURCE_DIR = path.join(__dirname, '..', 'test', 'unit');
module.exports = function (exit) {
// banner line
console.info(chalk.yellow.bold('Running unit tests using mocha on node...'));
sh.test('-d', COV_REPORT_PATH) && sh.rm('-rf', COV_REPORT_PATH);
sh.mkdir('-p', COV_REPORT_PATH);
var Mocha = require('mocha'),
nyc = new NYC({
hookRequire: true,
reporter: ['text', 'lcov', 'text-summary', 'json'],
reportDir: COV_REPORT_PATH,
tempDirectory: COV_REPORT_PATH
});
nyc.reset();
nyc.wrap();
// add all spec files to mocha
recursive(SPEC_SOURCE_DIR, function (err, files) {
if (err) { console.error(err); return exit(1); }
var mocha = new Mocha({ timeout: 1000 * 60 });
files.filter(function (file) { // extract all test files
return (file.substr(-8) === '.test.js');
}).forEach(mocha.addFile.bind(mocha));
mocha.run(function (runError) {
runError && console.error(runError.stack || runError);
nyc.writeCoverageFile();
nyc.report();
nyc.checkCoverage({
statements: 55,
branches: 40,
functions: 70,
lines: 55
});
exit(process.exitCode || runError ? 1 : 0);
});
});
};
// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(process.exit);

43
node_modules/node-oauth1/package.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "node-oauth1",
"version": "1.3.0",
"description": "A fork of Netflix's implementation of the OAuth1 protocol",
"main": "index.js",
"scripts": {
"test": "npm run test-unit && npm run test-browser",
"test-unit": "node npm/test-unit.js",
"test-browser": "node npm/test-browser.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/czardoz/node-oauth1.git"
},
"keywords": [
"OAuth",
"OAuth-1.0a",
"OAuth1"
],
"author": "",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/czardoz/node-oauth1/issues"
},
"homepage": "https://github.com/czardoz/node-oauth1#readme",
"dependencies": {},
"devDependencies": {
"browserify": "16.5.1",
"chai": "4.2.0",
"chalk": "2.4.2",
"colors": "1.4.0",
"karma": "3.1.4",
"karma-browserify": "6.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-mocha": "1.3.0",
"karma-mocha-reporter": "2.2.5",
"mocha": "7.1.2",
"nyc": "14.1.1",
"puppeteer": "1.20.0",
"recursive-readdir": "2.2.2",
"shelljs": "0.8.4"
}
}

84
node_modules/node-oauth1/test/karma.conf.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
// Karma configuration
// Generated on Mon Nov 09 2015 18:53:12 GMT+0530 (IST)
process.env.CHROME_BIN = require('puppeteer').executablePath(); // eslint-disable-line no-process-env
module.exports = function (config) {
var configuration = {
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'browserify'],
// list of files / patterns to load in the browser
files: [
'../index.js',
'../test/unit/**/*.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'../index.js': ['browserify'], // Mention path as per your test js folder
'../test/unit/**/*.js': ['browserify'] // Mention path as per your library js folder
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['mocha'],
// web server port
port: 9876,
// the number of milliseconds to wait for an idle browser to come back up before bailing
browserNoActivityTimeout: 20000,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// one of: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_WARN,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['chrome_without_security'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultanous
concurrency: Infinity,
// Uncomment "karma-browserify" if you see an error like this:
// Error: No provider for "framework:browserify"! (Resolving: framework:browserify)
plugins: [
'karma-mocha',
'karma-chrome-launcher',
'karma-browserify',
'karma-mocha-reporter'
],
// Pass options to the client frameworks.
client: {
mocha: {
timeout: 10000 // 10 seconds
}
},
customLaunchers: {
chrome_without_security: {
base: 'ChromeHeadless',
flags: ['--disable-web-security']
}
}
};
config.set(configuration);
};

View File

@@ -0,0 +1,77 @@
var expect = require('chai').expect,
oauth = require('../../index'),
encode = oauth.percentEncode,
getAuthHeader = oauth.getAuthorizationHeader;
describe('getAuthorizationHeader()', function () {
it('should include all oauth1 params', function () {
var key,
params = {
oauth_signature_method: 'PLAINTEXT',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0',
oauth_callback: 'http://postman.com',
oauth_verifier: 'secret',
oauth_body_hash: 'xyz=',
oauth_signature: 'generatedSignature=='
},
authHeader = getAuthHeader(null, params);
for (key in params) {
expect(authHeader).to.include(`${key}="${encode(params[key])}"`);
}
});
it('should not encode params when disableParamsEncoding:true', function () {
var params = {
oauth_signature_method: 'PLAINTEXT',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0',
oauth_callback: 'http://postman.com',
oauth_verifier: 'secret',
oauth_body_hash: 'xyz=',
oauth_signature: 'generatedSignature=='
},
key,
authHeader = getAuthHeader(null, params, true);
for (key in params) {
expect(authHeader).to.include(`${key}="${params[key]}"`);
}
});
it('should add relm if provided', function () {
var realm = 'postman',
params = {
oauth_signature_method: 'PLAINTEXT',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
};
expect(getAuthHeader(realm, params)).to.include('realm="postman"');
});
it('should not include non-oauth1 params', function () {
var realm = 'postman',
params = {
oauth_signature_method: 'PLAINTEXT',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0',
random: 'non-oauth1 param'
};
expect(getAuthHeader(realm, params)).to.not.include('random');
});
});

View File

@@ -0,0 +1,273 @@
var expect = require('chai').expect,
sign = require('../../index').SignatureMethod.sign;
describe('SignatureMethod.sign()', function () {
it('should throw error for unsupported signature method', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'UNKNOWN'
}
},
accessor = {};
expect(function () {sign(message, accessor)}).to.throw('Unsupported signature method');
});
it('should generate correct PLAINTEXT signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'PLAINTEXT',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
consumerSecret: 'alpha',
tokenSecret: 'beta'
},
signature = 'alpha&beta';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct HMAC-SHA1 signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'HMAC-SHA1',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
consumerSecret: 'alpha',
tokenSecret: 'beta'
},
signature= 'kst31ZZPywC/vi+UVOU93hgdEMg=';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct HMAC-SHA256 signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'HMAC-SHA256',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
consumerSecret: 'alpha',
tokenSecret: 'beta'
},
signature= 'H3w+AlCMRPSZNn8gOI6GyvEXol6R0jVqNw4rr58nZmg=';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct HMAC-SHA512 signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'HMAC-SHA512',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
consumerSecret: 'alpha',
tokenSecret: 'beta'
},
signature = 'GF7ju0CZzAT7dM7cYx8z1km5MOrrjaQ+cJY00CX1sz052gIOOWacY55NcJkqSi28OQqcO6mhdxTOnO60uH4cEw==';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct RSA-SHA1 signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'RSA-SHA1',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
privateKey: '-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgFKLvzM9zbm3I0+HWcHlBSqpfRY/bKs6NDLclERrzfnReFV4utjkhjaEQPPT6tHVHKrZkcxmIgwe3XrkJkUjcuingXIF+Fc3KpY61qJ4HSM50qIuHdi+C5YfuXwNrh6OOeZAhhqgSw2e2XqPfATbkYYwpIFpdVdcH/Pb2ynpd6VXAgMBAAECgYAbQE+LFyhH25Iou0KCpJ0kDHhjU+UIUlrRP8kjHYQOqXzUmtr0p903OkpHNPsc8wJX1SQxGra60aXE4HVR9fYFQNliAnSmA/ztGR4ddnirK1Gzog4y2OOkicTdSqJ/1XXtTEDSRkA0Z2DIqcWgudeSDzVjUpreYwQ/rCEZbi50AQJBAJcf9wi5bU8tdZUCg3/8MNDwHhr4If4V/9kmhsgNp+M/9tHwCbD05hCbiGS7g58DPF+6V2K30qQYq7yvBP8Te4ECQQCL1GhX/YwkD6rexi0E1bjz+RqhNLTR9kexkTfSYmL6zHeeIFSH8ROioGOJMU51lUtMNkkrKEeki5SZpkfaQOzXAkAvBnJPU6vQ7HtfH8YdiDMEgQNNLxMcxmmzf4qHK8CnNRsvnnrVho8kcdFSTwsY6t/Zhdl1TXANQeQGtYtfeAeBAkEAhUB351JSWJMtrHqCsFbTmHxNKk7F+kiObeMLpUvpM0PiwifhJmNQ6Oubr0Pzlw4c4ZXiCGSsUVxK0lmpo423pQJATYDoxVhZrKA3xDAifWoyxbyxf/WXtUGDaAOuZc/naVN5TKiqaEO6G+k3NpmOXNKsYU/Zd9e6P/TnfU74TyDDDA==\n-----END RSA PRIVATE KEY-----'
},
signature = 'Tok9L4dAnBWzd0KNgI9/kR3fhfE2keZybvf8UYPB1/bbdQsMHQRQYL1Ui1V94ZBlijeQmyHo67XLJe1zGwCTK5fAGSOtQU0mfvj4AvG4sG5SVg8auWgm5BQt/Lhe9cQJpVNqRhV8rMxOZ6mF9STpDGSx80MY2+FG4eThexe0vkQ=';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct RSA-SHA256 signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'RSA-SHA256',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
privateKey: '-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgFKLvzM9zbm3I0+HWcHlBSqpfRY/bKs6NDLclERrzfnReFV4utjkhjaEQPPT6tHVHKrZkcxmIgwe3XrkJkUjcuingXIF+Fc3KpY61qJ4HSM50qIuHdi+C5YfuXwNrh6OOeZAhhqgSw2e2XqPfATbkYYwpIFpdVdcH/Pb2ynpd6VXAgMBAAECgYAbQE+LFyhH25Iou0KCpJ0kDHhjU+UIUlrRP8kjHYQOqXzUmtr0p903OkpHNPsc8wJX1SQxGra60aXE4HVR9fYFQNliAnSmA/ztGR4ddnirK1Gzog4y2OOkicTdSqJ/1XXtTEDSRkA0Z2DIqcWgudeSDzVjUpreYwQ/rCEZbi50AQJBAJcf9wi5bU8tdZUCg3/8MNDwHhr4If4V/9kmhsgNp+M/9tHwCbD05hCbiGS7g58DPF+6V2K30qQYq7yvBP8Te4ECQQCL1GhX/YwkD6rexi0E1bjz+RqhNLTR9kexkTfSYmL6zHeeIFSH8ROioGOJMU51lUtMNkkrKEeki5SZpkfaQOzXAkAvBnJPU6vQ7HtfH8YdiDMEgQNNLxMcxmmzf4qHK8CnNRsvnnrVho8kcdFSTwsY6t/Zhdl1TXANQeQGtYtfeAeBAkEAhUB351JSWJMtrHqCsFbTmHxNKk7F+kiObeMLpUvpM0PiwifhJmNQ6Oubr0Pzlw4c4ZXiCGSsUVxK0lmpo423pQJATYDoxVhZrKA3xDAifWoyxbyxf/WXtUGDaAOuZc/naVN5TKiqaEO6G+k3NpmOXNKsYU/Zd9e6P/TnfU74TyDDDA==\n-----END RSA PRIVATE KEY-----'
},
signature = 'A8ayuJe1RJd0zL4R8aBgbEY0PFviN6bk8G4QqAcGPSZfeGjFjwBlXWFysNy5iR8mm3/yWGboUMHWmtyPDtOnL2cJTc8fKhXwITFi7FmsUeA5cBK/HdWYoHLdWuNIZgDHsv8qvZCS4QD4qIILiys4uFK+W1br0zSJR9bsOTIZLng=';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct RSA-SHA512 signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'RSA-SHA512',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
privateKey: '-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgFKLvzM9zbm3I0+HWcHlBSqpfRY/bKs6NDLclERrzfnReFV4utjkhjaEQPPT6tHVHKrZkcxmIgwe3XrkJkUjcuingXIF+Fc3KpY61qJ4HSM50qIuHdi+C5YfuXwNrh6OOeZAhhqgSw2e2XqPfATbkYYwpIFpdVdcH/Pb2ynpd6VXAgMBAAECgYAbQE+LFyhH25Iou0KCpJ0kDHhjU+UIUlrRP8kjHYQOqXzUmtr0p903OkpHNPsc8wJX1SQxGra60aXE4HVR9fYFQNliAnSmA/ztGR4ddnirK1Gzog4y2OOkicTdSqJ/1XXtTEDSRkA0Z2DIqcWgudeSDzVjUpreYwQ/rCEZbi50AQJBAJcf9wi5bU8tdZUCg3/8MNDwHhr4If4V/9kmhsgNp+M/9tHwCbD05hCbiGS7g58DPF+6V2K30qQYq7yvBP8Te4ECQQCL1GhX/YwkD6rexi0E1bjz+RqhNLTR9kexkTfSYmL6zHeeIFSH8ROioGOJMU51lUtMNkkrKEeki5SZpkfaQOzXAkAvBnJPU6vQ7HtfH8YdiDMEgQNNLxMcxmmzf4qHK8CnNRsvnnrVho8kcdFSTwsY6t/Zhdl1TXANQeQGtYtfeAeBAkEAhUB351JSWJMtrHqCsFbTmHxNKk7F+kiObeMLpUvpM0PiwifhJmNQ6Oubr0Pzlw4c4ZXiCGSsUVxK0lmpo423pQJATYDoxVhZrKA3xDAifWoyxbyxf/WXtUGDaAOuZc/naVN5TKiqaEO6G+k3NpmOXNKsYU/Zd9e6P/TnfU74TyDDDA==\n-----END RSA PRIVATE KEY-----'
},
signature = 'ArsxDvfXOVTQBfXLbNEkWEm+xfEnzAQLM7RET04cMtHrrcm80mWWMcsMN1jykR8ZnXVsVufO565cJQgWqBJ2aWQgUa4Yu2RQWGLuIYwnaiX6TxysO/ZuV5zDlTWQdQpjUmFWKuixZouMDH7CiV37PJLKkYaJzQaGTamHsJiUubE=';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct HMAC signature without tokenSecret', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'HMAC-SHA512',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
consumerSecret: 'alpha',
tokenSecret: undefined
},
signature = 'zWgwoT1cmeYYmDXiEo9ylEAwu9h7qu/EG+Ylj6n0cedV9aK/gMkgGmTylrAbFpCmEKWo6wwfyvh+YFuJl2+1EQ==';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct HMAC signature without consumerSecret', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'HMAC-SHA512',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
consumerSecret: undefined,
tokenSecret: 'beta'
},
signature = 'gyU8TWOoUeCIWgduAZvQ7WpA7hcvdvfvulksm8vyR17fQt+ZwuwnL6TSZCXbCtV7gmTi3Ggr6hO/UjEItG2qew==';
expect(sign(message, accessor)).to.eql(signature);
});
it('should generate correct HMAC signature without consumerSecret and tokenSecret', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'HMAC-SHA512',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
consumerSecret: 'alpha',
tokenSecret: undefined
},
signature = 'zWgwoT1cmeYYmDXiEo9ylEAwu9h7qu/EG+Ylj6n0cedV9aK/gMkgGmTylrAbFpCmEKWo6wwfyvh+YFuJl2+1EQ==';
expect(sign(message, accessor)).to.eql(signature);
});
it('should throw error if private key is absent for RSA signature', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'RSA-SHA512',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
privateKey: undefined
};
expect(function () {sign(message, accessor)}).to.throw();
});
it('should throw error if private key is not in valid PEM format', function () {
var message = {
action: 'https://postman.com/path',
method: 'GET',
parameters: {
oauth_signature_method: 'RSA-SHA512',
oauth_consumer_key: 'foo',
oauth_token: 'bar',
oauth_nonce: 'baz',
oauth_timestamp: '1588771035',
oauth_version: '1.0'
}
},
accessor = {
privateKey: 'invalid private key!!'
};
expect(function () {sign(message, accessor)}).to.throw();
});
});