add tests
This commit is contained in:
parent
ae22e22f5c
commit
ca2674e502
5
index.js
5
index.js
@ -43,8 +43,6 @@ async function authenticate (user, password) {
|
|||||||
const user_entry
|
const user_entry
|
||||||
= await new Promise ((res) => res (me.get_user (user)));
|
= await new Promise ((res) => res (me.get_user (user)));
|
||||||
|
|
||||||
console.log ('auth: got user', JSON.stringify (user_entry, null, 2));
|
|
||||||
|
|
||||||
if (!user_entry)
|
if (!user_entry)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -110,7 +108,6 @@ async function request_handler_authenticate (session, user, key, res, next) {
|
|||||||
: consts.http.status_ok
|
: consts.http.status_ok
|
||||||
);
|
);
|
||||||
res.end (user_salt);
|
res.end (user_salt);
|
||||||
console.log ('sent salt');
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +156,6 @@ async function request_handler_authenticate (session, user, key, res, next) {
|
|||||||
* @param {any} next next handler
|
* @param {any} next next handler
|
||||||
*/
|
*/
|
||||||
async function request_handler (req, res, next) {
|
async function request_handler (req, res, next) {
|
||||||
console.log (req.headers);
|
|
||||||
|
|
||||||
if (Array.isArray (me.ignore_paths)) {
|
if (Array.isArray (me.ignore_paths)) {
|
||||||
for (const regex of me.ignore_paths) {
|
for (const regex of me.ignore_paths) {
|
||||||
if (regex.test (req.url)) {
|
if (regex.test (req.url)) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"author": "Timo Hocker <t-hocker@web.de>",
|
"author": "Timo Hocker <t-hocker@web.de>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scode/auth-client-helper": "^1.0.5",
|
"@scode/auth-client-helper": "^1.0.6",
|
||||||
"@scode/crypto-helper": "^1.1.9",
|
"@scode/crypto-helper": "^1.1.9",
|
||||||
"@scode/eslint-config": "^1.2.26",
|
"@scode/eslint-config": "^1.2.26",
|
||||||
"ava": "^3.5.0",
|
"ava": "^3.5.0",
|
||||||
@ -24,6 +24,6 @@
|
|||||||
"ci": "yarn && node jenkins.js"
|
"ci": "yarn && node jenkins.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@scode/consts": "^1.0.2"
|
"@scode/consts": "^1.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,21 +27,17 @@ test ('login', async (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test ('reject invalid user', async (t) => {
|
test ('reject invalid user', async (t) => {
|
||||||
const session = await client.login (
|
await t.throwsAsync (client.login (
|
||||||
'foo',
|
'foo',
|
||||||
'foo',
|
'foo',
|
||||||
'http://localhost:3000'
|
'http://localhost:3000'
|
||||||
);
|
));
|
||||||
|
|
||||||
t.is (typeof session, 'string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test ('reject invalid password', async (t) => {
|
test ('reject invalid password', async (t) => {
|
||||||
const session = await client.login (
|
await t.throwsAsync (client.login (
|
||||||
'testuser',
|
'testuser',
|
||||||
'bar',
|
'bar',
|
||||||
'http://localhost:3000'
|
'http://localhost:3000'
|
||||||
);
|
));
|
||||||
|
|
||||||
t.is (typeof session, 'string');
|
|
||||||
});
|
});
|
||||||
|
22
yarn.lock
22
yarn.lock
@ -169,21 +169,21 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
safe-buffer "^5.1.2"
|
safe-buffer "^5.1.2"
|
||||||
|
|
||||||
"@scode/auth-client-helper@^1.0.4":
|
"@scode/auth-client-helper@^1.0.6":
|
||||||
version "1.0.5"
|
version "1.0.6"
|
||||||
resolved "https://npm.scode.ovh/@scode%2fauth-client-helper/-/auth-client-helper-1.0.5.tgz#c8ea2a998311f8ac8798bd56c1edd0a52a39aa6b"
|
resolved "https://npm.scode.ovh/@scode%2fauth-client-helper/-/auth-client-helper-1.0.6.tgz#b6ebee3c488f9af58c20981f68944fbe0dc2ed2d"
|
||||||
integrity sha512-m2UUQyd7iu8Ri1K+mVaLaRv0dZsDSbeT5zu/c+ZgLzWJEWa6Pg4cp2R6l0rU8uElaPDG9Mg//zln6ORemWZl8Q==
|
integrity sha512-+1xqrLNtws1S9TPRk95MguoPeaaQ+iMH8A1R7eWB/MuyhysasKMGkryeOEt9LZvS+m+k+m2aVQVVljTPYPN8wQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@scode/consts" "^1.0.1"
|
"@scode/consts" "^1.0.3"
|
||||||
"@scode/crypto-helper" "^1.0.2"
|
"@scode/crypto-helper" "^1.1.9"
|
||||||
node-fetch "^2.6.0"
|
node-fetch "^2.6.0"
|
||||||
|
|
||||||
"@scode/consts@^1.0.1", "@scode/consts@^1.0.2":
|
"@scode/consts@^1.0.3":
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://npm.scode.ovh/@scode%2fconsts/-/consts-1.0.3.tgz#afeba5e5255a2854be3849d53815f9f593fa20a6"
|
resolved "https://npm.scode.ovh/@scode%2fconsts/-/consts-1.0.3.tgz#afeba5e5255a2854be3849d53815f9f593fa20a6"
|
||||||
integrity sha512-w/7LvhZzIi/nRr5TO1naLyQVdPIPDhOZ99r8lHbjP8TzycAFiwl6cb0tmybab5i4dFq290Xs4hgm62ae/5eEFw==
|
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"
|
version "1.1.9"
|
||||||
resolved "https://npm.scode.ovh/@scode%2fcrypto-helper/-/crypto-helper-1.1.9.tgz#4ae3bd0aba7a3aa909cae73ead0f4ab3a5e511f2"
|
resolved "https://npm.scode.ovh/@scode%2fcrypto-helper/-/crypto-helper-1.1.9.tgz#4ae3bd0aba7a3aa909cae73ead0f4ab3a5e511f2"
|
||||||
integrity sha512-+UKNMrB/uqTtp+0M4hPzNPrvEKNhyoJtXztk//MMGSrKqdXyW12W0fcEi1OPbt+P/6ZUz0saQWwKMMNgabeSwQ==
|
integrity sha512-+UKNMrB/uqTtp+0M4hPzNPrvEKNhyoJtXztk//MMGSrKqdXyW12W0fcEi1OPbt+P/6ZUz0saQWwKMMNgabeSwQ==
|
||||||
@ -250,9 +250,9 @@
|
|||||||
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
|
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
|
||||||
|
|
||||||
"@types/node@*":
|
"@types/node@*":
|
||||||
version "13.7.7"
|
version "13.9.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.7.tgz#1628e6461ba8cc9b53196dfeaeec7b07fa6eea99"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.0.tgz#5b6ee7a77faacddd7de719017d0bc12f52f81589"
|
||||||
integrity sha512-Uo4chgKbnPNlxQwoFmYIwctkQVkMMmsAoGGU4JKwLuvBefF0pCq4FybNSnfkfRCpC7ZW7kttcC/TrRtAJsvGtg==
|
integrity sha512-0ARSQootUG1RljH2HncpsY2TJBfGQIKOOi7kxzUY6z54ePu/ZD+wJA8zI2Q6v8rol2qpG/rvqsReco8zNMPvhQ==
|
||||||
|
|
||||||
"@types/normalize-package-data@^2.4.0":
|
"@types/normalize-package-data@^2.4.0":
|
||||||
version "2.4.0"
|
version "2.4.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user