From 9f0d325bfdef538effb550289125a8af698ad1a2 Mon Sep 17 00:00:00 2001 From: maxceem Date: Tue, 20 Oct 2020 15:41:19 +0300 Subject: [PATCH 1/8] feat: updated project permissions - also updated Permissions HTML CSS styles ref issue #4135 --- docs/permissions.html | 222 ++------------------------- scripts/permissions-doc/template.hbs | 17 +- src/permissions/constants.js | 39 ++--- 3 files changed, 37 insertions(+), 241 deletions(-) diff --git a/docs/permissions.html b/docs/permissions.html index 33f4d536..ad9e0c98 100644 --- a/docs/permissions.html +++ b/docs/permissions.html @@ -85,6 +85,11 @@ background-color: #b8daff; vertical-align: middle; } + + .badge-crossed { + opacity: 0.4; + text-decoration: line-through; + } @@ -96,11 +101,11 @@

Permissions

Legend:

@@ -175,7 +180,7 @@

Read Project
READ_PROJECT
-
+
Read project when user is a member.
@@ -219,14 +224,6 @@

Connect Admin administrator Connect Manager - Connect Account Manager - Connect Copilot Manager - Business Development Representative - Presales - Account Executive - Program Manager - Solution Architect - Project Manager

@@ -1260,84 +1257,6 @@

✅ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - copilot - - - - - - - - - - - - - - - - - - - - ✅ - - - - - - - - - - - - - - - - - - - account_manager - - ✅ - - - - - - ✅ @@ -1351,92 +1270,14 @@

- - ✅ - - - ✅ - - + ✅ - + ✅ - - - - - - - account_executive - - - - - - - - - - - - - - - - - - - - ✅ - - - - - - - - - - - - - - - - project_manager - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ✅ @@ -1446,16 +1287,7 @@

- solution_architect - - - - - - - - - + copilot @@ -1483,36 +1315,6 @@

- - - program_manager - - - - - - - - - - - - - - - - - - - - - - - - - - ✅ - diff --git a/scripts/permissions-doc/template.hbs b/scripts/permissions-doc/template.hbs index 41d49140..f4a9a644 100644 --- a/scripts/permissions-doc/template.hbs +++ b/scripts/permissions-doc/template.hbs @@ -85,6 +85,11 @@ background-color: #b8daff; vertical-align: middle; } + + .badge-crossed { + opacity: 0.4; + text-decoration: line-through; + } @@ -96,11 +101,11 @@

Legend:

  • allowed Project Role - users with such a Project Role are allowed to perform the action
  • -
  • denied Project Role - users with such a Project Role are denied to perform the action even they have some other allow roles
  • +
  • denied Project Role - users with such a Project Role are denied to perform the action even they have some other allow roles
  • allowed Topcoder Role - users with such a Topcoder Role are allowed to perform the action
  • -
  • denied Topcoder Role - users with such a Topcoder Role are denied to perform the action even they have some other allow roles
  • +
  • denied Topcoder Role - users with such a Topcoder Role are denied to perform the action even they have some other allow roles
  • allowed M2M Scope - M2M tokens with such a scope are allowed to perform the action
  • -
  • denied M2M Scope - M2M tokens with such a scope are allowed to perform the action even they have some other allow scopes
  • +
  • denied M2M Scope - M2M tokens with such a scope are allowed to perform the action even they have some other allow scopes

