Skip to content

Commit df2fc26

Browse files
committed
Fix review comments
1 parent b42919c commit df2fc26

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

forge/comms/v2AuthRoutes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = async function (app) {
4242
result: 'allow',
4343
is_superuser: false,
4444
client_attrs: {
45-
team: 'ff/v1/internal/c/'
45+
team: ''
4646
}
4747
})
4848
} else {

forge/ee/routes/teamBroker/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = async function (app) {
3939
* @memberof forge.routes.api.team.broker
4040
*/
4141
app.get('/clients', {
42+
preHandler: app.needsPermission('broker:clients:list'),
4243
schema: {
4344
summary: 'List MQTT clients for the team',
4445
tags: ['MQTT Broker'],
@@ -80,7 +81,7 @@ module.exports = async function (app) {
8081
* @memberof forge.routes.api.team.broker
8182
*/
8283
app.post('/client', {
83-
preHandler: app.needsPermission('project:create'),
84+
preHandler: app.needsPermission('broker:clients:create'),
8485
schema: {
8586
summary: 'Create new MQTT client for the team',
8687
tags: ['MQTT Broker'],
@@ -139,6 +140,7 @@ module.exports = async function (app) {
139140
* @memberof forge.routes.api.team.broker
140141
*/
141142
app.get('/client/:username', {
143+
preHandler: app.needsPermission('broker:clients:list'),
142144
schema: {
143145
summary: 'Get details about a specific MQTT client',
144146
tags: ['MQTT Broker'],
@@ -181,8 +183,8 @@ module.exports = async function (app) {
181183
* @static
182184
* @memberof forge.routes.api.team.broker
183185
*/
184-
app.patch('/client/:username', {
185-
preHandler: app.needsPermission('project:create'),
186+
app.put('/client/:username', {
187+
preHandler: app.needsPermission('broker:clients:edit'),
186188
schema: {
187189
summary: 'Modify a MQTT Client',
188190
tags: ['MQTT Broker'],
@@ -264,7 +266,7 @@ module.exports = async function (app) {
264266
* @memberof forge.routes.api.team.broker
265267
*/
266268
app.delete('/client/:username', {
267-
preHandler: app.needsPermission('project:create'),
269+
preHandler: app.needsPermission('broker:clients:delete'),
268270
schema: {
269271
summary: 'Delete a MQTT client',
270272
tags: ['MQTT Broker'],

forge/lib/permissions.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ const Permissions = {
172172
'project:files:list': { description: 'List files under a project', role: Roles.Member },
173173
'project:files:create': { description: 'Upload files to a project', role: Roles.Member },
174174
'project:files:edit': { description: 'Modify files in a project', role: Roles.Member },
175-
'project:files:delete': { description: 'Delete files in a project', role: Roles.Member }
175+
'project:files:delete': { description: 'Delete files in a project', role: Roles.Member },
176+
177+
// Team Broker
178+
'broker:clients:list': { description: 'List Team Broker clients', role: Roles.Member },
179+
'broker:clients:create': { description: 'Create Team Broker clients', role: Roles.Admin },
180+
'broker:clients:edit': { description: 'Edit Team Broker clients', role: Roles.Admin },
181+
'broker:clients:delete': { description: 'Delete Team Broker clients', role: Roles.Admin }
176182
}
177183

178184
module.exports = {

test/unit/forge/ee/routes/teamBroker/index_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const setup = require('../../setup')
44

55
const MAX_BROKER_USERS = 5
66

7-
describe('Team Broker API', function () {
7+
describe.only('Team Broker API', function () {
88
let app
99
const TestObjects = { tokens: {} }
1010

@@ -101,7 +101,7 @@ describe('Team Broker API', function () {
101101

102102
it('Modify an existing MQTT broker user for a team', async function () {
103103
const response = await app.inject({
104-
method: 'PATCH',
104+
method: 'PUT',
105105
url: `/api/v1/teams/${app.team.hashid}/broker/client/alice`,
106106
body: {
107107
acls: [
@@ -264,7 +264,7 @@ describe('Team Broker API', function () {
264264
})
265265
it('Test Authentication pass after password change', async function () {
266266
let response = await app.inject({
267-
method: 'PATCH',
267+
method: 'PUT',
268268
url: `/api/v1/teams/${app.team.hashid}/broker/client/alice`,
269269
body: {
270270
password: 'ccPassword'
@@ -399,7 +399,7 @@ describe('Team Broker API', function () {
399399
result.should.have.property('result', 'allow')
400400
result.should.have.property('is_superuser', false)
401401
result.should.have.property('client_attrs')
402-
result.client_attrs.should.have.property('team', 'ff/v1/internal/c/')
402+
result.client_attrs.should.have.property('team', '')
403403
})
404404
it('Test Authentication forge_platform fail', async function () {
405405
const response = await app.inject({

0 commit comments

Comments
 (0)