post test

This commit is contained in:
jusax23 2023-03-18 12:46:17 +01:00
parent eacb94bfa5
commit 8ea756921d
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
4 changed files with 49 additions and 3 deletions

View file

@ -62,7 +62,7 @@ async function postTester(url) {
} }
if (typeof expData == "object" && expData != null) { if (typeof expData == "object" && expData != null) {
if (!shallowEqual(expData, resp.data)) { if (!shallowEqual(expData, resp.data)) {
console.error(`Expected data: '${expData}', but got: '${resp.data}'`); console.error(`Expected data: '${JSON.stringify(expData, null, 2)}', but got: '${JSON.stringify(resp.data, null, 2)}'`);
kill(); kill();
process.exit(1); process.exit(1);
} }

View file

@ -1,4 +1,5 @@
import { generateSigningKey, sign } from '../../dist/sys/crypto.js'; import { generateSigningKey, sign } from '../../dist/sys/crypto.js';
import { PERMISSIONS } from '../../dist/server/permissions.js';
let name1 = "testUser1"; let name1 = "testUser1";
let name2 = "testUser2"; let name2 = "testUser2";
@ -88,6 +89,51 @@ const list = [
sign: await sign(challenge, privateKey) sign: await sign(challenge, privateKey)
}, "ok", ""); }, "ok", "");
}], ["account", async (req) => {
await req({
"authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}`
}, "getMyAccount", {}, "ok", {
rights: PERMISSIONS.ALL,
name: name1,
viewable: true,
maxRooms: 3,
maxRoomSize: 10,
maxUsersPerRoom: 2,
});
await req({
"authorization": `Digest name=${name2} server=localhost:7224 accountKey=${accountKey}`
}, "getMyAccount", {}, "ok", {
rights: PERMISSIONS.DEFAULT,
name: name2,
viewable: true,
maxRooms: 3,
maxRoomSize: 10,
maxUsersPerRoom: 2,
});
}], ["change account", async (req) => {
await req({
"authorization": `Digest name=${name2} server=localhost:7224 accountKey=${accountKey}`
}, "changePassword", {
accountKey: accountKey + "lol"
}, "ok", "");
await req({}, "signin", {
name: name2,
server: "localhost:7224",
accountKey
}, "error", "auth");
await req({}, "signin", {
name: name2,
server: "localhost:7224",
accountKey: accountKey + "lol"
}, "ok", "");
await req({
"authorization": `Digest name=${name2} server=localhost:7224 accountKey=${accountKey + "lol"}`
}, "deleteAccount", {}, "ok", "");
await req({}, "signin", {
name: name2,
server: "localhost:7224",
accountKey: accountKey + "lol"
}, "error", "auth");
}] }]
]; ];

View file

@ -104,7 +104,7 @@ const list = [
maxRoomSize: 10, maxRoomSize: 10,
maxUsersPerRoom: 2, maxUsersPerRoom: 2,
}); });
}], ["account", async (handler, req, newHandler) => { }], ["change account", async (handler, req, newHandler) => {
await req(handler, "signin", { await req(handler, "signin", {
name: name2, name: name2,
server: "localhost:7224", server: "localhost:7224",

View file

@ -110,7 +110,7 @@ async function wsTester(url) {
} }
if (typeof expData == "object" && expData != null) { if (typeof expData == "object" && expData != null) {
if (!shallowEqual(expData, resp.data)) { if (!shallowEqual(expData, resp.data)) {
console.error(`Expected data: '${expData}', but got: '${resp.data}'`); console.error(`Expected data: '${JSON.stringify(expData, null, 2)}', but got: '${JSON.stringify(resp.data, null, 2)}'`);
kill(); kill();
process.exit(1); process.exit(1);
} }