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
6 changes: 6 additions & 0 deletions src/api.authz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1139,4 +1139,10 @@ describe('API authz tests', () => {
await agent.post('/alpha/teams/team1/agents').send(agentData).expect(401)
})
})
test('team member cannot access settings', async () => {
await agent.get('/v1/settings').set('Authorization', `Bearer ${teamMemberToken}`).expect(403)
})
test('team admin cannot access settings', async () => {
await agent.get('/v1/settings').set('Authorization', `Bearer ${teamAdminToken}`).expect(403)
})
})
6 changes: 3 additions & 3 deletions src/api/v1/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const debug = Debug('otomi:api:v1:dashboard')
* Get dashboard information
*/
export const getDashboard = (req: OpenApiRequestExt, res: Response): void => {
const { teamName } = req.query
debug(`getDashboard(${teamName})`)
const v = req.otomi.getDashboard(teamName as string)
const { teamId } = req.query
debug(`getDashboard(${teamId})`)
const v = req.otomi.getDashboard(teamId as string)
res.json(v)
}
2 changes: 0 additions & 2 deletions src/openapi/settings.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Settings:
x-acl:
platformAdmin: [read-any, update-any]
teamAdmin: [read]
teamMember: [read]
additionalProperties: false
properties:
alerts:
Expand Down
14 changes: 7 additions & 7 deletions src/otomi-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1278,13 +1278,13 @@ export default class OtomiStack {
return internalRepoUrls
}

getDashboard(teamName: string): Array<any> {
const codeRepos = teamName ? this.getTeamAplCodeRepos(teamName) : this.getAllCodeRepos()
const builds = teamName ? this.getTeamAplBuilds(teamName) : this.getAllBuilds()
const workloads = teamName ? this.getTeamAplWorkloads(teamName) : this.getAllWorkloads()
const services = teamName ? this.getTeamAplServices(teamName) : this.getAllServices()
const secrets = teamName ? this.getAplSealedSecrets(teamName) : this.getAllAplSealedSecrets()
const netpols = teamName ? this.getTeamAplNetpols(teamName) : this.getAllNetpols()
getDashboard(teamId: string): Array<any> {
const codeRepos = teamId ? this.getTeamAplCodeRepos(teamId) : this.getAllCodeRepos()
const builds = teamId ? this.getTeamAplBuilds(teamId) : this.getAllBuilds()
const workloads = teamId ? this.getTeamAplWorkloads(teamId) : this.getAllWorkloads()
const services = teamId ? this.getTeamAplServices(teamId) : this.getAllServices()
const secrets = teamId ? this.getAplSealedSecrets(teamId) : this.getAllAplSealedSecrets()
const netpols = teamId ? this.getTeamAplNetpols(teamId) : this.getAllNetpols()

return [
{ name: 'code-repositories', count: codeRepos?.length },
Expand Down
Loading