diff --git a/README.md b/README.md index dc0ad691..a1593091 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,9 @@ The following parameters can be set in config files or in env variables: - ES.ES_TYPE: Elasticsearch index type - ES.ES_REFRESH: Elasticsearch refresh method. Default to string `true`(i.e. refresh immediately) - FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes -- CHALLENGES_API_URL: TC challenges API base URL +- RESOURCES_API_URL: TC resources API base URL - GROUPS_API_URL: TC groups API base URL +- PROJECTS_API_URL: TC projects API base URL - COPILOT_RESOURCE_ROLE_IDS: copilot resource role ids allowed to upload attachment - HEALTH_CHECK_TIMEOUT: health check timeout in milliseconds - SCOPES: the configurable M2M token scopes, refer `config/default.js` for more details @@ -76,6 +77,7 @@ It starts Elasticsearch, DynamoDB and S3 compatible server. ## Mock api For postman verification, please use the mock api under mock-api folder. It provides mock endpoint to fetch challenge resources and groups. +You need to ensure DynamoDB configuration in `mock-api/config/default.js` is consistent with `config/default.js` Go to `mock-api` folder and run command `npm run start` to start the mock-api listening on port 4000 ## Create Tables @@ -90,6 +92,7 @@ Go to `mock-api` folder and run command `npm run start` to start the mock-api li 4. Initialize/Clear database in default environment: `npm run init-db` 5. View table data in default environment: `npm run view-data `, ModelName can be `Challenge`, `ChallengeType`, `ChallengeSetting`, `AuditLog`, `Phase`, `TimelineTemplate`or `Attachment` 6. Create Elasticsearch index: `npm run init-db`, or to re-create index: `npm run init-db force` +7. Synchronize ES data and DynamoDB data: `npm run sync-es` ### Notes - The seed data are located in `src/scripts/seed` @@ -115,6 +118,7 @@ Go to `mock-api` folder and run command `npm run start` to start the mock-api li - Create DynamoDB tables. - Initialize ES index. - Various config parameters should be properly set. + Seeding db data is not needed. ### Running unit tests diff --git a/Verification.md b/Verification.md index 569e77f1..1e99b55c 100644 --- a/Verification.md +++ b/Verification.md @@ -1,8 +1,10 @@ # TopCoder Challenge API Verification ## Postman tests +- clear the environment, run command `npm run init-db` and `npm run init-es force` - import Postman collection and environment in the docs folder to Postman - run tests from up to down in order +- You need to run command `npm run sync-es` before you run `Challenges/get challenge` and `Challenges/search challenge` test case. ## DynamoDB Verification Run command `npm run view-data ` to view table data, ModelName can be `Challenge`, `ChallengeType`, `ChallengeSetting`, `AuditLog`, `Phase`, `TimelineTemplate`or `Attachment` diff --git a/app-routes.js b/app-routes.js index d99154ea..fa2e17a0 100644 --- a/app-routes.js +++ b/app-routes.js @@ -59,6 +59,8 @@ module.exports = (app) => { if (def.access && !helper.checkIfExists(def.access, req.authUser.roles)) { next(new errors.ForbiddenError('You are not allowed to perform this action!')) } else { + // user token is used in create/update challenge to ensure user can create/update challenge under specific project + req.userToken = req.headers.authorization.split(' ')[1] next() } } else { diff --git a/app.js b/app.js index 2201a65d..0d9c29d7 100644 --- a/app.js +++ b/app.js @@ -58,7 +58,7 @@ require('./app-routes')(app) app.use((err, req, res, next) => { logger.logFullError(err, req.signature || `${req.method} ${req.url}`) const errorResponse = {} - const status = err.isJoi ? HttpStatus.BAD_REQUEST : (err.httpStatus || HttpStatus.INTERNAL_SERVER_ERROR) + const status = err.isJoi ? HttpStatus.BAD_REQUEST : (err.httpStatus || _.get(err, 'response.status') || HttpStatus.INTERNAL_SERVER_ERROR) if (_.isArray(err.details)) { if (err.isJoi) { @@ -73,6 +73,11 @@ app.use((err, req, res, next) => { }) } } + if (_.get(err, 'response.status')) { + // extra error message from axios http response(v4 and v5 tc api) + errorResponse.message = _.get(err, 'response.data.result.content.message') || _.get(err, 'response.data.message') + } + if (_.isUndefined(errorResponse.message)) { if (err.message && status !== HttpStatus.INTERNAL_SERVER_ERROR) { errorResponse.message = err.message diff --git a/config/default.js b/config/default.js index 94ce29a0..fde568a6 100644 --- a/config/default.js +++ b/config/default.js @@ -42,8 +42,9 @@ module.exports = { // in bytes FILE_UPLOAD_SIZE_LIMIT: process.env.FILE_UPLOAD_SIZE_LIMIT ? Number(process.env.FILE_UPLOAD_SIZE_LIMIT) : 50 * 1024 * 1024, // 50M - CHALLENGES_API_URL: process.env.CHALLENGES_API_URL || 'http://localhost:4000/v5/challenges', + RESOURCES_API_URL: process.env.RESOURCES_API_URL || 'http://localhost:4000/v5/resources', GROUPS_API_URL: process.env.GROUPS_API_URL || 'http://localhost:4000/v5/groups', + PROJECTS_API_URL: process.env.PROJECTS_API_URL || 'http://localhost:4000/v4/projects', // copilot resource role ids allowed to upload attachment COPILOT_RESOURCE_ROLE_IDS: process.env.COPILOT_RESOURCE_ROLE_IDS ? process.env.COPILOT_RESOURCE_ROLE_IDS.split(',') : ['10ba038e-48da-487b-96e8-8d3b99b6d18b'], diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 906d9394..a5a9ce8c 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -156,6 +156,11 @@ paths: description: Filter by 'updatedBy' field, case-insensitive, partial matches are allowed. required: false type: string + - name: memberId + in: query + description: Filter by member, only return challenges this member can access to + required: false + type: string responses: '200': description: OK diff --git a/docs/topcoder-challenge-api.postman_collection.json b/docs/topcoder-challenge-api.postman_collection.json index 06d0f21b..afa28406 100644 --- a/docs/topcoder-challenge-api.postman_collection.json +++ b/docs/topcoder-challenge-api.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "8c95de1a-8571-4a3a-907c-077bc68ffd2c", + "_postman_id": "2ce9137e-3a64-455b-8d3d-de11a98100a5", "name": "topcoder-challenge-api", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -877,10 +877,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings?name=-NAME-&page=2&perPage=2", "host": [ @@ -942,10 +938,6 @@ "value": "Bearer {{copilot1_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings?invalid=-NAME-&page=2&perPage=2", "host": [ @@ -1007,10 +999,6 @@ "value": "Bearer invalid" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings?name=-NAME-&page=2&perPage=2", "host": [ @@ -1067,10 +1055,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings?name=-NAME-&page=2&perPage=2", "host": [ @@ -1132,10 +1116,6 @@ "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings?name=-NAME-&page=2&perPage=2", "host": [ @@ -1197,10 +1177,6 @@ "value": "Bearer {{m2m_challenge_settings_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings?name=-NAME-&page=2&perPage=2", "host": [ @@ -1262,10 +1238,6 @@ "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings?name=-NAME-&page=2&perPage=2", "host": [ @@ -1333,10 +1305,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/{{SETTINGA_ID}}", "host": [ @@ -1385,10 +1353,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/{{SETTINGB_ID}}", "host": [ @@ -1437,10 +1401,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/invalid-id", "host": [ @@ -1484,10 +1444,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/{{SETTINGB_ID}}", "host": [ @@ -1536,10 +1492,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/{{SETTINGB_ID}}", "host": [ @@ -1588,10 +1540,6 @@ "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/{{SETTINGB_ID}}", "host": [ @@ -1640,10 +1588,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/11111111-a41a-4b80-b6dd-90f3816ada99", "host": [ @@ -1692,10 +1636,6 @@ "value": "Bearer {{m2m_challenge_settings_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/{{SETTINGA_ID}}", "host": [ @@ -1744,10 +1684,6 @@ "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeSettings/{{SETTINGA_ID}}", "host": [ @@ -3104,10 +3040,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeTypes?name=-name-&description=cri&isActive=true", "host": [ @@ -3164,10 +3096,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeTypes?isActive=true&page=2&perPage=2", "host": [ @@ -3224,10 +3152,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeTypes?invalid=test", "host": [ @@ -3282,10 +3206,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeTypes/{{TYPEA_ID}}", "host": [ @@ -3329,10 +3249,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeTypes/{{TYPEB_ID}}", "host": [ @@ -3376,10 +3292,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeTypes/invalid-id", "host": [ @@ -3423,10 +3335,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeTypes/{{SETTINGA_ID}}", "host": [ @@ -5100,10 +5008,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases?name=ph", "host": [ @@ -5157,10 +5061,6 @@ "value": "Bearer {{copilot1_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases", "host": [ @@ -5208,10 +5108,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases?invalid=test", "host": [ @@ -5260,10 +5156,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases", "host": [ @@ -5311,10 +5203,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases", "host": [ @@ -5362,10 +5250,6 @@ "value": "Bearer {{expire_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases", "host": [ @@ -5413,10 +5297,6 @@ "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases", "host": [ @@ -5464,67 +5344,6 @@ "value": "Bearer {{m2m_challenge_phases_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{URL}}/challengePhases?name=ph", - "host": [ - "{{URL}}" - ], - "path": [ - "challengePhases" - ], - "query": [ - { - "key": "name", - "value": "ph" - } - ] - } - }, - "response": [] - }, - { - "name": "failure search challenge phases using forbidden m2m 403", - "event": [ - { - "listen": "test", - "script": { - "id": "7fbd663d-76fb-4c4d-b7b6-0baf9ca6b86e", - "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Accept", - "type": "text", - "value": "application/json" - }, - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{m2m_challenges_read}}" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases?name=ph", "host": [ @@ -5584,10 +5403,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{PHASEA_ID}}", "host": [ @@ -5636,10 +5451,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{PHASEB_ID}}", "host": [ @@ -5688,10 +5499,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/invalid-id", "host": [ @@ -5735,10 +5542,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{PHASEB_ID}}", "host": [ @@ -5787,10 +5590,6 @@ "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{PHASEB_ID}}", "host": [ @@ -5839,10 +5638,6 @@ "value": "Bearer {{expire_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{PHASEB_ID}}", "host": [ @@ -5891,10 +5686,6 @@ "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{PHASEB_ID}}", "host": [ @@ -5943,10 +5734,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{TYPEA_ID}}", "host": [ @@ -5995,10 +5782,6 @@ "value": "Bearer {{m2m_challenge_phases_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{TEST_PHASE_M2M_ID}}", "host": [ @@ -6047,10 +5830,6 @@ "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengePhases/{{TEST_PHASE_M2M_ID}}", "host": [ @@ -8198,10 +7977,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/timelineTemplates?name=1", "host": [ @@ -8255,10 +8030,6 @@ "value": "Bearer {{copilot1_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/timelineTemplates?name=LA", "host": [ @@ -8312,10 +8083,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/timelineTemplates?invalid=test", "host": [ @@ -8333,17 +8100,23 @@ } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + }, + { + "name": "get timeline template", + "item": [ { - "name": "search timeline template without token 401", + "name": "get timeline template by admin", "event": [ { "listen": "test", "script": { - "id": "7fbd663d-76fb-4c4d-b7b6-0baf9ca6b86e", + "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -8362,40 +8135,36 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates?name=1", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates" - ], - "query": [ - { - "key": "name", - "value": "1" - } + "timelineTemplates", + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "search timeline template with invalid token 401", + "name": "get timeline template by copilot", "event": [ { "listen": "test", "script": { - "id": "7fbd663d-76fb-4c4d-b7b6-0baf9ca6b86e", + "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -8418,41 +8187,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer invalid" + "value": "Bearer {{copilot1_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates?name=1", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEB_ID}}", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates" - ], - "query": [ - { - "key": "name", - "value": "1" - } + "timelineTemplates", + "{{TEMPLATEB_ID}}" ] } }, "response": [] }, { - "name": "search timeline template with expired token 401", + "name": "failure get timeline template invalid id 400", "event": [ { "listen": "test", "script": { - "id": "7fbd663d-76fb-4c4d-b7b6-0baf9ca6b86e", + "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -8475,41 +8235,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{expire_token}}" + "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates?name=1", + "raw": "{{URL}}/timelineTemplates/invalid-id", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates" - ], - "query": [ - { - "key": "name", - "value": "1" - } + "timelineTemplates", + "invalid-id" ] } }, "response": [] }, { - "name": "search timeline template by user", + "name": "failure get timeline template with expired token 401", "event": [ { "listen": "test", "script": { - "id": "7fbd663d-76fb-4c4d-b7b6-0baf9ca6b86e", + "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -8532,41 +8283,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{user_token}}" + "value": "Bearer {{expire_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates?name=1", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates" - ], - "query": [ - { - "key": "name", - "value": "1" - } + "timelineTemplates", + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "search timeline template using m2m", + "name": "failure get timeline template with invalid token 401", "event": [ { "listen": "test", "script": { - "id": "7fbd663d-76fb-4c4d-b7b6-0baf9ca6b86e", + "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -8589,41 +8331,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_timeline_templates_read}}" + "value": "Bearer invalid" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates?name=1", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates" - ], - "query": [ - { - "key": "name", - "value": "1" - } + "timelineTemplates", + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "failure search timeline template using forbidden m2m 403", + "name": "failure get timeline template without token 401", "event": [ { "listen": "test", "script": { - "id": "7fbd663d-76fb-4c4d-b7b6-0baf9ca6b86e", + "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -8642,51 +8375,31 @@ "key": "Content-Type", "type": "text", "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates?name=1", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates" - ], - "query": [ - { - "key": "name", - "value": "1" - } + "timelineTemplates", + "{{TEMPLATEA_ID}}" ] } }, "response": [] - } - ], - "_postman_isSubFolder": true - }, - { - "name": "get timeline template", - "item": [ + }, { - "name": "get timeline template by admin", + "name": "failure get timeline template by user 403", "event": [ { "listen": "test", "script": { "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -8709,13 +8422,9 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ @@ -8730,15 +8439,15 @@ "response": [] }, { - "name": "get timeline template by copilot", + "name": "failure get timeline template not found 404", "event": [ { "listen": "test", "script": { "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -8761,36 +8470,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{copilot1_token}}" + "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEB_ID}}", + "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEB_ID}}" + "{{SETTINGA_ID}}" ] } }, "response": [] }, { - "name": "failure get timeline template invalid id 400", + "name": "get timeline template using m2m", "event": [ { "listen": "test", "script": { "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -8813,36 +8518,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{m2m_timeline_templates_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates/invalid-id", + "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "invalid-id" + "{{TEST_TEMPLATE_M2M_ID}}" ] } }, "response": [] }, { - "name": "failure get timeline template with expired token 401", + "name": "failure get timeline template using forbidden m2m 403", "event": [ { "listen": "test", "script": { "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -8865,36 +8566,38 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{expire_token}}" + "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEST_TEMPLATE_M2M_ID}}" ] } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + }, + { + "name": "partial update timeline template", + "item": [ { - "name": "failure get timeline template with invalid token 401", + "name": "partial update timeline template 1", "event": [ { "listen": "test", "script": { - "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", + "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -8902,7 +8605,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -8917,12 +8620,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer invalid" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" }, "url": { "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", @@ -8938,15 +8641,15 @@ "response": [] }, { - "name": "failure get timeline template without token 401", + "name": "partial update timeline template 2", "event": [ { "listen": "test", "script": { - "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", + "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -8954,7 +8657,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -8965,35 +8668,40 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"template-2\",\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\t\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEB_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEMPLATEB_ID}}" ] } }, "response": [] }, { - "name": "failure get timeline template by user 403", + "name": "failure partial update timeline template phases can't be empty 400", "event": [ { "listen": "test", "script": { - "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", + "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -9001,7 +8709,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -9016,12 +8724,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{user_token}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\",\n \"phases\": []\n}\n" }, "url": { "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", @@ -9037,15 +8745,15 @@ "response": [] }, { - "name": "failure get timeline template not found 404", + "name": "failure partial update timeline template with invalid token 401", "event": [ { "listen": "test", "script": { - "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", + "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -9053,7 +8761,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -9068,36 +8776,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer invalid" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{SETTINGA_ID}}" + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "get timeline template using m2m", + "name": "failure partial update timeline template with expired token 401", "event": [ { "listen": "test", "script": { - "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", + "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -9105,7 +8813,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -9120,33 +8828,33 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_timeline_templates_read}}" + "value": "Bearer {{expire_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEST_TEMPLATE_M2M_ID}}" + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "failure get timeline template using forbidden m2m 403", + "name": "failure partial update timeline template by copilot 403", "event": [ { "listen": "test", "script": { - "id": "3e3dd07c-3ce6-47fe-86eb-a0a01ea1cfec", + "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -9157,7 +8865,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -9172,42 +8880,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_read}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEST_TEMPLATE_M2M_ID}}" + "{{TEMPLATEA_ID}}" ] } }, "response": [] - } - ], - "_postman_isSubFolder": true - }, - { - "name": "partial update timeline template", - "item": [ + }, { - "name": "partial update timeline template 1", + "name": "failure partial update timeline template not found 404", "event": [ { "listen": "test", "script": { "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -9238,28 +8940,28 @@ "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{SETTINGA_ID}}" ] } }, "response": [] }, { - "name": "partial update timeline template 2", + "name": "failure partial update timeline template duplicate name 409", "event": [ { "listen": "test", "script": { "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 409\", function () {", + " pm.response.to.have.status(409);", "});" ], "type": "text/javascript" @@ -9287,31 +8989,31 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-2\",\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\t\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "{\n\t\"name\": \"template-2\",\n \"description\": \"new-desc-1\"\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEB_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEB_ID}}" + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "failure partial update timeline template phases can't be empty 400", + "name": "partial update timeline template using m2m token", "event": [ { "listen": "test", "script": { "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -9334,36 +9036,42 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{m2m_timeline_templates_update}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\",\n \"phases\": []\n}\n" + "raw": "{\n\t\"name\": \"new-template-m2m\",\n \"description\": \"new-desc-m2m\"\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEST_TEMPLATE_M2M_ID}}" ] } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + }, + { + "name": "update timeline template", + "item": [ { - "name": "failure partial update timeline template with invalid token 401", + "name": "update timeline template 1", "event": [ { "listen": "test", "script": { - "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", + "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -9371,7 +9079,7 @@ } ], "request": { - "method": "PATCH", + "method": "PUT", "header": [ { "key": "Accept", @@ -9386,12 +9094,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer invalid" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" + "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", @@ -9407,15 +9115,15 @@ "response": [] }, { - "name": "failure partial update timeline template with expired token 401", + "name": "update timeline template 2", "event": [ { "listen": "test", "script": { - "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", + "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -9423,7 +9131,7 @@ } ], "request": { - "method": "PATCH", + "method": "PUT", "header": [ { "key": "Accept", @@ -9438,36 +9146,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{expire_token}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" + "raw": "{\n\t\"name\": \"template-2\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEB_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEMPLATEB_ID}}" ] } }, "response": [] }, { - "name": "failure partial update timeline template by copilot 403", + "name": "failure update timeline template incorrect phase 400", "event": [ { "listen": "test", "script": { - "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", + "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -9475,7 +9183,7 @@ } ], "request": { - "method": "PATCH", + "method": "PUT", "header": [ { "key": "Accept", @@ -9490,36 +9198,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{copilot1_token}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" + "raw": "{\n\t\"name\": \"template-3\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{SETTINGA_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEMPLATEC_ID}}" ] } }, "response": [] }, { - "name": "failure partial update timeline template not found 404", + "name": "failure update timeline template inconsistent phase 400", "event": [ { "listen": "test", "script": { - "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", + "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -9527,7 +9235,7 @@ } ], "request": { - "method": "PATCH", + "method": "PUT", "header": [ { "key": "Accept", @@ -9547,31 +9255,31 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"new-template-1\",\n \"description\": \"new-desc-1\"\n}\n" + "raw": "{\n\t\"name\": \"template-3\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"inconsistent-datat\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{SETTINGA_ID}}" + "{{TEMPLATEC_ID}}" ] } }, "response": [] }, { - "name": "failure partial update timeline template duplicate name 409", + "name": "failure update timeline template invalid id", "event": [ { "listen": "test", "script": { - "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", + "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 409\", function () {", - " pm.response.to.have.status(409);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -9579,7 +9287,7 @@ } ], "request": { - "method": "PATCH", + "method": "PUT", "header": [ { "key": "Accept", @@ -9599,31 +9307,31 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-2\",\n \"description\": \"new-desc-1\"\n}\n" + "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/invalid-id", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "invalid-id" ] } }, "response": [] }, { - "name": "partial update timeline template using m2m token", + "name": "failure update timeline template with expired token 401", "event": [ { "listen": "test", "script": { - "id": "c6ad399d-6048-445e-a0c1-b99395ce0b76", + "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -9631,7 +9339,7 @@ } ], "request": { - "method": "PATCH", + "method": "PUT", "header": [ { "key": "Accept", @@ -9646,42 +9354,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_timeline_templates_update}}" + "value": "Bearer {{expire_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"new-template-m2m\",\n \"description\": \"new-desc-m2m\"\n}\n" + "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEST_TEMPLATE_M2M_ID}}" + "{{TEMPLATEA_ID}}" ] } }, "response": [] - } - ], - "_postman_isSubFolder": true - }, - { - "name": "update timeline template", - "item": [ + }, { - "name": "update timeline template 1", + "name": "failure update timeline template invalid token 401", "event": [ { "listen": "test", "script": { "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -9704,7 +9406,7 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer invalid" } ], "body": { @@ -9725,15 +9427,15 @@ "response": [] }, { - "name": "update timeline template 2", + "name": "failure update timeline template by copilot 403", "event": [ { "listen": "test", "script": { "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -9756,36 +9458,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-2\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEB_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEB_ID}}" + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "failure update timeline template incorrect phase 400", + "name": "failure update timeline template not found 404", "event": [ { "listen": "test", "script": { "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -9813,31 +9515,31 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-3\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{SETTINGA_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", + "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEC_ID}}" + "{{SETTINGA_ID}}" ] } }, "response": [] }, { - "name": "failure update timeline template inconsistent phase 400", + "name": "failure update timeline template duplicate name 409", "event": [ { "listen": "test", "script": { "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 409\", function () {", + " pm.response.to.have.status(409);", "});" ], "type": "text/javascript" @@ -9865,31 +9567,31 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-3\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"inconsistent-datat\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "{\n\t\"name\": \"TEMPlate-2\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEC_ID}}" + "{{TEMPLATEA_ID}}" ] } }, "response": [] }, { - "name": "failure update timeline template invalid id", + "name": "update timeline template using m2m", "event": [ { "listen": "test", "script": { - "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", + "id": "09e1d09d-b72f-4809-ac29-c458b90cb631", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -9912,36 +9614,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{m2m_timeline_templates_update}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "{\n\t\"name\": \"update-template-by-m2m\",\n \"description\": \"update-desc-by-m2m\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/invalid-id", + "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "invalid-id" + "{{TEST_TEMPLATE_M2M_ID}}" ] } }, "response": [] }, { - "name": "failure update timeline template with expired token 401", + "name": "failure update timeline template using forbidden m2m 403", "event": [ { "listen": "test", "script": { - "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", + "id": "09e1d09d-b72f-4809-ac29-c458b90cb631", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -9964,36 +9666,42 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{expire_token}}" + "value": "Bearer {{m2m_challenges_read}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "{\n\t\"name\": \"update-template-by-m2m\",\n \"description\": \"update-desc-by-m2m\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEST_TEMPLATE_M2M_ID}}" ] } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + }, + { + "name": "delete timeline template", + "item": [ { - "name": "failure update timeline template invalid token 401", + "name": "delete timeline template", "event": [ { "listen": "test", "script": { - "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", + "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -10001,7 +9709,7 @@ } ], "request": { - "method": "PUT", + "method": "DELETE", "header": [ { "key": "Accept", @@ -10016,36 +9724,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer invalid" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEMPLATEC_ID}}" ] } }, "response": [] }, { - "name": "failure update timeline template by copilot 403", + "name": "failure delete timeline template invalid id 400", "event": [ { "listen": "test", "script": { - "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", + "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -10053,7 +9761,7 @@ } ], "request": { - "method": "PUT", + "method": "DELETE", "header": [ { "key": "Accept", @@ -10068,36 +9776,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{copilot1_token}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/invalid-id", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "invalid-id" ] } }, "response": [] }, { - "name": "failure update timeline template not found 404", + "name": "failure delete timeline template without token 401", "event": [ { "listen": "test", "script": { - "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", + "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -10105,7 +9813,7 @@ } ], "request": { - "method": "PUT", + "method": "DELETE", "header": [ { "key": "Accept", @@ -10116,40 +9824,35 @@ "key": "Content-Type", "type": "text", "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"template-1\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{SETTINGA_ID}}" + "{{TEMPLATEC_ID}}" ] } }, "response": [] }, { - "name": "failure update timeline template duplicate name 409", + "name": "failure delete timeline template with invalid token 401", "event": [ { "listen": "test", "script": { - "id": "4ea1db72-9445-4dae-a372-fcd7c8c9de80", + "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 409\", function () {", - " pm.response.to.have.status(409);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -10157,7 +9860,7 @@ } ], "request": { - "method": "PUT", + "method": "DELETE", "header": [ { "key": "Accept", @@ -10171,37 +9874,37 @@ }, { "key": "Authorization", - "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer invalid", + "type": "text" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"TEMPlate-2\",\n \"description\": \"desc-1\",\n \"isActive\": true,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEA_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEA_ID}}" + "{{TEMPLATEC_ID}}" ] } }, "response": [] }, { - "name": "update timeline template using m2m", + "name": "failure delete timeline template with expired token 401", "event": [ { "listen": "test", "script": { - "id": "09e1d09d-b72f-4809-ac29-c458b90cb631", + "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 401\", function () {", + " pm.response.to.have.status(401);", "});" ], "type": "text/javascript" @@ -10209,7 +9912,7 @@ } ], "request": { - "method": "PUT", + "method": "DELETE", "header": [ { "key": "Accept", @@ -10224,33 +9927,33 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_timeline_templates_update}}" + "value": "Bearer {{expire_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"update-template-by-m2m\",\n \"description\": \"update-desc-by-m2m\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEST_TEMPLATE_M2M_ID}}" + "{{TEMPLATEC_ID}}" ] } }, "response": [] }, { - "name": "failure update timeline template using forbidden m2m 403", + "name": "failure delete timeline template by copilot 403", "event": [ { "listen": "test", "script": { - "id": "09e1d09d-b72f-4809-ac29-c458b90cb631", + "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -10261,7 +9964,7 @@ } ], "request": { - "method": "PUT", + "method": "DELETE", "header": [ { "key": "Accept", @@ -10276,42 +9979,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_read}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"update-template-by-m2m\",\n \"description\": \"update-desc-by-m2m\",\n \"isActive\": false,\n \"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 20000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n\t \"predecessor\": \"{{PHASEA_ID}}\",\n \t\"isActive\": true,\n\t \"duration\": 10000\n }\n ]\n}\n" + "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEST_TEMPLATE_M2M_ID}}" + "{{TEMPLATEC_ID}}" ] } }, "response": [] - } - ], - "_postman_isSubFolder": true - }, - { - "name": "delete timeline template", - "item": [ + }, { - "name": "delete timeline template", + "name": "failure delete timeline template not found 404", "event": [ { "listen": "test", "script": { "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -10342,28 +10039,28 @@ "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", + "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEC_ID}}" + "{{SETTINGA_ID}}" ] } }, "response": [] }, { - "name": "failure delete timeline template invalid id 400", + "name": "delete timeline template using m2m token", "event": [ { "listen": "test", "script": { "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -10386,7 +10083,7 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{m2m_timeline_templates_delete}}" } ], "body": { @@ -10394,28 +10091,28 @@ "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/invalid-id", + "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "invalid-id" + "{{TEST_TEMPLATE_M2M_ID}}" ] } }, "response": [] }, { - "name": "failure delete timeline template without token 401", + "name": "failure delete timeline template using forbidden m2m token 403", "event": [ { "listen": "test", "script": { "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -10434,6 +10131,11 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_challenges_read}}" } ], "body": { @@ -10441,28 +10143,40 @@ "raw": "" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", + "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "timelineTemplates", - "{{TEMPLATEC_ID}}" + "{{TEST_TEMPLATE_M2M_ID}}" ] } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + } + ] + }, + { + "name": "Challenges", + "item": [ + { + "name": "create challenge", + "item": [ { - "name": "failure delete timeline template with invalid token 401", + "name": "create challenge by admin", "event": [ { "listen": "test", "script": { - "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + " pm.environment.set(\"CHALLENGE_ID1\", pm.response.json().id);", "});" ], "type": "text/javascript" @@ -10470,51 +10184,51 @@ } ], "request": { - "method": "DELETE", + "method": "POST", "header": [ { "key": "Accept", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" }, { "key": "Content-Type", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" }, { "key": "Authorization", - "value": "Bearer invalid", + "value": "Bearer {{admin_token}}", "type": "text" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\",\n\t\"startDate\": \"2019-06-22T16:28:39.882Z\"\n}" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", + "raw": "{{URL}}/challenges", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates", - "{{TEMPLATEC_ID}}" + "challenges" ] } }, "response": [] }, { - "name": "failure delete timeline template with expired token 401", + "name": "create challenge by copilot", "event": [ { "listen": "test", "script": { - "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 401\", function () {", - " pm.response.to.have.status(401);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + " pm.environment.set(\"CHALLENGE_ID2\", pm.response.json().id);", "});" ], "type": "text/javascript" @@ -10522,7 +10236,7 @@ } ], "request": { - "method": "DELETE", + "method": "POST", "header": [ { "key": "Accept", @@ -10537,36 +10251,35 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{expire_token}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID2}}\",\n\t\"track\": \"test-track-1\",\n\t\"name\": \"test-create-copilot\",\n\t\"description\": \"test-description\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID3}}\",\n\t\t\t\"value\": \"value3\"\n\t\t},\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID4}}\",\n\t\t\t\"value\": \"value4\"\n\t\t}\n\t],\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\",\n\t\"groups\": [\"group1\", \"group2\"],\n\t\"startDate\": \"2019-06-22T16:28:39.882Z\"\n}" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", + "raw": "{{URL}}/challenges", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates", - "{{TEMPLATEC_ID}}" + "challenges" ] } }, "response": [] }, { - "name": "failure delete timeline template by copilot 403", + "name": "failure create challenge invalid tags", "event": [ { "listen": "test", "script": { - "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -10574,7 +10287,7 @@ } ], "request": { - "method": "DELETE", + "method": "POST", "header": [ { "key": "Accept", @@ -10589,36 +10302,35 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{copilot1_token}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": {\"tag1\": \"tag2\"},\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEMPLATEC_ID}}", + "raw": "{{URL}}/challenges", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates", - "{{TEMPLATEC_ID}}" + "challenges" ] } }, "response": [] }, { - "name": "failure delete timeline template not found 404", + "name": "failure create challenge invalid status", "event": [ { "listen": "test", "script": { - "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -10626,7 +10338,7 @@ } ], "request": { - "method": "DELETE", + "method": "POST", "header": [ { "key": "Accept", @@ -10646,31 +10358,30 @@ ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"invalid\"\n}" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{SETTINGA_ID}}", + "raw": "{{URL}}/challenges", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates", - "{{SETTINGA_ID}}" + "challenges" ] } }, "response": [] }, { - "name": "delete timeline template using m2m token", + "name": "failure create challenge using invactive time template 400", "event": [ { "listen": "test", "script": { - "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -10678,7 +10389,7 @@ } ], "request": { - "method": "DELETE", + "method": "POST", "header": [ { "key": "Accept", @@ -10693,36 +10404,35 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_timeline_templates_delete}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEB_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", + "raw": "{{URL}}/challenges", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates", - "{{TEST_TEMPLATE_M2M_ID}}" + "challenges" ] } }, "response": [] }, { - "name": "failure delete timeline template using forbidden m2m token 403", + "name": "failure create challenge using empty prizeSets 400", "event": [ { "listen": "test", "script": { - "id": "e547ddc3-44a5-413e-a9e7-f98bb2262398", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -10730,7 +10440,7 @@ } ], "request": { - "method": "DELETE", + "method": "POST", "header": [ { "key": "Accept", @@ -10745,48 +10455,35 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_read}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { - "raw": "{{URL}}/timelineTemplates/{{TEST_TEMPLATE_M2M_ID}}", + "raw": "{{URL}}/challenges", "host": [ "{{URL}}" ], "path": [ - "timelineTemplates", - "{{TEST_TEMPLATE_M2M_ID}}" + "challenges" ] } }, "response": [] - } - ], - "_postman_isSubFolder": true - } - ] - }, - { - "name": "Challenges", - "item": [ - { - "name": "create challenge", - "item": [ + }, { - "name": "create challenge by admin", + "name": "failure create challenge using empty prizes array 400", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 201\", function () {", - " pm.response.to.have.status(201);", - " pm.environment.set(\"CHALLENGE_ID1\", pm.response.json().id);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -10798,23 +10495,23 @@ "header": [ { "key": "Accept", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" }, { "key": "Content-Type", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" }, { "key": "Authorization", - "value": "Bearer {{admin_token}}", - "type": "text" + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\",\n\t\"startDate\": \"2019-06-22T16:28:39.882Z\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": []\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -10829,16 +10526,15 @@ "response": [] }, { - "name": "create challenge by copilot", + "name": "failure create challenge invalid parameter 400", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 201\", function () {", - " pm.response.to.have.status(201);", - " pm.environment.set(\"CHALLENGE_ID2\", pm.response.json().id);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -10861,12 +10557,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{copilot1_token}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID2}}\",\n\t\"track\": \"test-track-1\",\n\t\"name\": \"test-create-copilot\",\n\t\"description\": \"test-description\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID3}}\",\n\t\t\t\"value\": \"value3\"\n\t\t},\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID4}}\",\n\t\t\t\"value\": \"value4\"\n\t\t}\n\t],\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\",\n\t\"groups\": [\"group1\", \"group2\"],\n\t\"startDate\": \"2019-06-22T16:28:39.882Z\"\n}" + "raw": "{\n\t\"typeId\": 12345,\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -10881,7 +10577,7 @@ "response": [] }, { - "name": "failure create challenge invalid tags", + "name": "failure create challenge using empty phases 400", "event": [ { "listen": "test", @@ -10917,7 +10613,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": {\"tag1\": \"tag2\"},\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -10932,7 +10628,7 @@ "response": [] }, { - "name": "failure create challenge invalid status", + "name": "failure create challenge missing parameter 400", "event": [ { "listen": "test", @@ -10968,7 +10664,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"invalid\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t]\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -10983,7 +10679,7 @@ "response": [] }, { - "name": "failure create challenge using invactive time template 400", + "name": "failure create challenge invalid settings 400", "event": [ { "listen": "test", @@ -11019,7 +10715,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEB_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TYPEA_ID}}\",\n\t\t\t\"value\": \"value3\"\n\t\t},\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID4}}\",\n\t\t\t\"value\": \"value4\"\n\t\t}\n\t],\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11034,7 +10730,7 @@ "response": [] }, { - "name": "failure create challenge using empty prizeSets 400", + "name": "failure create challenge invalid phases 400", "event": [ { "listen": "test", @@ -11070,7 +10766,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"inconsistent\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASED_ID}}\",\n \t\"name\": \"phase-4\",\n \t\t\"isActive\": false,\n\t \t\"duration\": 2000000\n },\n {\n \t\"id\": \"{{TYPEA_ID}}\",\n \t\"name\": \"not-found\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11085,7 +10781,7 @@ "response": [] }, { - "name": "failure create challenge using empty prizes array 400", + "name": "failure create challenge invalid prizeSet type 400", "event": [ { "listen": "test", @@ -11121,7 +10817,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": []\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"invalid\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11136,7 +10832,7 @@ "response": [] }, { - "name": "failure create challenge invalid parameter 400", + "name": "faiclure reate challenge invalid prize type", "event": [ { "listen": "test", @@ -11172,7 +10868,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": 12345,\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"invalid\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11187,15 +10883,15 @@ "response": [] }, { - "name": "failure create challenge using empty phases 400", + "name": "failure create challenge by user 403", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -11218,12 +10914,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{user_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11238,15 +10934,16 @@ "response": [] }, { - "name": "failure create challenge missing parameter 400", + "name": "create challenge using m2m", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + " pm.environment.set(\"TEST_CHALLENGE_M2M_ID\", pm.response.json().id);", "});" ], "type": "text/javascript" @@ -11269,12 +10966,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{m2m_challenges_create}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t]\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create-m2m\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\",\n\t\"startDate\": \"2019-06-22T16:28:39.882Z\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11289,7 +10986,7 @@ "response": [] }, { - "name": "failure create challenge invalid settings 400", + "name": "failure create challenge project not found 400", "event": [ { "listen": "test", @@ -11320,12 +11017,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TYPEA_ID}}\",\n\t\t\t\"value\": \"value3\"\n\t\t},\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID4}}\",\n\t\t\t\"value\": \"value4\"\n\t\t}\n\t],\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID2}}\",\n\t\"track\": \"test-track-1\",\n\t\"name\": \"test-create-copilot\",\n\t\"description\": \"test-description\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID3}}\",\n\t\t\t\"value\": \"value3\"\n\t\t},\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID4}}\",\n\t\t\t\"value\": \"value4\"\n\t\t}\n\t],\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 10000,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\",\n\t\"groups\": [\"group1\", \"group2\"],\n\t\"startDate\": \"2019-06-22T16:28:39.882Z\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11340,15 +11037,15 @@ "response": [] }, { - "name": "failure create challenge invalid phases 400", + "name": "failure create challenge user can't access specific project", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -11371,12 +11068,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"inconsistent\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASED_ID}}\",\n \t\"name\": \"phase-4\",\n \t\t\"isActive\": false,\n\t \t\"duration\": 2000000\n },\n {\n \t\"id\": \"{{TYPEA_ID}}\",\n \t\"name\": \"not-found\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID2}}\",\n\t\"track\": \"test-track-1\",\n\t\"name\": \"test-create-copilot\",\n\t\"description\": \"test-description\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID3}}\",\n\t\t\t\"value\": \"value3\"\n\t\t},\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID4}}\",\n\t\t\t\"value\": \"value4\"\n\t\t}\n\t],\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 200,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\",\n\t\"groups\": [\"group1\", \"group2\"],\n\t\"startDate\": \"2019-06-22T16:28:39.882Z\"\n}" }, "url": { "raw": "{{URL}}/challenges", @@ -11389,17 +11086,24 @@ } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + }, + { + "name": "upload attachment", + "item": [ { - "name": "failure create challenge invalid prizeSet type 400", + "name": "upload attachment by admin", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " pm.environment.set(\"ATTACHMENT_ID1\", pm.response.json().id);", "});" ], "type": "text/javascript" @@ -11409,16 +11113,6 @@ "request": { "method": "POST", "header": [ - { - "key": "Accept", - "type": "text", - "value": "application/json" - }, - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, { "key": "Authorization", "type": "text", @@ -11426,31 +11120,40 @@ } ], "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"invalid\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "mode": "formdata", + "formdata": [ + { + "key": "attachment", + "value": "", + "type": "file" + } + ] }, "url": { - "raw": "{{URL}}/challenges", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}/attachments", "host": [ "{{URL}}" ], "path": [ - "challenges" + "challenges", + "{{CHALLENGE_ID1}}", + "attachments" ] } }, "response": [] }, { - "name": "faiclure reate challenge invalid prize type", + "name": "upload attachment by copilot", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " pm.environment.set(\"ATTACHMENT_ID2\", pm.response.json().id);", "});" ], "type": "text/javascript" @@ -11460,40 +11163,38 @@ "request": { "method": "POST", "header": [ - { - "key": "Accept", - "type": "text", - "value": "application/json" - }, - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Code\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"invalid\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" + "mode": "formdata", + "formdata": [ + { + "key": "attachment", + "value": "", + "type": "file" + } + ] }, "url": { - "raw": "{{URL}}/challenges", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}/attachments", "host": [ "{{URL}}" ], "path": [ - "challenges" + "challenges", + "{{CHALLENGE_ID2}}", + "attachments" ] } }, "response": [] }, { - "name": "failure create challenge by user 403", + "name": "failure upload attachment by normal user 403", "event": [ { "listen": "test", @@ -11512,216 +11213,7 @@ "method": "POST", "header": [ { - "key": "Accept", - "type": "text", - "value": "application/json" - }, - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{user_token}}" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\"\n}" - }, - "url": { - "raw": "{{URL}}/challenges", - "host": [ - "{{URL}}" - ], - "path": [ - "challenges" - ] - } - }, - "response": [] - }, - { - "name": "create challenge using m2m", - "event": [ - { - "listen": "test", - "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", - "exec": [ - "pm.test(\"Status code is 201\", function () {", - " pm.response.to.have.status(201);", - " pm.environment.set(\"TEST_CHALLENGE_M2M_ID\", pm.response.json().id);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "type": "text", - "value": "application/json" - }, - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{m2m_challenges_create}}" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create-m2m\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" - }, - "url": { - "raw": "{{URL}}/challenges", - "host": [ - "{{URL}}" - ], - "path": [ - "challenges" - ] - } - }, - "response": [] - } - ], - "_postman_isSubFolder": true - }, - { - "name": "upload attachment", - "item": [ - { - "name": "upload attachment by admin", - "event": [ - { - "listen": "test", - "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - " pm.environment.set(\"ATTACHMENT_ID1\", pm.response.json().id);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{admin_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "attachment", - "type": "file", - "src": "" - } - ] - }, - "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}/attachments", - "host": [ - "{{URL}}" - ], - "path": [ - "challenges", - "{{CHALLENGE_ID1}}", - "attachments" - ] - } - }, - "response": [] - }, - { - "name": "upload attachment by copilot", - "event": [ - { - "listen": "test", - "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - " pm.environment.set(\"ATTACHMENT_ID2\", pm.response.json().id);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{copilot1_token}}" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "attachment", - "type": "file", - "src": "" - } - ] - }, - "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}/attachments", - "host": [ - "{{URL}}" - ], - "path": [ - "challenges", - "{{CHALLENGE_ID2}}", - "attachments" - ] - } - }, - "response": [] - }, - { - "name": "failure upload attachment by normal user 403", - "event": [ - { - "listen": "test", - "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", - "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Authorization", + "key": "Authorization", "type": "text", "value": "Bearer {{user_token}}" } @@ -11731,8 +11223,8 @@ "formdata": [ { "key": "attachment", - "type": "file", - "src": "" + "value": "", + "type": "file" } ] }, @@ -11780,8 +11272,8 @@ "formdata": [ { "key": "attachment", - "type": "file", - "src": "" + "value": "", + "type": "file" } ] }, @@ -11829,8 +11321,8 @@ "formdata": [ { "key": "attachment", - "type": "file", - "src": "" + "value": "", + "type": "file" } ] }, @@ -11872,8 +11364,8 @@ "formdata": [ { "key": "attachment", - "type": "file", - "src": "" + "value": "", + "type": "file" } ] }, @@ -11921,8 +11413,8 @@ "formdata": [ { "key": "wrong", - "type": "file", - "src": "" + "value": "", + "type": "file" } ] }, @@ -11971,8 +11463,8 @@ "formdata": [ { "key": "attachment", - "type": "file", - "src": "" + "value": "", + "type": "file" } ] }, @@ -12020,8 +11512,8 @@ "formdata": [ { "key": "attachment", - "type": "file", - "src": "" + "value": "", + "type": "file" } ] }, @@ -12070,10 +11562,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}/attachments/{{ATTACHMENT_ID1}}", "host": [ @@ -12114,10 +11602,6 @@ "value": "Bearer {{copilot1_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}/attachments/{{ATTACHMENT_ID2}}", "host": [ @@ -12158,10 +11642,6 @@ "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}/attachments/{{ATTACHMENT_ID2}}", "host": [ @@ -12202,10 +11682,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{TYPEA_ID}}/attachments/{{ATTACHMENT_ID1}}", "host": [ @@ -12246,10 +11722,6 @@ "value": "Bearer {{expire_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}/attachments/{{ATTACHMENT_ID1}}", "host": [ @@ -12290,10 +11762,6 @@ "value": "Bearer invalid" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}/attachments/{{ATTACHMENT_ID1}}", "host": [ @@ -12334,10 +11802,6 @@ "value": "Bearer {{copilot2_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}/attachments/{{ATTACHMENT_ID2}}", "host": [ @@ -12372,10 +11836,6 @@ "request": { "method": "GET", "header": [], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}/attachments/{{ATTACHMENT_ID2}}", "host": [ @@ -12416,10 +11876,6 @@ "value": "Bearer {{m2m_challenge_attachments_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}/attachments/{{TEST_ATTACHMENT_M2M_ID}}", "host": [ @@ -12460,10 +11916,6 @@ "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}/attachments/{{TEST_ATTACHMENT_M2M_ID}}", "host": [ @@ -12505,15 +11957,15 @@ "_postman_isSubFolder": true }, { - "name": "search challenge", + "name": "update challenge", "item": [ { - "name": "search challenge by admin", + "name": "update challenge 1 by admin", "event": [ { "listen": "test", "script": { - "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -12524,133 +11976,48 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" }, { "key": "Content-Type", - "value": "application/json", - "type": "text" - }, + "type": "text", + "value": "application/json" + }, { "key": "Authorization", - "value": "Bearer {{admin_token}}", - "type": "text" + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456456,\n\t\"legacyId\": 112233,\n\t\"status\": \"Active\"\n}" }, "url": { - "raw": "{{URL}}/challenges?page=1&perPage=10&id={{ES_CHALLENGE_ID}}&typeId={{ES_TYPE_ID}}&track=coDE&name=TEST&description=a b&timelineTemplateId={{ES_TIMELINE_TEMPLATE_ID}}&reviewType=code&tag=tag2&projectId=12&forumId=45&legacyId=55&status=Active&group=g1&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z&updatedDateStart=2017-02-22T00:00:00Z&updatedDateEnd=2028-02-22T00:00:00Z&createdBy=admin&updatedBy=user", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ - "challenges" - ], - "query": [ - { - "key": "page", - "value": "1" - }, - { - "key": "perPage", - "value": "10" - }, - { - "key": "id", - "value": "{{ES_CHALLENGE_ID}}" - }, - { - "key": "typeId", - "value": "{{ES_TYPE_ID}}" - }, - { - "key": "track", - "value": "coDE" - }, - { - "key": "name", - "value": "TEST" - }, - { - "key": "description", - "value": "a b" - }, - { - "key": "timelineTemplateId", - "value": "{{ES_TIMELINE_TEMPLATE_ID}}" - }, - { - "key": "reviewType", - "value": "code" - }, - { - "key": "tag", - "value": "tag2" - }, - { - "key": "projectId", - "value": "12" - }, - { - "key": "forumId", - "value": "45" - }, - { - "key": "legacyId", - "value": "55" - }, - { - "key": "status", - "value": "Active" - }, - { - "key": "group", - "value": "g1" - }, - { - "key": "createdDateStart", - "value": "2017-02-22T00:00:00Z" - }, - { - "key": "createdDateEnd", - "value": "2022-03-22T00:00:00Z" - }, - { - "key": "updatedDateStart", - "value": "2017-02-22T00:00:00Z" - }, - { - "key": "updatedDateEnd", - "value": "2028-02-22T00:00:00Z" - }, - { - "key": "createdBy", - "value": "admin" - }, - { - "key": "updatedBy", - "value": "user" - } + "challenges", + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "search challenge by copilot", + "name": "update challenge 1 with attachment by M2M", "event": [ { "listen": "test", "script": { - "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -12661,7 +12028,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -12676,51 +12043,33 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{copilot1_token}}" + "value": "Bearer {{m2m_challenges_update}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456456,\n\t\"legacyId\": 112233,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID1}}\"]\n}" }, "url": { - "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ - "challenges" - ], - "query": [ - { - "key": "perPage", - "value": "10" - }, - { - "key": "createdBy", - "value": "TonyJ", - "disabled": true - }, - { - "key": "createdDateStart", - "value": "2017-02-22T00:00:00Z" - }, - { - "key": "createdDateEnd", - "value": "2022-03-22T00:00:00Z" - } + "challenges", + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "search challenge by normal user", + "name": "update challenge 2 by copilot", "event": [ { "listen": "test", "script": { - "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -12731,7 +12080,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -12746,54 +12095,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{user_token}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"],\n\t\"groups\": [\"group1\", \"group2\", \"group3\"]\n}" }, "url": { - "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ - "challenges" - ], - "query": [ - { - "key": "perPage", - "value": "10" - }, - { - "key": "createdBy", - "value": "TonyJ", - "disabled": true - }, - { - "key": "createdDateStart", - "value": "2017-02-22T00:00:00Z" - }, - { - "key": "createdDateEnd", - "value": "2022-03-22T00:00:00Z" - } + "challenges", + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "search challenge by anonymous user", + "name": "failure update challenge invalid groups 400", "event": [ { "listen": "test", "script": { - "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -12801,7 +12132,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -12812,53 +12143,40 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID1}}\"],\n\t\"groups\": \"group1 group2\"\n}" }, "url": { - "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ - "challenges" - ], - "query": [ - { - "key": "perPage", - "value": "10" - }, - { - "key": "createdBy", - "value": "TonyJ", - "disabled": true - }, - { - "key": "createdDateStart", - "value": "2017-02-22T00:00:00Z" - }, - { - "key": "createdDateEnd", - "value": "2022-03-22T00:00:00Z" - } + "challenges", + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "failure search challenge invalid date 400", + "name": "failure update challenge attachment not found 404", "event": [ { "listen": "test", "script": { - "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -12866,7 +12184,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -12877,50 +12195,37 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{TYPEA_ID}}\"]\n}" }, "url": { - "raw": "{{URL}}/challenges?perPage=10&createdDateStart=abc&createdDateEnd=2022-03-22T00:00:00Z", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ - "challenges" - ], - "query": [ - { - "key": "perPage", - "value": "10" - }, - { - "key": "createdBy", - "value": "TonyJ", - "disabled": true - }, - { - "key": "createdDateStart", - "value": "abc" - }, - { - "key": "createdDateEnd", - "value": "2022-03-22T00:00:00Z" - } + "challenges", + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "failure search challenge invalid parameter 400", + "name": "failure update challenge invalid parameter 400", "event": [ { "listen": "test", "script": { - "id": "475c83d7-16fa-4e68-a5ce-5021b0ba1af2", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -12931,7 +12236,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -12942,40 +12247,92 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"invalid\": 123,\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID1}}\"]\n}" }, "url": { - "raw": "{{URL}}/challenges?invalid=test-", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ - "challenges" + "challenges", + "{{CHALLENGE_ID1}}" + ] + } + }, + "response": [] + }, + { + "name": "failure update challenge by different copilot 403", + "event": [ + { + "listen": "test", + "script": { + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "exec": [ + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "type": "text", + "value": "application/json" + }, + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot2_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"]\n}" + }, + "url": { + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "host": [ + "{{URL}}" ], - "query": [ - { - "key": "invalid", - "value": "test-" - } + "path": [ + "challenges", + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "search challenge using m2m with read scope", + "name": "failure update challenge by user 403", "event": [ { "listen": "test", "script": { - "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -12983,7 +12340,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -12998,51 +12355,85 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_read}}" + "value": "Bearer {{user_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"]\n}" }, "url": { - "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2016-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ - "challenges" + "challenges", + "{{CHALLENGE_ID2}}" + ] + } + }, + "response": [] + }, + { + "name": "failure update challenge not found 404", + "event": [ + { + "listen": "test", + "script": { + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "type": "text", + "value": "application/json" + }, + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"]\n}" + }, + "url": { + "raw": "{{URL}}/challenges/{{TYPEA_ID}}", + "host": [ + "{{URL}}" ], - "query": [ - { - "key": "perPage", - "value": "10" - }, - { - "key": "createdBy", - "value": "TonyJ", - "disabled": true - }, - { - "key": "createdDateStart", - "value": "2016-02-22T00:00:00Z" - }, - { - "key": "createdDateEnd", - "value": "2022-03-22T00:00:00Z" - } + "path": [ + "challenges", + "{{TYPEA_ID}}" ] } }, "response": [] }, { - "name": "search challenge using m2m without read scope(same as anonymous user)", + "name": "update challenge using m2m token", "event": [ { "listen": "test", "script": { - "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -13053,7 +12444,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -13068,60 +12459,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenge_attachments_read}}" + "value": "Bearer {{m2m_challenges_update}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-update-m2m\",\n\t\"description\": \"test-update-m2m\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { - "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", + "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ - "challenges" - ], - "query": [ - { - "key": "perPage", - "value": "10" - }, - { - "key": "createdBy", - "value": "TonyJ", - "disabled": true - }, - { - "key": "createdDateStart", - "value": "2017-02-22T00:00:00Z" - }, - { - "key": "createdDateEnd", - "value": "2022-03-22T00:00:00Z" - } + "challenges", + "{{TEST_CHALLENGE_M2M_ID}}" ] } }, "response": [] - } - ], - "_postman_isSubFolder": true - }, - { - "name": "get challenge", - "item": [ + }, { - "name": "get ES challenge by admin", + "name": "failure update challenge using forbidden m2m token 403", "event": [ { "listen": "test", "script": { - "id": "c1b8d8ca-64df-494c-9b8a-8507058e8692", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -13129,7 +12496,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -13143,37 +12510,37 @@ }, { "key": "Authorization", - "value": "Bearer {{admin_token}}", - "type": "text" + "type": "text", + "value": "Bearer {{m2m_challenge_attachments_read}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-update-m2m\",\n\t\"description\": \"test-update-m2m\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { - "raw": "{{URL}}/challenges/{{ES_CHALLENGE_ID}}", + "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{ES_CHALLENGE_ID}}" + "{{TEST_CHALLENGE_M2M_ID}}" ] } }, "response": [] }, { - "name": "get ES challenge by M2M", + "name": "failure update challenge project not found 400", "event": [ { "listen": "test", "script": { - "id": "c1b8d8ca-64df-494c-9b8a-8507058e8692", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -13181,7 +12548,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -13196,33 +12563,33 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_read}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 10000,\n\t\"forumId\": 456456,\n\t\"legacyId\": 112233,\n\t\"status\": \"Active\"\n}" }, "url": { - "raw": "{{URL}}/challenges/{{ES_CHALLENGE_ID}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{ES_CHALLENGE_ID}}" + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "failure get ES challenge by anonymous user", + "name": "failure update challenge user can't access the project 403", "event": [ { "listen": "test", "script": { - "id": "c1b8d8ca-64df-494c-9b8a-8507058e8692", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -13233,7 +12600,7 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Accept", @@ -13244,32 +12611,43 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 200,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"],\n\t\"groups\": [\"group1\", \"group2\", \"group3\"]\n}" }, "url": { - "raw": "{{URL}}/challenges/{{ES_CHALLENGE_ID}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{ES_CHALLENGE_ID}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + }, + { + "name": "partial update challenge", + "item": [ { - "name": "get challenge 1 by anonymous user", + "name": "partial update challenge 1 by admin", "event": [ { "listen": "test", "script": { - "id": "c1b8d8ca-64df-494c-9b8a-8507058e8692", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -13280,22 +12658,27 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" }, { "key": "Content-Type", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"legacyId\": 789789\n}" }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", @@ -13311,12 +12694,12 @@ "response": [] }, { - "name": "get challenge 2 by copilot", + "name": "partial update challenge 2 by copilot", "event": [ { "listen": "test", "script": { - "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -13327,7 +12710,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13341,13 +12724,13 @@ }, { "key": "Authorization", - "value": "Bearer {{copilot1_token}}", - "type": "text" + "type": "text", + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t],\n\t\"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 100\n }\n ]\n }\n ],\n\t\"status\": \"Completed\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"],\n\t\"groups\": [\"group1\", \"group2\", \"group3\", \"group4\"]\n}" }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", @@ -13363,15 +12746,15 @@ "response": [] }, { - "name": "get challenge 2 by admin", + "name": "failure partial update challenge duplicate groups 400", "event": [ { "listen": "test", "script": { - "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -13379,7 +12762,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13399,31 +12782,31 @@ ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 5000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 6000000\n }\n\t],\n\t\"tags\": [\"tag1\"],\n\t\"forumId\": 456456,\n\t\"status\": \"Completed\",\n\t\"groups\": [\"g1\", \"g1\"],\n\t\"attachmentIds\": []\n}" }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID2}}" + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "get challenge 2 by user without group access 403", + "name": "failure partial update challenge null group 400", "event": [ { "listen": "test", "script": { - "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -13431,7 +12814,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13446,36 +12829,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{user_token}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 5000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 6000000\n }\n\t],\n\t\"tags\": [\"tag1\"],\n\t\"forumId\": 456456,\n\t\"status\": \"Completed\",\n\t\"groups\": [null],\n\t\"attachmentIds\": []\n}" }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID2}}" + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "failure get challenge invalid id 400", + "name": "failure partial update challenge by different copilot 403", "event": [ { "listen": "test", "script": { - "id": "d24e0eab-d954-4abb-8444-8ef159337f07", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -13483,7 +12866,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13494,32 +12877,37 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot2_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{URL}}/challenges/invalid-id", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "invalid-id" + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "failure get challenge not found 404", + "name": "failure partial update challenge not found 404", "event": [ { "listen": "test", "script": { - "id": "d24e0eab-d954-4abb-8444-8ef159337f07", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -13530,7 +12918,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13541,11 +12929,16 @@ "key": "Content-Type", "type": "text", "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\"\n}" }, "url": { "raw": "{{URL}}/challenges/{{TYPEA_ID}}", @@ -13561,15 +12954,15 @@ "response": [] }, { - "name": "get challenge using m2m token with read scope", + "name": "failure partial update challenge invalid parameter 400", "event": [ { "listen": "test", "script": { - "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -13577,7 +12970,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13592,33 +12985,33 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_read}}" + "value": "Bearer {{admin_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"invalid\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\"\n}" }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID2}}" + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "failure get challenge 2 using m2m token without scope 403", + "name": "failure partial update challenge by user 403", "event": [ { "listen": "test", "script": { - "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -13629,7 +13022,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13644,12 +13037,12 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenge_attachments_read}}" + "value": "Bearer {{user_token}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t]\n}" }, "url": { "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", @@ -13665,12 +13058,12 @@ "response": [] }, { - "name": "failure get challenge 2 using invalid token 403", + "name": "failure partial update challenge using forbidden m2m token 403", "event": [ { "listen": "test", "script": { - "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", + "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -13681,7 +13074,7 @@ } ], "request": { - "method": "GET", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13696,43 +13089,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer invalid" + "value": "Bearer {{m2m_challenge_attachments_read}}" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"new-update-m2m\",\n\t\"description\": \"patch-update-m2m\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID2}}" + "{{TEST_CHALLENGE_M2M_ID}}" ] - }, - "description": "it will be consided as anonymous user" + } }, "response": [] - } - ], - "_postman_isSubFolder": true - }, - { - "name": "update challenge", - "item": [ + }, { - "name": "update challenge 1 by admin", + "name": "failure partial update challenge project not found", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -13740,7 +13126,7 @@ } ], "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13755,36 +13141,36 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"legacyId\": 112233,\n\t\"status\": \"Active\"\n}" + "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t],\n\t\"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 100\n }\n ]\n }\n ],\n\t\"status\": \"Completed\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"],\n\t\"groups\": [\"group1\", \"group2\", \"group3\", \"group4\"],\n\t\"projectId\": 1000\n}" }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID1}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "update challenge 1 with attachment by M2M", + "name": "failure partial update challenge user can't access specific project", "event": [ { "listen": "test", "script": { "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -13792,7 +13178,7 @@ } ], "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Accept", @@ -13807,33 +13193,39 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_update}}" + "value": "Bearer {{copilot1_token}}" } ], "body": { "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"legacyId\": 112233,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID1}}\"]\n}" + "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t],\n\t\"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 100\n }\n ]\n }\n ],\n\t\"status\": \"Completed\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"],\n\t\"groups\": [\"group1\", \"group2\", \"group3\", \"group4\"],\n\t\"projectId\": 200\n}" }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID1}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] - }, + } + ], + "_postman_isSubFolder": true + }, + { + "name": "get challenge", + "item": [ { - "name": "update challenge 2 by copilot", + "name": "get challenge 1 by anonymous user", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "c1b8d8ca-64df-494c-9b8a-8507058e8692", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -13844,51 +13236,42 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" }, { "key": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{copilot1_token}}" + "value": "application/json", + "type": "text" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"],\n\t\"groups\": [\"group1\", \"group2\", \"group3\"]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID2}}" + "{{CHALLENGE_ID1}}" ] } }, "response": [] }, { - "name": "failure update challenge invalid groups 400", + "name": "get challenge 2 by copilot", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -13896,7 +13279,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -13910,37 +13293,33 @@ }, { "key": "Authorization", - "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{copilot1_token}}", + "type": "text" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID1}}\"],\n\t\"groups\": \"group1 group2\"\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID1}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "failure update challenge attachment not found 404", + "name": "get challenge 2 by admin", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -13948,7 +13327,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -13966,33 +13345,29 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-create\",\n\t\"description\": \"test-description\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 10000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 600\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 300\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{TYPEA_ID}}\"]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID1}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "failure update challenge invalid parameter 400", + "name": "get challenge 2 by user without group access 403", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -14000,7 +13375,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -14015,36 +13390,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"invalid\": 123,\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 2\",\n\t\"tags\": [\"tag1\", \"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID1}}\"]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID1}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "failure update challenge by different copilot 403", + "name": "failure get challenge invalid id 400", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "d24e0eab-d954-4abb-8444-8ef159337f07", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -14052,7 +13423,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -14063,40 +13434,31 @@ "key": "Content-Type", "type": "text", "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{copilot2_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges/invalid-id", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID2}}" + "invalid-id" ] } }, "response": [] }, { - "name": "failure update challenge by user 403", + "name": "failure get challenge not found 404", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "d24e0eab-d954-4abb-8444-8ef159337f07", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -14104,7 +13466,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -14115,40 +13477,31 @@ "key": "Content-Type", "type": "text", "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges/{{TYPEA_ID}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{CHALLENGE_ID2}}" + "{{TYPEA_ID}}" ] } }, "response": [] }, { - "name": "failure update challenge not found 404", + "name": "get challenge using m2m token with read scope", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -14156,7 +13509,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -14171,36 +13524,32 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-track-1\",\n\t\"name\": \"update-name-1\",\n\t\"description\": \"update-description-1\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n {\n \"id\": \"{{PHASEA_ID}}\",\n \"name\": \"new-phase-1\",\n \"isActive\": true,\n \"duration\": 1000000\n },\n {\n \"id\": \"{{PHASEB_ID}}\",\n \"name\": \"new-PHASE-2\",\n \"description\": \"add-description-in-put\",\n \"predecessor\": \"{{PHASEA_ID}}\",\n \"isActive\": true,\n \"duration\": 2000000\n }\n ],\n \"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"description\": \"desc\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 500\n },\n {\n \"description\": \"desc-second\",\n \"type\": \"second place\",\n \"value\": 250\n }\n ]\n }\n ],\n\t\"reviewType\": \"review type 222\",\n\t\"tags\": [\"tag3\", \"tag4\"],\n\t\"projectId\": 123123,\n\t\"forumId\": 456456,\n\t\"status\": \"Active\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{TYPEA_ID}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{TYPEA_ID}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "update challenge using m2m token", + "name": "failure get challenge 2 using m2m token without scope 403", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(403);", "});" ], "type": "text/javascript" @@ -14208,7 +13557,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -14223,33 +13572,29 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenges_update}}" + "value": "Bearer {{m2m_challenge_attachments_read}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-update-m2m\",\n\t\"description\": \"test-update-m2m\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{TEST_CHALLENGE_M2M_ID}}" + "{{CHALLENGE_ID2}}" ] } }, "response": [] }, { - "name": "failure update challenge using forbidden m2m token 403", + "name": "failure get challenge 2 using invalid token 403", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0a63d8e6-2604-4836-9d3a-1f4f5b099305", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -14260,7 +13605,7 @@ } ], "request": { - "method": "PUT", + "method": "GET", "header": [ { "key": "Accept", @@ -14275,23 +13620,20 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{m2m_challenge_attachments_read}}" + "value": "Bearer invalid" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"test-update-m2m\",\n\t\"description\": \"test-update-m2m\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}", + "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", "host": [ "{{URL}}" ], "path": [ "challenges", - "{{TEST_CHALLENGE_M2M_ID}}" + "{{CHALLENGE_ID2}}" ] - } + }, + "description": "it will be consided as anonymous user" }, "response": [] } @@ -14299,15 +13641,15 @@ "_postman_isSubFolder": true }, { - "name": "partial update challenge", + "name": "search challenge", "item": [ { - "name": "partial update challenge 1 by admin", + "name": "search challenge by admin", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -14318,48 +13660,109 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" }, { "key": "Content-Type", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" }, { "key": "Authorization", - "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{admin_token}}", + "type": "text" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"legacyId\": 789789\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges?page=1&perPage=10&id={{CHALLENGE_ID1}}&track=track&name=TEST&description=test&reviewType=review type&tag=tag3&projectId=123&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z&updatedDateStart=2017-02-22T00:00:00Z&updatedDateEnd=2028-02-22T00:00:00Z&createdBy=Tonyj&updatedBy=Tonyj&memberId=40309246", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{CHALLENGE_ID1}}" + "challenges" + ], + "query": [ + { + "key": "page", + "value": "1" + }, + { + "key": "perPage", + "value": "10" + }, + { + "key": "id", + "value": "{{CHALLENGE_ID1}}" + }, + { + "key": "track", + "value": "track" + }, + { + "key": "name", + "value": "TEST" + }, + { + "key": "description", + "value": "test" + }, + { + "key": "reviewType", + "value": "review type" + }, + { + "key": "tag", + "value": "tag3" + }, + { + "key": "projectId", + "value": "123" + }, + { + "key": "createdDateStart", + "value": "2017-02-22T00:00:00Z" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + }, + { + "key": "updatedDateStart", + "value": "2017-02-22T00:00:00Z" + }, + { + "key": "updatedDateEnd", + "value": "2028-02-22T00:00:00Z" + }, + { + "key": "createdBy", + "value": "Tonyj" + }, + { + "key": "updatedBy", + "value": "Tonyj" + }, + { + "key": "memberId", + "value": "40309246" + } ] } }, "response": [] }, { - "name": "partial update challenge 2 by copilot", + "name": "search challenge by copilot", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -14370,7 +13773,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14388,33 +13791,51 @@ "value": "Bearer {{copilot1_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t],\n\t\"prizeSets\": [\n {\n \"type\": \"Challenge prizes\",\n \"prizes\": [\n {\n \"description\": \"desc-first\",\n \"type\": \"first place\",\n \"value\": 100\n }\n ]\n }\n ],\n\t\"status\": \"Completed\",\n\t\"attachmentIds\": [\"{{ATTACHMENT_ID2}}\"],\n\t\"groups\": [\"group1\", \"group2\", \"group3\", \"group4\"]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z&memberId=40309246", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{CHALLENGE_ID2}}" + "challenges" + ], + "query": [ + { + "key": "perPage", + "value": "10" + }, + { + "key": "createdBy", + "value": "TonyJ", + "disabled": true + }, + { + "key": "createdDateStart", + "value": "2017-02-22T00:00:00Z" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + }, + { + "key": "memberId", + "value": "40309246" + } ] } }, "response": [] }, { - "name": "failure partial update challenge duplicate groups 400", + "name": "search challenge by copilot using another memberId", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -14422,7 +13843,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14437,36 +13858,54 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{copilot1_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 5000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 6000000\n }\n\t],\n\t\"tags\": [\"tag1\"],\n\t\"forumId\": 456456,\n\t\"status\": \"Completed\",\n\t\"groups\": [\"g1\", \"g1\"],\n\t\"attachmentIds\": []\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z&memberId=151743", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{CHALLENGE_ID1}}" + "challenges" + ], + "query": [ + { + "key": "perPage", + "value": "10" + }, + { + "key": "createdBy", + "value": "TonyJ", + "disabled": true + }, + { + "key": "createdDateStart", + "value": "2017-02-22T00:00:00Z" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + }, + { + "key": "memberId", + "value": "151743" + } ] } }, "response": [] }, { - "name": "failure partial update challenge null group 400", + "name": "search challenge by normal user", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -14474,7 +13913,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14489,36 +13928,50 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{admin_token}}" + "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 5000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 6000000\n }\n\t],\n\t\"tags\": [\"tag1\"],\n\t\"forumId\": 456456,\n\t\"status\": \"Completed\",\n\t\"groups\": [null],\n\t\"attachmentIds\": []\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{CHALLENGE_ID1}}" + "challenges" + ], + "query": [ + { + "key": "perPage", + "value": "10" + }, + { + "key": "createdBy", + "value": "TonyJ", + "disabled": true + }, + { + "key": "createdDateStart", + "value": "2017-02-22T00:00:00Z" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + } ] } }, "response": [] }, { - "name": "failure partial update challenge by different copilot 403", + "name": "search challenge by anonymous user", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -14526,7 +13979,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14537,40 +13990,49 @@ "key": "Content-Type", "type": "text", "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{copilot2_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{CHALLENGE_ID2}}" + "challenges" + ], + "query": [ + { + "key": "perPage", + "value": "10" + }, + { + "key": "createdBy", + "value": "TonyJ", + "disabled": true + }, + { + "key": "createdDateStart", + "value": "2017-02-22T00:00:00Z" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + } ] } }, "response": [] }, { - "name": "failure partial update challenge not found 404", + "name": "failure search challenge invalid date 400", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -14578,7 +14040,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14589,37 +14051,46 @@ "key": "Content-Type", "type": "text", "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\"\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{TYPEA_ID}}", + "raw": "{{URL}}/challenges?perPage=10&createdDateStart=abc&createdDateEnd=2022-03-22T00:00:00Z", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{TYPEA_ID}}" + "challenges" + ], + "query": [ + { + "key": "perPage", + "value": "10" + }, + { + "key": "createdBy", + "value": "TonyJ", + "disabled": true + }, + { + "key": "createdDateStart", + "value": "abc" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + } ] } }, "response": [] }, { - "name": "failure partial update challenge invalid parameter 400", + "name": "failure search challenge invalid parameter 400", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "475c83d7-16fa-4e68-a5ce-5021b0ba1af2", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -14630,7 +14101,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14641,40 +14112,36 @@ "key": "Content-Type", "type": "text", "value": "application/json" - }, - { - "key": "Authorization", - "type": "text", - "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"invalid\": \"{{TEST_TYPE_ID4}}\",\n\t\"track\": \"update-new-track\",\n\t\"name\": \"update-name\"\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID1}}", + "raw": "{{URL}}/challenges?invalid=test-", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{CHALLENGE_ID1}}" + "challenges" + ], + "query": [ + { + "key": "invalid", + "value": "test-" + } ] } }, "response": [] }, { - "name": "failure partial update challenge by user 403", + "name": "search challenge using m2m with read scope", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -14682,7 +14149,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14697,36 +14164,50 @@ { "key": "Authorization", "type": "text", - "value": "Bearer {{user_token}}" + "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"name\": \"update-new-name-1\",\n\t\"challengeSettings\": [\n\t\t{\n\t\t\t\"type\": \"{{TEST_SETTING_ID5}}\",\n\t\t\t\"value\": \"value5\"\n\t\t}\n\t]\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{CHALLENGE_ID2}}", + "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2016-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{CHALLENGE_ID2}}" + "challenges" + ], + "query": [ + { + "key": "perPage", + "value": "10" + }, + { + "key": "createdBy", + "value": "TonyJ", + "disabled": true + }, + { + "key": "createdDateStart", + "value": "2016-02-22T00:00:00Z" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + } ] } }, "response": [] }, { - "name": "failure partial update challenge using forbidden m2m token 403", + "name": "search challenge using m2m without read scope(same as anonymous user)", "event": [ { "listen": "test", "script": { - "id": "03483bad-dfb2-45d1-bf42-35dd3bd46dad", + "id": "0f5c58f0-3b8c-4a8a-a6c8-2df8bd6d2cf0", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(403);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -14734,7 +14215,7 @@ } ], "request": { - "method": "PATCH", + "method": "GET", "header": [ { "key": "Accept", @@ -14752,18 +14233,32 @@ "value": "Bearer {{m2m_challenge_attachments_read}}" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"typeId\": \"{{TEST_TYPE_ID1}}\",\n\t\"track\": \"test-track\",\n\t\"name\": \"new-update-m2m\",\n\t\"description\": \"patch-update-m2m\",\n\t\"timelineTemplateId\": \"{{TEMPLATEA_ID}}\",\n\t\"phases\": [\n\t\t{\n \t\"id\": \"{{PHASEA_ID}}\",\n \t\"name\": \"new-phase-1\",\n \t\"isActive\": true,\n \t\"duration\": 1000000\n },\n {\n \t\"id\": \"{{PHASEB_ID}}\",\n \t\"name\": \"new-PHASE-2\",\n \t\"description\": \"add-description-in-put\",\n\t \t\"predecessor\": \"{{PHASEA_ID}}\",\n \t\t\"isActive\": true,\n\t \t\"duration\": 2000000\n }\n\t],\n\t\"prizeSets\": [\n\t\t{\n\t\t\t\"type\": \"Challenge prizes\",\n\t\t\t\"description\": \"desc\",\n\t\t\t\"prizes\": [\n\t\t {\n\t\t \"description\": \"desc-first\",\n\t\t \"type\": \"first place\",\n\t\t \"value\": 500\n\t\t },\n\t\t {\n\t\t \"description\": \"desc-second\",\n\t\t \"type\": \"second place\",\n\t\t \"value\": 250\n\t\t }\n\t\t ]\n\t\t}\n\t],\n\t\"reviewType\": \"review type\",\n\t\"tags\": [\"tag1\", \"tag2\"],\n\t\"projectId\": 123,\n\t\"forumId\": 456,\n\t\"status\": \"Draft\"\n}" - }, "url": { - "raw": "{{URL}}/challenges/{{TEST_CHALLENGE_M2M_ID}}", + "raw": "{{URL}}/challenges?perPage=10&createdDateStart=2017-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", "host": [ "{{URL}}" ], "path": [ - "challenges", - "{{TEST_CHALLENGE_M2M_ID}}" + "challenges" + ], + "query": [ + { + "key": "perPage", + "value": "10" + }, + { + "key": "createdBy", + "value": "TonyJ", + "disabled": true + }, + { + "key": "createdDateStart", + "value": "2017-02-22T00:00:00Z" + }, + { + "key": "createdDateEnd", + "value": "2022-03-22T00:00:00Z" + } ] } }, @@ -14812,10 +14307,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeAuditLogs?challengeId={{CHALLENGE_ID1}}&createdDateStart=2019-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", "host": [ @@ -14897,10 +14388,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeAuditLogs?challengeId={{CHALLENGE_ID2}}&createdDateStart=2019-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z&createdBy=ghostar", "host": [ @@ -14971,10 +14458,6 @@ "value": "Bearer {{user_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeAuditLogs?challengeId={{CHALLENGE_ID1}}&fieldName=n&createdDateStart=2019-02-22T00:00:00Z&createdDateEnd=2019-03-22T00:00:00Z&createdBy=tonyj", "host": [ @@ -15044,10 +14527,6 @@ "value": "Bearer {{expire_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeAuditLogs?challengeId={{CHALLENGE_ID1}}&fieldName=n&createdDateStart=2019-02-22T00:00:00Z&createdDateEnd=2019-03-22T00:00:00Z&createdBy=tonyj", "host": [ @@ -15117,10 +14596,6 @@ "value": "Bearer {{admin_token}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeAuditLogs?challengeId={{CHALLENGE_ID1}}&invalid=n&createdDateStart=2019-02-22T00:00:00Z&createdDateEnd=2019-03-22T00:00:00Z&createdBy=tonyj", "host": [ @@ -15190,10 +14665,6 @@ "value": "Bearer {{m2m_challenge_audit_logs_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeAuditLogs?challengeId={{CHALLENGE_ID1}}&createdDateStart=2019-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", "host": [ @@ -15275,10 +14746,6 @@ "value": "Bearer {{m2m_challenges_read}}" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/challengeAuditLogs?challengeId={{CHALLENGE_ID1}}&createdDateStart=2019-02-22T00:00:00Z&createdDateEnd=2022-03-22T00:00:00Z", "host": [ @@ -15360,10 +14827,6 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "{{URL}}/health", "host": [ @@ -15401,4 +14864,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/docs/topcoder-challenge-api.postman_environment.json b/docs/topcoder-challenge-api.postman_environment.json index ecef0136..298e2ab6 100644 --- a/docs/topcoder-challenge-api.postman_environment.json +++ b/docs/topcoder-challenge-api.postman_environment.json @@ -1,5 +1,5 @@ { - "id": "e393fed9-558b-405c-a845-d454483173ba", + "id": "4979dbeb-b48c-430f-a03a-b81beef39755", "name": "topcoder-challenge-api", "values": [ { @@ -14,7 +14,7 @@ }, { "key": "copilot1_token", - "value": "eeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJjb3BpbG90IiwiQ29ubmVjdCBTdXBwb3J0Il0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJHaG9zdGFyIiwiZXhwIjoxNTgyODAwMDc3LCJ1c2VySWQiOiIxNTE3NDMiLCJpYXQiOjE1NDk3OTk0NzcsImVtYWlsIjoiZW1haWxAZG9tYWluLmNvbS56IiwianRpIjoiMTJjMWMxMGItOTNlZi00NTMxLTgzMDUtYmE2NjVmYzRlMWI0In0.Y3SsmT-C21ahWrQQgd2SALDBgC_4qKyrWXesc2cB1Ys", + "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJjb3BpbG90IiwiQ29ubmVjdCBTdXBwb3J0Il0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJHaG9zdGFyIiwiZXhwIjoxNTgyODAwMDc3LCJ1c2VySWQiOiIxNTE3NDMiLCJpYXQiOjE1NDk3OTk0NzcsImVtYWlsIjoiZW1haWxAZG9tYWluLmNvbS56IiwianRpIjoiMTJjMWMxMGItOTNlZi00NTMxLTgzMDUtYmE2NjVmYzRlMWI0In0.Y3SsmT-C21ahWrQQgd2SALDBgC_4qKyrWXesc2cB1Ys", "enabled": true }, { @@ -286,36 +286,9 @@ "key": "TEST_ATTACHMENT_M2M_ID", "value": "", "enabled": true - }, - { - "key": "ES_CHALLENGE_ID", - "value": "173803d3-019e-4033-b1cf-d7205c7f774c", - "description": { - "content": "", - "type": "text/plain" - }, - "enabled": true - }, - { - "key": "ES_TYPE_ID", - "value": "45415132-79fa-4d13-a9ac-71f50020dc10", - "description": { - "content": "", - "type": "text/plain" - }, - "enabled": true - }, - { - "key": "ES_TIMELINE_TEMPLATE_ID", - "value": "8e17090c-465b-4c17-b6d9-dfa16300b0aa", - "description": { - "content": "", - "type": "text/plain" - }, - "enabled": true } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2019-06-16T20:45:25.574Z", - "_postman_exported_using": "Postman/6.4.4" + "_postman_exported_at": "2019-07-12T04:05:33.896Z", + "_postman_exported_using": "Postman/7.2.2" } \ No newline at end of file diff --git a/mock-api/app.js b/mock-api/app.js index 284a7b04..5f94f16d 100755 --- a/mock-api/app.js +++ b/mock-api/app.js @@ -1,10 +1,12 @@ /** * The application entry point for mock API */ + const express = require('express') const cors = require('cors') const config = require('config') const winston = require('winston') +const helper = require('../src/common/helper') const app = express() app.set('port', config.PORT) @@ -12,8 +14,8 @@ app.set('port', config.PORT) app.use(cors()) // get challenge resources -app.get('/v5/challenges/:challengeId/resources', (req, res) => { - const challengeId = req.params.challengeId +app.get('/v5/resources', (req, res) => { + const challengeId = req.query.challengeId winston.info(`Get resources of challenge id ${challengeId}`) const resources = [{ @@ -34,6 +36,52 @@ app.get('/v5/challenges/:challengeId/resources', (req, res) => { res.json(resources) }) +// get challenges member can access to +app.get('/v5/resources/:memberId/challenges', (req, res) => { + const memberId = req.params.memberId + if (memberId === '40309246' || memberId === '151743') { + helper.scan('Challenge') + .then(result => { + const ret = [] + for (const element of result) { + if (memberId === '151743') { + if (element.createdBy === 'Ghostar') { + ret.push(element.id) + } + } else { + ret.push(element.id) + } + } + res.json(ret) + }) + .catch(e => { + winston.error(e) + res.json([]) + }) + } else { + res.json([]) + } +}) + +// get project by id +app.get('/v4/projects/:projectId', (req, res) => { + const projectId = req.params.projectId + if (projectId === '111' || projectId === '123' || projectId === '112233') { + res.end() + } else if (projectId === '200') { + res.status(403).send({ + id: '6e97fe68-f89c-4c45-b25b-d17933a3c4b9', + result: { + success: false, + status: 403, + content: { message: 'You do not have permissions to perform this action' } + } + }) + } else { + res.status(404).end() + } +}) + // search groups app.get('/v5/groups', (req, res) => { const page = Number(req.query.page || 1) diff --git a/mock-api/config/default.js b/mock-api/config/default.js index d976fc14..8a4045c1 100755 --- a/mock-api/config/default.js +++ b/mock-api/config/default.js @@ -4,4 +4,12 @@ module.exports = { PORT: process.env.PORT || 4000, + + AMAZON: { + AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID || 'FAKE_ACCESS_KEY', + AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY || 'FAKE_SECRET_ACCESS_KEY', + AWS_REGION: process.env.AWS_REGION || 'ap-northeast-1', + IS_LOCAL_DB: process.env.IS_LOCAL_DB ? process.env.IS_LOCAL_DB === 'true' : true, + DYNAMODB_URL: process.env.DYNAMODB_URL || 'http://localhost:7777' + }, }; diff --git a/package.json b/package.json index f1eea21d..6e372a21 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "lint:fix": "standard --fix", "init-es": "node src/init-es.js", "init-db": "node src/init-db.js", + "sync-es": "node src/scripts/sync-es.js", "drop-tables": "node src/scripts/drop-tables.js", "create-tables": "node src/scripts/create-tables.js", "seed-tables": "node src/scripts/seed-tables.js", diff --git a/src/common/helper.js b/src/common/helper.js index 2b533ae7..6148be5b 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -383,7 +383,7 @@ async function getM2MToken () { */ async function getChallengeResources (challengeId) { const token = await getM2MToken() - const url = `${config.CHALLENGES_API_URL}/${challengeId}/resources` + const url = `${config.RESOURCES_API_URL}?challengeId=${challengeId}` const res = await axios.get(url, { headers: { Authorization: `Bearer ${token}` } }) return res.data || [] } @@ -500,6 +500,46 @@ function getESClient () { return esClient } +/** +<<<<<<< HEAD + * Ensure project exist + * @param {String} projectId the project id + * @param {String} userToken the user token + */ +async function ensureProjectExist (projectId, userToken) { + let token + if (!userToken) { + token = await getM2MToken() + } + const url = `${config.PROJECTS_API_URL}/${projectId}` + try { + if (userToken) { + await axios.get(url, { headers: { Authorization: `Bearer ${userToken}` } }) + } else { + await axios.get(url, { headers: { Authorization: `Bearer ${token}` } }) + } + } catch (err) { + if (err.response.status === 404) { + throw new errors.BadRequestError(`Project with id: ${projectId} doesn't exist`) + } else { + // re-throw other error + throw err + } + } +} + +/** + * Lists challenge ids that given member has access to. + * @param {Number} memberId the member id + * @returns {Promise} an array of challenge ids represents challenges that given member has access to. + */ +async function listChallengesByMember (memberId) { + const token = await getM2MToken() + const url = `${config.RESOURCES_API_URL}/${memberId}/challenges` + const res = await axios.get(url, { headers: { Authorization: `Bearer ${token}` } }) + return res.data || [] +} + /** * Check if ES refresh method is valid. * @@ -534,5 +574,7 @@ module.exports = { ensureNoDuplicateOrNullElements, postBusEvent, getESClient, + ensureProjectExist, + listChallengesByMember, validateESRefreshMethod } diff --git a/src/common/logger.js b/src/common/logger.js index 1011716a..b8dc02b5 100644 --- a/src/common/logger.js +++ b/src/common/logger.js @@ -49,6 +49,12 @@ logger.logFullError = (err, signature) => { const _sanitizeObject = (obj) => { try { return JSON.parse(JSON.stringify(obj, (name, value) => { + // Array of field names that should not be logged + // add field if necessary (password, tokens etc) + const removeFields = ['userToken'] + if (_.includes(removeFields, name)) { + return '' + } if (_.isArray(value) && value.length > 30) { return `Array(${value.length})` } diff --git a/src/controllers/ChallengeController.js b/src/controllers/ChallengeController.js index a183e4e2..f7f34971 100644 --- a/src/controllers/ChallengeController.js +++ b/src/controllers/ChallengeController.js @@ -22,7 +22,7 @@ async function searchChallenges (req, res) { * @param {Object} res the response */ async function createChallenge (req, res) { - const result = await service.createChallenge(req.authUser, req.body) + const result = await service.createChallenge(req.authUser, req.body, req.userToken) res.status(HttpStatus.CREATED).send(result) } @@ -42,7 +42,7 @@ async function getChallenge (req, res) { * @param {Object} res the response */ async function fullyUpdateChallenge (req, res) { - const result = await service.fullyUpdateChallenge(req.authUser, req.params.challengeId, req.body) + const result = await service.fullyUpdateChallenge(req.authUser, req.params.challengeId, req.body, req.userToken) res.send(result) } @@ -52,7 +52,7 @@ async function fullyUpdateChallenge (req, res) { * @param {Object} res the response */ async function partiallyUpdateChallenge (req, res) { - const result = await service.partiallyUpdateChallenge(req.authUser, req.params.challengeId, req.body) + const result = await service.partiallyUpdateChallenge(req.authUser, req.params.challengeId, req.body, req.userToken) res.send(result) } diff --git a/src/init-es.js b/src/init-es.js index f3c8474b..022186b3 100644 --- a/src/init-es.js +++ b/src/init-es.js @@ -27,7 +27,18 @@ const initES = async () => { logger.info(`The index ${config.ES.ES_INDEX} exists.`) } else { logger.info(`The index ${config.ES.ES_INDEX} will be created.`) - await client.indices.create({ index: config.ES.ES_INDEX }) + + const body = { mappings: {} } + body.mappings[config.get('ES.ES_TYPE')] = { + properties: { + id: { type: 'keyword' } + } + } + + await client.indices.create({ + index: config.ES.ES_INDEX, + body + }) } } diff --git a/src/scripts/sync-es.js b/src/scripts/sync-es.js new file mode 100644 index 00000000..d6f5b8da --- /dev/null +++ b/src/scripts/sync-es.js @@ -0,0 +1,34 @@ +/** + * Migrate Data from Dynamo DB to ES + */ + +const config = require('config') +const logger = require('../common/logger') +const helper = require('../common/helper') + +const esClient = helper.getESClient() + +/* + * Migrate records from DB to ES + */ +async function migrateRecords () { + const result = await helper.scan('Challenge') + for (const challenge of result) { + await esClient.update({ + index: config.get('ES.ES_INDEX'), + type: config.get('ES.ES_TYPE'), + id: challenge.id, + body: { doc: challenge, doc_as_upsert: true } + }) + } +} + +migrateRecords() + .then(() => { + logger.info('Done') + process.exit() + }) + .catch((err) => { + logger.logFullError(err) + process.exit(1) + }) diff --git a/src/services/ChallengeService.js b/src/services/ChallengeService.js index 5962da02..7d77d823 100644 --- a/src/services/ChallengeService.js +++ b/src/services/ChallengeService.js @@ -63,11 +63,15 @@ async function searchChallenges (currentUser, criteria) { // construct ES query const boolQuery = [] _.forIn(_.omit(criteria, ['page', 'perPage', 'tag', 'group', 'createdDateStart', 'createdDateEnd', - 'updatedDateStart', 'updatedDateEnd']), (value, key) => { + 'updatedDateStart', 'updatedDateEnd', 'memberId']), (value, key) => { const filter = { match_phrase: {} } filter.match_phrase[key] = value boolQuery.push(filter) }) + if (criteria.memberId) { + const ids = await helper.listChallengesByMember(criteria.memberId) + boolQuery.push({ terms: { id: ids } }) + } if (criteria.tag) { boolQuery.push({ match_phrase: { tags: criteria.tag } }) } @@ -145,7 +149,8 @@ searchChallenges.schema = { updatedDateStart: Joi.date(), updatedDateEnd: Joi.date(), createdBy: Joi.string(), - updatedBy: Joi.string() + updatedBy: Joi.string(), + memberId: Joi.number().integer().positive() }) } @@ -188,9 +193,11 @@ async function validateChallengeData (challenge) { * Create challenge. * @param {Object} currentUser the user who perform operation * @param {Object} challenge the challenge to created + * @param {String} userToken the user token * @returns {Object} the created challenge */ -async function createChallenge (currentUser, challenge) { +async function createChallenge (currentUser, challenge, userToken) { + await helper.ensureProjectExist(challenge.projectId, userToken) await validateChallengeData(challenge) await helper.validatePhases(challenge.phases) helper.ensureNoDuplicateOrNullElements(challenge.tags, 'tags') @@ -253,7 +260,8 @@ createChallenge.schema = { startDate: Joi.date().required(), status: Joi.string().valid(_.values(constants.challengeStatuses)).required(), groups: Joi.array().items(Joi.string()) // group names - }).required() + }).required(), + userToken: Joi.any() } /** @@ -406,10 +414,15 @@ function isDifferentPrizeSets (prizeSets, otherPrizeSets) { * @param {Object} currentUser the user who perform operation * @param {String} challengeId the challenge id * @param {Object} data the challenge data to be updated + * @param {String} userToken the user token * @param {Boolean} isFull the flag indicate it is a fully update operation. * @returns {Object} the updated challenge */ -async function update (currentUser, challengeId, data, isFull) { +async function update (currentUser, challengeId, data, userToken, isFull) { + if (data.projectId) { + await helper.ensureProjectExist(data.projectId, userToken) + } + helper.ensureNoDuplicateOrNullElements(data.tags, 'tags') helper.ensureNoDuplicateOrNullElements(data.attachmentIds, 'attachmentIds') helper.ensureNoDuplicateOrNullElements(data.groups, 'groups') @@ -617,10 +630,11 @@ async function update (currentUser, challengeId, data, isFull) { * @param {Object} currentUser the user who perform operation * @param {String} challengeId the challenge id * @param {Object} data the challenge data to be updated + * @param {String} userToken the user token * @returns {Object} the updated challenge */ -async function fullyUpdateChallenge (currentUser, challengeId, data) { - return update(currentUser, challengeId, data, true) +async function fullyUpdateChallenge (currentUser, challengeId, data, userToken) { + return update(currentUser, challengeId, data, userToken, true) } fullyUpdateChallenge.schema = { @@ -662,7 +676,8 @@ fullyUpdateChallenge.schema = { status: Joi.string().valid(_.values(constants.challengeStatuses)).required(), attachmentIds: Joi.array().items(Joi.optionalId()), groups: Joi.array().items(Joi.string()) // group names - }).required() + }).required(), + userToken: Joi.any() } /** @@ -670,10 +685,11 @@ fullyUpdateChallenge.schema = { * @param {Object} currentUser the user who perform operation * @param {String} challengeId the challenge id * @param {Object} data the challenge data to be updated + * @param {String} userToken the user token * @returns {Object} the updated challenge */ -async function partiallyUpdateChallenge (currentUser, challengeId, data) { - return update(currentUser, challengeId, data) +async function partiallyUpdateChallenge (currentUser, challengeId, data, userToken) { + return update(currentUser, challengeId, data, userToken) } partiallyUpdateChallenge.schema = { @@ -715,7 +731,8 @@ partiallyUpdateChallenge.schema = { status: Joi.string().valid(_.values(constants.challengeStatuses)), attachmentIds: Joi.array().items(Joi.optionalId()), groups: Joi.array().items(Joi.string()) // group names - }).required() + }).required(), + userToken: Joi.any() } module.exports = { diff --git a/test/e2e/challenge.api.test.js b/test/e2e/challenge.api.test.js index 3603a1e9..6149fd2e 100644 --- a/test/e2e/challenge.api.test.js +++ b/test/e2e/challenge.api.test.js @@ -149,6 +149,28 @@ describe('challenge API E2E tests', () => { should.equal(response.body.message, `No challenge type found with id: ${notFoundId}.`) }) + it(`create challenge - user doesn't have permission to create challenge under specific project`, async () => { + const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) + challengeData.projectId = 200 + const response = await chai.request(app) + .post(basePath) + .set('Authorization', `Bearer ${config.COPILOT_TOKEN}`) + .send(challengeData) + should.equal(response.status, 403) + should.equal(response.body.message, 'You do not have permissions to perform this action') + }) + + it(`create challenge - project not found`, async () => { + const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) + challengeData.projectId = 100000 + const response = await chai.request(app) + .post(basePath) + .set('Authorization', `Bearer ${config.COPILOT_TOKEN}`) + .send(challengeData) + should.equal(response.status, 400) + should.equal(response.body.message, `Project with id: ${challengeData.projectId} doesn't exist`) + }) + it('create challenge - invalid track', async () => { const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) challengeData.track = [1, 2] @@ -338,7 +360,8 @@ describe('challenge API E2E tests', () => { group: data.challenge.groups[0], createdDateStart: '1992-01-02', createdDateEnd: '2022-01-02', - createdBy: data.challenge.createdBy + createdBy: data.challenge.createdBy, + memberId: 40309246 }) should.equal(response.status, 200) should.equal(response.headers['x-page'], '1') @@ -398,6 +421,40 @@ describe('challenge API E2E tests', () => { should.equal(response.body.length, 0) }) + it('search challenges successfully 3', async () => { + const response = await chai.request(app) + .get(basePath) + .set('Authorization', `Bearer ${config.M2M_READ_ACCESS_TOKEN}`) + .query({ + page: 1, + perPage: 10, + id: data.challenge.id, + typeId: data.challenge.typeId, + track: data.challenge.track, + name: data.challenge.name.substring(2).trim().toUpperCase(), + description: data.challenge.description, + timelineTemplateId: data.challenge.timelineTemplateId, + reviewType: data.challenge.reviewType, + tag: data.challenge.tags[0], + projectId: data.challenge.projectId, + forumId: data.challenge.forumId, + legacyId: data.challenge.legacyId, + status: data.challenge.status, + group: data.challenge.groups[0], + createdDateStart: '1992-01-02', + createdDateEnd: '2022-01-02', + createdBy: data.challenge.createdBy, + memberId: 23124329 + }) + should.equal(response.status, 200) + should.equal(response.headers['x-page'], '1') + should.equal(response.headers['x-per-page'], '10') + should.equal(response.headers['x-total'], '0') + should.equal(response.headers['x-total-pages'], '0') + + should.equal(response.body.length, 0) + }) + it('search challenges - invalid page', async () => { const response = await chai.request(app) .get(basePath) @@ -407,6 +464,15 @@ describe('challenge API E2E tests', () => { should.equal(response.body.message, '"page" must be larger than or equal to 1') }) + it('search challenges - invalid memberId', async () => { + const response = await chai.request(app) + .get(basePath) + .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) + .query({ memberId: 'abcde' }) + should.equal(response.status, 400) + should.equal(response.body.message, '"memberId" must be a number') + }) + it('search challenges - invalid perPage', async () => { const response = await chai.request(app) .get(basePath) @@ -608,6 +674,30 @@ describe('challenge API E2E tests', () => { should.equal(response.body.message, '"challengeId" must be a valid GUID') }) + it('fully update challenge - project not found', async () => { + const body = _.omit(data.challenge, ['id', 'created', 'createdBy']) + body.projectId = 100000 + + const response = await chai.request(app) + .put(`${basePath}/${id}`) + .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) + .send(body) + should.equal(response.status, 400) + should.equal(response.body.message, `Project with id: ${body.projectId} doesn't exist`) + }) + + it(`fully update challenge - user doesn't have permission to update challenge under specific project`, async () => { + const body = _.omit(data.challenge, ['id', 'created', 'createdBy']) + body.projectId = 200 + + const response = await chai.request(app) + .put(`${basePath}/${id}`) + .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) + .send(body) + should.equal(response.status, 403) + should.equal(response.body.message, 'You do not have permissions to perform this action') + }) + it('fully update challenge - null name', async () => { const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) challengeData.name = null @@ -764,6 +854,24 @@ describe('challenge API E2E tests', () => { should.equal(response.body.message, '"challengeId" must be a valid GUID') }) + it('partially update challenge - project not found', async () => { + const response = await chai.request(app) + .patch(`${basePath}/${id}`) + .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) + .send({ projectId: 100000 }) + should.equal(response.status, 400) + should.equal(response.body.message, `Project with id: 100000 doesn't exist`) + }) + + it(`partially update challenge - user doesn't have permission to update challenge under specific project`, async () => { + const response = await chai.request(app) + .patch(`${basePath}/${id}`) + .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) + .send({ projectId: 200 }) + should.equal(response.status, 403) + should.equal(response.body.message, 'You do not have permissions to perform this action') + }) + it('partially update challenge - null name', async () => { const response = await chai.request(app) .patch(`${basePath}/${id}`) diff --git a/test/unit/ChallengeService.test.js b/test/unit/ChallengeService.test.js index 5c0c3c92..a27e2739 100644 --- a/test/unit/ChallengeService.test.js +++ b/test/unit/ChallengeService.test.js @@ -4,6 +4,7 @@ require('../../app-bootstrap') const _ = require('lodash') +const config = require('config') const uuid = require('uuid/v4') const chai = require('chai') const fs = require('fs') @@ -97,6 +98,30 @@ describe('challenge service unit tests', () => { throw new Error('should not reach here') }) + it(`create challenge - user doesn't have permission to create challenge under specific project`, async () => { + const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) + challengeData.projectId = 200 + try { + await service.createChallenge({ userId: '16096823' }, challengeData, config.COPILOT_TOKEN) + } catch (e) { + should.equal(e.response.data.result.content.message, 'You do not have permissions to perform this action') + return + } + throw new Error('should not reach here') + }) + + it('create challenge - project not found', async () => { + const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) + challengeData.projectId = 100000 + try { + await service.createChallenge({ isMachine: true, sub: 'sub' }, challengeData) + } catch (e) { + should.equal(e.message, `Project with id: ${challengeData.projectId} doesn't exist`) + return + } + throw new Error('should not reach here') + }) + it('create challenge - invalid projectId', async () => { try { const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) @@ -237,7 +262,8 @@ describe('challenge service unit tests', () => { group: data.challenge.groups[0], createdDateStart: '1992-01-02', createdDateEnd: '2022-01-02', - createdBy: data.challenge.createdBy + createdBy: data.challenge.createdBy, + memberId: 40309246 }) should.equal(res.total, 1) should.equal(res.page, 1) @@ -288,6 +314,34 @@ describe('challenge service unit tests', () => { should.equal(result.result.length, 0) }) + it('search challenges successfully 3', async () => { + const res = await service.searchChallenges({ isMachine: true }, { + page: 1, + perPage: 10, + id: data.challenge.id, + typeId: data.challenge.typeId, + track: data.challenge.track, + name: data.challenge.name.substring(2).trim().toUpperCase(), + description: data.challenge.description, + timelineTemplateId: data.challenge.timelineTemplateId, + reviewType: data.challenge.reviewType, + tag: data.challenge.tags[0], + projectId: data.challenge.projectId, + forumId: data.challenge.forumId, + legacyId: data.challenge.legacyId, + status: data.challenge.status, + group: data.challenge.groups[0], + createdDateStart: '1992-01-02', + createdDateEnd: '2022-01-02', + createdBy: data.challenge.createdBy, + memberId: 23124329 + }) + should.equal(res.total, 0) + should.equal(res.page, 1) + should.equal(res.perPage, 10) + should.equal(res.result.length, 0) + }) + it('search challenges - invalid name', async () => { try { await service.searchChallenges({ isMachine: true }, { name: ['invalid'] }) @@ -298,6 +352,16 @@ describe('challenge service unit tests', () => { throw new Error('should not reach here') }) + it('search challenges - invalid memberId', async () => { + try { + await service.searchChallenges({ isMachine: true }, { memberId: 'abcde' }) + } catch (e) { + should.equal(e.message.indexOf('"memberId" must be a number') >= 0, true) + return + } + throw new Error('should not reach here') + }) + it('search challenges - invalid forumId', async () => { try { await service.searchChallenges({ isMachine: true }, { forumId: -1 }) @@ -495,6 +559,30 @@ describe('challenge service unit tests', () => { throw new Error('should not reach here') }) + it(`fully update challenge - project not found`, async () => { + try { + const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) + challengeData.projectId = 100000 + await service.fullyUpdateChallenge({ userId: '16096823' }, id, challengeData, config.COPILOT_TOKEN) + } catch (e) { + should.equal(e.message, `Project with id: 100000 doesn't exist`) + return + } + throw new Error('should not reach here') + }) + + it(`fully update challenge - user doesn't have permission to update challenge under specific project`, async () => { + try { + const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) + challengeData.projectId = 200 + await service.fullyUpdateChallenge({ userId: '16096823' }, id, challengeData, config.COPILOT_TOKEN) + } catch (e) { + should.equal(e.response.data.result.content.message, 'You do not have permissions to perform this action') + return + } + throw new Error('should not reach here') + }) + it('fully update challenge - null name', async () => { try { const challengeData = _.omit(data.challenge, ['id', 'created', 'createdBy']) @@ -590,6 +678,26 @@ describe('challenge service unit tests', () => { should.exist(result.updated) }) + it(`partially update challenge - project not found`, async () => { + try { + await service.partiallyUpdateChallenge({ userId: '16096823' }, id, { projectId: 100000 }, config.COPILOT_TOKEN) + } catch (e) { + should.equal(e.message, `Project with id: 100000 doesn't exist`) + return + } + throw new Error('should not reach here') + }) + + it(`partially update challenge - user doesn't have permission to update challenge under specific project`, async () => { + try { + await service.partiallyUpdateChallenge({ userId: '16096823' }, id, { projectId: 200 }, config.COPILOT_TOKEN) + } catch (e) { + should.equal(e.response.data.result.content.message, 'You do not have permissions to perform this action') + return + } + throw new Error('should not reach here') + }) + it('partially update challenge - timeline template not found', async () => { try { await service.partiallyUpdateChallenge({ isMachine: true, sub: 'sub3' }, id, {