From ca2674e502d04e0be3a6a7931c3c581066db4196 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Sat, 7 Mar 2020 18:29:18 +0100 Subject: [PATCH] add tests --- index.js | 5 ----- package.json | 4 ++-- test/index.js | 12 ++++-------- yarn.lock | 22 +++++++++++----------- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/index.js b/index.js index b37da15..1b3b364 100644 --- a/index.js +++ b/index.js @@ -43,8 +43,6 @@ async function authenticate (user, password) { const user_entry = await new Promise ((res) => res (me.get_user (user))); - console.log ('auth: got user', JSON.stringify (user_entry, null, 2)); - if (!user_entry) return null; @@ -110,7 +108,6 @@ async function request_handler_authenticate (session, user, key, res, next) { : consts.http.status_ok ); res.end (user_salt); - console.log ('sent salt'); return true; } @@ -159,8 +156,6 @@ async function request_handler_authenticate (session, user, key, res, next) { * @param {any} next next handler */ async function request_handler (req, res, next) { - console.log (req.headers); - if (Array.isArray (me.ignore_paths)) { for (const regex of me.ignore_paths) { if (regex.test (req.url)) { diff --git a/package.json b/package.json index 72e3bb5..6545f6f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Timo Hocker ", "license": "MIT", "devDependencies": { - "@scode/auth-client-helper": "^1.0.5", + "@scode/auth-client-helper": "^1.0.6", "@scode/crypto-helper": "^1.1.9", "@scode/eslint-config": "^1.2.26", "ava": "^3.5.0", @@ -24,6 +24,6 @@ "ci": "yarn && node jenkins.js" }, "dependencies": { - "@scode/consts": "^1.0.2" + "@scode/consts": "^1.0.3" } } diff --git a/test/index.js b/test/index.js index 690dd0b..a376f29 100644 --- a/test/index.js +++ b/test/index.js @@ -27,21 +27,17 @@ test ('login', async (t) => { }); test ('reject invalid user', async (t) => { - const session = await client.login ( + await t.throwsAsync (client.login ( 'foo', 'foo', 'http://localhost:3000' - ); - - t.is (typeof session, 'string'); + )); }); test ('reject invalid password', async (t) => { - const session = await client.login ( + await t.throwsAsync (client.login ( 'testuser', 'bar', 'http://localhost:3000' - ); - - t.is (typeof session, 'string'); + )); }); diff --git a/yarn.lock b/yarn.lock index 3df8669..39793e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -169,21 +169,21 @@ dependencies: safe-buffer "^5.1.2" -"@scode/auth-client-helper@^1.0.4": - version "1.0.5" - resolved "https://npm.scode.ovh/@scode%2fauth-client-helper/-/auth-client-helper-1.0.5.tgz#c8ea2a998311f8ac8798bd56c1edd0a52a39aa6b" - integrity sha512-m2UUQyd7iu8Ri1K+mVaLaRv0dZsDSbeT5zu/c+ZgLzWJEWa6Pg4cp2R6l0rU8uElaPDG9Mg//zln6ORemWZl8Q== +"@scode/auth-client-helper@^1.0.6": + version "1.0.6" + resolved "https://npm.scode.ovh/@scode%2fauth-client-helper/-/auth-client-helper-1.0.6.tgz#b6ebee3c488f9af58c20981f68944fbe0dc2ed2d" + integrity sha512-+1xqrLNtws1S9TPRk95MguoPeaaQ+iMH8A1R7eWB/MuyhysasKMGkryeOEt9LZvS+m+k+m2aVQVVljTPYPN8wQ== dependencies: - "@scode/consts" "^1.0.1" - "@scode/crypto-helper" "^1.0.2" + "@scode/consts" "^1.0.3" + "@scode/crypto-helper" "^1.1.9" node-fetch "^2.6.0" -"@scode/consts@^1.0.1", "@scode/consts@^1.0.2": +"@scode/consts@^1.0.3": version "1.0.3" resolved "https://npm.scode.ovh/@scode%2fconsts/-/consts-1.0.3.tgz#afeba5e5255a2854be3849d53815f9f593fa20a6" integrity sha512-w/7LvhZzIi/nRr5TO1naLyQVdPIPDhOZ99r8lHbjP8TzycAFiwl6cb0tmybab5i4dFq290Xs4hgm62ae/5eEFw== -"@scode/crypto-helper@^1.0.2", "@scode/crypto-helper@^1.1.9": +"@scode/crypto-helper@^1.1.9": version "1.1.9" resolved "https://npm.scode.ovh/@scode%2fcrypto-helper/-/crypto-helper-1.1.9.tgz#4ae3bd0aba7a3aa909cae73ead0f4ab3a5e511f2" integrity sha512-+UKNMrB/uqTtp+0M4hPzNPrvEKNhyoJtXztk//MMGSrKqdXyW12W0fcEi1OPbt+P/6ZUz0saQWwKMMNgabeSwQ== @@ -250,9 +250,9 @@ integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== "@types/node@*": - version "13.7.7" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.7.tgz#1628e6461ba8cc9b53196dfeaeec7b07fa6eea99" - integrity sha512-Uo4chgKbnPNlxQwoFmYIwctkQVkMMmsAoGGU4JKwLuvBefF0pCq4FybNSnfkfRCpC7ZW7kttcC/TrRtAJsvGtg== + version "13.9.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.0.tgz#5b6ee7a77faacddd7de719017d0bc12f52f81589" + integrity sha512-0ARSQootUG1RljH2HncpsY2TJBfGQIKOOi7kxzUY6z54ePu/ZD+wJA8zI2Q6v8rol2qpG/rvqsReco8zNMPvhQ== "@types/normalize-package-data@^2.4.0": version "2.4.0"