Reworking stuff

This commit is contained in:
2023-05-08 15:29:19 +02:00
parent c4a97644ed
commit 61590f684e
25 changed files with 1349 additions and 883 deletions

View File

@@ -1,4 +1,4 @@
FROM node:17.6.0-alpine3.15
FROM node:18.16.0-alpine3.17
WORKDIR /srv

1767
tests/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,11 +10,11 @@
"author": "Lilleman",
"license": "ISC",
"dependencies": {
"dotenv": "10.0.0",
"got": "11.8.2",
"jsonwebtoken": "8.5.1",
"dotenv": "16.0.3",
"got": "12.6.0",
"jsonwebtoken": "9.0.0",
"tap-spec": "5.0.0",
"tape": "5.3.1",
"tape-es": "1.2.15"
"tape": "5.6.3",
"tape-es": "1.2.17"
}
}

View File

@@ -39,13 +39,13 @@ test('test-cases/01basic.js: Authing with configurated API KEY', async t => {
test('test-cases/01basic.js: GETting the admin account, with the token we just obtained', async t => {
try {
await got(`${process.env.AUTH_URL}/account/${adminJWT.accountId}`);
t.fail('Calling /account/{id} without proper auth token should give 403');
await got(`${process.env.AUTH_URL}/accounts/${adminJWT.accountId}`);
t.fail('Calling /accounts/{id} without proper auth token should give 403');
} catch (err) {
t.equal(err.message, 'Response code 403 (Forbidden)', 'Calling /account/{id} without proper auth token should give 403');
t.equal(err.message, 'Response code 403 (Forbidden)', 'Calling /accounts/{id} without proper auth token should give 403');
}
const accountRes = await got(`${process.env.AUTH_URL}/account/${adminJWT.accountId}`, {
const accountRes = await got(`${process.env.AUTH_URL}/accounts/${adminJWT.accountId}`, {
headers: { 'Authorization': `bearer ${adminJWTString}`},
responseType: 'json',
});
@@ -155,8 +155,8 @@ test('test-cases/01basic.js: Auth by empty username and empty password', async t
}
});
test('test-cases/01basic.js: PUT /account/{id}/fields', async t => {
const res = await got.put(`${process.env.AUTH_URL}/account/${user.id}/fields`, {
test('test-cases/01basic.js: PUT /accounts/{id}/fields', async t => {
const res = await got.put(`${process.env.AUTH_URL}/accounts/${user.id}/fields`, {
headers: { 'Authorization': `bearer ${adminJWTString}`},
json: [
{
@@ -184,7 +184,7 @@ test('test-cases/01basic.js: PUT /account/{id}/fields', async t => {
test('test-cases/01basic.js: Remove an account', async t => {
try {
// Random uuid that should not exist in the db. The chance of this existing is... small
await got.delete(`${process.env.AUTH_URL}/account/a423e690-74b9-4f37-9976-f5bf75a5ea32`, {
await got.delete(`${process.env.AUTH_URL}/accounts/a423e690-74b9-4f37-9976-f5bf75a5ea32`, {
headers: { 'Authorization': `bearer ${adminJWTString}`},
responseType: 'json',
retry: 0,
@@ -194,7 +194,7 @@ test('test-cases/01basic.js: Remove an account', async t => {
t.equal(err.message, 'Response code 404 (Not Found)', 'Response status for DELETing an account that does not exist should be 404');
}
const delRes = await got.delete(`${process.env.AUTH_URL}/account/${user.id}`, {
const delRes = await got.delete(`${process.env.AUTH_URL}/accounts/${user.id}`, {
headers: { 'Authorization': `bearer ${adminJWTString}`},
responseType: 'json',
retry: 0,
@@ -203,7 +203,7 @@ test('test-cases/01basic.js: Remove an account', async t => {
t.equal(delRes.statusCode, 204, 'Response status for DELETE should be 204');
try {
await got(`${process.env.AUTH_URL}/account/${user.id}`, {
await got(`${process.env.AUTH_URL}/accounts/${user.id}`, {
headers: { 'Authorization': `bearer ${adminJWTString}`},
responseType: 'json',
retry: 0,