diff --git a/src/sys/db.ts b/src/sys/db.ts index 4d0bfb5..a83834a 100644 --- a/src/sys/db.ts +++ b/src/sys/db.ts @@ -14,9 +14,9 @@ export const connectToDB = async () => { password: oConf.get("Database", "password"), database: oConf.get("Database", "database"), }); - accounts.deleted.ops.maxRooms = oConf.get("Settings", "defaultMaxRooms"); - accounts.deleted.ops.maxRoomSize = oConf.get("Settings", "defaultMaxRoomSize"); - accounts.deleted.ops.maxUsersPerRoom = oConf.get("Settings", "defaultMaxUsersPerRoom"); + accounts.maxRooms.ops.default = oConf.get("Settings", "defaultMaxRooms"); + accounts.maxRoomSize.ops.default = oConf.get("Settings", "defaultMaxRoomSize"); + accounts.maxUsersPerRoom.ops.default = oConf.get("Settings", "defaultMaxUsersPerRoom"); try { await db.sync(true); log("Database", "Connected to Database!"); @@ -31,9 +31,9 @@ export const connectToDBCredentials = async (host: string, port: number, user: s db.connect({ host, port, user, password, database, }); - accounts.deleted.ops.maxRooms = oConf.get("Settings", "defaultMaxRooms"); - accounts.deleted.ops.maxRoomSize = oConf.get("Settings", "defaultMaxRoomSize"); - accounts.deleted.ops.maxUsersPerRoom = oConf.get("Settings", "defaultMaxUsersPerRoom"); + accounts.maxRooms.ops.default = oConf.get("Settings", "defaultMaxRooms"); + accounts.maxRoomSize.ops.default = oConf.get("Settings", "defaultMaxRoomSize"); + accounts.maxUsersPerRoom.ops.default = oConf.get("Settings", "defaultMaxUsersPerRoom"); try { await db.sync(true); } catch (e) { diff --git a/tests/tester.js b/tests/tester.js deleted file mode 100644 index 3575adc..0000000 --- a/tests/tester.js +++ /dev/null @@ -1,43 +0,0 @@ -import { spawn } from "child_process"; -import { postTester } from "./post.js"; -import { wsTester } from "./ws.js"; - -let inCI = process.argv.includes("ci"); - -const ls = spawn('node', ['.', '-c', inCI ? 'test.juml' : 'testLocal.juml', '-d']); - -process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; - -ls.stdout.on('data', (data) => { - process.stdout.write(data); - if (data.includes("Listening...")) test(); -}); - -ls.stderr.on('data', (data) => { - console.error(`stderr: ${data}`); - -}); - -ls.on('close', (code) => { - console.log(`child process exited with code ${code}`); - process.exit(code); -}); - -function kill() { - ls.kill('SIGINT'); -} - -let startet = false; - -async function test() { - if (startet) return; - startet = true; - console.log("Start testing"); - let url = "localhost:7224"; - await wsTester("wss://" + url + "/", kill); - await postTester("https://" + url + "/", kill); - kill(); -} - - - diff --git a/tests/tests/ws.js b/tests/tests/ws.js index ef39609..beaded8 100644 --- a/tests/tests/ws.js +++ b/tests/tests/ws.js @@ -1,4 +1,5 @@ import { generateSigningKey, sign } from '../../dist/sys/crypto.js'; +import { PERMISSIONS } from '../../dist/server/permissions.js'; let name1 = "testUser1"; let name2 = "testUser2"; @@ -75,6 +76,62 @@ const list = [ await req(h2, "remote2", { sign: await sign(challenge, privateKey) }, "ok", ""); + }], ["account", async (handler, req, newHandler) => { + await req(handler, "signin", { + name: name1, + server: "localhost:7224", + accountKey + }, "ok", ""); + await req(handler, "getMyAccount", {}, "ok", { + rights: PERMISSIONS.ALL, + name: name1, + viewable: true, + maxRooms: 3, + maxRoomSize: 10, + maxUsersPerRoom: 2, + }); + let h2 = await newHandler(); + await req(h2, "signin", { + name: name2, + server: "localhost:7224", + accountKey + }, "ok", ""); + await req(h2, "getMyAccount", {}, "ok", { + rights: PERMISSIONS.DEFAULT, + name: name2, + viewable: true, + maxRooms: 3, + maxRoomSize: 10, + maxUsersPerRoom: 2, + }); + }], ["account", async (handler, req, newHandler) => { + await req(handler, "signin", { + name: name2, + server: "localhost:7224", + accountKey + }, "ok", ""); + await req(handler, "changePassword", { + accountKey: accountKey + "lol" + }, "ok", ""); + let h2 = await newHandler(); + await req(h2, "signin", { + name: name2, + server: "localhost:7224", + accountKey + }, "error", "auth"); + await req(h2, "signin", { + name: name2, + server: "localhost:7224", + accountKey: accountKey + "lol" + }, "ok", ""); + await req(h2, "deleteAccount", {}, "ok", ""); + + let h3 = await newHandler(); + await req(h3, "signin", { + name: name2, + server: "localhost:7224", + accountKey: accountKey + "lol" + }, "error", "auth"); }] ];