account related tests and fixes
This commit is contained in:
parent
a3fb4c4db0
commit
eacb94bfa5
3 changed files with 63 additions and 49 deletions
|
@ -14,9 +14,9 @@ export const connectToDB = async () => {
|
||||||
password: oConf.get("Database", "password"),
|
password: oConf.get("Database", "password"),
|
||||||
database: oConf.get("Database", "database"),
|
database: oConf.get("Database", "database"),
|
||||||
});
|
});
|
||||||
accounts.deleted.ops.maxRooms = oConf.get("Settings", "defaultMaxRooms");
|
accounts.maxRooms.ops.default = oConf.get("Settings", "defaultMaxRooms");
|
||||||
accounts.deleted.ops.maxRoomSize = oConf.get("Settings", "defaultMaxRoomSize");
|
accounts.maxRoomSize.ops.default = oConf.get("Settings", "defaultMaxRoomSize");
|
||||||
accounts.deleted.ops.maxUsersPerRoom = oConf.get("Settings", "defaultMaxUsersPerRoom");
|
accounts.maxUsersPerRoom.ops.default = oConf.get("Settings", "defaultMaxUsersPerRoom");
|
||||||
try {
|
try {
|
||||||
await db.sync(true);
|
await db.sync(true);
|
||||||
log("Database", "Connected to Database!");
|
log("Database", "Connected to Database!");
|
||||||
|
@ -31,9 +31,9 @@ export const connectToDBCredentials = async (host: string, port: number, user: s
|
||||||
db.connect({
|
db.connect({
|
||||||
host, port, user, password, database,
|
host, port, user, password, database,
|
||||||
});
|
});
|
||||||
accounts.deleted.ops.maxRooms = oConf.get("Settings", "defaultMaxRooms");
|
accounts.maxRooms.ops.default = oConf.get("Settings", "defaultMaxRooms");
|
||||||
accounts.deleted.ops.maxRoomSize = oConf.get("Settings", "defaultMaxRoomSize");
|
accounts.maxRoomSize.ops.default = oConf.get("Settings", "defaultMaxRoomSize");
|
||||||
accounts.deleted.ops.maxUsersPerRoom = oConf.get("Settings", "defaultMaxUsersPerRoom");
|
accounts.maxUsersPerRoom.ops.default = oConf.get("Settings", "defaultMaxUsersPerRoom");
|
||||||
try {
|
try {
|
||||||
await db.sync(true);
|
await db.sync(true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
|
@ -75,6 +76,62 @@ const list = [
|
||||||
await req(h2, "remote2", {
|
await req(h2, "remote2", {
|
||||||
sign: await sign(challenge, privateKey)
|
sign: await sign(challenge, privateKey)
|
||||||
}, "ok", "");
|
}, "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");
|
||||||
}]
|
}]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue