mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 07:24:52 +09:00
Fix tests relating to permissions
This commit is contained in:
4 files changed
+19
-15
No files matched your search
@@ -8,16 +8,17 @@ export default class Permission {
|
||||
public name: string,
|
||||
public title: string,
|
||||
public description: string,
|
||||
public grantByDefault?: boolean,
|
||||
public grantByDefault: boolean = false,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
name: Type.String(),
|
||||
title: Type.String(),
|
||||
description: Type.String(),
|
||||
grantByDefault: Type.Optional(Type.Boolean()),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.name, json.title, json.description);
|
||||
return new this(json.name, json.title, json.description, Boolean(json.grantByDefault));
|
||||
}
|
||||
}
|
||||
@@ -1655,12 +1655,13 @@ describe("Integration of Clusterio", function() {
|
||||
});
|
||||
it("should grant default permissions with --grant-default", async function() {
|
||||
await execCtl("role edit new --grant-default");
|
||||
let roles = await getControl().send(new lib.RoleListRequest());
|
||||
const control = getControl();
|
||||
let roles = await control.send(new lib.RoleListRequest());
|
||||
let newRole = roles.find(role => role.name === "new");
|
||||
let defaultPermissions = [...lib.permissions.values()]
|
||||
const permissions = await control.send(new lib.PermissionListRequest());
|
||||
const defaultPermissions = permissions
|
||||
.filter(p => p.grantByDefault)
|
||||
.map(p => p.name)
|
||||
;
|
||||
.map(p => p.name);
|
||||
assert.deepEqual(new Set(newRole.permissions), new Set(defaultPermissions));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -240,14 +240,16 @@ describe("lib/config/definitions/validators", function() {
|
||||
});
|
||||
|
||||
describe("plugin.load_plugin", function() {
|
||||
const initialConfigFields = {
|
||||
"global_chat.load_plugin": false,
|
||||
"inventory_sync.load_plugin": false,
|
||||
"player_auth.load_plugin": false,
|
||||
"research_sync.load_plugin": false,
|
||||
"statistics_exporter.load_plugin": false,
|
||||
"subspace_storage.load_plugin": false,
|
||||
};
|
||||
const initialConfigFields = {};
|
||||
|
||||
before(function() {
|
||||
for (const fieldName of Object.keys(InstanceConfig.fieldDefinitions)) {
|
||||
if (fieldName.endsWith("load_plugin")) {
|
||||
initialConfigFields[fieldName] = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("should validate against factorio.enable_save_patching", function() {
|
||||
class TestInstanceConfig extends InstanceConfig {
|
||||
static fieldDefinitions = { ...InstanceConfig.fieldDefinitions };
|
||||
|
||||
@@ -586,7 +586,7 @@ describe("lib/subscriptions", function() {
|
||||
});
|
||||
|
||||
it("should throw if action is not supported", async function() {
|
||||
const request = new lib.SubscriptionRequest(StringPermissionEvent.name, "invalid action");
|
||||
const request = new lib.SubscriptionRequest(RegisteredEvent.name, "invalid action");
|
||||
await assert.rejects(subscriptions.handleRequest(
|
||||
getLink(0), request, connectorSetupDate[0].dst, connectorSetupDate[0].src
|
||||
), /unreachable case: invalid action/);
|
||||
|
||||
Reference in new issue
Block a user