Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global describe it before */
const should = require('should');
const simple = require('simple-mock');
const supertest = require('supertest');
const cheerio = require('cheerio');
const APP = require('../../app/app');
const Clients = require('../../app/models/clients');
const Messages = require('../../app/models/messages');
const Users = require('../../app/models/users');
const db = require('../../app/db.js');
const primary = supertest.agent(APP);
const supervisor = supertest.agent(APP);
// a client to be created and referenced throughout tests
const uniqueID1 = '123JKL98237iuh23bkj';
const reqBody = {
first: 'Steven',
middle: undefined,
last: 'Nixon',
dob: '03/12/1990',
targetUser: 2, // TODO: this must be the user that is logged in
uniqueID1,
uniqueID2: '456ABC',
};
const logInAsOwner = (done) => {
supervisor.get('/login')
.end(function(err, res) {
const assert = require('assert');
const supertest = require('supertest');
const should = require('should');
const cheerio = require('cheerio');
const APP = require('../../app/app');
const Communications = require('../../app/models/communications');
const owner = supertest.agent(APP);
const anonUser = supertest.agent(APP);
const twilioAgent = supertest.agent(APP);
const smsData = require('../data/testSMSData');
const createUID = () => String(Math.random().toString(36).substring(7));
// will create a random, unique string
const inboundBodyMsg = createUID();
describe('Capture Board view', () => {
before((done) => {
owner.get('/login').end(function(err, res) {
if (res.status == '302') {
done();
} else {
userAndGraph.pop()
userAndGraph = userAndGraph.slice(-2) // last two parts
var localName = argv._[1] || userAndGraph[1]
userAndGraph = userAndGraph.join('/')
var url = '/data/graph/' + userAndGraph +'.json'
var localHttp = 'http://127.0.0.1:8000'
var remoteHttp = 'https://'+hn
var cdnHttp = 'https://cdn.vizor.io:443'
var remote = request.agent(remoteHttp)
var cdn = request.agent(cdnHttp)
var local = request.agent(localHttp)
if (localHttp === remoteHttp) {
console.error('Not writing to source', localHttp, remoteHttp)
process.exit(1)
}
function sendGraph(path, graphData, cb) {
return local.post('/graph').send({
path: path,
private: 'false',
editable: true,
graph: JSON.stringify(graphData)
})
.expect(200)
.end(cb)
}
it('should return 200 with error message Only admins may access the admin page', function(done){
const user = request.agent(app);
user.post('/auth/login')
.send(sample_user_info)
.expect(302, function(err, res) {
if(err) return done(err)
user.get('/admin/')
.expect(200, done)
})
})
})
const assert = require('assert');
const supertest = require('supertest');
const should = require('should');
const APP = require('../../app/app');
const Emails = require('../../app/models/emails');
const Capture = require('../../app/models/capture');
const CommConns = require('../../app/models/commConns');
const Communications = require('../../app/models/communications');
const Conversations = require('../../app/models/conversations');
const Messages = require('../../app/models/messages');
const twilioAgent = supertest.agent(APP);
const smsData = require('../data/testSMSData');
describe('Sms inbound message endpoint', () => {
it('should accept a new text', (done) => {
twilioAgent.post('/webhook/sms')
.send(smsData)
.set('X-Twilio-Signature', 'Hwg7BlBJGBLRPcRAlKwKlwtQ+q0=')
.expect(200)
.end((err, res) => {
done(err);
});
});
it.skip('should not accept an unsigned new text', (done) => {
twilioAgent.post('/webhook/sms')
.send(smsData)
it('/api/ping should return "pong"', async() => {
const request = require('supertest');
const agent = request.agent(server.app);
await agent
.get('/api/ping')
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200)
.then((res) => {
expect(res.body.message).to.equal('pong!');
});
});
before('Creates a server', async function () {
scaffold(tempPath);
const flintServer = new Flint({ publicPath, listen: false });
server = await flintServer.startServer();
global.agent = supertest.agent(server);
await populateDB();
return global.agent
.post('/admin/login')
.send({ email: mocks.users[0].email, password: 'password' })
.expect(200);
});
before(function(done) {
pool = new http.Agent({
keepAlive: true
});
agent = supertest.agent('http://localhost:3000');
child = util.startProcess(
path.join(__dirname, '../../scenarios/end_to_end_cluster.js'));
setTimeout(done, 1000);
});
before(function(done) {
agent = supertest.agent('http://localhost:3000');
var entrypoint = path.join(__dirname,
'../../../demos/1. Crashes/b. express with thehelp-cluster.js');
child = startProcess(entrypoint);
setTimeout(done, 1000);
});
import request from 'supertest';
import faker from 'faker';
import app from '../../../app';
const agent = request.agent(app);
describe('Menu Details API', async () => {
let token;
beforeAll(async () => {
const loginData = {
email: 'admin@boldr.io',
password: 'password',
};
const { body } = await agent.post('/api/v1/auth/login').set('Accept', 'application/json').send(loginData);
token = body.token;
});
it('+++ GET /menu-details -- It should return menu details', () => {
return agent.get('/api/v1/menu-details').set('Accept', 'application/json').expect(res => {
expect(res.status).toBe(200);
expect(typeof res.body).toBe('object');