add tests

This commit is contained in:
Timo Hocker 2020-03-07 18:29:18 +01:00
parent ae22e22f5c
commit ca2674e502
4 changed files with 17 additions and 26 deletions

View File

@ -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)) {

View File

@ -5,7 +5,7 @@
"author": "Timo Hocker <t-hocker@web.de>",
"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"
}
}

View File

@ -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');
));
});

View File

@ -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"