diff --git a/.gitignore b/.gitignore index 4c49bd7..05e3156 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,64 @@ -.env +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Newman tests +newman + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env* + +# next.js build output +.next diff --git a/README.md b/README.md index d7327b9..88c2e53 100755 --- a/README.md +++ b/README.md @@ -55,9 +55,27 @@ Configuration for the application is at `config/default.js` and `config/producti - `KAFKA_ERROR_TOPIC`: The error topic at which bus api will publish any errors - `KAFKA_MESSAGE_ORIGINATOR`: The originator value for the kafka messages - `SKILLS_ERROR_TOPIC`: Kafka topic for report operation error +- `AUTOMATED_TESTING_NAME_PREFIX`:: the name prefix for every `Skill`/`Taxonomy` record **NOTE** AUTH0 related configuration normally is shared on challenge forum. + +Configuration for testing is at `config/test.js`, only add such new configurations different from `config/default.js` +- API_BASE_URL: the api base url +- API_VERSION: the api version +- WAIT_TIME: wait time used in test, default is 6000 or 6 seconds +- AUTH_V2_URL: The auth v2 url +- AUTH_V2_CLIENT_ID: The auth v2 client id +- AUTH_V3_URL: The auth v3 url +- ADMIN_CREDENTIALS_USERNAME: The user's username with admin role +- ADMIN_CREDENTIALS_PASSWORD: The user's password with admin role +- COPILOT_CREDENTIALS_USERNAME: The user's username with copilot role +- COPILOT_CREDENTIALS_PASSWORD: The user's password with copilot role +- USER_CREDENTIALS_USERNAME: The user's username with user role +- USER_CREDENTIALS_PASSWORD: The user's password with user role +- AUTOMATED_TESTING_REPORTERS_FORMAT: indicates reporters format. It is an array of the formats. e.g. `['html']` produces html format. `['cli', 'json', 'junit', 'html']` is the full format. + *For the details of the supported format, please refer to https://www.npmjs.com/package/newman#reporters*. + ## DB and Elasticsearch In Docker - Navigate to the directory `docker-pgsql-es` folder. Rename `sample.env` to `.env` and change any values if required. - Run `docker-compose up -d` to have docker instances of pgsql and elasticsearch to use with the api @@ -122,6 +140,8 @@ Setup your Postgresql DB and Elasticsearch instance and ensure that they are up | `npm run delete-index` | Delete Elasticsearch indexes. Use `-- --force` flag to skip confirmation | | `npm run generate:doc:permissions` | Generate [permissions.html](docs/permissions.html) | | `npm run generate:doc:permissions:dev` | Generate [permissions.html](docs/permissions.html) on any changes (useful during development). | +| `npm run test:newman` | Run the postman E2E tests. | +| `npm run test:newman:clear` | Clear the testing data which is brought by the postman E2E tests. | ## JWT Authentication Authentication is handled via Authorization (Bearer) token header field. Token is a JWT token. @@ -173,3 +193,60 @@ These tokens have been signed with the secret `CLIENT_SECRET`. This secret shoul - [permissions.html](docs/permissions.html) - the list of all permissions in Skills API. - [swagger.yaml](docs/swagger.yaml) - the Swagger API Definition. + +## Running tests + +### Configuration +Test configuration is at `config/test.js`. You don't need to change them. + +The following test parameters can be set in config file or in env variables: + +- WAIT_TIME: wait time +- AUTH_V2_URL: The auth v2 url +- AUTH_V2_CLIENT_ID: The auth v2 client id +- AUTH_V3_URL: The auth v3 url +- ADMIN_CREDENTIALS_USERNAME: The user's username with admin role +- ADMIN_CREDENTIALS_PASSWORD: The user's password with admin role +- COPILOT_CREDENTIALS_USERNAME: The user's username with copilot role +- COPILOT_CREDENTIALS_PASSWORD: The user's password with copilot role +- USER_CREDENTIALS_USERNAME: The user's username with user role +- USER_CREDENTIALS_PASSWORD: The user's password with user role +- AUTOMATED_TESTING_REPORTERS_FORMAT: indicates reporters format. It is an array of the formats. + +### Prepare + +- Start local environment by running the `docker-compose up` from `docker-pgsql-es` folder. Make sure you have set the environment like `sample.env` form that folder. + +### Running E2E tests with Postman + +#### `Start` the app server before running e2e tests. You may need to set the env variables by calling `source env.sh` before calling `npm run test:newman`. + +- Make sure the db and es are started +```bash + $ cd skills-api + + # NOTE: + # if tables and data already exist, please run first + + # $ npm run delete-data + + # to drop data and tables + + $ npm run create-db + $ npm run migrations up +``` + +To run postman e2e tests. + +```bash +npm run test:newman +``` + +To clear the testing data from postman e2e tests. + +```bash +npm run test:newman:clear +``` + +## Running tests in CI +- TBD diff --git a/Verification.md b/Verification.md new file mode 100644 index 0000000..1e9def7 --- /dev/null +++ b/Verification.md @@ -0,0 +1,54 @@ +# Topcoder Skills API + +## E2E testing with Postman + +You should be able to find the tests result from the command window of running `npm run test:newman` for each test case. + +Below is a sample output result of finding resources by member. + +``` +skill-api + +Iteration 1/3 + +❏ taxonomies / create taxonomy +↳ create taxonomy by admin + POST http://127.0.0.1:3001/api/1.0/taxonomies [200 OK, 449B, 84ms] + ✓ Status code is 200 + +Iteration 2/3 + +↳ create taxonomy by admin + POST http://127.0.0.1:3001/api/1.0/taxonomies [200 OK, 447B, 34ms] + ✓ Status code is 200 + +Iteration 3/3 + +↳ create taxonomy by admin + POST http://127.0.0.1:3001/api/1.0/taxonomies [200 OK, 404B, 33ms] + ✓ Status code is 200 + +┌─────────────────────────┬───────────────────┬──────────────────┐ +│ │ executed │ failed │ +├─────────────────────────┼───────────────────┼──────────────────┤ +│ iterations │ 3 │ 0 │ +├─────────────────────────┼───────────────────┼──────────────────┤ +│ requests │ 3 │ 0 │ +├─────────────────────────┼───────────────────┼──────────────────┤ +│ test-scripts │ 3 │ 0 │ +├─────────────────────────┼───────────────────┼──────────────────┤ +│ prerequest-scripts │ 3 │ 0 │ +├─────────────────────────┼───────────────────┼──────────────────┤ +│ assertions │ 3 │ 0 │ +├─────────────────────────┴───────────────────┴──────────────────┤ +│ total run duration: 273ms │ +├────────────────────────────────────────────────────────────────┤ +│ total data received: 496B (approx) │ +├────────────────────────────────────────────────────────────────┤ +│ average response time: 50ms [min: 33ms, max: 84ms, s.d.: 23ms] │ +└────────────────────────────────────────────────────────────────┘ +``` + +Then you can run `npm run test:newman:clear` to delete all testing data by above postman tests. +If 'socket hang up' appears while running the `npm run test:newman`. You can increase the `WAIT_TIME` from the `default/test.js`. + Then run `npm run test:newman:clear` before calling `npm run test:newman` again. diff --git a/config/default.js b/config/default.js index 42c4df4..085921f 100755 --- a/config/default.js +++ b/config/default.js @@ -38,7 +38,7 @@ module.exports = { ES: { HOST: process.env.ES_HOST || 'http://localhost:9200', ES_REFRESH: process.env.ES_REFRESH || 'true', - ES_API_VERSION: process.env.ES_API_VERSION || "7.4", + ES_API_VERSION: process.env.ES_API_VERSION || '7.4', ELASTICCLOUD: { id: process.env.ELASTICCLOUD_ID, @@ -59,5 +59,7 @@ module.exports = { }, MAX_BATCH_SIZE: parseInt(process.env.MAX_BATCH_SIZE, 10) || 10000, MAX_BULK_SIZE: parseInt(process.env.MAX_BULK_SIZE, 10) || 100 - } + }, + + AUTOMATED_TESTING_NAME_PREFIX: process.env.AUTOMATED_TESTING_NAME_PREFIX || 'POSTMANE2E-' } diff --git a/config/test.js b/config/test.js new file mode 100644 index 0000000..6b5cbbb --- /dev/null +++ b/config/test.js @@ -0,0 +1,19 @@ +/** + * The configuration file. + */ + +module.exports = { + API_BASE_URL: 'http://localhost:3001/api', + API_VERSION: '1.0', + WAIT_TIME: 6000, + AUTH_V2_URL: process.env.AUTH_V2_URL || 'https://topcoder-dev.auth0.com/oauth/ro', + AUTH_V2_CLIENT_ID: process.env.AUTH_V2_CLIENT_ID || '', + AUTH_V3_URL: process.env.AUTH_V3_URL || 'https://api.topcoder-dev.com/v3/authorizations', + ADMIN_CREDENTIALS_USERNAME: process.env.ADMIN_CREDENTIALS_USERNAME || '', + ADMIN_CREDENTIALS_PASSWORD: process.env.ADMIN_CREDENTIALS_PASSWORD || '', + COPILOT_CREDENTIALS_USERNAME: process.env.COPILOT_CREDENTIALS_USERNAME || '', + COPILOT_CREDENTIALS_PASSWORD: process.env.COPILOT_CREDENTIALS_PASSWORD || '', + USER_CREDENTIALS_USERNAME: process.env.USER_CREDENTIALS_USERNAME || '', + USER_CREDENTIALS_PASSWORD: process.env.USER_CREDENTIALS_PASSWORD || '', + AUTOMATED_TESTING_REPORTERS_FORMAT: process.env.AUTOMATED_TESTING_REPORTERS_FORMAT || ['cli', 'html'] +} diff --git a/package.json b/package.json index 1e662fd..7a63bd2 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "create-index": "node scripts/es/createIndex.js", "delete-index": "node scripts/es/deleteIndex.js", "generate:doc:permissions": "node scripts/permissions-doc", - "generate:doc:permissions:dev": "npx nodemon --watch scripts/permissions-doc --watch src --ext js,jsx,hbs --exec npm run generate:doc:permissions" + "generate:doc:permissions:dev": "npx nodemon --watch scripts/permissions-doc --watch src --ext js,jsx,hbs --exec npm run generate:doc:permissions", + "test:newman": "NODE_ENV=test node test/postman/newman.js", + "test:newman:clear": "NODE_ENV=test node test/postman/clearTestData.js" }, "repository": { "type": "git", @@ -48,7 +50,8 @@ }, "devDependencies": { "nodemon": "^2.0.12", - "standard": "^14.3.0" + "standard": "^14.3.0", + "tc-api-testing-lib": "topcoder-platform/api-automated-testing.git" }, "engines": { "node": "12.x" diff --git a/src/common/helper.js b/src/common/helper.js index 6cf0f1b..7421a73 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -6,6 +6,9 @@ const config = require('config') const busApi = require('@topcoder-platform/topcoder-bus-api-wrapper') const busApiClient = busApi(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME', 'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'BUSAPI_URL', 'KAFKA_ERROR_TOPIC', 'AUTH0_PROXY_SERVER_URL'])) +const request = require('superagent') +const m2mAuth = require('tc-core-library-js').auth.m2m +const m2m = m2mAuth(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME', 'AUTH0_PROXY_SERVER_URL'])) /** * get auth user handle or id @@ -130,11 +133,29 @@ async function publishError (topic, payload, action) { await busApiClient.postEvent(message) } +/** + * Uses superagent to proxy post request + * @param {String} url the url + * @param {Object} data the query parameters, optional + * @returns {Object} the response + */ +async function postRequest (url, data) { + const m2mToken = await m2m.getMachineToken(config.AUTH0_CLIENT_ID, config.AUTH0_CLIENT_SECRET) + + return request + .post(url) + .set('Authorization', `Bearer ${m2mToken}`) + .set('Content-Type', 'application/json') + .set('Accept', 'application/json') + .send(data) +} + module.exports = { getAuthUser, injectSearchMeta, setLastModifiedHeader, getControllerMethods, omitAuditFields, - publishError + publishError, + postRequest } diff --git a/src/modules/cleanup/controller.js b/src/modules/cleanup/controller.js new file mode 100644 index 0000000..e5fa2cb --- /dev/null +++ b/src/modules/cleanup/controller.js @@ -0,0 +1,19 @@ +/** + * Controller for cleaning up test data + */ + +const service = require('./service') + +/** + * Get all resources of a challenge + * @param {Object} req the request + * @param {Object} res the response + */ +async function cleanUpTestData (req, res) { + await service.cleanUpTestData() + res.sendStatus(200) +} + +module.exports = { + cleanUpTestData +} diff --git a/src/modules/cleanup/route.js b/src/modules/cleanup/route.js new file mode 100644 index 0000000..6eaaf87 --- /dev/null +++ b/src/modules/cleanup/route.js @@ -0,0 +1,15 @@ +/** + * The Clean up data routes. + */ + +const Controller = require('./controller') + +module.exports = { + '/skills/internal/jobs/clean': { + post: { + method: Controller.cleanUpTestData, + auth: 'jwt', + permission: 'skill.delete' + } + } +} diff --git a/src/modules/cleanup/service.js b/src/modules/cleanup/service.js new file mode 100644 index 0000000..961e190 --- /dev/null +++ b/src/modules/cleanup/service.js @@ -0,0 +1,48 @@ +/** + * This service provides operations to clean up the environment for running automated tests. + */ +const config = require('config') +const sequelize = require('../../models') +const logger = require('../../common/logger') +const dbHelper = require('../../common/db-helper') +const serviceHelper = require('../../common/service-helper') + +/** + * Delete the postman records from the given table. + * @param {string} tableName the table name + * @param {object} model the db model + * @param resourceName the resource name of the model + * @returns {void} + */ +const deleteFromTable = async (tableName, model, resourceName) => { + logger.info(`Delete postman records ${resourceName}`) + const records = await sequelize.query(`SELECT * FROM "${tableName}" where name like :value`, { + model: model, + replacements: { value: `${config.AUTOMATED_TESTING_NAME_PREFIX}%` }, + mapToModel: true + }) + const resource = serviceHelper.getResource(resourceName) + for (const r of records) { + const id = r.dataValues.id + logger.debug('Deleting records with id: ', id) + await dbHelper.remove(model, id) + await serviceHelper.deleteRecordFromEs(id, undefined, resource) + } +} + +/** + * Clear the postman test data. The main function of this class. + * @returns {Promise} + */ +const cleanUpTestData = async () => { + logger.info('Start clean up the test data from postman test!') + await sequelize.transaction(async () => { + await deleteFromTable('Skills', sequelize.models.Skill, 'Skill') + await deleteFromTable('Taxonomies', sequelize.models.Taxonomy, 'Taxonomy') + }) + logger.info('Finish clean up the test data from postman test!') +} + +module.exports = { + cleanUpTestData +} diff --git a/test/postman/ClearPostmanData.md b/test/postman/ClearPostmanData.md new file mode 100644 index 0000000..64d34a3 --- /dev/null +++ b/test/postman/ClearPostmanData.md @@ -0,0 +1,68 @@ +# Clear Testing data which are from Postman Tests + +## How to clear the Postman related testing data +- To summarize, simply run below command after running the Postman tests. +``` + npm run test:newman:clear +``` +- You should follow the ReadMe.md to run the tests. Then you will get output like below: +``` +> NODE_ENV=test node test/postman/clearTestData.js + +2021-08-27T12:54:12.608Z info: Clear the Postman test data. +2021-08-27T12:54:13.831Z info: Completed! +``` +From the API console, you can find the output like: +``` +2021-08-27T12:54:13.499Z debug: ENTER Method 'cleanup/service.cleanUpTestData' +2021-08-27T12:54:13.499Z debug: ##input arguments, {} +2021-08-27T12:54:13.499Z info: Start clean up the test data from postman test! +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): START TRANSACTION; +2021-08-27T12:54:13.508Z info: Delete postman records Skill +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT * FROM "Skills" where name like 'POSTMANE2E-%' +2021-08-27T12:54:13.511Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "externalId", "uri", "metadata", "created", "updated", "taxonomyId" FROM "Skills" AS "Skill" WHERE "Skill"."id" = '28b300d0-ae3d-40d3-96a0-4fd6b58204e4'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Skills" WHERE "id" = '28b300d0-ae3d-40d3-96a0-4fd6b58204e4' +2021-08-27T12:54:13.548Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "externalId", "uri", "metadata", "created", "updated", "taxonomyId" FROM "Skills" AS "Skill" WHERE "Skill"."id" = '4fd24ed0-f033-440a-8104-e0456f3ccb0a'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Skills" WHERE "id" = '4fd24ed0-f033-440a-8104-e0456f3ccb0a' +2021-08-27T12:54:13.586Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "externalId", "uri", "metadata", "created", "updated", "taxonomyId" FROM "Skills" AS "Skill" WHERE "Skill"."id" = 'e629a663-6257-4296-8fbe-d67f2728886b'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Skills" WHERE "id" = 'e629a663-6257-4296-8fbe-d67f2728886b' +2021-08-27T12:54:13.613Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "externalId", "uri", "metadata", "created", "updated", "taxonomyId" FROM "Skills" AS "Skill" WHERE "Skill"."id" = 'b76f574a-cc11-430d-bd02-853b76e77f26'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Skills" WHERE "id" = 'b76f574a-cc11-430d-bd02-853b76e77f26' +2021-08-27T12:54:13.651Z info: Delete postman records Taxonomy +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT * FROM "Taxonomies" where name like 'POSTMANE2E-%' +2021-08-27T12:54:13.653Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "metadata", "created", "updated" FROM "Taxonomies" AS "Taxonomy" WHERE "Taxonomy"."id" = 'ba742dae-34a4-48a5-bdc9-8e8f9b015ce1'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Taxonomies" WHERE "id" = 'ba742dae-34a4-48a5-bdc9-8e8f9b015ce1' +2021-08-27T12:54:13.679Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "metadata", "created", "updated" FROM "Taxonomies" AS "Taxonomy" WHERE "Taxonomy"."id" = 'f7838d83-76d8-4d9d-8125-3a97678bd83a'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Taxonomies" WHERE "id" = 'f7838d83-76d8-4d9d-8125-3a97678bd83a' +2021-08-27T12:54:13.713Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "metadata", "created", "updated" FROM "Taxonomies" AS "Taxonomy" WHERE "Taxonomy"."id" = '0a7987e9-0969-4cd2-813e-5d49c7bfe46d'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Taxonomies" WHERE "id" = '0a7987e9-0969-4cd2-813e-5d49c7bfe46d' +2021-08-27T12:54:13.759Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "metadata", "created", "updated" FROM "Taxonomies" AS "Taxonomy" WHERE "Taxonomy"."id" = '93c288be-1787-4d4b-a342-fa865a48cd92'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Taxonomies" WHERE "id" = '93c288be-1787-4d4b-a342-fa865a48cd92' +2021-08-27T12:54:13.788Z debug: Deleting records with id: +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): SELECT "id", "createdBy", "updatedBy", "name", "metadata", "created", "updated" FROM "Taxonomies" AS "Taxonomy" WHERE "Taxonomy"."id" = '13dac351-e2d1-45b7-b049-ef8753f67854'; +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): DELETE FROM "Taxonomies" WHERE "id" = '13dac351-e2d1-45b7-b049-ef8753f67854' +Executing (7c33d1b9-b826-4f8a-8dfc-504473c2dc28): COMMIT; +2021-08-27T12:54:13.829Z info: Finish clean up the test data from postman test! +2021-08-27T12:54:13.829Z debug: ##output arguments, No any result returned +2021-08-27T12:54:13.829Z debug: EXIT Method 'cleanup/service.cleanUpTestData' +``` +## Strategy +1. Setup the `AUTOMATED_TESTING_NAME_PREFIX` from the test environment. This prefix should be a name that will never be used +set as part of the skill/taxonomy name. e.g. 'POSTMANE2E-'. In this case, the created `Skill`/`Taxonomy` will have a name like 'POSTMANE2E-skill-01'. + +2. You can use use Postman's mock server for the bus api. You can refer to https://drive.google.com/file/d/1GXMzyqpzwix-LDBwieiRFfpJlJxrTIgI/view?usp=sharing + for details. You need to update the environment variable `BUSAPI_URL` to your Postman mock server. + +3. Steps of clearing the test data from Postman tests. + * Find all `Skill` records whose names are starting with `AUTOMATED_TESTING_NAME_PREFIX`. And delete those records from both DB and ES. + * Find all `Taxonomy` records whose names are starting with `AUTOMATED_TESTING_NAME_PREFIX`. And delete those records from both DB and ES. + +4. Note, in production enviroment, there is no need to run `npm run insert-data`. diff --git a/test/postman/README.md b/test/postman/README.md new file mode 100644 index 0000000..ba7bcc3 --- /dev/null +++ b/test/postman/README.md @@ -0,0 +1,110 @@ +# Automated testing using Postman + Newman +## Configurations + +- All configurations are set in [/config/test.js](../../config/test.js). +- All test data is set in [/test/postman/testData](testData/). + +## Running the tests locally + +- Follow the steps from the [Readme](../../ReadMe.md) + +## Running the tests on CircleCI + +- With every commit in the `develop` branch, and after the API is deployed on the development environment, a `Run-Newman-Test` job is created on CircleCI. +- You need to approve this step in order to trigger the test execution. +- The progress as well as the results can be monitored within CircleCI and the final result (pass/fail) will also be visible on the repository page on Github. +- If you simply want to trigger the tests, you can either rerun the test workflow from within CircleCI or push an empty commit to trigger a new deployment. +## Testing summary + +The following scenarios have been tested: + +- create taxonomy by admin +- create taxonomy by m2m +- create taxonomy with all kinds of invalid request body +- create taxonomy with all kinds of invalid token +- list taxonomies by admin +- list taxonomies by m2m +- list taxonomies by copilot +- list taxonomies by user +- list taxonomies by anonymous +- list taxonomies with various parameters +- list taxonomies with invalid parameters +- head taxonomies by admin +- head taxonomies by m2m +- head taxonomies by copilot +- head taxonomies by user +- head taxonomies by anonymous +- head taxonomies with various parameters +- head taxonomies with invalid parameters +- get taxonomy by admin +- get taxonomy by m2m +- get taxonomy by copilot +- get taxonomy by user +- get taxonomy by anonymous +- get taxonomy with invalid requests +- head taxonomy by admin +- head taxonomy by m2m +- head taxonomy by copilot +- head taxonomy by user +- head taxonomy by anonymous +- head taxonomy with invalid requests +- patch taxonomy by admin +- patch taxonomy by m2m +- patch taxonomy with all kinds of invalid request body +- patch taxonomy with all kinds of invalid token +- update taxonomy by admin +- update taxonomy by m2m +- update taxonomy with all kinds of invalid request body +- update taxonomy with all kinds of invalid token +- delete taxonomy by admin +- delete taxonomy by m2m +- delete taxonomy with all kinds of invalid request +- create skill by admin +- create skill by m2m +- create skill with all kinds of invalid request body +- create skill with all kinds of invalid token +- list skills by admin +- list skills by m2m +- list skills by copilot +- list skills by user +- list skills by anonymous +- list skills with various parameters +- list skills with invalid parameters +- head skills by admin +- head skills by m2m +- head skills by copilot +- head skills by user +- head skills by anonymous +- head skills with various parameters +- head skills with invalid parameters +- get skill by admin +- get skill by m2m +- get skill by copilot +- get skill by user +- get skill by anonymous +- get skill with invalid requests +- head skill by admin +- head skill by m2m +- head skill by copilot +- head skill by user +- head skill by anonymous +- head skill with invalid requests +- patch skill by admin +- patch skill by m2m +- patch skill with all kinds of invalid request body +- patch skill with all kinds of invalid token +- update skill by admin +- update skill by m2m +- update skill with all kinds of invalid request body +- update skill with all kinds of invalid token +- delete skill by admin +- delete skill by m2m +- delete skill with all kinds of invalid request + + +### Roles tested + +- M2M +- Admin +- Copilot +- User diff --git a/test/postman/clearTestData.js b/test/postman/clearTestData.js new file mode 100644 index 0000000..e7feb56 --- /dev/null +++ b/test/postman/clearTestData.js @@ -0,0 +1,28 @@ +/** + * Clear the postman test data. All data created by postman e2e tests will be cleared. + */ +const logger = require('../../src/common/logger') +const helper = require('../../src/common/helper') +const config = require('config') + +logger.info('Clear the Postman test data.') + +/** + * Clear the postman test data. The main function of this class. + * @returns {Promise} + */ +const clearTestData = async () => { + await helper.postRequest(`${config.API_BASE_URL}/${config.API_VERSION}/skills/internal/jobs/clean`) +} + +clearTestData().then(() => { + logger.info('Completed!') + process.exit() +}).catch((e) => { + logger.logFullError(e) + process.exit(1) +}) + +module.exports = { + clearTestData +} diff --git a/test/postman/newman.js b/test/postman/newman.js new file mode 100644 index 0000000..bdac97e --- /dev/null +++ b/test/postman/newman.js @@ -0,0 +1,346 @@ +const config = require('config') +const apiTestLib = require('tc-api-testing-lib') +const helper = require('../../src/common/helper') +const logger = require('../../src/common/logger') + +const requests = [ + { + folder: 'create taxonomy by admin', + iterationData: require('./testData/taxonomy/create-taxonomy-by-admin.json') + }, + { + folder: 'create taxonomy by m2m', + iterationData: require('./testData/taxonomy/create-taxonomy-by-m2m.json') + }, + { + folder: 'create taxonomy with all kinds of invalid request body', + iterationData: require('./testData/taxonomy/create-taxonomy-with-invalid-data.json') + }, + { + folder: 'create taxonomy with all kinds of invalid token', + iterationData: require('./testData/taxonomy/create-taxonomy-with-invalid-tokens.json') + }, + { + folder: 'list taxonomies by admin', + iterationData: require('./testData/taxonomy/list-taxonomies.json') + }, + { + folder: 'list taxonomies by m2m', + iterationData: require('./testData/taxonomy/list-taxonomies.json') + }, + { + folder: 'list taxonomies by copilot', + iterationData: require('./testData/taxonomy/list-taxonomies.json') + }, + { + folder: 'list taxonomies by user', + iterationData: require('./testData/taxonomy/list-taxonomies.json') + }, + { + folder: 'list taxonomies by anonymous', + iterationData: require('./testData/taxonomy/list-taxonomies.json') + }, + { + folder: 'list taxonomies with various parameters', + iterationData: require('./testData/taxonomy/list-taxonomies-with-various-parameters.json') + }, + { + folder: 'list taxonomies with invalid parameters', + iterationData: require('./testData/taxonomy/list-taxonomies-with-invalid-parameters.json') + }, + { + folder: 'head taxonomies by admin' + }, + { + folder: 'head taxonomies by m2m' + }, + { + folder: 'head taxonomies by copilot' + }, + { + folder: 'head taxonomies by user' + }, + { + folder: 'head taxonomies by anonymous' + }, + { + folder: 'head taxonomies with various parameters', + iterationData: require('./testData/taxonomy/head-taxonomies-with-various-parameters.json') + }, + { + folder: 'head taxonomies with invalid parameters', + iterationData: require('./testData/taxonomy/head-taxonomies-with-invalid-parameters.json') + }, + { + folder: 'get taxonomy by admin', + iterationData: require('./testData/taxonomy/get-taxonomy.json') + }, + { + folder: 'get taxonomy by m2m', + iterationData: require('./testData/taxonomy/get-taxonomy.json') + }, + { + folder: 'get taxonomy by copilot', + iterationData: require('./testData/taxonomy/get-taxonomy.json') + }, + { + folder: 'get taxonomy by user', + iterationData: require('./testData/taxonomy/get-taxonomy.json') + }, + { + folder: 'get taxonomy by anonymous', + iterationData: require('./testData/taxonomy/get-taxonomy.json') + }, + { + folder: 'get taxonomy with invalid requests', + iterationData: require('./testData/taxonomy/get-taxonomy-with-invalid-parameters.json') + }, + { + folder: 'head taxonomy by admin', + iterationData: require('./testData/taxonomy/head-taxonomy.json') + }, + { + folder: 'head taxonomy by m2m', + iterationData: require('./testData/taxonomy/head-taxonomy.json') + }, + { + folder: 'head taxonomy by copilot', + iterationData: require('./testData/taxonomy/head-taxonomy.json') + }, + { + folder: 'head taxonomy by user', + iterationData: require('./testData/taxonomy/head-taxonomy.json') + }, + { + folder: 'head taxonomy by anonymous', + iterationData: require('./testData/taxonomy/head-taxonomy.json') + }, + { + folder: 'head taxonomy with invalid requests', + iterationData: require('./testData/taxonomy/head-taxonomy-with-invalid-parameters.json') + }, + { + folder: 'patch taxonomy by admin', + iterationData: require('./testData/taxonomy/patch-taxonomy-by-admin.json') + }, + { + folder: 'patch taxonomy by m2m', + iterationData: require('./testData/taxonomy/patch-taxonomy-by-m2m.json') + }, + { + folder: 'patch taxonomy with all kinds of invalid request body', + iterationData: require('./testData/taxonomy/patch-taxonomy-with-invalid-data.json') + }, + { + folder: 'patch taxonomy with all kinds of invalid token', + iterationData: require('./testData/taxonomy/patch-taxonomy-with-invalid-tokens.json') + }, + { + folder: 'update taxonomy by admin', + iterationData: require('./testData/taxonomy/update-taxonomy-by-admin.json') + }, + { + folder: 'update taxonomy by m2m', + iterationData: require('./testData/taxonomy/update-taxonomy-by-m2m.json') + }, + { + folder: 'update taxonomy with all kinds of invalid request body', + iterationData: require('./testData/taxonomy/update-taxonomy-with-invalid-data.json') + }, + { + folder: 'update taxonomy with all kinds of invalid token', + iterationData: require('./testData/taxonomy/update-taxonomy-with-invalid-tokens.json') + }, + { + folder: 'delete taxonomy by admin' + }, + { + folder: 'delete taxonomy by m2m' + }, + { + folder: 'delete taxonomy with all kinds of invalid request', + iterationData: require('./testData/taxonomy/delete-taxonomy-with-invalid-request.json') + }, + { + folder: 'create skill by admin', + iterationData: require('./testData/skill/create-skill-by-admin.json') + }, + { + folder: 'create skill by m2m', + iterationData: require('./testData/skill/create-skill-by-m2m.json') + }, + { + folder: 'create skill with all kinds of invalid request body', + iterationData: require('./testData/skill/create-skill-with-invalid-data.json') + }, + { + folder: 'create skill with all kinds of invalid token', + iterationData: require('./testData/skill/create-skill-with-invalid-tokens.json') + }, + { + folder: 'list skills by admin', + iterationData: require('./testData/skill/list-skills.json') + }, + { + folder: 'list skills by m2m', + iterationData: require('./testData/skill/list-skills.json') + }, + { + folder: 'list skills by copilot', + iterationData: require('./testData/skill/list-skills.json') + }, + { + folder: 'list skills by user', + iterationData: require('./testData/skill/list-skills.json') + }, + { + folder: 'list skills by anonymous', + iterationData: require('./testData/skill/list-skills.json') + }, + { + folder: 'list skills with various parameters', + iterationData: require('./testData/skill/list-skills-with-various-parameters.json') + }, + { + folder: 'list skills with invalid parameters', + iterationData: require('./testData/skill/list-skills-with-invalid-parameters.json') + }, + { + folder: 'head skills by admin' + }, + { + folder: 'head skills by m2m' + }, + { + folder: 'head skills by copilot' + }, + { + folder: 'head skills by user' + }, + { + folder: 'head skills by anonymous' + }, + { + folder: 'head skills with various parameters', + iterationData: require('./testData/skill/head-skills-with-various-parameters.json') + }, + { + folder: 'head skills with invalid parameters', + iterationData: require('./testData/skill/head-skills-with-invalid-parameters.json') + }, + { + folder: 'get skill by admin', + iterationData: require('./testData/skill/get-skill.json') + }, + { + folder: 'get skill by m2m', + iterationData: require('./testData/skill/get-skill.json') + }, + { + folder: 'get skill by copilot', + iterationData: require('./testData/skill/get-skill.json') + }, + { + folder: 'get skill by user', + iterationData: require('./testData/skill/get-skill.json') + }, + { + folder: 'get skill by anonymous', + iterationData: require('./testData/skill/get-skill.json') + }, + { + folder: 'get skill with invalid requests', + iterationData: require('./testData/skill/get-skill-with-invalid-parameters.json') + }, + { + folder: 'head skill by admin', + iterationData: require('./testData/skill/head-skill.json') + }, + { + folder: 'head skill by m2m', + iterationData: require('./testData/skill/head-skill.json') + }, + { + folder: 'head skill by copilot', + iterationData: require('./testData/skill/head-skill.json') + }, + { + folder: 'head skill by user', + iterationData: require('./testData/skill/head-skill.json') + }, + { + folder: 'head skill by anonymous', + iterationData: require('./testData/skill/head-skill.json') + }, + { + folder: 'head skill with invalid requests', + iterationData: require('./testData/skill/head-skill-with-invalid-parameters.json') + }, + { + folder: 'patch skill by admin', + iterationData: require('./testData/skill/patch-skill-by-admin.json') + }, + { + folder: 'patch skill by m2m', + iterationData: require('./testData/skill/patch-skill-by-m2m.json') + }, + { + folder: 'patch skill with all kinds of invalid request body', + iterationData: require('./testData/skill/patch-skill-with-invalid-data.json') + }, + { + folder: 'patch skill with all kinds of invalid token', + iterationData: require('./testData/skill/patch-skill-with-invalid-tokens.json') + }, + { + folder: 'update skill by admin', + iterationData: require('./testData/skill/update-skill-by-admin.json') + }, + { + folder: 'update skill by m2m', + iterationData: require('./testData/skill/update-skill-by-m2m.json') + }, + { + folder: 'update skill with all kinds of invalid request body', + iterationData: require('./testData/skill/update-skill-with-invalid-data.json') + }, + { + folder: 'update skill with all kinds of invalid token', + iterationData: require('./testData/skill/update-skill-with-invalid-tokens.json') + }, + { + folder: 'delete skill by admin' + }, + { + folder: 'delete skill by m2m' + }, + { + folder: 'delete skill with all kinds of invalid request', + iterationData: require('./testData/skill/delete-skill-with-invalid-request.json') + } +] + +/** + * Clear the test data. + * @return {Promise} + */ +async function clearTestData () { + logger.info('Clear the Postman test data.') + await helper.postRequest(`${config.API_BASE_URL}/${config.API_VERSION}/skills/internal/jobs/clean`) + logger.info('Finished clear the Postman test data.') +} + +/** + * Run the postman tests. + */ +apiTestLib.runTests(requests, require.resolve('./skill-api.postman_collection.json'), + require.resolve('./skill-api.postman_environment.json')).then(async () => { + logger.info('newman test completed!') + await clearTestData() +}).catch(async (err) => { + logger.logFullError(err) + // Only calling the clean up function when it is not validation error. + if (err.name !== 'ValidationError') { + await clearTestData() + } +}) diff --git a/test/postman/skill-api.postman_collection.json b/test/postman/skill-api.postman_collection.json new file mode 100644 index 0000000..6f9ad7e --- /dev/null +++ b/test/postman/skill-api.postman_collection.json @@ -0,0 +1,4883 @@ +{ + "info": { + "_postman_id": "66b5954f-09f2-42bd-94ff-cb668b95ea87", + "name": "skill-api", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "taxonomies", + "item": [ + { + "name": "create taxonomy", + "item": [ + { + "name": "create taxonomy by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " if (iterationData.get('idLabel')) {", + " const idLabel = iterationData.get('idLabel')", + " pm.environment.set(idLabel, response.id)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{admin_token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "create taxonomy by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " if (iterationData.get('idLabel')) {", + " const idLabel = iterationData.get('idLabel')", + " pm.environment.set(idLabel, response.id)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{m2m_token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "create taxonomy with all kinds of invalid request body", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "create taxonomy with all kinds of invalid token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"POSTMANE2E-taxonomy_valid\",\n \"metadata\": {\n \"a_valid_field\": \"a valid value\"\n }\n}" + }, + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "list taxonomies", + "item": [ + { + "name": "list taxonomies by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{admin_token}}", + "type": "text" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "list taxonomies by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "list taxonomies by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "list taxonomies by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "list taxonomies by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "list taxonomies with various parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gte(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + " pm.expect(response.length > 0).to.eq(true)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + }, + { + "name": "list taxonomies with invalid parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "head taxonomies", + "item": [ + { + "name": "head taxonomies by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{admin_token}}", + "type": "text" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomies by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomies by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomies by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomies by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomies with various parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.headers", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " pm.expect(_.isEqual(response.get(key), expected[key])).to.eq(true)", + " }", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + }, + { + "name": "head taxonomies with invalid parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "get taxonomy", + "item": [ + { + "name": "get taxonomy by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get taxonomy by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get taxonomy by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get taxonomy by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get taxonomy by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get taxonomy with invalid requests", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "head taxonomy", + "item": [ + { + "name": "head taxonomy by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomy by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomy by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomy by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomy by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head taxonomy with invalid requests", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "patch taxonomy", + "item": [ + { + "name": "patch taxonomy by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "patch taxonomy by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "patch taxonomy with all kinds of invalid request body", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.contains(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "patch taxonomy with all kinds of invalid token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "update taxonomy", + "item": [ + { + "name": "update taxonomy by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "update taxonomy by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "update taxonomy with all kinds of invalid request body", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.contains(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "update taxonomy with all kinds of invalid token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"POSTMANE2E-taxonomy_02_by_admin updated\",\n \"metadata\": {}\n}" + }, + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "delete taxonomy", + "item": [ + { + "name": "delete taxonomy by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 204`, function () {", + " pm.response.to.have.status(204)", + " const response = pm.response.text()", + " pm.expect(response).to.eq('')", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{TAXONOMY_5}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{TAXONOMY_5}}" + ] + } + }, + "response": [] + }, + { + "name": "delete taxonomy by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 204`, function () {", + " pm.response.to.have.status(204)", + " const response = pm.response.text()", + " pm.expect(response).to.eq('')", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{TAXONOMY_6}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{TAXONOMY_6}}" + ] + } + }, + "response": [] + }, + { + "name": "delete taxonomy with all kinds of invalid request", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.contains(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "url": { + "raw": "{{URL}}/taxonomies/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "taxonomies", + "{{id}}" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "skills", + "item": [ + { + "name": "create skill", + "item": [ + { + "name": "create skill by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " if (iterationData.get('idLabel')) {", + " const idLabel = iterationData.get('idLabel')", + " pm.environment.set(idLabel, response.id)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{admin_token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "create skill by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " if (iterationData.get('idLabel')) {", + " const idLabel = iterationData.get('idLabel')", + " pm.environment.set(idLabel, response.id)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{m2m_token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "create skill with all kinds of invalid request body", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.contain(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "create skill with all kinds of invalid token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"taxonomyId\":\"{{TAXONOMY_1}}\",\n \"name\": \"POSTMANE2E-skill_valid_name\",\n \"metadata\": {\n \"a_valid_field\": \"a valid value\"\n }\n}" + }, + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "list skills", + "item": [ + { + "name": "list skills by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{admin_token}}", + "type": "text" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "list skills by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "list skills by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "list skills by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "list skills by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gt(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "list skills with various parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " const response = pm.response.json()", + " pm.expect(response.length).to.gte(0)", + " const iterationData = pm.iterationData", + " const expectedFields = iterationData.get('expectedFields')", + " for (let item of response) {", + " // make sure the list returns the expected fields", + " pm.expect(expectedFields.every(r=> Object.keys(item).indexOf(r) >= 0)).to.eq(true)", + " }", + " pm.expect(response.length > 0).to.eq(true)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + }, + { + "name": "list skills with invalid parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "head skills", + "item": [ + { + "name": "head skills by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{admin_token}}", + "type": "text" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "head skills by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "head skills by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "head skills by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "head skills by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + " pm.expect(parseInt(pm.response.headers.get('X-Page'))).to.eq(1)", + " pm.expect(parseInt(pm.response.headers.get('X-Per-Page'))).to.eq(20)", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + " pm.expect(pm.response.headers.get('Link').length).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ] + } + }, + "response": [] + }, + { + "name": "head skills with various parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.headers", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " pm.expect(_.isEqual(response.get(key), expected[key])).to.eq(true)", + " }", + " pm.expect(parseInt(pm.response.headers.get('X-Total'))).to.gt(0)", + " pm.expect(parseInt(pm.response.headers.get('X-Total-Pages'))).to.gt(0)", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + }, + { + "name": "head skills with invalid parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills?{{params}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills" + ], + "query": [ + { + "key": "{{params}}", + "value": null + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "get skill", + "item": [ + { + "name": "get skill by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get skill by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get skill by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get skill by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get skill by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " if(httpCode === 200){", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "get skill with invalid requests", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "head skill", + "item": [ + { + "name": "head skill by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head skill by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head skill by copilot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{copilot_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head skill by user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{user_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head skill by anonymous", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode); ", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "head skill with invalid requests", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "HEAD", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "patch skill", + "item": [ + { + "name": "patch skill by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "patch skill by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "patch skill with all kinds of invalid request body", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.contains(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "patch skill with all kinds of invalid token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "update skill", + "item": [ + { + "name": "update skill by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "update skill by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " const iterationData = pm.iterationData", + " const expected = iterationData.get('expected')", + " for (let key of Object.keys(expected)) {", + " if (_.isObject(response[key])) {", + " pm.expect(_.isMatch(response[key], expected[key])).to.eq(true)", + " } else {", + " pm.expect(_.isEqual(response[key], expected[key])).to.eq(true)", + " }", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "update skill with all kinds of invalid request body", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " pm.expect(response.message).to.contains(iterationData.get('message'))", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var inputJSONdata = pm.iterationData.get(\"input\");", + "pm.variables.set(\"input_body\",JSON.stringify(inputJSONdata));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + } + ], + "body": { + "mode": "raw", + "raw": "{{input_body}}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + }, + { + "name": "update skill with all kinds of invalid token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.eq(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"POSTMANE2E-skill_02_by_admin updated\",\n \"taxonomyId\":\"{{TAXONOMY_1}}\",\n \"metadata\": {}\n}" + }, + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "delete skill", + "item": [ + { + "name": "delete skill by admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 204`, function () {", + " pm.response.to.have.status(204)", + " const response = pm.response.text()", + " pm.expect(response).to.eq('')", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{admin_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills/{{SKILL_5}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{SKILL_5}}" + ] + } + }, + "response": [] + }, + { + "name": "delete skill by m2m", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 204`, function () {", + " pm.response.to.have.status(204)", + " const response = pm.response.text()", + " pm.expect(response).to.eq('')", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{m2m_token}}" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{URL}}/skills/{{SKILL_6}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{SKILL_6}}" + ] + } + }, + "response": [] + }, + { + "name": "delete skill with all kinds of invalid request", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const iterationData = pm.iterationData", + "const httpCode = iterationData.get('httpCode')", + "pm.test(`Status code is ${httpCode}`, function () {", + " pm.response.to.have.status(httpCode);", + " const response = pm.response.json()", + " if (response.message) {", + " pm.expect(response.message).to.contains(iterationData.get('message'))", + " } else {", + " pm.expect(response.result.content.message).to.eq(iterationData.get('message'))", + " }", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "{{jwtToken}}" + } + ], + "url": { + "raw": "{{URL}}/skills/{{id}}", + "host": [ + "{{URL}}" + ], + "path": [ + "skills", + "{{id}}" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "health", + "item": [ + { + "name": "check health", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(`Status code is 200`, function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{admin_token}}", + "type": "text" + } + ], + "url": { + "raw": "{{URL}}/health", + "host": [ + "{{URL}}" + ], + "path": [ + "health" + ] + } + }, + "response": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/test/postman/skill-api.postman_environment.json b/test/postman/skill-api.postman_environment.json new file mode 100644 index 0000000..1b9767f --- /dev/null +++ b/test/postman/skill-api.postman_environment.json @@ -0,0 +1,309 @@ +{ + "_": { + "postman_variable_scope": "environment", + "postman_exported_at": "2021-08-27T13:47:19.584Z", + "postman_exported_using": "Newman/5.2.4" + }, + "id": "55ea82e5-e087-4418-afc6-d24706b731a0", + "name": "skill-api", + "values": [ + { + "type": "any", + "value": "http://127.0.0.1:3001/api/1.0", + "key": "URL" + }, + { + "type": "any", + "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJDb25uZWN0IENvcGlsb3QiLCJjb3BpbG90IiwiVG9wY29kZXIgVXNlciJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoiVENDb25uQ29waWxvdCIsImV4cCI6MTYzMDA3MjYzNSwidXNlcklkIjoiNDAxNTg5OTQiLCJpYXQiOjE2MzAwNzIwMzUsImVtYWlsIjoidG9wY29kZXJjb25uZWN0K0NvcGlsb3RAZ21haWwuY29tIiwianRpIjoiNDk1ZDFlZGYtZmNlYS00ODFmLTlhY2EtODYwMWVmZGZlNzBlIn0.BtNyJWI1GeG3cCT6rsRKODHKIsd-bpG7Rf7xWRVi3zo", + "key": "copilot_token" + }, + { + "type": "any", + "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJjb3BpbG90IiwiVG9wY29kZXIgVXNlciIsImFkbWluaXN0cmF0b3IiXSwiaXNzIjoiaHR0cHM6Ly9hcGkudG9wY29kZXItZGV2LmNvbSIsImhhbmRsZSI6Im1lc3MiLCJleHAiOjE2MzAwNzI2MzIsInVzZXJJZCI6IjMwNTM4NCIsImlhdCI6MTYzMDA3MjAzMiwiZW1haWwiOiJtZXNzQGFwcGlyaW8uY29tIiwianRpIjoiYTA1YTJiNWUtZDMwNC00NmZiLTg0ZTgtNTQxNjQ5M2ViNzM0In0.xf9ZbLwKAxaBI5_BqWbFagh5cd28SvCPHwANhEn22PQ", + "key": "admin_token" + }, + { + "type": "any", + "value": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5VSkZORGd4UlRVME5EWTBOVVkzTlRkR05qTXlRamxETmpOQk5UYzVRVUV3UlRFeU56TTJRUSJ9.eyJpc3MiOiJodHRwczovL3RvcGNvZGVyLWRldi5hdXRoMC5jb20vIiwic3ViIjoiakdJZjJwZDNmNDRCMWpxdk9haTMwQklLVFphbllCZlVAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vbTJtLnRvcGNvZGVyLWRldi5jb20vIiwiaWF0IjoxNjMwMDE5MTY1LCJleHAiOjE2MzAxMDU1NjUsImF6cCI6ImpHSWYycGQzZjQ0QjFqcXZPYWkzMEJJS1RaYW5ZQmZVIiwic2NvcGUiOiJ1cGRhdGU6dXNlcl9wcm9maWxlcyB3cml0ZTp1c2VyX3Byb2ZpbGVzIGNyZWF0ZTpjb25uZWN0X3Byb2plY3QgYWxsOmNoYWxsZW5nZXMgcmVhZDpjaGFsbGVuZ2VzIHdyaXRlOmNoYWxsZW5nZXMgYWxsOmdyb3VwcyB3cml0ZTpncm91cHMgcmVhZDpncm91cHMgdXBkYXRlOnN1Ym1pc3Npb24gcmVhZDpzdWJtaXNzaW9uIGRlbGV0ZTpzdWJtaXNzaW9uIGNyZWF0ZTpzdWJtaXNzaW9uIGFsbDpzdWJtaXNzaW9uIHVwZGF0ZTpyZXZpZXdfdHlwZSByZWFkOnJldmlld190eXBlIGRlbGV0ZTpyZXZpZXdfdHlwZSBhbGw6cmV2aWV3X3R5cGUgdXBkYXRlOnJldmlld19zdW1tYXRpb24gcmVhZDpyZXZpZXdfc3VtbWF0aW9uIGRlbGV0ZTpyZXZpZXdfc3VtbWF0aW9uIGNyZWF0ZTpyZXZpZXdfc3VtbWF0aW9uIGFsbDpyZXZpZXdfc3VtbWF0aW9uIHVwZGF0ZTpyZXZpZXcgcmVhZDpyZXZpZXcgZGVsZXRlOnJldmlldyBjcmVhdGU6cmV2aWV3IGFsbDpyZXZpZXcgcmVhZDpwcm9qZWN0IGFsbDpjb25uZWN0X3Byb2plY3QgcmVhZDpidXNfdG9waWNzIHdyaXRlOmJ1c19hcGkgcmVhZDplbWFpbF90ZW1wbGF0ZXMgcmVhZDp1c2VyX3Byb2ZpbGVzIHJlYWQ6cm9sZXMgcmVhZDpwcm9qZWN0LXVzZXIgcmVhZDpwcm9qZWN0LXBlcm1pc3Npb24gcmVhZDpyZXNvdXJjZXMgd3JpdGU6cmVzb3VyY2VzIGRlbGV0ZTpyZXNvdXJjZXMgdXBkYXRlOnJlc291cmNlcyBhbGw6cmVzb3VyY2VzIHJlYWQ6dGVybXMgYWxsOnRlcm1zIGFsbDpwcm9qZWN0cyByZWFkOnByb2plY3RzIGFsbDpza2lsbCBjcmVhdGU6c2tpbGwgYWxsOnNjaGVkdWxlcyByZWFkOnNjaGVkdWxlcyBjcmVhdGU6c2NoZWR1bGVzIHVwZGF0ZTpzY2hlZHVsZXMgZGVsZXRlOnNjaGVkdWxlcyByZWFkOnByb2plY3QtYmlsbGluZy1hY2NvdW50LWRldGFpbHMgY3JlYXRlOnRheG9ub215IGFsbDp0YXhvbm9teSIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyJ9.IVNMNMl1xfkD6466nWRXuFEP7k-IwhwMPiq8v_6TXmQa9l6TkxkxPynoBEUUVqhDzvpJW-VlrGDn7YakS7G3vlw8TabdmWUJGn6W62b2vsqiICpuT9q50tFsAseHOWY7FF0XzmmmEv2g8sgQ0lzARzl9wf6BmqCrDQ6UQGXI-fEfROYqs97XspOl4GvTeaGty1IBcg3LmXwa7xg1FZg84fordxG7bwQ6QJh84gy289UIuotNS2kJDEiZp0NKX6C5H-5MJBq24KBSDxp9l6Q7ga_WVoR0LW-OCQCyjRLdwKDLFuV6dC5nfEgPs03P1aM-lH7E1Et0Fo_3cPGMBjUtBg", + "key": "m2m_token" + }, + { + "type": "any", + "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJCdXNpbmVzcyBVc2VyIiwiVG9wY29kZXIgVXNlciJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoidGNfdGVzdGVyNzc3IiwiZXhwIjoxNjMwMDcyNjM4LCJ1c2VySWQiOiI4ODc3NDYxNSIsImlhdCI6MTYzMDA3MjAzOCwiZW1haWwiOiJ6Ym5vb2JAZ21haWwuY29tIiwianRpIjoiZGIzYTdmYWMtNjI5YS00ZmM0LWIyYjUtMTdiODg1NmJhZDk4In0.XDXg_eJw-Lno5jTXtvTUJApGFGfuJE0WfZFyXrnKDoQ", + "key": "user_token" + }, + { + "type": "any", + "value": "53184cd9-46e0-43c2-97aa-534c7ba6b7d1", + "key": "TAXONOMY_1" + }, + { + "type": "any", + "value": "48ca2236-fa9a-4119-a9e4-d8e4c5754df0", + "key": "TAXONOMY_2" + }, + { + "type": "any", + "value": "cf461c91-300c-477f-9467-00f51a913194", + "key": "TAXONOMY_3" + }, + { + "type": "any", + "value": "4843d9cb-0f28-4f74-91b0-a05491b45031", + "key": "TAXONOMY_4" + }, + { + "type": "any", + "value": "21a256c7-e45c-4831-b3fe-923ec99565b9", + "key": "TAXONOMY_5" + }, + { + "type": "any", + "value": "6105b646-60e4-4094-a6d2-4f22c582664f", + "key": "TAXONOMY_6" + }, + { + "type": "any", + "value": "e629a663-6257-4296-8fbe-d67f2728886b", + "key": "SKILL_1" + }, + { + "type": "any", + "value": "4fd24ed0-f033-440a-8104-e0456f3ccb0a", + "key": "SKILL_2" + }, + { + "type": "any", + "value": "bc7f9adc-da6c-4063-85ec-2f4e078a1674", + "key": "SKILL_3" + }, + { + "type": "any", + "value": "0de81ed6-65d0-4bb3-8932-d06995cb3b2d", + "key": "SKILL_5" + }, + { + "type": "any", + "value": "c5fca55f-8d89-4a6d-8e76-89916463fed1", + "key": "SKILL_6" + }, + { + "type": "any", + "value": "28b300d0-ae3d-40d3-96a0-4fd6b58204e4", + "key": "SKILL_4" + }, + { + "type": "any", + "value": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5VSkZORGd4UlRVME5EWTBOVVkzTlRkR05qTXlRamxETmpOQk5UYzVRVUV3UlRFeU56TTJRUSJ9.eyJpc3MiOiJodHRwczovL3RvcGNvZGVyLWRldi5hdXRoMC5jb20vIiwic3ViIjoiakdJZjJwZDNmNDRCMWpxdk9haTMwQklLVFphbllCZlVAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vbTJtLnRvcGNvZGVyLWRldi5jb20vIiwiaWF0IjoxNjMwMDcyMDI2LCJleHAiOjE2MzAxNTg0MjYsImF6cCI6ImpHSWYycGQzZjQ0QjFqcXZPYWkzMEJJS1RaYW5ZQmZVIiwic2NvcGUiOiJ1cGRhdGU6dXNlcl9wcm9maWxlcyB3cml0ZTp1c2VyX3Byb2ZpbGVzIGNyZWF0ZTpjb25uZWN0X3Byb2plY3QgYWxsOmNoYWxsZW5nZXMgcmVhZDpjaGFsbGVuZ2VzIHdyaXRlOmNoYWxsZW5nZXMgYWxsOmdyb3VwcyB3cml0ZTpncm91cHMgcmVhZDpncm91cHMgdXBkYXRlOnN1Ym1pc3Npb24gcmVhZDpzdWJtaXNzaW9uIGRlbGV0ZTpzdWJtaXNzaW9uIGNyZWF0ZTpzdWJtaXNzaW9uIGFsbDpzdWJtaXNzaW9uIHVwZGF0ZTpyZXZpZXdfdHlwZSByZWFkOnJldmlld190eXBlIGRlbGV0ZTpyZXZpZXdfdHlwZSBhbGw6cmV2aWV3X3R5cGUgdXBkYXRlOnJldmlld19zdW1tYXRpb24gcmVhZDpyZXZpZXdfc3VtbWF0aW9uIGRlbGV0ZTpyZXZpZXdfc3VtbWF0aW9uIGNyZWF0ZTpyZXZpZXdfc3VtbWF0aW9uIGFsbDpyZXZpZXdfc3VtbWF0aW9uIHVwZGF0ZTpyZXZpZXcgcmVhZDpyZXZpZXcgZGVsZXRlOnJldmlldyBjcmVhdGU6cmV2aWV3IGFsbDpyZXZpZXcgcmVhZDpwcm9qZWN0IGFsbDpjb25uZWN0X3Byb2plY3QgcmVhZDpidXNfdG9waWNzIHdyaXRlOmJ1c19hcGkgcmVhZDplbWFpbF90ZW1wbGF0ZXMgcmVhZDp1c2VyX3Byb2ZpbGVzIHJlYWQ6cm9sZXMgcmVhZDpwcm9qZWN0LXVzZXIgcmVhZDpwcm9qZWN0LXBlcm1pc3Npb24gcmVhZDpyZXNvdXJjZXMgd3JpdGU6cmVzb3VyY2VzIGRlbGV0ZTpyZXNvdXJjZXMgdXBkYXRlOnJlc291cmNlcyBhbGw6cmVzb3VyY2VzIHJlYWQ6dGVybXMgYWxsOnRlcm1zIGFsbDpwcm9qZWN0cyByZWFkOnByb2plY3RzIGFsbDpza2lsbCBjcmVhdGU6c2tpbGwgYWxsOnNjaGVkdWxlcyByZWFkOnNjaGVkdWxlcyBjcmVhdGU6c2NoZWR1bGVzIHVwZGF0ZTpzY2hlZHVsZXMgZGVsZXRlOnNjaGVkdWxlcyByZWFkOnByb2plY3QtYmlsbGluZy1hY2NvdW50LWRldGFpbHMgY3JlYXRlOnRheG9ub215IGFsbDp0YXhvbm9teSIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyJ9.BErLrXuRXBEcCKfjE53aMgXiQ1QCpjDlZHgizxW2U4prBwV1sJxaoeeqm5D6HPgiQD5mTF8uL8shi6oAzIYGTn44R1LBeksB72HnKkp7dQuRgbeTViOD-zvXkDB0xfr9EAL6VLO4g1YvylL1ogVaFGwZtRhPn1B0VjLubD_5l5ovniE3CITN0XAxbRAlxYZajNSwVWQWlhS6UtpXqH9xpqUEELcEbyh0K5jX2qvV_IMgvaCjz32vdUXtaQ7Eae6IgeRBtMMMeRbu0V5q26FUs2J_vGqQQqPGiDllKcxyiKW-a-OS8IvDD54sA02cfrN1pM3rWCt44dgwiw4kWyHaLw", + "key": "M2M_TOKEN" + }, + { + "type": "any", + "value": { + "input": { + "name": "POSTMANE2E-taxonomy_01_by_m2m", + "metadata": { + "random_field_01": "random_value_01_by_m2m" + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_m2m", + "metadata": { + "random_field_01": "random_value_01_by_m2m" + } + }, + "idLabel": "TAXONOMY_4", + "httpCode": 200 + }, + "key": "0" + }, + { + "type": "any", + "value": { + "input": { + "name": "POSTMANE2E-taxonomy_02_by_m2m", + "metadata": { + "abc": "random_value_02_by_m2m", + "efg": 123 + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_02_by_m2m", + "metadata": { + "abc": "random_value_02_by_m2m", + "efg": 123 + } + }, + "idLabel": "TAXONOMY_5", + "httpCode": 200 + }, + "key": "1" + }, + { + "type": "any", + "value": { + "input": { + "name": "POSTMANE2E-taxonomy_03_by_m2m" + }, + "expected": { + "name": "POSTMANE2E-taxonomy_03_by_m2m" + }, + "idLabel": "TAXONOMY_6", + "httpCode": 200 + }, + "key": "2" + }, + { + "type": "any", + "value": { + "id": "{{SKILL_3}}", + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + "key": "3" + }, + { + "type": "any", + "value": { + "id": "{{SKILL_3}}", + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + "key": "4" + }, + { + "type": "any", + "value": { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "jwtToken": "Bearer {{admin_token}}", + "httpCode": 404, + "message": "cannot find Skill where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + }, + "key": "5" + }, + { + "type": "any", + "value": { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId": "{{TAXONOMY_1}}", + "metadata": {}, + "externalId": "" + }, + "httpCode": 400, + "message": "\"entity.externalId\" is not allowed to be empty" + }, + "key": "6" + }, + { + "type": "any", + "value": { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId": "{{TAXONOMY_1}}", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "777" + } + }, + "httpCode": 400, + "message": "memberProminence must be a string with value in the range [0, 1]" + }, + "key": "7" + }, + { + "type": "any", + "value": { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId": "{{TAXONOMY_1}}", + "metadata": { + "challengeProminence": "777", + "memberProminence": "0.2" + } + }, + "httpCode": 400, + "message": "challengeProminence must be a string with value in the range [0, 1]" + }, + "key": "8" + }, + { + "type": "any", + "value": { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_03_by_admin", + "taxonomyId": "{{TAXONOMY_2}}", + "metadata": {}, + "uri": "http://www.google.com" + }, + "httpCode": 409, + "message": "Skill already exists with taxonomyId" + }, + "key": "9" + }, + { + "type": "any", + "value": { + "input": { + "taxonomyId": "{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "uri": "", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.uri\" is not allowed to be empty" + }, + "key": "10" + }, + { + "type": "any", + "value": { + "input": { + "taxonomyId": "{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "externalId": 123, + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.externalId\" must be a string" + }, + "key": "11" + }, + { + "type": "any", + "value": { + "input": { + "taxonomyId": "{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "externalId": "", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.externalId\" is not allowed to be empty" + }, + "key": "12" + }, + { + "type": "any", + "value": { + "input": { + "name": "POSTMANE2E-skill_03_by_admin", + "taxonomyId": "{{TAXONOMY_2}}", + "metadata": {} + }, + "httpCode": 409, + "message": "Skill already exists with taxonomyId" + }, + "key": "13" + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2021-08-27T13:47:25.964Z", + "_postman_exported_using": "Newman/5.2.4" +} \ No newline at end of file diff --git a/test/postman/testData/skill/create-skill-by-admin.json b/test/postman/testData/skill/create-skill-by-admin.json new file mode 100644 index 0000000..c81adba --- /dev/null +++ b/test/postman/testData/skill/create-skill-by-admin.json @@ -0,0 +1,59 @@ +[ + { + "input": { + "name": "POSTMANE2E-skill_01_by_admin", + "taxonomyId":"{{TAXONOMY_1}}", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "0.5" + } + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_admin", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "0.5" + } + }, + "idLabel": "SKILL_1", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-skill_02_by_admin", + "taxonomyId":"{{TAXONOMY_1}}", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + } + }, + "expected": { + "name": "POSTMANE2E-skill_02_by_admin", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + } + }, + "idLabel": "SKILL_2", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-skill_03_by_admin", + "taxonomyId":"{{TAXONOMY_2}}", + "metadata": { + } + }, + "expected": { + "name": "POSTMANE2E-skill_03_by_admin", + "metadata": { + } + }, + "idLabel": "SKILL_3", + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/create-skill-by-m2m.json b/test/postman/testData/skill/create-skill-by-m2m.json new file mode 100644 index 0000000..d7c2128 --- /dev/null +++ b/test/postman/testData/skill/create-skill-by-m2m.json @@ -0,0 +1,58 @@ +[ + { + "input": { + "name": "POSTMANE2E-skill_01_by_m2m", + "taxonomyId":"{{TAXONOMY_1}}", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "0.5" + } + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_m2m", + "uri":"http://www.google.com", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "0.5" + } + }, + "idLabel": "SKILL_4", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-skill_02_by_m2m", + "taxonomyId":"{{TAXONOMY_1}}", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + } + }, + "expected": { + "name": "POSTMANE2E-skill_02_by_m2m", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + } + }, + "idLabel": "SKILL_5", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-skill_03_by_m2m", + "taxonomyId":"{{TAXONOMY_2}}", + "metadata": { + } + }, + "expected": { + "name": "POSTMANE2E-skill_03_by_m2m", + "metadata": { + } + }, + "idLabel": "SKILL_6", + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/create-skill-with-invalid-data.json b/test/postman/testData/skill/create-skill-with-invalid-data.json new file mode 100644 index 0000000..59755ad --- /dev/null +++ b/test/postman/testData/skill/create-skill-with-invalid-data.json @@ -0,0 +1,138 @@ +[ + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.name\" is required" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.name\" is not allowed to be empty" + }, + { + "input": { + "name": "POSTMANE2E-name-valid", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.taxonomyId\" is required" + }, + { + "input": { + "taxonomyId":"", + "name": "POSTMANE2E-name-valid", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.taxonomyId\" is not allowed to be empty" + }, + { + "input": { + "taxonomyId":"aaa", + "name": "POSTMANE2E-name-valid", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.taxonomyId\" must be a valid GUID" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "metadata": 123 + }, + "httpCode": 400, + "message": "\"entity.metadata\" must be of type object" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "metadata": {}, + "abc": 123 + }, + "httpCode": 400, + "message": "\"entity.abc\" is not allowed" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "metadata": { + "challengeProminence": "777", + "memberProminence": "0.5" + } + }, + "httpCode": 400, + "message": "challengeProminence must be a string with value in the range [0, 1]" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "metadata": { + "challengeProminence": "0.5", + "memberProminence": "777" + } + }, + "httpCode": 400, + "message": "memberProminence must be a string with value in the range [0, 1]" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "uri":123, + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.uri\" must be a string" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "uri": "", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.uri\" is not allowed to be empty" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "externalId": 123, + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.externalId\" must be a string" + }, + { + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-name-valid", + "externalId": "", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.externalId\" is not allowed to be empty" + }, + { + "input": { + "name": "POSTMANE2E-skill_03_by_admin", + "taxonomyId":"{{TAXONOMY_2}}", + "metadata": { + } + }, + "httpCode": 409, + "message": "Skill already exists with taxonomyId" + } +] diff --git a/test/postman/testData/skill/create-skill-with-invalid-tokens.json b/test/postman/testData/skill/create-skill-with-invalid-tokens.json new file mode 100644 index 0000000..3604db2 --- /dev/null +++ b/test/postman/testData/skill/create-skill-with-invalid-tokens.json @@ -0,0 +1,27 @@ +[ + { + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "jwtToken": "", + "httpCode": 403, + "message": "No token provided." + }, + { + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + } +] diff --git a/test/postman/testData/skill/delete-skill-with-invalid-request.json b/test/postman/testData/skill/delete-skill-with-invalid-request.json new file mode 100644 index 0000000..0e221ab --- /dev/null +++ b/test/postman/testData/skill/delete-skill-with-invalid-request.json @@ -0,0 +1,37 @@ +[ + { + "id": "{{SKILL_3}}", + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "id": "{{SKILL_3}}", + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "id": "{{SKILL_3}}", + "httpCode": 403, + "message": "No token provided." + }, + { + "id": "{{SKILL_3}}", + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "{{SKILL_3}}", + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "jwtToken": "Bearer {{admin_token}}", + "httpCode": 404, + "message": "cannot find Skill where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + } +] diff --git a/test/postman/testData/skill/get-skill-with-invalid-parameters.json b/test/postman/testData/skill/get-skill-with-invalid-parameters.json new file mode 100644 index 0000000..703cb6c --- /dev/null +++ b/test/postman/testData/skill/get-skill-with-invalid-parameters.json @@ -0,0 +1,12 @@ +[ + { + "id": "12345", + "httpCode": 400, + "message": "\"id\" must be a valid GUID" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "httpCode": 404, + "message": "cannot find Skill where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + } +] diff --git a/test/postman/testData/skill/get-skill.json b/test/postman/testData/skill/get-skill.json new file mode 100644 index 0000000..b23e066 --- /dev/null +++ b/test/postman/testData/skill/get-skill.json @@ -0,0 +1,28 @@ +[ + { + "id": "{{SKILL_1}}", + "expected": { + "name": "POSTMANE2E-skill_01_by_admin", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "0.5" + } + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_4}}", + "expected": { + "name": "POSTMANE2E-skill_01_by_m2m", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "0.5" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/head-skill-with-invalid-parameters.json b/test/postman/testData/skill/head-skill-with-invalid-parameters.json new file mode 100644 index 0000000..4ff2b26 --- /dev/null +++ b/test/postman/testData/skill/head-skill-with-invalid-parameters.json @@ -0,0 +1,10 @@ +[ + { + "id": "12345", + "httpCode": 400 + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "httpCode": 404 + } +] diff --git a/test/postman/testData/skill/head-skill.json b/test/postman/testData/skill/head-skill.json new file mode 100644 index 0000000..af07253 --- /dev/null +++ b/test/postman/testData/skill/head-skill.json @@ -0,0 +1,10 @@ +[ + { + "id": "{{SKILL_1}}", + "httpCode": 200 + }, + { + "id": "{{SKILL_4}}", + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/head-skills-with-invalid-parameters.json b/test/postman/testData/skill/head-skills-with-invalid-parameters.json new file mode 100644 index 0000000..8e8b11a --- /dev/null +++ b/test/postman/testData/skill/head-skills-with-invalid-parameters.json @@ -0,0 +1,38 @@ +[ + { + "params": "page=-1&perPage=10", + "httpCode": 400 + }, + { + "params": "page=1&perPage=-10", + "httpCode": 400 + }, + { + "params": "aaa=abc", + "httpCode": 400 + }, + { + "params": "orderBy=invalid", + "httpCode": 500 + }, + { + "params": "taxonomyId=invalid", + "httpCode": 400 + }, + { + "params": "taxonomyId=", + "httpCode": 400 + }, + { + "params": "orderBy=", + "httpCode": 400 + }, + { + "params": "externalId=", + "httpCode": 400 + }, + { + "params": "name=", + "httpCode": 400 + } +] diff --git a/test/postman/testData/skill/head-skills-with-various-parameters.json b/test/postman/testData/skill/head-skills-with-various-parameters.json new file mode 100644 index 0000000..9726595 --- /dev/null +++ b/test/postman/testData/skill/head-skills-with-various-parameters.json @@ -0,0 +1,42 @@ +[ + { + "params": "name=POSTMANE2E-skill_01_by_admin", + "expected": { + "X-Page": "1", + "X-Per-Page": "20" + }, + "httpCode": 200 + }, + { + "params": "page=2&perPage=1", + "expected": { + "X-Prev-Page": "1", + "X-Next-Page": "3" + }, + "httpCode": 200 + }, + { + "params": "taxonomyId={{TAXONOMY_1}}", + "expected": { + "X-Page": "1", + "X-Per-Page": "20" + }, + "httpCode": 200 + }, + { + "params": "externalId=externalId_01", + "expected": { + "X-Page": "1", + "X-Per-Page": "20" + }, + "httpCode": 200 + }, + { + "params": "taxonomyId={{TAXONOMY_1}}&name=POSTMANE2E-skill_01_by_admin&externalId=externalId_01&page=1&perPage=1", + "expected": { + "X-Page": "1", + "X-Per-Page": "1" + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/list-skills-with-invalid-parameters.json b/test/postman/testData/skill/list-skills-with-invalid-parameters.json new file mode 100644 index 0000000..aff35d3 --- /dev/null +++ b/test/postman/testData/skill/list-skills-with-invalid-parameters.json @@ -0,0 +1,47 @@ +[ + { + "params": "page=-1&perPage=10", + "httpCode": 400, + "message": "\"query.page\" must be larger than or equal to 1" + }, + { + "params": "page=1&perPage=-10", + "httpCode": 400, + "message": "\"query.perPage\" must be larger than or equal to 1" + }, + { + "params": "aaa=abc", + "httpCode": 400, + "message": "\"query.aaa\" is not allowed" + }, + { + "params": "orderBy=invalid", + "httpCode": 500, + "message": "column Skill.orderBy does not exist" + }, + { + "params": "taxonomyId=invalid", + "httpCode": 400, + "message": "\"query.taxonomyId\" must be a valid GUID" + }, + { + "params": "taxonomyId=", + "httpCode": 400, + "message": "\"query.taxonomyId\" is not allowed to be empty" + }, + { + "params": "orderBy=", + "httpCode": 400, + "message": "\"query.orderBy\" is not allowed to be empty" + }, + { + "params": "externalId=", + "httpCode": 400, + "message": "\"query.externalId\" is not allowed to be empty" + }, + { + "params": "name=", + "httpCode": 400, + "message": "\"query.name\" is not allowed to be empty" + } +] diff --git a/test/postman/testData/skill/list-skills-with-various-parameters.json b/test/postman/testData/skill/list-skills-with-various-parameters.json new file mode 100644 index 0000000..abd5006 --- /dev/null +++ b/test/postman/testData/skill/list-skills-with-various-parameters.json @@ -0,0 +1,74 @@ +[ + { + "params": "name=POSTMANE2E-skill_01_by_admin", + "expectedFields": [ + "id", + "name", + "metadata", + "externalId", + "uri", + "taxonomyId", + "taxonomyName" + ] + }, + { + "params": "page=1&perPage=10", + "expectedFields": [ + "id", + "name", + "metadata", + "externalId", + "uri", + "taxonomyId", + "taxonomyName" + ] + }, + { + "params": "taxonomyId={{TAXONOMY_1}}", + "expectedFields": [ + "id", + "name", + "metadata", + "externalId", + "uri", + "taxonomyId", + "taxonomyName" + ] + }, + { + "params": "externalId=externalId_01", + "expectedFields": [ + "id", + "name", + "metadata", + "externalId", + "uri", + "taxonomyId", + "taxonomyName" + ] + }, + { + "params": "orderBy=name", + "expectedFields": [ + "id", + "name", + "metadata", + "externalId", + "uri", + "taxonomyId", + "taxonomyName" + ] + }, + { + "params": "name=POSTMANE2E-skill_01_by_admin&taxonomyId={{TAXONOMY_1}}&externalId=externalId_01&orderBy=name&page=1&perPage=10", + "expectedFields": [ + "id", + "name", + "metadata", + "externalId", + "uri", + "taxonomyId", + "taxonomyName" + ] + } +] diff --git a/test/postman/testData/skill/list-skills.json b/test/postman/testData/skill/list-skills.json new file mode 100644 index 0000000..c762fe6 --- /dev/null +++ b/test/postman/testData/skill/list-skills.json @@ -0,0 +1,13 @@ +[ + { + "expectedFields": [ + "id", + "name", + "metadata", + "externalId", + "uri", + "taxonomyId", + "taxonomyName" + ] + } +] diff --git a/test/postman/testData/skill/patch-skill-by-admin.json b/test/postman/testData/skill/patch-skill-by-admin.json new file mode 100644 index 0000000..b896310 --- /dev/null +++ b/test/postman/testData/skill/patch-skill-by-admin.json @@ -0,0 +1,85 @@ +[ + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_01_by_admin updated" + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_admin updated" + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_1}}", + "input": { + "metadata": { + "field updated": "field_value updated" + } + }, + "expected": { + "metadata": { + "field updated": "field_value updated" + } + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_1}}", + "input": { + "externalId": "externalId_updated" + }, + "expected": { + "externalId": "externalId_updated" + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_1}}", + "input": { + "uri": "uri_updated" + }, + "expected": { + "uri": "uri_updated" + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_01_by_admin updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_admin updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_01_by_admin updated 3", + "taxonomyId":"{{TAXONOMY_3}}", + "uri":"http://www.googleupdated.com", + "externalId":"externalId_01 updated", + "metadata": { + "challengeProminence": "0.1", + "memberProminence": "0.3" + } + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_admin updated 3", + "uri":"http://www.googleupdated.com", + "externalId":"externalId_01 updated", + "metadata": { + "challengeProminence": "0.1", + "memberProminence": "0.3" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/patch-skill-by-m2m.json b/test/postman/testData/skill/patch-skill-by-m2m.json new file mode 100644 index 0000000..24ab24f --- /dev/null +++ b/test/postman/testData/skill/patch-skill-by-m2m.json @@ -0,0 +1,85 @@ +[ + { + "id": "{{SKILL_4}}", + "input": { + "name": "POSTMANE2E-skill_01_by_m2m updated" + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_m2m updated" + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_4}}", + "input": { + "metadata": { + "field updated": "field_value updated" + } + }, + "expected": { + "metadata": { + "field updated": "field_value updated" + } + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_4}}", + "input": { + "externalId": "externalId_updated" + }, + "expected": { + "externalId": "externalId_updated" + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_4}}", + "input": { + "uri": "uri_updated" + }, + "expected": { + "uri": "uri_updated" + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_4}}", + "input": { + "name": "POSTMANE2E-skill_01_by_m2m updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_m2m updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_4}}", + "input": { + "name": "POSTMANE2E-skill_01_by_m2m updated 3", + "taxonomyId":"{{TAXONOMY_3}}", + "uri":"http://www.googleupdated.com", + "externalId":"externalId_01 updated", + "metadata": { + "challengeProminence": "0.1", + "memberProminence": "0.3" + } + }, + "expected": { + "name": "POSTMANE2E-skill_01_by_m2m updated 3", + "uri":"http://www.googleupdated.com", + "externalId":"externalId_01 updated", + "metadata": { + "challengeProminence": "0.1", + "memberProminence": "0.3" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/patch-skill-with-invalid-data.json b/test/postman/testData/skill/patch-skill-with-invalid-data.json new file mode 100644 index 0000000..ac44c7b --- /dev/null +++ b/test/postman/testData/skill/patch-skill-with-invalid-data.json @@ -0,0 +1,93 @@ +[ + { + "id": "{{SKILL_1}}", + "input": { + "name": "" + }, + "httpCode": 400, + "message": "\"entity.name\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "metadata": 123 + }, + "httpCode": 400, + "message": "\"entity.metadata\" must be of type object" + }, + { + "id": "{{SKILL_1}}", + "input": { + "abc": 123 + }, + "httpCode": 400, + "message": "\"entity.abc\" is not allowed" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "input": { + "metadata": {} + }, + "httpCode": 404, + "message": "cannot find Skill where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + }, + { + "id": "{{SKILL_1}}", + "input": { + "taxonomyId": "" + }, + "httpCode": 400, + "message": "\"entity.taxonomyId\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "uri": "" + }, + "httpCode": 400, + "message": "\"entity.uri\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "externalId": "" + }, + "httpCode": 400, + "message": "\"entity.externalId\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "777" + } + }, + "httpCode": 400, + "message": "memberProminence must be a string with value in the range [0, 1]" + }, + { + "id": "{{SKILL_1}}", + "input": { + "metadata": { + "challengeProminence": "777", + "memberProminence": "0.2" + } + }, + "httpCode": 400, + "message": "challengeProminence must be a string with value in the range [0, 1]" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin", + "taxonomyId":"{{TAXONOMY_1}}", + "uri":"http://www.google.com", + "externalId":"externalId_01", + "metadata": { + } + }, + "httpCode": 409, + "message": "Skill already exists with taxonomyId" + } +] diff --git a/test/postman/testData/skill/patch-skill-with-invalid-tokens.json b/test/postman/testData/skill/patch-skill-with-invalid-tokens.json new file mode 100644 index 0000000..64b2765 --- /dev/null +++ b/test/postman/testData/skill/patch-skill-with-invalid-tokens.json @@ -0,0 +1,32 @@ +[ + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "", + "httpCode": 403, + "message": "No token provided." + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + } +] diff --git a/test/postman/testData/skill/update-skill-by-admin.json b/test/postman/testData/skill/update-skill-by-admin.json new file mode 100644 index 0000000..d13f779 --- /dev/null +++ b/test/postman/testData/skill/update-skill-by-admin.json @@ -0,0 +1,38 @@ +[ + { + "id": "{{SKILL_2}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + } + }, + "expected": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "metadata": { + } + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_2}}", + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-skill_02_by_admin updated 2", + "uri":"http://updated.google.com", + "externalId":"updated externalId_02", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-skill_02_by_admin updated 2", + "uri":"http://updated.google.com", + "externalId":"updated externalId_02", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/update-skill-by-m2m.json b/test/postman/testData/skill/update-skill-by-m2m.json new file mode 100644 index 0000000..e527040 --- /dev/null +++ b/test/postman/testData/skill/update-skill-by-m2m.json @@ -0,0 +1,38 @@ +[ + { + "id": "{{SKILL_5}}", + "input": { + "name": "POSTMANE2E-skill_02_by_m2m updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + } + }, + "expected": { + "name": "POSTMANE2E-skill_02_by_m2m updated", + "metadata": { + } + }, + "httpCode": 200 + }, + { + "id": "{{SKILL_5}}", + "input": { + "taxonomyId":"{{TAXONOMY_1}}", + "name": "POSTMANE2E-skill_02_by_m2m updated 2", + "uri":"http://updated.google.com", + "externalId":"updated externalId_02", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-skill_02_by_m2m updated 2", + "uri":"http://updated.google.com", + "externalId":"updated externalId_02", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/skill/update-skill-with-invalid-data.json b/test/postman/testData/skill/update-skill-with-invalid-data.json new file mode 100644 index 0000000..6f9e74a --- /dev/null +++ b/test/postman/testData/skill/update-skill-with-invalid-data.json @@ -0,0 +1,119 @@ +[ + { + "id": "{{SKILL_1}}", + "input": { + "name": "", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + } + }, + "httpCode": 400, + "message": "\"entity.name\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": 123 + }, + "httpCode": 400, + "message": "\"entity.metadata\" must be of type object" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + }, + "abc": 123 + }, + "httpCode": 400, + "message": "\"entity.abc\" is not allowed" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + } + }, + "httpCode": 404, + "message": "cannot find Skill where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "metadata": { + }, + "taxonomyId": "" + }, + "httpCode": 400, + "message": "\"entity.taxonomyId\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + }, + "uri": "" + }, + "httpCode": 400, + "message": "\"entity.uri\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + }, + "externalId": "" + }, + "httpCode": 400, + "message": "\"entity.externalId\" is not allowed to be empty" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + "challengeProminence": "0.2", + "memberProminence": "777" + } + }, + "httpCode": 400, + "message": "memberProminence must be a string with value in the range [0, 1]" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_02_by_admin updated", + "taxonomyId":"{{TAXONOMY_1}}", + "metadata": { + "challengeProminence": "777", + "memberProminence": "0.2" + } + }, + "httpCode": 400, + "message": "challengeProminence must be a string with value in the range [0, 1]" + }, + { + "id": "{{SKILL_1}}", + "input": { + "name": "POSTMANE2E-skill_03_by_admin", + "taxonomyId":"{{TAXONOMY_2}}", + "metadata": { + }, + "uri":"http://www.google.com" + }, + "httpCode": 409, + "message": "Skill already exists with taxonomyId" + } +] diff --git a/test/postman/testData/skill/update-skill-with-invalid-tokens.json b/test/postman/testData/skill/update-skill-with-invalid-tokens.json new file mode 100644 index 0000000..64b2765 --- /dev/null +++ b/test/postman/testData/skill/update-skill-with-invalid-tokens.json @@ -0,0 +1,32 @@ +[ + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "", + "httpCode": 403, + "message": "No token provided." + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "{{SKILL_1}}", + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + } +] diff --git a/test/postman/testData/taxonomy/create-taxonomy-by-admin.json b/test/postman/testData/taxonomy/create-taxonomy-by-admin.json new file mode 100644 index 0000000..be2e9ea --- /dev/null +++ b/test/postman/testData/taxonomy/create-taxonomy-by-admin.json @@ -0,0 +1,46 @@ +[ + { + "input": { + "name": "POSTMANE2E-taxonomy_01_by_admin", + "metadata": { + "random_field_01": "random_value_01_by_admin" + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_admin", + "metadata": { + "random_field_01": "random_value_01_by_admin" + } + }, + "idLabel": "TAXONOMY_1", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-taxonomy_02_by_admin", + "metadata": { + "abc": "random_value_02_by_admin", + "efg": 123 + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_02_by_admin", + "metadata": { + "abc": "random_value_02_by_admin", + "efg": 123 + } + }, + "idLabel": "TAXONOMY_2", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-taxonomy_03_by_admin" + }, + "expected": { + "name": "POSTMANE2E-taxonomy_03_by_admin" + }, + "idLabel": "TAXONOMY_3", + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/create-taxonomy-by-m2m.json b/test/postman/testData/taxonomy/create-taxonomy-by-m2m.json new file mode 100644 index 0000000..4e2bf40 --- /dev/null +++ b/test/postman/testData/taxonomy/create-taxonomy-by-m2m.json @@ -0,0 +1,46 @@ +[ + { + "input": { + "name": "POSTMANE2E-taxonomy_01_by_m2m", + "metadata": { + "random_field_01": "random_value_01_by_m2m" + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_m2m", + "metadata": { + "random_field_01": "random_value_01_by_m2m" + } + }, + "idLabel": "TAXONOMY_4", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-taxonomy_02_by_m2m", + "metadata": { + "abc": "random_value_02_by_m2m", + "efg": 123 + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_02_by_m2m", + "metadata": { + "abc": "random_value_02_by_m2m", + "efg": 123 + } + }, + "idLabel": "TAXONOMY_5", + "httpCode": 200 + }, + { + "input": { + "name": "POSTMANE2E-taxonomy_03_by_m2m" + }, + "expected": { + "name": "POSTMANE2E-taxonomy_03_by_m2m" + }, + "idLabel": "TAXONOMY_6", + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/create-taxonomy-with-invalid-data.json b/test/postman/testData/taxonomy/create-taxonomy-with-invalid-data.json new file mode 100644 index 0000000..0efaa7e --- /dev/null +++ b/test/postman/testData/taxonomy/create-taxonomy-with-invalid-data.json @@ -0,0 +1,34 @@ +[ + { + "input": { + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.name\" is required" + }, + { + "input": { + "name": "", + "metadata": {} + }, + "httpCode": 400, + "message": "\"entity.name\" is not allowed to be empty" + }, + { + "input": { + "name": "POSTMANE2E-name-valid", + "metadata": 123 + }, + "httpCode": 400, + "message": "\"entity.metadata\" must be of type object" + }, + { + "input": { + "name": "POSTMANE2E-name-valid", + "metadata": {}, + "abc": 123 + }, + "httpCode": 400, + "message": "\"entity.abc\" is not allowed" + } +] diff --git a/test/postman/testData/taxonomy/create-taxonomy-with-invalid-tokens.json b/test/postman/testData/taxonomy/create-taxonomy-with-invalid-tokens.json new file mode 100644 index 0000000..3604db2 --- /dev/null +++ b/test/postman/testData/taxonomy/create-taxonomy-with-invalid-tokens.json @@ -0,0 +1,27 @@ +[ + { + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "jwtToken": "", + "httpCode": 403, + "message": "No token provided." + }, + { + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + } +] diff --git a/test/postman/testData/taxonomy/delete-taxonomy-with-invalid-request.json b/test/postman/testData/taxonomy/delete-taxonomy-with-invalid-request.json new file mode 100644 index 0000000..ad83fb0 --- /dev/null +++ b/test/postman/testData/taxonomy/delete-taxonomy-with-invalid-request.json @@ -0,0 +1,37 @@ +[ + { + "id": "{{TAXONOMY_6}}", + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "id": "{{TAXONOMY_6}}", + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "id": "{{TAXONOMY_6}}", + "httpCode": 403, + "message": "No token provided." + }, + { + "id": "{{TAXONOMY_6}}", + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "{{TAXONOMY_6}}", + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "jwtToken": "Bearer {{admin_token}}", + "httpCode": 404, + "message": "cannot find Taxonomy where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + } +] diff --git a/test/postman/testData/taxonomy/get-taxonomy-with-invalid-parameters.json b/test/postman/testData/taxonomy/get-taxonomy-with-invalid-parameters.json new file mode 100644 index 0000000..4cf6aee --- /dev/null +++ b/test/postman/testData/taxonomy/get-taxonomy-with-invalid-parameters.json @@ -0,0 +1,12 @@ +[ + { + "id": "12345", + "httpCode": 400, + "message": "\"id\" must be a valid GUID" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "httpCode": 404, + "message": "cannot find Taxonomy where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + } +] diff --git a/test/postman/testData/taxonomy/get-taxonomy.json b/test/postman/testData/taxonomy/get-taxonomy.json new file mode 100644 index 0000000..5cc175f --- /dev/null +++ b/test/postman/testData/taxonomy/get-taxonomy.json @@ -0,0 +1,22 @@ +[ + { + "id": "{{TAXONOMY_1}}", + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_admin", + "metadata": { + "random_field_01": "random_value_01_by_admin" + } + }, + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_4}}", + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_m2m", + "metadata": { + "random_field_01": "random_value_01_by_m2m" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/head-taxonomies-with-invalid-parameters.json b/test/postman/testData/taxonomy/head-taxonomies-with-invalid-parameters.json new file mode 100644 index 0000000..df59a8b --- /dev/null +++ b/test/postman/testData/taxonomy/head-taxonomies-with-invalid-parameters.json @@ -0,0 +1,14 @@ +[ + { + "params": "page=-1&perPage=10", + "httpCode": 400 + }, + { + "params": "page=1&perPage=-10", + "httpCode": 400 + }, + { + "params": "aaa=abc", + "httpCode": 400 + } +] diff --git a/test/postman/testData/taxonomy/head-taxonomies-with-various-parameters.json b/test/postman/testData/taxonomy/head-taxonomies-with-various-parameters.json new file mode 100644 index 0000000..d199696 --- /dev/null +++ b/test/postman/testData/taxonomy/head-taxonomies-with-various-parameters.json @@ -0,0 +1,20 @@ +[ + { + "params": "name=POSTMANE2E-taxonomy_01_by_admin", + "expected": { + "X-Page": "1", + "X-Per-Page": "20" + }, + "httpCode": 200 + }, + { + "params": "page=2&perPage=1", + "expected": { + "X-Prev-Page": "1", + "X-Next-Page": "3", + "X-Page": "2", + "X-Per-Page": "1" + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/head-taxonomy-with-invalid-parameters.json b/test/postman/testData/taxonomy/head-taxonomy-with-invalid-parameters.json new file mode 100644 index 0000000..4ff2b26 --- /dev/null +++ b/test/postman/testData/taxonomy/head-taxonomy-with-invalid-parameters.json @@ -0,0 +1,10 @@ +[ + { + "id": "12345", + "httpCode": 400 + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "httpCode": 404 + } +] diff --git a/test/postman/testData/taxonomy/head-taxonomy.json b/test/postman/testData/taxonomy/head-taxonomy.json new file mode 100644 index 0000000..a08dd47 --- /dev/null +++ b/test/postman/testData/taxonomy/head-taxonomy.json @@ -0,0 +1,10 @@ +[ + { + "id": "{{TAXONOMY_1}}", + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_4}}", + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/list-taxonomies-with-invalid-parameters.json b/test/postman/testData/taxonomy/list-taxonomies-with-invalid-parameters.json new file mode 100644 index 0000000..4d73c6a --- /dev/null +++ b/test/postman/testData/taxonomy/list-taxonomies-with-invalid-parameters.json @@ -0,0 +1,17 @@ +[ + { + "params": "page=-1&perPage=10", + "httpCode": 400, + "message": "\"query.page\" must be larger than or equal to 1" + }, + { + "params": "page=1&perPage=-10", + "httpCode": 400, + "message": "\"query.perPage\" must be larger than or equal to 1" + }, + { + "params": "aaa=abc", + "httpCode": 400, + "message": "\"query.aaa\" is not allowed" + } +] diff --git a/test/postman/testData/taxonomy/list-taxonomies-with-various-parameters.json b/test/postman/testData/taxonomy/list-taxonomies-with-various-parameters.json new file mode 100644 index 0000000..48b49d2 --- /dev/null +++ b/test/postman/testData/taxonomy/list-taxonomies-with-various-parameters.json @@ -0,0 +1,18 @@ +[ + { + "params": "name=POSTMANE2E-taxonomy_01_by_admin", + "expectedFields": [ + "id", + "name", + "metadata" + ] + }, + { + "params": "page=1&perPage=10", + "expectedFields": [ + "id", + "name", + "metadata" + ] + } +] diff --git a/test/postman/testData/taxonomy/list-taxonomies.json b/test/postman/testData/taxonomy/list-taxonomies.json new file mode 100644 index 0000000..43e14a6 --- /dev/null +++ b/test/postman/testData/taxonomy/list-taxonomies.json @@ -0,0 +1,9 @@ +[ + { + "expectedFields": [ + "id", + "name", + "metadata" + ] + } +] diff --git a/test/postman/testData/taxonomy/patch-taxonomy-by-admin.json b/test/postman/testData/taxonomy/patch-taxonomy-by-admin.json new file mode 100644 index 0000000..695b770 --- /dev/null +++ b/test/postman/testData/taxonomy/patch-taxonomy-by-admin.json @@ -0,0 +1,42 @@ +[ + { + "id": "{{TAXONOMY_1}}", + "input": { + "name": "POSTMANE2E-taxonomy_01_by_admin updated" + }, + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_admin updated" + }, + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_1}}", + "input": { + "metadata": { + "field updated": "field_value updated" + } + }, + "expected": { + "metadata": { + "field updated": "field_value updated" + } + }, + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_1}}", + "input": { + "name": "POSTMANE2E-taxonomy_01_by_admin updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_admin updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/patch-taxonomy-by-m2m.json b/test/postman/testData/taxonomy/patch-taxonomy-by-m2m.json new file mode 100644 index 0000000..161451b --- /dev/null +++ b/test/postman/testData/taxonomy/patch-taxonomy-by-m2m.json @@ -0,0 +1,42 @@ +[ + { + "id": "{{TAXONOMY_4}}", + "input": { + "name": "POSTMANE2E-taxonomy_01_by_m2m updated" + }, + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_m2m updated" + }, + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_4}}", + "input": { + "metadata": { + "field updated": "field_value updated" + } + }, + "expected": { + "metadata": { + "field updated": "field_value updated" + } + }, + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_4}}", + "input": { + "name": "POSTMANE2E-taxonomy_01_by_m2m updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_01_by_m2m updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/patch-taxonomy-with-invalid-data.json b/test/postman/testData/taxonomy/patch-taxonomy-with-invalid-data.json new file mode 100644 index 0000000..50d3ff4 --- /dev/null +++ b/test/postman/testData/taxonomy/patch-taxonomy-with-invalid-data.json @@ -0,0 +1,34 @@ +[ + { + "id": "{{TAXONOMY_1}}", + "input": { + "name": "" + }, + "httpCode": 400, + "message": "\"entity.name\" is not allowed to be empty" + }, + { + "id": "{{TAXONOMY_1}}", + "input": { + "metadata": 123 + }, + "httpCode": 400, + "message": "\"entity.metadata\" must be of type object" + }, + { + "id": "{{TAXONOMY_1}}", + "input": { + "abc": 123 + }, + "httpCode": 400, + "message": "\"entity.abc\" is not allowed" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "input": { + "metadata": {} + }, + "httpCode": 404, + "message": "cannot find Taxonomy where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + } +] diff --git a/test/postman/testData/taxonomy/patch-taxonomy-with-invalid-tokens.json b/test/postman/testData/taxonomy/patch-taxonomy-with-invalid-tokens.json new file mode 100644 index 0000000..4c1bf02 --- /dev/null +++ b/test/postman/testData/taxonomy/patch-taxonomy-with-invalid-tokens.json @@ -0,0 +1,32 @@ +[ + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "", + "httpCode": 403, + "message": "No token provided." + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + } +] diff --git a/test/postman/testData/taxonomy/update-taxonomy-by-admin.json b/test/postman/testData/taxonomy/update-taxonomy-by-admin.json new file mode 100644 index 0000000..f636f42 --- /dev/null +++ b/test/postman/testData/taxonomy/update-taxonomy-by-admin.json @@ -0,0 +1,32 @@ +[ + { + "id": "{{TAXONOMY_2}}", + "input": { + "name": "POSTMANE2E-taxonomy_02_by_admin updated", + "metadata": { + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_02_by_admin updated", + "metadata": { + } + }, + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_2}}", + "input": { + "name": "POSTMANE2E-taxonomy_02_by_admin updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_02_by_admin updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/update-taxonomy-by-m2m.json b/test/postman/testData/taxonomy/update-taxonomy-by-m2m.json new file mode 100644 index 0000000..56b7fc5 --- /dev/null +++ b/test/postman/testData/taxonomy/update-taxonomy-by-m2m.json @@ -0,0 +1,28 @@ +[ + { + "id": "{{TAXONOMY_5}}", + "input": { + "name": "POSTMANE2E-taxonomy_02_by_m2m updated" + }, + "expected": { + "name": "POSTMANE2E-taxonomy_02_by_m2m updated" + }, + "httpCode": 200 + }, + { + "id": "{{TAXONOMY_5}}", + "input": { + "name": "POSTMANE2E-taxonomy_02_by_m2m updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "expected": { + "name": "POSTMANE2E-taxonomy_02_by_m2m updated 2", + "metadata": { + "field updated": "field_value updated 2" + } + }, + "httpCode": 200 + } +] diff --git a/test/postman/testData/taxonomy/update-taxonomy-with-invalid-data.json b/test/postman/testData/taxonomy/update-taxonomy-with-invalid-data.json new file mode 100644 index 0000000..470a8df --- /dev/null +++ b/test/postman/testData/taxonomy/update-taxonomy-with-invalid-data.json @@ -0,0 +1,37 @@ +[ + { + "id": "{{TAXONOMY_1}}", + "input": { + "name": "" + }, + "httpCode": 400, + "message": "\"entity.name\" is not allowed to be empty" + }, + { + "id": "{{TAXONOMY_1}}", + "input": { + "name": "POSTMANE2E-taxonomy_02_by_admin updated", + "metadata": 123 + }, + "httpCode": 400, + "message": "\"entity.metadata\" must be of type object" + }, + { + "id": "{{TAXONOMY_1}}", + "input": { + "name": "POSTMANE2E-taxonomy_02_by_admin updated", + "abc": 123 + }, + "httpCode": 400, + "message": "\"entity.abc\" is not allowed" + }, + { + "id": "6ffcbc99-7891-48c7-8c0c-84940f405e9b", + "input": { + "name": "POSTMANE2E-taxonomy_02_by_admin updated", + "metadata": {} + }, + "httpCode": 404, + "message": "cannot find Taxonomy where id = 6ffcbc99-7891-48c7-8c0c-84940f405e9b" + } +] diff --git a/test/postman/testData/taxonomy/update-taxonomy-with-invalid-tokens.json b/test/postman/testData/taxonomy/update-taxonomy-with-invalid-tokens.json new file mode 100644 index 0000000..4c1bf02 --- /dev/null +++ b/test/postman/testData/taxonomy/update-taxonomy-with-invalid-tokens.json @@ -0,0 +1,32 @@ +[ + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer invalid", + "httpCode": 403, + "message": "Invalid Token." + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiQ29ubmVjdCBTdXBwb3J0IiwiYWRtaW5pc3RyYXRvciIsInRlc3RSb2xlIiwiYWFhIiwidG9ueV90ZXN0XzEiLCJDb25uZWN0IE1hbmFnZXIiLCJDb25uZWN0IEFkbWluIiwiY29waWxvdCIsIkNvbm5lY3QgQ29waWxvdCBNYW5hZ2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJUb255SiIsImV4cCI6MTU1MTA2MzIxMSwidXNlcklkIjoiODU0Nzg5OSIsImlhdCI6MTU1MTA1MzIxMSwiZW1haWwiOiJ0amVmdHMrZml4QHRvcGNvZGVyLmNvbSIsImp0aSI6ImY5NGQxZTI2LTNkMGUtNDZjYS04MTE1LTg3NTQ1NDRhMDhmMSJ9.97-pjuSGGqDAqK2FG2yi_3nmzB7ZMXQwtG0bi8_PlKk", + "httpCode": 403, + "message": "Failed to authenticate token." + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "", + "httpCode": 403, + "message": "No token provided." + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer {{user_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + }, + { + "id": "{{TAXONOMY_1}}", + "jwtToken": "Bearer {{copilot_token}}", + "httpCode": 403, + "message": "You do not have permissions to perform this action" + } +]