Fix/add unit tests for GET /v5/projects/:projectId/billingAccount
#638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Verification
outputs:
{"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"level":30,"msg":"Registering models ... true","time":"2021-03-10T04:05:07.895Z","v":0} Project Billing Accounts list Get /projects/{id}/billingAccounts Deleting "projects_test" index... Creating "projects_test" index... Deleting "timelines_test" index... Creating "timelines_test" index... Deleting "metadata_test" index... Creating "metadata_test" index... {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"52c700dc-f651-432d-a4a9-8ff4a1ee2915","level":30,"msg":"start request { method: 'GET', url: '/v5/projects/1/billingAccount' }","time":"2021-03-10T04:05:08.605Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"52c700dc-f651-432d-a4a9-8ff4a1ee2915","level":30,"msg":"end request {\n method: 'GET',\n url: '/v5/projects/1/billingAccount',\n statusCode: 403,\n statusMessage: 'Forbidden',\n duration: 2.182916\n}","time":"2021-03-10T04:05:08.608Z","v":0} ✓ should return 403 for anonymous user Deleting "projects_test" index... Creating "projects_test" index... Deleting "timelines_test" index... Creating "timelines_test" index... Deleting "metadata_test" index... Creating "metadata_test" index... {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"b6bbca4e-dddf-4998-942e-727cc2b52226","level":30,"msg":"start request { method: 'GET', url: '/v5/projects/1/billingAccount' }","time":"2021-03-10T04:05:08.943Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"b6bbca4e-dddf-4998-942e-727cc2b52226","level":50,"err":{"message":"You do not have permissions to perform this action","name":"Error","stack":"Error: You do not have permissions to perform this action\n at /home/caizheng/my_projects/topcoder-tc-project-service-throw-404-if-billing-account-id-not-found/tc-project-service/src/permissions/generalPermission.js:1:7422"},"msg":"You do not have permissions to perform this action","time":"2021-03-10T04:05:08.954Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"b6bbca4e-dddf-4998-942e-727cc2b52226","level":30,"msg":"end request {\n method: 'GET',\n url: '/v5/projects/1/billingAccount',\n statusCode: 403,\n statusMessage: 'Forbidden',\n duration: 12.334105\n}","time":"2021-03-10T04:05:08.955Z","v":0} ✓ should return 403 for admin Deleting "projects_test" index... Creating "projects_test" index... Deleting "timelines_test" index... Creating "timelines_test" index... Deleting "metadata_test" index... Creating "metadata_test" index... {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"60d27176-acc0-4064-86a5-8d340b013953","level":30,"msg":"start request { method: 'GET', url: '/v5/projects/11223344/billingAccount' }","time":"2021-03-10T04:05:09.264Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"60d27176-acc0-4064-86a5-8d340b013953","level":50,"err":{"message":"Project with id \"11223344\" not found","name":"Error","stack":"Error: Project with id \"11223344\" not found\n at module.exports (/home/caizheng/my_projects/topcoder-tc-project-service-throw-404-if-billing-account-id-not-found/tc-project-service/src/routes/billingAccounts/get.js:1:5850)"},"msg":"Project with id \"11223344\" not found","time":"2021-03-10T04:05:09.269Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"60d27176-acc0-4064-86a5-8d340b013953","level":50,"err":{"message":"Project with id \"11223344\" not found","name":"Error","stack":"Error: Project with id \"11223344\" not found\n at module.exports (/home/caizheng/my_projects/topcoder-tc-project-service-throw-404-if-billing-account-id-not-found/tc-project-service/src/routes/billingAccounts/get.js:1:5850)"},"msg":"Project with id \"11223344\" not found","time":"2021-03-10T04:05:09.269Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"60d27176-acc0-4064-86a5-8d340b013953","level":30,"msg":"end request {\n method: 'GET',\n url: '/v5/projects/11223344/billingAccount',\n statusCode: 404,\n statusMessage: 'Not Found',\n duration: 5.157681999999999\n}","time":"2021-03-10T04:05:09.270Z","v":0} ✓ should return 404 if the project is not found Deleting "projects_test" index... Creating "projects_test" index... Deleting "timelines_test" index... Creating "timelines_test" index... Deleting "metadata_test" index... Creating "metadata_test" index... {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"64f2eb72-9da3-480e-8fb1-5c0374484b0e","level":30,"msg":"start request { method: 'GET', url: '/v5/projects/2/billingAccount' }","time":"2021-03-10T04:05:09.573Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"64f2eb72-9da3-480e-8fb1-5c0374484b0e","level":50,"err":{"message":"Billing Account not found","name":"Error","stack":"Error: Billing Account not found\n at module.exports (/home/caizheng/my_projects/topcoder-tc-project-service-throw-404-if-billing-account-id-not-found/tc-project-service/src/routes/billingAccounts/get.js:1:6176)"},"msg":"Billing Account not found","time":"2021-03-10T04:05:09.576Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"64f2eb72-9da3-480e-8fb1-5c0374484b0e","level":50,"err":{"message":"Billing Account not found","name":"Error","stack":"Error: Billing Account not found\n at module.exports (/home/caizheng/my_projects/topcoder-tc-project-service-throw-404-if-billing-account-id-not-found/tc-project-service/src/routes/billingAccounts/get.js:1:6176)"},"msg":"Billing Account not found","time":"2021-03-10T04:05:09.576Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"64f2eb72-9da3-480e-8fb1-5c0374484b0e","level":30,"msg":"end request {\n method: 'GET',\n url: '/v5/projects/2/billingAccount',\n statusCode: 404,\n statusMessage: 'Not Found',\n duration: 3.266934\n}","time":"2021-03-10T04:05:09.576Z","v":0} ✓ should return 404 if billing account is not defined in the project Deleting "projects_test" index... Creating "projects_test" index... Deleting "timelines_test" index... Creating "timelines_test" index... Deleting "metadata_test" index... Creating "metadata_test" index... {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"3176cf95-0397-4894-875d-fe504311b209","level":30,"msg":"start request { method: 'GET', url: '/v5/projects/1/billingAccount' }","time":"2021-03-10T04:05:09.868Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"3176cf95-0397-4894-875d-fe504311b209","level":20,"msg":"SELECT TopCoder_Billing_Account_Id__c, Mark_Up__c from Topcoder_Billing_Account__c tba where TopCoder_Billing_Account_Id__c='1'","time":"2021-03-10T04:05:09.871Z","v":0} {"name":"tc-projects-service-prod","hostname":"caizheng-nuc10i7fnk","pid":2308147,"requestId":"3176cf95-0397-4894-875d-fe504311b209","level":30,"msg":"end request {\n method: 'GET',\n url: '/v5/projects/1/billingAccount',\n statusCode: 200,\n statusMessage: 'OK',\n duration: 3.462307\n}","time":"2021-03-10T04:05:09.872Z","v":0} ✓ should return billing account details using M2M token with "read:project-billing-account-details" scope 5 passing (2s) =============================== Coverage summary =============================== Statements : 31.04% ( 2263/7290 ) Branches : 2.64% ( 64/2427 ) Functions : 5.62% ( 76/1352 ) Lines : 32.2% ( 2255/7003 ) ================================================================================