mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Removed chai + misc auth test cleanup
refs: https://github.com/TryGhost/Toolbox/issues/158 - We only use chai in a handful of places now, and it seems totally unnecessary - Use assert instead - Made other minor changes with a view to this being a reference aka "perfect" test suite
This commit is contained in:
parent
da44ccaf11
commit
c885dac30a
3 changed files with 11 additions and 61 deletions
|
@ -185,7 +185,6 @@
|
|||
"@tryghost/express-test": "0.4.1",
|
||||
"@tryghost/jest-snapshot": "0.3.1",
|
||||
"c8": "7.11.0",
|
||||
"chai": "4.3.6",
|
||||
"coffeescript": "2.6.1",
|
||||
"cssnano": "5.0.17",
|
||||
"eslint": "8.8.0",
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
const {expect} = require('chai');
|
||||
const assert = require('assert');
|
||||
const {agentProvider, mockManager, fixtureManager, matchers} = require('../../../utils/e2e-framework');
|
||||
const {anyEtag, anyDate, anyErrorId} = matchers;
|
||||
|
||||
const security = require('@tryghost/security');
|
||||
const {tokens} = require('@tryghost/security');
|
||||
const models = require('../../../../core/server/models');
|
||||
const settingsCache = require('../../../../core/shared/settings-cache');
|
||||
|
||||
// Requires needed to enable a labs flag
|
||||
const sinon = require('sinon');
|
||||
|
||||
describe('Authentication API', function () {
|
||||
let agent;
|
||||
|
||||
|
@ -67,7 +64,8 @@ describe('Authentication API', function () {
|
|||
to: 'test@example.com'
|
||||
});
|
||||
|
||||
expect(await settingsCache.get('active_theme')).to.eq('dawn');
|
||||
const activeTheme = await settingsCache.get('active_theme');
|
||||
assert.equal(activeTheme, 'dawn', 'The theme dawn should have been isntalled');
|
||||
});
|
||||
|
||||
it('is setup? yes', async function () {
|
||||
|
@ -243,14 +241,14 @@ describe('Authentication API', function () {
|
|||
it('reset password', async function () {
|
||||
const ownerUser = await fixtureManager.getCurrentOwnerUser();
|
||||
|
||||
const token = security.tokens.resetToken.generateHash({
|
||||
const token = tokens.resetToken.generateHash({
|
||||
expires: Date.now() + (1000 * 60),
|
||||
email: email,
|
||||
dbHash: settingsCache.get('db_hash'),
|
||||
password: ownerUser.get('password')
|
||||
});
|
||||
|
||||
const res = await agent.put('authentication/passwordreset')
|
||||
await agent.put('authentication/passwordreset')
|
||||
.header('Accept', 'application/json')
|
||||
.body({
|
||||
passwordreset: [{
|
||||
|
@ -292,7 +290,7 @@ describe('Authentication API', function () {
|
|||
const ownerUser = await fixtureManager.getCurrentOwnerUser();
|
||||
|
||||
const dateInThePast = Date.now() - (1000 * 60);
|
||||
const token = security.tokens.resetToken.generateHash({
|
||||
const token = tokens.resetToken.generateHash({
|
||||
expires: dateInThePast,
|
||||
email: email,
|
||||
dbHash: settingsCache.get('db_hash'),
|
||||
|
@ -321,7 +319,7 @@ describe('Authentication API', function () {
|
|||
});
|
||||
|
||||
it('reset password: unmatched token', async function () {
|
||||
const token = security.tokens.resetToken.generateHash({
|
||||
const token = tokens.resetToken.generateHash({
|
||||
expires: Date.now() + (1000 * 60),
|
||||
email: email,
|
||||
dbHash: settingsCache.get('db_hash'),
|
||||
|
@ -395,12 +393,12 @@ describe('Authentication API', function () {
|
|||
// All users locked
|
||||
const users = await models.User.fetchAll();
|
||||
for (const user of users) {
|
||||
expect(user.get('status')).to.equal('locked');
|
||||
assert.equal(user.get('status'), 'locked', `Status should be locked for user ${user.get('email')}`);
|
||||
}
|
||||
|
||||
// No session left
|
||||
const sessions = await models.Session.fetchAll();
|
||||
expect(sessions.length).to.equal(0);
|
||||
assert.equal(sessions.length, 0, 'There should be no sessions left in the DB');
|
||||
|
||||
mockManager.assert.sentEmailCount(2);
|
||||
|
||||
|
|
49
yarn.lock
49
yarn.lock
|
@ -2750,11 +2750,6 @@ assert-plus@1.0.0, assert-plus@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
|
||||
integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=
|
||||
|
||||
assertion-error@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
|
||||
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
|
||||
|
||||
assign-symbols@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
|
||||
|
@ -3324,19 +3319,6 @@ ccount@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.1.0.tgz#246687debb6014735131be8abab2d93898f8d043"
|
||||
integrity sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg==
|
||||
|
||||
chai@4.3.6:
|
||||
version "4.3.6"
|
||||
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.6.tgz#ffe4ba2d9fa9d6680cc0b370adae709ec9011e9c"
|
||||
integrity sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==
|
||||
dependencies:
|
||||
assertion-error "^1.1.0"
|
||||
check-error "^1.0.2"
|
||||
deep-eql "^3.0.1"
|
||||
get-func-name "^2.0.0"
|
||||
loupe "^2.3.1"
|
||||
pathval "^1.1.1"
|
||||
type-detect "^4.0.5"
|
||||
|
||||
chalk@4.1.2, chalk@^4.0.0, chalk@^4.1.0, chalk@~4.1.0:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
|
||||
|
@ -3390,11 +3372,6 @@ charenc@0.0.2:
|
|||
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
|
||||
integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=
|
||||
|
||||
check-error@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
|
||||
integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=
|
||||
|
||||
cheerio-select@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/cheerio-select/-/cheerio-select-1.5.0.tgz#faf3daeb31b17c5e1a9dabcee288aaf8aafa5823"
|
||||
|
@ -4166,13 +4143,6 @@ decompress-response@^6.0.0:
|
|||
dependencies:
|
||||
mimic-response "^3.1.0"
|
||||
|
||||
deep-eql@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
|
||||
integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==
|
||||
dependencies:
|
||||
type-detect "^4.0.0"
|
||||
|
||||
deep-extend@^0.6.0:
|
||||
version "0.6.0"
|
||||
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
|
||||
|
@ -5622,11 +5592,6 @@ get-caller-file@^2.0.5:
|
|||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
||||
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
||||
|
||||
get-func-name@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
|
||||
integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=
|
||||
|
||||
get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6"
|
||||
|
@ -7935,13 +7900,6 @@ longest-streak@^2.0.1:
|
|||
resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4"
|
||||
integrity sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==
|
||||
|
||||
loupe@^2.3.1:
|
||||
version "2.3.3"
|
||||
resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.3.tgz#5a92027d54cfb6de4c327d3c3b705561d394d3c6"
|
||||
integrity sha512-krIV4Cf1BIGIx2t1e6tucThhrBemUnIUjMtD2vN4mrMxnxpBvrcosBSpooqunBqP/hOEEV1w/Cr1YskGtqw5Jg==
|
||||
dependencies:
|
||||
get-func-name "^2.0.0"
|
||||
|
||||
lower-case@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28"
|
||||
|
@ -9442,11 +9400,6 @@ path-to-regexp@^1.0.0, path-to-regexp@^1.7.0:
|
|||
dependencies:
|
||||
isarray "0.0.1"
|
||||
|
||||
pathval@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d"
|
||||
integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==
|
||||
|
||||
pause@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/pause/-/pause-0.0.1.tgz#1d408b3fdb76923b9543d96fb4c9dfd535d9cb5d"
|
||||
|
@ -11489,7 +11442,7 @@ type-check@~0.3.2:
|
|||
dependencies:
|
||||
prelude-ls "~1.1.2"
|
||||
|
||||
type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8:
|
||||
type-detect@4.0.8, type-detect@^4.0.8:
|
||||
version "4.0.8"
|
||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
|
||||
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
|
||||
|
|
Loading…
Add table
Reference in a new issue