Skip to content

Create Jobs in TaaS using user token instead of M2M #626

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

Merged

Conversation

imcaizheng
Copy link
Contributor

Verification

Prepare

tc-project-service

  1. I 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.

  2. Configure the taasJobApiUrl property at config/development.json with value http://localhost:3000/api/v5/jobs.

  3. Enable debug messages and start the project service.

taas-apis

  1. Clone taas-apis onto local machine.

  2. Modify the helper.checkIsMemberOfProject function(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:

        .get(`${config.TC_API}/projects/${projectId}`)

    with:

        .get(`http://localhost:8001/v5/projects/${projectId}`)
  3. Start the taas service.

Check With Regular User

  1. 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": "Cazheid@ddo.com"
        },
        "hideDiscussions": true
      },
      "type": "talent-as-a-service",
      "templateId": 235,
      "name": "Taas Test",
      "version": "v3",
      "estimation": [],
      "attachments": []
    }
  2. 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.

  3. Create a project via POST :8001/v5/projects with the JWT token and the request body.

  4. Some log similar to as following could be found on the console:

    [2021-02-12T05:57:42.640Z] DEBUG: tc-projects-service-dev/897729 on caizheng-nuc10i7fnk: jobId: 2cc6b631-df57-46b8-a968-d9081925921a job created with title "Designer"
    [2021-02-12T05:57:42.640Z] DEBUG: tc-projects-service-dev/897729 on caizheng-nuc10i7fnk: jobId: ee952c1e-b187-43d0-83e7-90bba10f0dff job created with title "Software Engineer"
  5. 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.

Copy link
Contributor

@maxceem maxceem left a comment

Choose a reason for hiding this comment

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

Thank you @imcaizheng. The validation guide was very helpful works perfectly.

@maxceem maxceem merged commit c44df10 into topcoder-platform:develop Feb 13, 2021
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.

2 participants