Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or
* https://opensource.org/licenses/BSD-3-Clause
*/
/**
* tests/api/v1/collectors/pause.js
*/
'use strict'; // eslint-disable-line strict
const supertest = require('supertest');
const Promise = require('bluebird');
supertest.Test.prototype.endAsync = Promise.promisify(supertest.Test
.prototype.end);
const api = supertest(require('../../../../express').app);
const constants = require('../../../../api/v1/constants');
const tu = require('../../../testUtils');
const u = require('./utils');
const pausePath = '/v1/collectors/{key}/pause';
const expect = require('chai').expect;
const Collector = tu.db.Collector;
const Generator = tu.db.Generator;
const CollectorGroup = tu.db.CollectorGroup;
const GeneratorTemplate = tu.db.GeneratorTemplate;
const sgUtils = require('../generators/utils');
const gtUtil = sgUtils.gtUtil;
const sinon = require('sinon');
describe('tests/api/v1/collectors/pause.js >', () => {
/**
* Copyright (c) 2016, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or
* https://opensource.org/licenses/BSD-3-Clause
*/
/**
* tests/api/v1/aspects/patch.js
*/
'use strict'; // eslint-disable-line strict
const supertest = require('supertest');
const Promise = require('bluebird');
supertest.Test.prototype.endAsync =
Promise.promisify(supertest.Test.prototype.end);
const api = supertest(require('../../../../express').app);
const constants = require('../../../../api/v1/constants');
const tu = require('../../../testUtils');
const u = require('./utils');
const gu = require('../generators/utils');
const gtu = require('../generatorTemplates/utils');
const Aspect = tu.db.Aspect;
const Sample = tu.Sample;
const Generator = tu.db.Generator;
const GeneratorTemplate = tu.db.GeneratorTemplate;
const path = '/v1/aspects';
const samplePath = '/v1/samples';
const expect = require('chai').expect;
const featureToggles = require('feature-toggles');
describe('tests/api/v1/aspects/patch.js >', () => {
*/
'use strict'; // eslint-disable-line strict
const expect = require('chai').expect;
const sinon = require('sinon');
const interceptor = require('express-interceptor');
const Promise = require('bluebird');
const supertest = require('supertest');
const ms = require('ms');
const app = require('../../../express').app;
const tu = require('../../testUtils');
const forkUtils = require('./forkUtils');
const constants = require('../../../api/v1/constants');
const genPath = '/v1/generators';
const cgPath = '/v1/collectorGroups';
const api = supertest(app);
supertest.Test.prototype.end = Promise.promisify(supertest.Test.prototype.end);
supertest.Test.prototype.then = function (resolve, reject) {
return this.end().then(resolve).catch(reject);
};
let token;
module.exports = {
setupInterception,
stopGenerator,
resumeGenerator,
clearBlocking,
doStart,
getGenerator,
postGenerator,
patchGenerator,
putGenerator,
/**
* tests/api/v1/aspects/put.js
*/
'use strict'; // eslint-disable-line strict
const supertest = require('supertest');
const api = supertest(require('../../../../express').app);
const constants = require('../../../../api/v1/constants');
const tu = require('../../../testUtils');
const u = require('./utils');
const gu = require('../generators/utils');
const gtu = require('../generatorTemplates/utils');
const featureToggles = require('feature-toggles');
const Promise = require('bluebird');
supertest.Test.prototype.endAsync =
Promise.promisify(supertest.Test.prototype.end);
const Aspect = tu.db.Aspect;
const Sample = tu.Sample;
const Generator = tu.db.Generator;
const GeneratorTemplate = tu.db.GeneratorTemplate;
const path = '/v1/aspects';
const samplePath = '/v1/samples';
const expect = require('chai').expect;
const ZERO = 0;
const ONE = 1;
const TWO = 2;
describe('tests/api/v1/aspects/put.js >', () => {
let token;
let aspectId = 0;
before((done) => {
'use strict'; // eslint-disable-line strict
const expect = require('chai').expect;
const sinon = require('sinon');
const interceptor = require('express-interceptor');
const Promise = require('bluebird');
const supertest = require('supertest');
const ms = require('ms');
const app = require('../../../express').app;
const tu = require('../../testUtils');
const forkUtils = require('./forkUtils');
const constants = require('../../../api/v1/constants');
const genPath = '/v1/generators';
const cgPath = '/v1/collectorGroups';
const api = supertest(app);
supertest.Test.prototype.end = Promise.promisify(supertest.Test.prototype.end);
supertest.Test.prototype.then = function (resolve, reject) {
return this.end().then(resolve).catch(reject);
};
let token;
module.exports = {
setupInterception,
stopGenerator,
resumeGenerator,
clearBlocking,
doStart,
getGenerator,
postGenerator,
patchGenerator,
putGenerator,
patchCollectorGroup,
* https://opensource.org/licenses/BSD-3-Clause
*/
/**
* tests/api/v1/common/createdAtUpdatedAtFilters.js
*/
'use strict';
const supertest = require('supertest');
const api = supertest(require('../../../../express').app);
const tu = require('../../../testUtils');
const constants = require('../../../../api/v1/constants');
const expect = require('chai').expect;
const Promise = require('bluebird');
const sinon = require('sinon');
const ms = require('ms');
supertest.Test.prototype.end = Promise.promisify(supertest.Test.prototype.end);
supertest.Test.prototype.then = function (resolve, reject) {
return this.end().then(resolve).catch(reject);
};
let clock;
/* Admin token is created at Date.now().
Fake test start time = now - 2000d
User created at fake start time + 1d
Fake now = now - 1000d (or test start time + 1000d)
This setup helps clean teardown and test results, like only delete records
created in this test, do not delete something created before the test like
admin user, only return records created in setup, etc. */
const testStartTime = Date.now() - ms('2000d');
const createUserTime = testStartTime - ms('1d');
"use strict";
var supertest = require("supertest");
var Test = supertest.Test;
var oldEnd = Test.prototype.end;
Test.prototype.end = function(){
if(arguments.length > 0)
return oldEnd.apply(this, arguments);
var self = this;
return function(callback){
oldEnd.call(self, function(err, res){
// allow events handlers to run first
process.nextTick(function(){
callback(err, res);
});
});
};
}
describe('wechat-mp', function() {
var mp, app, req
supertest.Test.prototype.addsig = function addsig(token) {
var query = {
echostr: 'abc',
timestamp: +new Date(),
nounce: Math.random()
}
query.signature = calcSig(token, query.timestamp, query.nonce)
return this.query(query)
}
beforeEach(function() {
app = express()
request = supertest(app)
})
it('should block', function(done) {
mp = Wechat('abc')
const status = require('../../../../api/v1/constants').httpStatus;
const u = require('./utils');
const gu = require('../generators/utils');
const tu = require('../../../testUtils');
const gtUtil = require('../generatorTemplates/utils');
const expect = require('chai').expect;
const cryptUtils = require('../../../../utils/cryptUtils');
const GlobalConfig = tu.db.GlobalConfig;
const dbConstants = require('../../../../db/constants');
const config = require('../../../../config');
const Promise = require('bluebird');
const GeneratorTemplate = tu.db.GeneratorTemplate;
const Generator = tu.db.Generator;
const Collector = tu.db.Collector;
const CollectorGroup = tu.db.CollectorGroup;
supertest.Test.prototype.end = Promise.promisify(supertest.Test.prototype.end);
supertest.Test.prototype.then = function (resolve, reject) {
return this.end().then(resolve).catch(reject);
};
const password = 'superlongandsupersecretpassword';
const secretInformation = 'asecretthatyoushouldnotknow';
const otherNonSecretInformation = 'nonsecretInformation';
const secretKey = 'mySecretKey';
const algorithm = 'aes-256-cbc';
const contextDefinition = {
password: {
description: 'password description...',
encrypted: true,
},
secretInformation: {