@@ -131,7 +136,7 @@ {{/each}} {{/if}} {{#each denyRule.projectRoles}} - {{this}} + {{this}} {{/each}}
@@ -144,7 +149,7 @@ {{/each}} {{/if}} {{#each denyRule.topcoderRoles}} - {{this}} + {{this}} {{/each}} @@ -153,7 +158,7 @@ {{this}} {{/each}} {{#each denyRule.scopes}} - {{this}} + {{this}} {{/each}} diff --git a/src/permissions/constants.js b/src/permissions/constants.js index 6c65d0d7..bb615745 100644 --- a/src/permissions/constants.js +++ b/src/permissions/constants.js @@ -161,6 +161,7 @@ export const PERMISSION = { // eslint-disable-line import/prefer-default-export meta: { title: 'Read Project', group: 'Project', + description: 'Read project when user is a member.', }, topcoderRoles: TOPCODER_ROLES_MANAGERS_AND_ADMINS, projectRoles: ALL, @@ -173,7 +174,10 @@ export const PERMISSION = { // eslint-disable-line import/prefer-default-export group: 'Project', description: 'Read any project, even when not a member.', }, - topcoderRoles: TOPCODER_ROLES_MANAGERS_AND_ADMINS, + topcoderRoles: [ + ...TOPCODER_ROLES_ADMINS, + USER_ROLE.MANAGER, + ], scopes: SCOPES_PROJECTS_READ, }, @@ -577,12 +581,6 @@ export const PROJECT_TO_TOPCODER_ROLES_MATRIX = { USER_ROLE.TOPCODER_ADMIN, USER_ROLE.CONNECT_ADMIN, USER_ROLE.MANAGER, - ], - [PROJECT_MEMBER_ROLE.COPILOT]: [ - USER_ROLE.COPILOT, - ], - [PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER]: [ - USER_ROLE.MANAGER, USER_ROLE.TOPCODER_ACCOUNT_MANAGER, USER_ROLE.BUSINESS_DEVELOPMENT_REPRESENTATIVE, USER_ROLE.PRESALES, @@ -591,17 +589,8 @@ export const PROJECT_TO_TOPCODER_ROLES_MATRIX = { USER_ROLE.SOLUTION_ARCHITECT, USER_ROLE.PROJECT_MANAGER, ], - [PROJECT_MEMBER_ROLE.ACCOUNT_EXECUTIVE]: [ - USER_ROLE.ACCOUNT_EXECUTIVE, - ], - [PROJECT_MEMBER_ROLE.PROJECT_MANAGER]: [ - USER_ROLE.PROJECT_MANAGER, - ], - [PROJECT_MEMBER_ROLE.SOLUTION_ARCHITECT]: [ - USER_ROLE.SOLUTION_ARCHITECT, - ], - [PROJECT_MEMBER_ROLE.PROGRAM_MANAGER]: [ - USER_ROLE.PROGRAM_MANAGER, + [PROJECT_MEMBER_ROLE.COPILOT]: [ + USER_ROLE.COPILOT, ], }; @@ -626,28 +615,28 @@ export const DEFAULT_PROJECT_ROLE = [ projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.TOPCODER_ACCOUNT_MANAGER, - projectRole: PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.BUSINESS_DEVELOPMENT_REPRESENTATIVE, - projectRole: PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.PRESALES, - projectRole: PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.COPILOT, projectRole: PROJECT_MEMBER_ROLE.COPILOT, }, { topcoderRole: USER_ROLE.ACCOUNT_EXECUTIVE, - projectRole: PROJECT_MEMBER_ROLE.ACCOUNT_EXECUTIVE, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.PROGRAM_MANAGER, - projectRole: PROJECT_MEMBER_ROLE.PROGRAM_MANAGER, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.SOLUTION_ARCHITECT, - projectRole: PROJECT_MEMBER_ROLE.SOLUTION_ARCHITECT, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.PROJECT_MANAGER, - projectRole: PROJECT_MEMBER_ROLE.PROJECT_MANAGER, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.TOPCODER_USER, projectRole: PROJECT_MEMBER_ROLE.CUSTOMER, From 827d096ac812686bb4417d73b50da6908988aa80 Mon Sep 17 00:00:00 2001 From: maxceem Date: Tue, 20 Oct 2020 15:42:10 +0300 Subject: [PATCH 2/8] chore: improve local setup process set default value for Identity Service in DEV environment --- config/development.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/development.json b/config/development.json index 631024c1..3f3e909b 100644 --- a/config/development.json +++ b/config/development.json @@ -5,5 +5,6 @@ "connectProjectsUrl": "https://connect.topcoder-dev.com/projects/", "fileServiceEndpoint": "https://api.topcoder-dev.com/v3/files/", "connectProjectsUrl": "https://connect.topcoder-dev.com/projects/", - "memberServiceEndpoint": "https://api.topcoder-dev.com/v3/members" + "memberServiceEndpoint": "https://api.topcoder-dev.com/v3/members", + "identityServiceEndpoint": "https://api.topcoder-dev.com/v3/" } From 1384f4d797d433b91b6e11c32828a58ec04346bd Mon Sep 17 00:00:00 2001 From: maxceem Date: Tue, 20 Oct 2020 16:13:15 +0300 Subject: [PATCH 3/8] fix: remove unit tests that are not valid anymore ref issue #4135 --- .../projectMemberInvites/create.spec.js | 25 ------------------- src/routes/projectMembers/create.spec.js | 11 -------- 2 files changed, 36 deletions(-) diff --git a/src/routes/projectMemberInvites/create.spec.js b/src/routes/projectMemberInvites/create.spec.js index cef73d72..76493414 100644 --- a/src/routes/projectMemberInvites/create.spec.js +++ b/src/routes/projectMemberInvites/create.spec.js @@ -723,31 +723,6 @@ describe('Project Member Invite create', () => { }); }); - it('should return 201 if try to create account_manager with MANAGER_ROLES', (done) => { - util.getUserRoles.restore(); - sandbox.stub(util, 'getUserRoles', () => Promise.resolve([USER_ROLE.MANAGER])); - request(server) - .post(`/v5/projects/${project1.id}/invites`) - .set({ - Authorization: `Bearer ${testUtil.jwts.manager}`, - }) - .send({ - handles: ['test_manager4'], - role: 'account_manager', - }) - .expect('Content-Type', /json/) - .expect(201) - .end((err, res) => { - const resJson = res.body.success[0]; - should.exist(resJson); - resJson.role.should.equal('account_manager'); - resJson.projectId.should.equal(project1.id); - resJson.userId.should.equal(40051336); - server.services.pubsub.publish.calledWith('project.member.invite.created').should.be.true; - done(); - }); - }); - it('should return 403 if try to create account_manager with CUSTOMER_ROLE', (done) => { util.getUserRoles.restore(); sandbox.stub(util, 'getUserRoles', () => Promise.resolve(['Topcoder User'])); diff --git a/src/routes/projectMembers/create.spec.js b/src/routes/projectMembers/create.spec.js index 12234fc4..536323f5 100644 --- a/src/routes/projectMembers/create.spec.js +++ b/src/routes/projectMembers/create.spec.js @@ -344,17 +344,6 @@ describe('Project Members create', () => { .expect(401, done); }); - it('should return 401 if register admin as role other than manager (project manager) ', (done) => { - request(server) - .post(`/v5/projects/${project1.id}/members/`) - .set({ - Authorization: `Bearer ${testUtil.jwts.admin}`, - }) - .send({ role: PROJECT_MEMBER_ROLE.PROJECT_MANAGER }) - .expect('Content-Type', /json/) - .expect(401, done); - }); - describe('Bus api', () => { let createEventSpy; From 422d744028fc22982ddcdbd82696a6ba6fdeb40c Mon Sep 17 00:00:00 2001 From: RishiRaj Date: Mon, 2 Nov 2020 20:17:37 +0530 Subject: [PATCH 4/8] Deploy feature to dev. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ab77efc..0a68088b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -115,7 +115,7 @@ workflows: - test filters: branches: - only: ['develop'] + only: ['develop', 'feature/project-permissions-updates'] - deployProd: context : org-global requires: From aad5f294e2b1fca6e6f8fa0671ab70cf0e9a6533 Mon Sep 17 00:00:00 2001 From: maxceem Date: Wed, 4 Nov 2020 15:41:25 +0200 Subject: [PATCH 5/8] fix: allow Copilot Manager be invited as "manager" --- docs/permissions.html | 12 +++++++++++- src/permissions/constants.js | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/permissions.html b/docs/permissions.html index ad9e0c98..a7a2b570 100644 --- a/docs/permissions.html +++ b/docs/permissions.html @@ -1194,6 +1194,7 @@

Project \ Topcoder
Connect Manager
+
Connect Copilot Manager
Connect Admin
administrator
Connect Account Manager
@@ -1243,6 +1244,9 @@

✅ + + ✅ + ✅ @@ -1267,6 +1271,9 @@

✅ + + ✅ + @@ -1305,6 +1312,9 @@

+ + + ✅ @@ -1328,7 +1338,7 @@

- +
- means default Project Role if user with according Topcoder Role directly joins the project (if they are allowed to join directly). If user has multiple Topcoder Roles then the most left Topcoder Role on the table would define default Project Role. diff --git a/src/permissions/constants.js b/src/permissions/constants.js index bb615745..589b8531 100644 --- a/src/permissions/constants.js +++ b/src/permissions/constants.js @@ -588,6 +588,7 @@ export const PROJECT_TO_TOPCODER_ROLES_MATRIX = { USER_ROLE.PROGRAM_MANAGER, USER_ROLE.SOLUTION_ARCHITECT, USER_ROLE.PROJECT_MANAGER, + USER_ROLE.COPILOT_MANAGER, ], [PROJECT_MEMBER_ROLE.COPILOT]: [ USER_ROLE.COPILOT, @@ -607,6 +608,9 @@ export const DEFAULT_PROJECT_ROLE = [ { topcoderRole: USER_ROLE.MANAGER, projectRole: PROJECT_MEMBER_ROLE.MANAGER, + }, { + topcoderRole: USER_ROLE.COPILOT_MANAGER, + projectRole: PROJECT_MEMBER_ROLE.MANAGER, }, { topcoderRole: USER_ROLE.CONNECT_ADMIN, projectRole: PROJECT_MEMBER_ROLE.MANAGER, From 4f7dab193b52a85cc1e5719a671716e2d9841fdf Mon Sep 17 00:00:00 2001 From: maxceem Date: Fri, 6 Nov 2020 10:13:14 +0200 Subject: [PATCH 6/8] fix: read project permission --- docs/permissions.html | 8 -------- src/permissions/constants.js | 5 ++++- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/permissions.html b/docs/permissions.html index a7a2b570..56ece148 100644 --- a/docs/permissions.html +++ b/docs/permissions.html @@ -191,14 +191,6 @@

Connect Admin administrator Connect Manager - Connect Account Manager - Connect Copilot Manager - Business Development Representative - Presales - Account Executive - Program Manager - Solution Architect - Project Manager
diff --git a/src/permissions/constants.js b/src/permissions/constants.js index 589b8531..3cd64fb3 100644 --- a/src/permissions/constants.js +++ b/src/permissions/constants.js @@ -163,7 +163,10 @@ export const PERMISSION = { // eslint-disable-line import/prefer-default-export group: 'Project', description: 'Read project when user is a member.', }, - topcoderRoles: TOPCODER_ROLES_MANAGERS_AND_ADMINS, + topcoderRoles: [ + ...TOPCODER_ROLES_ADMINS, + USER_ROLE.MANAGER, + ], projectRoles: ALL, scopes: SCOPES_PROJECTS_READ, }, From c316c789fb4e4b253d33b15b070473b05ca35754 Mon Sep 17 00:00:00 2001 From: maxceem Date: Fri, 6 Nov 2020 12:06:49 +0200 Subject: [PATCH 7/8] fix: copilot and above should include all managers --- docs/permissions.html | 4 +++- src/permissions/constants.js | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/permissions.html b/docs/permissions.html index 56ece148..43823aa0 100644 --- a/docs/permissions.html +++ b/docs/permissions.html @@ -1160,10 +1160,12 @@

+ manager + account_manager program_manager + account_executive solution_architect project_manager - manager copilot
diff --git a/src/permissions/constants.js b/src/permissions/constants.js index 3cd64fb3..c69cf36f 100644 --- a/src/permissions/constants.js +++ b/src/permissions/constants.js @@ -565,10 +565,7 @@ export const PERMISSION = { // eslint-disable-line import/prefer-default-export }, topcoderRoles: TOPCODER_ROLES_ADMINS, projectRoles: [ - PROJECT_MEMBER_ROLE.PROGRAM_MANAGER, - PROJECT_MEMBER_ROLE.SOLUTION_ARCHITECT, - PROJECT_MEMBER_ROLE.PROJECT_MANAGER, - PROJECT_MEMBER_ROLE.MANAGER, + ...PROJECT_ROLES_MANAGEMENT, PROJECT_MEMBER_ROLE.COPILOT, ], }, From 02dc999f8d0cf38cf85fad94d7c0f89ece23f863 Mon Sep 17 00:00:00 2001 From: RishiRaj Date: Tue, 10 Nov 2020 18:10:02 +0530 Subject: [PATCH 8/8] removed feature. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 375fd156..d9851d0d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -114,7 +114,7 @@ workflows: - test filters: branches: - only: ['develop', 'feature/project-permissions-updates'] + only: ['develop'] - deployProd: context : org-global requires: