test('bin: no module /w root check', (t) => { t.plan(1); const proc = spawn(citgmPath, ['-s']); proc.on('error', (err) => { t.error(err); t.fail('we should not get an error'); }); proc.on('close', (code) => { t.equal(code, 0, 'we should exit with a code of 0'); }); });
tap.test("CSRF attack should fail with wrong referer", (t) => { t.plan(1); supertest(app) .post("/conn/settings/stop") .set("Host", "example.com") .expect(400) .end(t.error); });
test('default root route', (t) => { t.plan(2) const app = build(t) app.inject({ url: '/' }, (err, res) => { t.error(err) t.deepEqual(JSON.parse(res.payload), { root: true }) }) })
test('support works standalone', (t) => { t.plan(2) const fastify = Fastify() fastify.register(Support) fastify.ready((err) => { t.error(err) t.equal(fastify.someSupport(), 'hugs') }) })
test('Should call the function', t => { t.plan(2) const easyBreaker = EasyBreaker(asyncOp, { threshold: 2, timeout: 1000, resetTimeout: 1000 }) easyBreaker(false, err => { t.error(err) t.is(easyBreaker._failures, 0) }) })
tap.test("CSRF attack should fail with no referer", (t) => { t.plan(1); supertest(app).post("/conn/settings/stop").expect(400).end(t.error); });
test('gun namespace should exist', t => { t.plan(3) const fastify = Fastify() fastify .register(gunPlugin, { name: 'test' }) .ready(err => { t.error(err) t.ok(fastify.gun) fastify.close(() => { t.pass('unlock') }) }) })
test('citgm-all: fail expectFail', (t) => { t.plan(1); const proc = spawn(citgmAllPath, [ '-l', 'test/fixtures/custom-lookup-expectFail.json' ]); proc.on('error', (err) => { t.error(err); }); proc.on('close', (code) => { t.equals(code, 0, 'citgm-all should exit with signal 0'); }); });
test('example is loaded', (t) => { t.plan(2) const app = build(t) app.inject({ url: '/example' }, (err, res) => { t.error(err) t.equal(res.payload, 'this is an example') }) })
tap.test("DNS rebind attack fails", (t) => { t.plan(1); supertest(app) .get("/inbox") .set("Host", "example.com") .expect(400) .end(t.error); });
test('bin: omg-i-pass /w local module', (t) => { t.plan(1); const proc = spawn(citgmPath, ['./test/fixtures/omg-i-pass']); proc.on('error', (err) => { t.error(err); t.fail('we should not get an error testing omg-i-pass'); }); proc.on('close', (code) => { t.ok(code === 0, 'omg-i-pass should pass and exit with a code of zero'); }); });
test('citgm-all: pass expectFail', (t) => { t.plan(1); const proc = spawn(citgmAllPath, [ '-l', 'test/fixtures/custom-lookup-expectFail-fail.json' ]); proc.on('error', (err) => { t.error(err); }); proc.on('close', (code) => { t.equals(code, 1, 'citgm-all should exit with signal 1'); }); });
test('citgm-all: flaky-fail', (t) => { t.plan(1); const proc = spawn(citgmAllPath, [ '-l', 'test/fixtures/custom-lookup-flaky.json' ]); proc.on('error', (err) => { t.error(err); }); proc.on('close', (code) => { t.equals(code, 0, 'citgm-all should exit with signal 0'); }); });
test('citgm-all: test with replace', (t) => { t.plan(1); const proc = spawn(citgmAllPath, [ '-l', 'test/fixtures/custom-lookup-backwards-compatibilty.json' ]); proc.on('error', (err) => { t.error(err); }); proc.on('close', (code) => { t.equals(code, 0, 'citgm-all should exit with signal 0'); }); });