Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions apps/meteor/ee/server/api/abac/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,11 @@ const abacEndpoints = API.v1
400: GenericErrorSchema,
403: validateUnauthorizedErrorResponse,
},
license: ['abac'],
},
async function action() {
const { offset, count } = await getPaginationItems(this.queryParams as Record<string, string | string[] | number | null | undefined>);
const { key, values } = this.queryParams;

if (!settings.get('ABAC_Enabled')) {
throw new Error('error-abac-not-enabled');
}

return API.v1.success(
await Abac.listAbacAttributes({
key,
Expand Down Expand Up @@ -239,13 +234,10 @@ const abacEndpoints = API.v1
400: GenericErrorSchema,
403: validateUnauthorizedErrorResponse,
},
license: ['abac'],
},
async function action() {
const { _id } = this.urlParams;
if (!settings.get('ABAC_Enabled')) {
throw new Error('error-abac-not-enabled');
}

const result = await Abac.getAbacAttributeById(_id);
return API.v1.success(result);
},
Expand All @@ -262,13 +254,10 @@ const abacEndpoints = API.v1
400: GenericErrorSchema,
403: validateUnauthorizedErrorResponse,
},
license: ['abac'],
},
async function action() {
const { _id } = this.urlParams;
if (!settings.get('ABAC_Enabled')) {
throw new Error('error-abac-not-enabled');
}

await Abac.deleteAbacAttributeById(_id);
return API.v1.success();
},
Expand All @@ -285,13 +274,10 @@ const abacEndpoints = API.v1
400: GenericErrorSchema,
403: validateUnauthorizedErrorResponse,
},
license: ['abac'],
},
async function action() {
const { key } = this.urlParams;
if (!settings.get('ABAC_Enabled')) {
throw new Error('error-abac-not-enabled');
}

const inUse = await Abac.isAbacAttributeInUseByKey(key);
return API.v1.success({ inUse });
},
Expand Down
40 changes: 0 additions & 40 deletions apps/meteor/tests/end-to-end/api/abac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,26 +990,6 @@ const addAbacAttributesToUserDirectly = async (userId: string, abacAttributes: I
});
});

it('GET /abac/attributes should fail while disabled', async () => {
await request
.get(`${v1}/abac/attributes`)
.set(credentials)
.expect(400)
.expect((res) => {
expect(res.body.error).to.include('error-abac-not-enabled');
});
});

it('GET /abac/attributes/:_id should fail while disabled', async () => {
await request
.get(`${v1}/abac/attributes/${secondAttributeId}`)
.set(credentials)
.expect(400)
.expect((res) => {
expect(res.body.error).to.include('error-abac-not-enabled');
});
});

it('PUT /abac/attributes/:_id should fail while disabled', async () => {
await request
.put(`${v1}/abac/attributes/${secondAttributeId}`)
Expand All @@ -1021,26 +1001,6 @@ const addAbacAttributesToUserDirectly = async (userId: string, abacAttributes: I
});
});

it('DELETE /abac/attributes/:_id should fail while disabled', async () => {
await request
.delete(`${v1}/abac/attributes/${secondAttributeId}`)
.set(credentials)
.expect(400)
.expect((res) => {
expect(res.body.error).to.include('error-abac-not-enabled');
});
});

it('GET /abac/attributes/:key/is-in-use should fail while disabled', async () => {
await request
.get(`${v1}/abac/attributes/${secondKey}/is-in-use`)
.set(credentials)
.expect(400)
.expect((res) => {
expect(res.body.error).to.include('error-abac-not-enabled');
});
});

it('POST /abac/rooms/:rid/attributes/:key should fail while disabled', async () => {
await request
.post(`${v1}/abac/rooms/${testRoom._id}/attributes/${secondKey}`)
Expand Down
Loading