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

Check permissions logic #12

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Matthew-Clendenning
Copy link
Collaborator

Fixes #11

What was changed: Created a file that listed the roles and their specific permissions. Used test cases to verify that each role was configured correctly and had the correct permissions.

Why was it changed: These changes were made because student users can't have the same permissions as a teacher/owner of the project.

How was it changed: I created a Permissions dictionary inside the permissions.mjs file where the keys (e.g. OWNER, LEADER, CONTRIBUTOR) represent roles, and their corresponding values are arrays that hold their permissions. Inside the same file is a function called checkPermissions to check that certain roles have certain permissions. I created a helper function called generatePatterns so any order of actions, scopes and entities are accounted for when testing. Finally, I created a separate file called __test__.mjs that holds the test cases for each role.

Copy link
Collaborator

@sarah-fidahussain-SLU sarah-fidahussain-SLU left a comment

Choose a reason for hiding this comment

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

Overall, very thorough and when I ran the test.mjs file, all tests passed. There was one case of commented out code that may need to be addressed.

components/classroom/groups/__test__.mjs Outdated Show resolved Hide resolved
Copy link
Collaborator

@MutyaSowmya123 MutyaSowmya123 left a comment

Choose a reason for hiding this comment

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

The code permissions.mjs file is implemented for the given permissions correctly.
Remove the package-lock.json file, as its not required even with just package.json file npx jest will still run the test cases.

And update the package.json file with

{
  "devDependencies":{
    "jest":"^29.7.0"
  },
  "scripts": {
      "test": "jest"
  },
  "jest": {
    "transform": {},
    "testMatch": [
      "**/__test__.mjs"
    ]
  }
}

just remove this code from package.json file:

    "@babel/core": "^7.25.2",
    "@babel/preset-env": "^7.25.4",
    "babel-jest": "^29.7.0",

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.

Implement Permission Logic and Check Function in Classroom Groups Folder
3 participants