Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1964 - Added role to restrict MSFAA reissue #1985

Merged
merged 11 commits into from
Jun 6, 2023

Conversation

andrepestana-aot
Copy link
Collaborator

@andrepestana-aot andrepestana-aot commented Jun 1, 2023

  • Added role to aest-business-administrators group on DEV and TEST;
  • Added role to enums;
  • Added decorator on the api call to restrict only to business administrator role;
  • Passed value to hide button when user has not business administrator role;
  • Updated User profile matrix spreadsheet;
  • Added the following tests:
    Auth Ministry
    √ Should have specific roles when ministry user is a business administrator. (400 ms)
    ApplicationAESTController(e2e)-reissueMSFAA
    √ Should not reissue an MSFAA when user is not a business administrator.

@andrepestana-aot andrepestana-aot self-assigned this Jun 2, 2023
@andrepestana-aot andrepestana-aot marked this pull request as ready for review June 2, 2023 00:37
@andrepestana-aot andrepestana-aot linked an issue Jun 2, 2023 that may be closed by this pull request
3 tasks
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start, please take a look at the comments.
I believe that we need to include in this ticket the API endpoint decorator and disable/remove the MSFAA button from the form when the user does not have the role.

@andrepestana-aot andrepestana-aot marked this pull request as draft June 2, 2023 18:04
@@ -30,4 +30,5 @@ export enum Role {
InstitutionCreateNote = "institution-create-note",
InstitutionApproveDeclineDesignation = "institution-approve-decline-designation",
InstitutionApproveDeclineOfferingChanges = "institution-approve-decline-offering-changes",
StudentReissueMSFAA = "student-reissue-msfaa",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding <check-permission-role> in the vue side. I know the Vue button is inside form.io. But is there a way to disable the button when the user does not have right permission?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm working on that. Thanks.

@andrepestana-aot andrepestana-aot marked this pull request as ready for review June 5, 2023 21:57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the test/ dir be named as _tests_?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to the same directory as auth.e2e-spec.ts and institution.e2e-spec.ts. What do you guys think @dheepak-aot @andrewsignori-aot @guru-aot @sh16011993 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our application we do not follow the test package at root pattern like typically what OOTB code template creates.
I would suggest this e2e-spec to be in $same_directory_of_code_which_is_tested/tests/auth.aest.e2e-spec.ts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the application structure, I believe the directory should be renamed to _tests_ and the test should be moved to the directory of the code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I moved that test to the same directory of aest-token-helpers.ts.

Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a minor comment

@dheepak-aot
Copy link
Collaborator

Looks good @andrepestana-aot . Just one comment on have auth.aest.e2e-spec.ts on appropriate folder.

Also, please add the role name student-reissue-msfaa to the ticket.

@@ -12,7 +12,7 @@
</template>
<notice-of-assessment-form-view
:assessment-id="assessmentId"
:can-reissue-m-s-f-a-a="true"
:can-reissue-m-s-f-a-a="hasStudentReissueMSFAARole"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that usually, the vue is disabling the component instead of hiding it. For this case to keep it simple I would no mind having it removed.

Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work @andrepestana-aot 👍


const jwtService = new JwtService();

describe("(e2e)-getAESTToken()", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using the "Auth" as a prefix, like Auth(e2e)-getAESTToken().


describe("(e2e)-getAESTToken()", () => {
it("Should have all roles when ministry user is a business administrator.", async () => {
//Act
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change it to "// Act"?

decodedToken.resource_access.aest.roles.sort((a, b) => a.localeCompare(b));
const allAESTRoles = Object.values(Role).sort((a, b) => a.localeCompare(b));

//Assert
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change it to "// Assert"?

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the changes, look good 👍

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.8% 3.8% Duplication

@github-actions
Copy link

github-actions bot commented Jun 6, 2023

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.92% ( 2092 / 11673 )
Methods: 8.23% ( 123 / 1494 )
Lines: 20.7% ( 1833 / 8854 )
Branches: 10.26% ( 136 / 1325 )

@github-actions
Copy link

github-actions bot commented Jun 6, 2023

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 49.81% ( 267 / 536 )
Methods: 41.56% ( 32 / 77 )
Lines: 55.33% ( 218 / 394 )
Branches: 26.15% ( 17 / 65 )

@github-actions
Copy link

github-actions bot commented Jun 6, 2023

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 69.4% ( 390 / 562 )
Methods: 59.15% ( 42 / 71 )
Lines: 71.52% ( 344 / 481 )
Branches: 40% ( 4 / 10 )

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes and adding role name to ticket. 👍

Copy link
Collaborator

@sh16011993 sh16011993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank You for making the changes. LGTM 👍

@github-actions
Copy link

github-actions bot commented Jun 6, 2023

E2E SIMS API Coverage Report

Totals Coverage
Statements: 43.54% ( 3042 / 6986 )
Methods: 37.65% ( 340 / 903 )
Lines: 48.62% ( 2535 / 5214 )
Branches: 19.22% ( 167 / 869 )

Copy link
Collaborator

@guru-aot guru-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work @andrepestana-aot

@andrepestana-aot andrepestana-aot merged commit 144058f into main Jun 6, 2023
@andrepestana-aot andrepestana-aot deleted the 1964_add_role_to_restrict_msfaa_reissue branch June 6, 2023 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add role to restrict MSFAA Reissue
6 participants