mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 15:04:52 +09:00
Move integration tests for lists sync
Move the integration tests for the admin, user, and ban list sync to be done while an instance is running in order to hit more lines in the coverage with them.
This commit is contained in:
1 parent
84450b83b4
commit
08ec542907
1 file changed
+44
-44
@@ -170,6 +170,50 @@ describe("Integration of Clusterio", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("user set-admin/whitelisted/banned", function() {
|
||||
async function getUsers() {
|
||||
let result = await link.messages.listUsers.send(getControl());
|
||||
return new Map(result.list.map(user => [user.name, user]));
|
||||
}
|
||||
|
||||
let lists = ["admin", "whitelisted", "banned"];
|
||||
it("should add and remove the given user to the list", async function() {
|
||||
slowTest(this);
|
||||
await link.messages.createUser.send(getControl(), { name: "list_test" });
|
||||
let user = (await getUsers()).get("list_test");
|
||||
for (let list of lists) {
|
||||
assert.equal(user[`is_${list}`], false, `unexpected ${list} status`);
|
||||
await execCtl(`user set-${list} list_test`);
|
||||
}
|
||||
user = (await getUsers()).get("list_test");
|
||||
for (let list of lists) {
|
||||
assert.equal(user[`is_${list}`], true, `unexpected ${list} status`);
|
||||
let remove = { admin: "--revoke", whitelisted: "--remove", banned: "--pardon" }[list];
|
||||
await execCtl(`user set-${list} ${remove} list_test`);
|
||||
}
|
||||
user = (await getUsers()).get("list_test");
|
||||
for (let list of lists) {
|
||||
assert.equal(user[`is_${list}`], false, `unexpected ${list} status`);
|
||||
}
|
||||
});
|
||||
it("should not create the user if not instructed to", async function() {
|
||||
for (let list of lists) {
|
||||
try {
|
||||
await execCtl(`user set-${list} no_create_test`);
|
||||
} catch (err) { /* ignore */ }
|
||||
}
|
||||
let user = (await getUsers()).get("no_create_test");
|
||||
assert.equal(user, undefined, "user was unexpectedly created");
|
||||
});
|
||||
it("should create the user if instructed to", async function() {
|
||||
for (let list of lists) {
|
||||
await execCtl(`user set-${list} --create test_create_${list}`);
|
||||
let user = (await getUsers()).get(`test_create_${list}`);
|
||||
assert.equal(user && user[`is_${list}`], true, `user not created and added to ${list}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("instance stop", function() {
|
||||
it("stops the instance", async function() {
|
||||
slowTest(this);
|
||||
@@ -242,50 +286,6 @@ describe("Integration of Clusterio", function() {
|
||||
});
|
||||
});
|
||||
|
||||
async function getUsers() {
|
||||
let result = await link.messages.listUsers.send(getControl());
|
||||
return new Map(result.list.map(user => [user.name, user]));
|
||||
}
|
||||
|
||||
describe("user set-admin/whitelisted/banned", function() {
|
||||
let lists = ["admin", "whitelisted", "banned"];
|
||||
it("should add and remove the given user to the list", async function() {
|
||||
slowTest(this);
|
||||
await link.messages.createUser.send(getControl(), { name: "list_test" });
|
||||
let user = (await getUsers()).get("list_test");
|
||||
for (let list of lists) {
|
||||
assert.equal(user[`is_${list}`], false, `unexpected ${list} status`);
|
||||
await execCtl(`user set-${list} list_test`);
|
||||
}
|
||||
user = (await getUsers()).get("list_test");
|
||||
for (let list of lists) {
|
||||
assert.equal(user[`is_${list}`], true, `unexpected ${list} status`);
|
||||
let remove = { admin: "--revoke", whitelisted: "--remove", banned: "--pardon" }[list];
|
||||
await execCtl(`user set-${list} ${remove} list_test`);
|
||||
}
|
||||
user = (await getUsers()).get("list_test");
|
||||
for (let list of lists) {
|
||||
assert.equal(user[`is_${list}`], false, `unexpected ${list} status`);
|
||||
}
|
||||
});
|
||||
it("should not create the user if not instructed to", async function() {
|
||||
for (let list of lists) {
|
||||
try {
|
||||
await execCtl(`user set-${list} no_create_test`);
|
||||
} catch (err) { /* ignore */ }
|
||||
}
|
||||
let user = (await getUsers()).get("no_create_test");
|
||||
assert.equal(user, undefined, "user was unexpectedly created");
|
||||
});
|
||||
it("should create the user if instructed to", async function() {
|
||||
for (let list of lists) {
|
||||
await execCtl(`user set-${list} --create test_create_${list}`);
|
||||
let user = (await getUsers()).get(`test_create_${list}`);
|
||||
assert.equal(user && user[`is_${list}`], true, `user not created and added to ${list}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("user set-roles", function() {
|
||||
it("should set the roles on the user", async function() {
|
||||
await execCtl("user set-roles temp Admin");
|
||||
|
||||
Reference in new issue
Block a user