-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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",
…TPEN-interfaces into check-permissions-logic
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.