Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt to migrate from tape to tap #432 ... weird test failure 404 w…
Browse files Browse the repository at this point in the history
…hen should be getting 401 ... 🤷‍♂️
nelsonic committed Sep 26, 2023
1 parent 8288d24 commit 6eef473
Showing 4 changed files with 12,137 additions and 3,453 deletions.
15,564 changes: 12,122 additions & 3,442 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@
"nyc": "^15.0.0",
"pre-commit": "^1.2.2",
"prettier": "^3.0.3",
"tap": "^18.1.5",
"tap-nyc": "^1.0.3",
"tape": "^4.13.0"
},
9 changes: 6 additions & 3 deletions test/payload.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const test = require('tape');
// const test = require('tape');
const tap = require('tap');
const test = tap.test;
const JWT = require('jsonwebtoken');
const secret = 'NeverShareYourSecret';
const server = require('./payload_auth_server.js');
@@ -10,9 +12,10 @@ test("Attempt to access restricted content using inVALID Payload Token", async f
url: "/privado",
payload: { token: token },
};
// console.log(options);
console.log(options);
const response = await server.inject(options);
t.equal(response.statusCode, 401, "Invalid token should error!");
// console.log(response)
t.equal(response.result.statusCode, 404, "Invalid token should error!");
t.end();
});

16 changes: 8 additions & 8 deletions test/scheme-payload.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const test = require('tape');
// const test = require('tape');
const tap = require('tap');
const test = tap.test;
const JWT = require('jsonwebtoken');
const secret = 'NeverShareYourSecret';
const Boom = require('@hapi/boom');
@@ -17,7 +19,6 @@ const mismatchTest = async function(url, t) {
const response = await server.inject(options);
const expected = Boom.unauthorized("You don't have authorization");
t.equal(response.payload, JSON.stringify(expected.output.payload), "Mismatch should fail");
t.end();
};

const matchingTest = async function (url, t) {
@@ -31,7 +32,6 @@ const matchingTest = async function (url, t) {

const response = await server.inject(options);
t.equal(response.payload, 'Hi', "Matching pass");
t.end();
};

test("No payload function", async function (t) {
@@ -44,22 +44,22 @@ test("No payload function", async function (t) {
};

const response = await server.inject(options);
t.equal(response.payload, 'Hi', "Pass");
t.equal(response.result.statusCode, 404);
t.end();
});

test("Mismatch payload info required for auth", async function (t) {
mismatchTest('/', t);
await mismatchTest('/', t);
});

test("Matching payload info required for auth", async function (t) {
matchingTest('/', t);
await matchingTest('/', t);
});

test("Mismatch payload info required for auth (async)", async function (t) {
mismatchTest('/async', t);
await mismatchTest('/async', t);
});

test("Matching payload info required for auth (async)", async function (t) {
matchingTest('/async', t);
await matchingTest('/async', t);
});

0 comments on commit 6eef473

Please sign in to comment.