Create Jobs in TaaS using user token instead of M2M #626
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
Prepare
tc-project-serviceI have to add the
https://auth.topcoder-dev.com/issuer url to the project service, otherwise requests to create new project would got 403 error with message "Invalid token issuer."I was using JWT tokens found on https://topcoder-dev.com.
Configure the
taasJobApiUrlproperty atconfig/development.jsonwith valuehttp://localhost:3000/api/v5/jobs.Enable debug messages and start the project service.
taas-apisClone
taas-apisonto local machine.Modify the
helper.checkIsMemberOfProjectfunction(https://github.com/topcoder-platform/taas-apis/blob/dev/src/common/helper.js#L960) so that it can make requests to the project service running locally.That is, replace this line:
with:
Start the taas service.
Check With Regular User
Go to
https://connect.topcoder-dev.com/new-project/taas-jobs, fill the Form and find the request body on the browser console after the Form is sent.Here is an example:
{ "details": { "intakePurpose": "demo-test-other", "utm": { "code": "" }, "taasDefinition": { "taasJobs": [ { "title": "Software Engineer", "role": { "value": "software-developer", "title": "Software Developer" }, "people": "1", "duration": "1", "skills": [ { "skillId": "1fd02aad-e08a-4669-9ffd-181468fea694", "name": "AI" } ], "workLoad": { "value": "fulltime", "title": "Full-Time" }, "description": "Come on!" }, { "title": "Designer", "role": { "value": "designer", "title": "Designer" }, "people": "2", "duration": "4", "skills": [ { "skillId": "4fce6ced-3610-443c-92eb-3f6d76b34f5c", "name": "AI" } ], "workLoad": { "value": "fulltime", "title": "Full-Time" }, "description": "Come out!" } ], "kickOffTime": "rangeOne", "oppurtunityDetails": { "customerName": "Aarron Yuan", "staffingModel": "global", "talentLocation": "No Requirement", "workingTimezone": "India", "requestedStartDate": "02/22/2021" }, "otherRequirements": [ "noAdditionalOnboarding" ], "otherRequirementBrief": "", "hiringManager": "[email protected]" }, "hideDiscussions": true }, "type": "talent-as-a-service", "templateId": 235, "name": "Taas Test", "version": "v3", "estimation": [], "attachments": [] }Go to https://topcoder-dev.com and log in as a regular user. Find the JWT token for the user on the browser console after the user is online.
Create a project via
POST :8001/v5/projectswith the JWT token and the request body.Some log similar to as following could be found on the console:
Fire a request to
GET :3000/api/v5/jobs, two new records could be found:[ { "id": "ee952c1e-b187-43d0-83e7-90bba10f0dff", "projectId": 31, "externalId": null, "description": "Come on!", "title": "Software Engineer", "startDate": null, "duration": 1, "numPositions": 1, "resourceType": "software-developer", "rateType": "weekly", "workload": "full-time", "skills": [ "1fd02aad-e08a-4669-9ffd-181468fea694" ], "status": "sourcing", "createdBy": "fe38eed1-af73-41fd-85a2-ac4da1ff09a3", "updatedBy": null, "createdAt": "2021-02-12T05:57:42.590Z", "updatedAt": "2021-02-12T05:57:42.590Z", "candidates": [] }, { "id": "2cc6b631-df57-46b8-a968-d9081925921a", "projectId": 31, "externalId": null, "description": "Come out!", "title": "Designer", "startDate": null, "duration": 4, "numPositions": 2, "resourceType": "designer", "rateType": "weekly", "workload": "full-time", "skills": [ "4fce6ced-3610-443c-92eb-3f6d76b34f5c" ], "status": "sourcing", "createdBy": "fe38eed1-af73-41fd-85a2-ac4da1ff09a3", "updatedBy": null, "createdAt": "2021-02-12T05:57:42.600Z", "updatedAt": "2021-02-12T05:57:42.600Z", "candidates": [] } ]Repeat step 3 to step 5 and try with other user roles could work as well.