-
Notifications
You must be signed in to change notification settings - Fork 5
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
Completed Tasks 4 & 5 with unit tests. #8
Conversation
…ensure tasks 4 & 5 unit tests ran correctly. Created a seperate utility file for creating JWT tokens
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.
please use snake_case for filenames.
also, please implement validating the session and getting the logged in user's username in the job description and resume upload endpoints. you might have to update your branch to get them since they got merged last night.
backend/api/deps.ts
Outdated
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.
use the import map instead of re-exporting
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.
you should delete this file
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.
File deleted
backend/api/register.ts
Outdated
return; | ||
} | ||
|
||
// Hash the password |
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.
can you salt the password using the username and something unique to our application? something like "team6-resume-analyser" would suffice.
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.
Created a hashing function for the password and JWT token.
backend/api/userLogin.test.ts
Outdated
email: "[email protected]", | ||
username: "user123", | ||
password: | ||
"debe062ddaaf9f8b06720167c7b65c778c934a89ca89329dcb82ca79d19e17d2", // SHA-256 hash for 'securePassword' |
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.
it would be clearer and easier to modify if you hashed the string "securePassword" right here instead of hardcoding it.
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.
Used the hashing function instead of hard coding
backend/api/userLogin.test.ts
Outdated
email: "[email protected]", | ||
username: "user123", | ||
password: | ||
"debe062ddaaf9f8b06720167c7b65c778c934a89ca89329dcb82ca79d19e17d2", // SHA-256 hash for 'securePassword' |
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.
it would be clearer and easier to modify if you hashed the string right here instead of hardcoding it.
backend/api/userLogin.test.ts
Outdated
email: "[email protected]", | ||
username: "user123", | ||
password: | ||
"debe062ddaaf9f8b06720167c7b65c778c934a89ca89329dcb82ca79d19e17d2", // SHA-256 hash for 'securePassword' |
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.
it would be clearer and easier to modify if you hashed the string right here instead of hardcoding it.
backend/api/userLogin.ts
Outdated
// Send the token | ||
ctx.response.status = 200; | ||
ctx.response.body = { token }; | ||
} catch (error) { |
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.
you dont need to explicitly define this behavior, oak will send a 500 error automatically. remove the try/catch.
backend/services/createJWTSig.ts
Outdated
alg: "HS256", | ||
}; | ||
// Secret key for JWT | ||
const jwtKey = "59c4b48eac7e9ac37c046ba88964870d"; |
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.
Secret key should be in an environment file, not in the code. Please do not use this key anymore. It has already been compromised.
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.
(and the environment file should never be added to source control)
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.
Normally I'd never have the key in plain text (the above key is one used for testing to see the effects of creating JWT tokens). I created my own .env file with a JWT key, but I dont know of a way to share the secret key without having to put in a readme what the key is so everyone will have it.
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.
in prod, we will put this on a server with a key. for testing, you should add instructions in SETUP.md for generating a key and putting it in .env.local
…on for hashing. Removed the try/catch with the error status 500.
…y. Need to use �[0m�[38;5;245mrunning 3 tests from ./api/register_component/user_registration.test.ts�[0m POST /api/register - Successful Registration ... �[0m�[32mok�[0m �[0m�[38;5;245m(6ms)�[0m POST /api/register - Missing Fields ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m POST /api/register - Duplicate Email ... �[0m�[32mok�[0m �[0m�[38;5;245m(3ms)�[0m �[0m�[38;5;245mrunning 1 test from ./api/user_login_component/user_login.test.ts�[0m POST /api/userLogin - Successful Login ... �[0m�[32mok�[0m �[0m�[38;5;245m(7ms)�[0m �[0m�[38;5;245mrunning 1 test from ./hello.test.ts�[0m hello test ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m �[0m�[38;5;245mrunning 5 tests from ./in_memory/in_memory.test.ts�[0m Generate session ID ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m storeData and retrieveData are successful ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m storeData retrieves null for non-existent sessionId ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m deleteData removes data correctly ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m clearAllData removes all session data ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 2 tests from ./upload/job_description_upload.test.ts�[0m Job Description - Valid Input ... �[0m�[32mok�[0m �[0m�[38;5;245m(9ms)�[0m Job Description - Exceeds Character Limit ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 3 tests from ./upload/resume_upload.test.ts�[0m Valid PDF ... �[0m�[32mok�[0m �[0m�[38;5;245m(8ms)�[0m Resume Upload - Invalid File Type ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m Oversized File ... �[0m�[32mok�[0m �[0m�[38;5;245m(31ms)�[0m �[0m�[38;5;245mrunning 0 tests from ./util/util.test.ts�[0m �[0m�[32mok�[0m | 15 passed | 0 failed �[0m�[38;5;245m(448ms)�[0m to allow for reading .env files
Fixed issue with reading .env file. Need to have |
Can you update the github workflow in .github/workflows/deno.yml and the pre-commit hook in hooks/pre-commit with that? |
…e test PDF's and extracted text for testing. Needed to remove the .env from the .gitignore as the name change to .env.local seemed to cause the file to not be found. Updated the command to run tests.
just saw this now. Sorry about that. Going to fix that in the githubworkflow |
…o current working file upload api's.
* Completed Tasks 4 & 5 with unit tests. Utilized the utils.test.ts to ensure tasks 4 & 5 unit tests ran correctly. Created a seperate utility file for creating JWT tokens * Changed filenames to snake_case. Deleted deps.ts file. Created function for hashing. Removed the try/catch with the error status 500. * Fixed issue with not being able to read .env files with secret JWT key. Need to use �[0m�[38;5;245mrunning 3 tests from ./api/register_component/user_registration.test.ts�[0m POST /api/register - Successful Registration ... �[0m�[32mok�[0m �[0m�[38;5;245m(6ms)�[0m POST /api/register - Missing Fields ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m POST /api/register - Duplicate Email ... �[0m�[32mok�[0m �[0m�[38;5;245m(3ms)�[0m �[0m�[38;5;245mrunning 1 test from ./api/user_login_component/user_login.test.ts�[0m POST /api/userLogin - Successful Login ... �[0m�[32mok�[0m �[0m�[38;5;245m(7ms)�[0m �[0m�[38;5;245mrunning 1 test from ./hello.test.ts�[0m hello test ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m �[0m�[38;5;245mrunning 5 tests from ./in_memory/in_memory.test.ts�[0m Generate session ID ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m storeData and retrieveData are successful ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m storeData retrieves null for non-existent sessionId ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m deleteData removes data correctly ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m clearAllData removes all session data ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 2 tests from ./upload/job_description_upload.test.ts�[0m Job Description - Valid Input ... �[0m�[32mok�[0m �[0m�[38;5;245m(9ms)�[0m Job Description - Exceeds Character Limit ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 3 tests from ./upload/resume_upload.test.ts�[0m Valid PDF ... �[0m�[32mok�[0m �[0m�[38;5;245m(8ms)�[0m Resume Upload - Invalid File Type ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m Oversized File ... �[0m�[32mok�[0m �[0m�[38;5;245m(31ms)�[0m �[0m�[38;5;245mrunning 0 tests from ./util/util.test.ts�[0m �[0m�[32mok�[0m | 15 passed | 0 failed �[0m�[38;5;245m(448ms)�[0m to allow for reading .env files * Finished task 11 along with tests. Created a folder to hold one of the test PDF's and extracted text for testing. Needed to remove the .env from the .gitignore as the name change to .env.local seemed to cause the file to not be found. Updated the command to run tests. * Ran the deno fmt command. Updated the deno.yml file with the correct testing command. * parse text from File object instead of file path * Updated pre-commit file to match deno test in deno.yml * improve jwt helpers * use json for login and registration endpoints * Trying to modify the routes.ts to use middlware to minimize changes to current working file upload api's. * use token for session data * add test for jwt * salt hashes * Created test file for session_middleware.ts. * test session middleware --------- Co-authored-by: julia <[email protected]>
* Completed Tasks 4 & 5 with unit tests. Utilized the utils.test.ts to ensure tasks 4 & 5 unit tests ran correctly. Created a seperate utility file for creating JWT tokens * Changed filenames to snake_case. Deleted deps.ts file. Created function for hashing. Removed the try/catch with the error status 500. * Fixed issue with not being able to read .env files with secret JWT key. Need to use �[0m�[38;5;245mrunning 3 tests from ./api/register_component/user_registration.test.ts�[0m POST /api/register - Successful Registration ... �[0m�[32mok�[0m �[0m�[38;5;245m(6ms)�[0m POST /api/register - Missing Fields ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m POST /api/register - Duplicate Email ... �[0m�[32mok�[0m �[0m�[38;5;245m(3ms)�[0m �[0m�[38;5;245mrunning 1 test from ./api/user_login_component/user_login.test.ts�[0m POST /api/userLogin - Successful Login ... �[0m�[32mok�[0m �[0m�[38;5;245m(7ms)�[0m �[0m�[38;5;245mrunning 1 test from ./hello.test.ts�[0m hello test ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m �[0m�[38;5;245mrunning 5 tests from ./in_memory/in_memory.test.ts�[0m Generate session ID ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m storeData and retrieveData are successful ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m storeData retrieves null for non-existent sessionId ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m deleteData removes data correctly ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m clearAllData removes all session data ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 2 tests from ./upload/job_description_upload.test.ts�[0m Job Description - Valid Input ... �[0m�[32mok�[0m �[0m�[38;5;245m(9ms)�[0m Job Description - Exceeds Character Limit ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 3 tests from ./upload/resume_upload.test.ts�[0m Valid PDF ... �[0m�[32mok�[0m �[0m�[38;5;245m(8ms)�[0m Resume Upload - Invalid File Type ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m Oversized File ... �[0m�[32mok�[0m �[0m�[38;5;245m(31ms)�[0m �[0m�[38;5;245mrunning 0 tests from ./util/util.test.ts�[0m �[0m�[32mok�[0m | 15 passed | 0 failed �[0m�[38;5;245m(448ms)�[0m to allow for reading .env files * Finished task 11 along with tests. Created a folder to hold one of the test PDF's and extracted text for testing. Needed to remove the .env from the .gitignore as the name change to .env.local seemed to cause the file to not be found. Updated the command to run tests. * Ran the deno fmt command. Updated the deno.yml file with the correct testing command. * parse text from File object instead of file path * Updated pre-commit file to match deno test in deno.yml * improve jwt helpers * use json for login and registration endpoints * Trying to modify the routes.ts to use middlware to minimize changes to current working file upload api's. * use token for session data * add test for jwt * salt hashes * Created test file for session_middleware.ts. * test session middleware --------- Co-authored-by: julia <[email protected]>
* create sign up card * add api/sign_up to postRequests * add api/sign_in to postRequests * change sign in username to email * reformat * remove sign up * create page for task_6 * add sign in * rename sign_up.test.tsx to task_6.test.tsx * fix unclosed brace * add register and login to fetching (#11) * create sign up card * add api/sign_up to postRequests * add api/sign_in to postRequests * change sign in username to email * reformat * remove sign up * create page for task_6 * add sign in * rename sign_up.test.tsx to task_6.test.tsx * add register and login to fetching * fix mismatched braces in fetching.ts * add token to headers in fetching.ts * save token to local storage * fix unable to find element * delete commented code * rename sign up and sign in to register and login respectively * split login and register into separate pages, add input validation, and take field data out of url * add user event library * add testing for login * add testing for register * format * fix eslint errors * fix eslint error * fix localstorage not being defined * fix localstorage not being defined --------- Co-authored-by: julia <[email protected]> * Completed Tasks 4 & 5 with unit tests. (#8) * Completed Tasks 4 & 5 with unit tests. Utilized the utils.test.ts to ensure tasks 4 & 5 unit tests ran correctly. Created a seperate utility file for creating JWT tokens * Changed filenames to snake_case. Deleted deps.ts file. Created function for hashing. Removed the try/catch with the error status 500. * Fixed issue with not being able to read .env files with secret JWT key. Need to use �[0m�[38;5;245mrunning 3 tests from ./api/register_component/user_registration.test.ts�[0m POST /api/register - Successful Registration ... �[0m�[32mok�[0m �[0m�[38;5;245m(6ms)�[0m POST /api/register - Missing Fields ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m POST /api/register - Duplicate Email ... �[0m�[32mok�[0m �[0m�[38;5;245m(3ms)�[0m �[0m�[38;5;245mrunning 1 test from ./api/user_login_component/user_login.test.ts�[0m POST /api/userLogin - Successful Login ... �[0m�[32mok�[0m �[0m�[38;5;245m(7ms)�[0m �[0m�[38;5;245mrunning 1 test from ./hello.test.ts�[0m hello test ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m �[0m�[38;5;245mrunning 5 tests from ./in_memory/in_memory.test.ts�[0m Generate session ID ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m storeData and retrieveData are successful ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m storeData retrieves null for non-existent sessionId ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m deleteData removes data correctly ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m clearAllData removes all session data ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 2 tests from ./upload/job_description_upload.test.ts�[0m Job Description - Valid Input ... �[0m�[32mok�[0m �[0m�[38;5;245m(9ms)�[0m Job Description - Exceeds Character Limit ... �[0m�[32mok�[0m �[0m�[38;5;245m(0ms)�[0m �[0m�[38;5;245mrunning 3 tests from ./upload/resume_upload.test.ts�[0m Valid PDF ... �[0m�[32mok�[0m �[0m�[38;5;245m(8ms)�[0m Resume Upload - Invalid File Type ... �[0m�[32mok�[0m �[0m�[38;5;245m(1ms)�[0m Oversized File ... �[0m�[32mok�[0m �[0m�[38;5;245m(31ms)�[0m �[0m�[38;5;245mrunning 0 tests from ./util/util.test.ts�[0m �[0m�[32mok�[0m | 15 passed | 0 failed �[0m�[38;5;245m(448ms)�[0m to allow for reading .env files * Finished task 11 along with tests. Created a folder to hold one of the test PDF's and extracted text for testing. Needed to remove the .env from the .gitignore as the name change to .env.local seemed to cause the file to not be found. Updated the command to run tests. * Ran the deno fmt command. Updated the deno.yml file with the correct testing command. * parse text from File object instead of file path * Updated pre-commit file to match deno test in deno.yml * improve jwt helpers * use json for login and registration endpoints * Trying to modify the routes.ts to use middlware to minimize changes to current working file upload api's. * use token for session data * add test for jwt * salt hashes * Created test file for session_middleware.ts. * test session middleware --------- Co-authored-by: julia <[email protected]> * routing and login/registration integration * add loading spinner & protect routes if not logged in * add more unit tests * cleanup and refactor (#16) * refactor frontend * refactor backend * format * add loading spinner & protect routes if not logged in * add more unit tests * format * add api/fit-score to getRequests * add backend get for fit score to dashboard frontend * adapt dashboard tests to using useB ackendGet * remove redundant sign up and sign in * add isError and message to git-score get request type * add isError and message to page * fix some issues from merging * delete task_6 folder * add testing for stars * add test for empty feedback * add message on screen if no suggestions/feedback * add test for null fit score * add message on screen if fit score is null * remove comment * add temporary mock data for testing page * add canvas and update next.js * resolve issues from merging with pdf generation code * resolve linting problems * fix dep issue * add jest canvas mock * loading state * format * add fit-score and analyze to fetching * change feedback.text to feedback.feedback * adapt dashboard to fit-score and analyze post requests * concatenate fit and analyze feedback * add category to feedback * take analyze out of null check * act error * wrap tests in act * backendPostMock before initialization * fix test * cleanup * error test doesnt pass * fix tests and add null analyze test * dont read analyzeResponse.data if analyzeResponse is null * make token handling more fault tolerant * lint * lint and setLoading() in then() * getting closer * Revert "remove unused nlp stuff" This reverts commit 1167343. * use standard nlp stuff to improve keyword extraction in fit-score * better handling for auth * remove console.log * update backend tests * fix mock data repitition and comment empty list test * add isEmpty * format * fix localstorage error --------- Co-authored-by: julia <[email protected]> Co-authored-by: Stephen Ordway <[email protected]>
Completed Tasks 4 & 5 with unit tests. Utilized the utils.test.ts to ensure tasks 4 & 5 unit tests ran correctly. Created a separate utility file for creating JWT tokens. Also create a deps.ts file to import/export all required dependencies to simplify importing common modules.