Revert "Add tests to check transactionJsonPath when detailedBlobValidation is true"

This reverts commit 438a7b3a7c.
This commit is contained in:
Luis Tejeda
2022-02-28 09:54:25 -06:00
parent 7ac8c9447c
commit fb88c34733
4 changed files with 19 additions and 671 deletions

View File

@@ -1,118 +0,0 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: https://postman-echo.com/get
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
format: date
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string`

View File

@@ -1,375 +0,0 @@
{
"item": [
{
"id": "ec09078b-8861-4367-9e9e-22f8c3d31f82",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "2c8762c9-54bc-4981-8d2c-09b71fadcebc",
"name": "List all pets",
"request": {
"name": "List all pets",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"disabled": false,
"key": "limit",
"value": "82526723",
"description": "How many items to return at one time (max 100)"
}
],
"variable": []
},
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"method": "GET",
"auth": null
},
"response": [
{
"id": "2d0c2488-0d26-4029-9294-fbc5c9b8363f",
"name": "A paged array of pets",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "82526723"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"disabled": false,
"description": "A link to the next page of responses",
"key": "x-next",
"value": "in nulla Lorem ex"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "[\n {\n \"id\": 41014273,\n \"name\": \"dolor eu minim in\",\n \"tag\": \"urn:uuid:94b326e4-ed11-bd40-c87d-1a1524b6bc2f\"\n },\n {\n \"id\": -74291521,\n \"name\": \"pariatur dolor e\",\n \"tag\": \"urn:uuid:092c825a-7a1d-1adc-71da-b9dbe24c2da6\"\n }\n]",
"cookie": [],
"_postman_previewlanguage": "json"
},
{
"id": "eb93bc02-1380-433a-9a6e-acd8875a8334",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "82526723"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": -57418069,\n \"message\": \"non quis proident\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
},
{
"id": "87611012-e59c-40e1-90f2-24a50fbbff1d",
"name": "Create a pet",
"request": {
"name": "Create a pet",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"id\": -56104459,\n \"name\": \"dolore incididunt pariatur occaecat\",\n \"tag\": \"9e6b59af-239e-b38b-74a7-f3110c87227e\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"response": [
{
"id": "813809b9-3290-43e3-8c43-f939db815d2c",
"name": "Null response",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"id\": -56104459,\n \"name\": \"dolore incididunt pariatur occaecat\",\n \"tag\": \"9e6b59af-239e-b38b-74a7-f3110c87227e\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"status": "Created",
"code": 201,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
},
{
"id": "436ebb0e-5c7a-4cba-883e-f36089ccd5e2",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"id\": -56104459,\n \"name\": \"dolore incididunt pariatur occaecat\",\n \"tag\": \"9e6b59af-239e-b38b-74a7-f3110c87227e\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": -57418069,\n \"message\": \"non quis proident\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": [],
"protocolProfileBehavior": {
"disableBodyPruning": true
}
},
{
"id": "ab623305-0ccf-4edc-9210-c3ed68d4e1dc",
"name": "Info for a specific pet",
"request": {
"name": "Info for a specific pet",
"description": {},
"url": {
"path": [
"pets",
":petId"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"disabled": false,
"type": "any",
"value": "in nulla Lorem ex",
"key": "petId",
"description": "(Required) The id of the pet to retrieve"
}
]
},
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"method": "GET",
"auth": null
},
"response": [
{
"id": "6de63e43-7e59-4713-8893-53bdbddeddef",
"name": "Expected response to a valid request",
"originalRequest": {
"url": {
"path": [
"pets",
":petId"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"disabled": false,
"type": "any",
"value": "in nulla Lorem ex",
"key": "petId",
"description": "(Required) The id of the pet to retrieve"
}
]
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"id\": -56104459,\n \"name\": \"dolore incididunt pariatur occaecat\",\n \"tag\": \"9e6b59af-239e-b38b-74a7-f3110c87227e\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
},
{
"id": "d221e68f-af12-4042-935e-ae2709ef52e7",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets",
":petId"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"disabled": false,
"type": "any",
"value": "in nulla Lorem ex",
"key": "petId",
"description": "(Required) The id of the pet to retrieve"
}
]
},
"method": "GET",
"body": {}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": -57418069,\n \"message\": \"non quis proident\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"type": "string",
"value": "https://postman-echo.com/get",
"key": "baseUrl"
}
],
"info": {
"_postman_id": "5baba942-df02-45da-9e3d-540db4667bc4",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -1,118 +0,0 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: https://postman-echo.com/get
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
format: date
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string`

View File

@@ -391,21 +391,21 @@ describe('The Validation option', function () {
{ detailedBlobValidation: true }),
historyRequest = [],
resultObj,
violatedKeywords = {
'data.items.minProperties': '$.request.body.data[0]',
'data.items.required': '$.request.body.data[0]',
'data.items.properties.entityId.maxLength': '$.request.body.data[0].entityId',
'data.items.properties.accountNumber.minLength': '$.request.body.data[0].accountNumber',
'data.items.properties.entityName.format': '$.request.body.data[0].entityName',
'data.items.properties.incType.enum': '$.request.body.data[0].incType',
'data.items.properties.companyNumber.exclusiveMinimum': '$.request.body.data[0].companyNumber',
'data.items.properties.website.type': '$.request.body.data[0].website',
'data.items.properties.turnover.multipleOf': '$.request.body.data[0].turnover',
'data.items.properties.description.pattern': '$.request.body.data[0].description',
'data.items.properties.wants.uniqueItems': '$.request.body.data[0].wants',
'meta.maxProperties': '$.request.body.meta',
'meta.additionalProperties': '$.request.body.meta'
};
violatedKeywords = [
'data.items.minProperties',
'data.items.required',
'data.items.properties.entityId.maxLength',
'data.items.properties.accountNumber.minLength',
'data.items.properties.entityName.format',
'data.items.properties.incType.enum',
'data.items.properties.companyNumber.exclusiveMinimum',
'data.items.properties.website.type',
'data.items.properties.turnover.multipleOf',
'data.items.properties.description.pattern',
'data.items.properties.wants.uniqueItems',
'meta.maxProperties',
'meta.additionalProperties'
];
getAllTransactions(JSON.parse(collection), historyRequest);
schemaPack.validateTransaction(historyRequest, (err, result) => {
@@ -416,8 +416,7 @@ describe('The Validation option', function () {
_.forEach(resultObj.mismatches, (mismatch) => {
// remove starting string '$.paths[/user].post.requestBody.content[application/json].schema.properties.'
let localJsonPath = mismatch.schemaJsonPath.slice(76);
expect(_.includes(_.keys(violatedKeywords), localJsonPath)).to.eql(true);
expect(_.includes(_.values(violatedKeywords), mismatch.transactionJsonPath)).to.eql(true);
expect(_.includes(violatedKeywords, localJsonPath)).to.eql(true);
// mark matched path as empty to ensure repetition does'n occur
violatedKeywords[_.indexOf(violatedKeywords, localJsonPath)] = '';
@@ -507,13 +506,6 @@ describe('VALIDATE FUNCTION TESTS ', function () {
VALIDATION_DATA_SCENARIOS_FOLDER_31_PATH
),
'/compositeSchemaSpec.yaml'
),
invalidTypeProperty = getSpecsPathByVersion(
getFoldersByVersion(
VALIDATION_DATA_FOLDER_PATH,
VALIDATION_DATA_SCENARIOS_FOLDER_31_PATH
),
'/invalidTypeProperty.yaml'
);
emptyParameterSpecs.forEach((specData) => {
@@ -757,7 +749,7 @@ describe('VALIDATE FUNCTION TESTS ', function () {
ignoreUnresolvedVariables: true,
validateMetadata: true,
suggestAvailableFixes: true,
detailedBlobValidation: true
detailedBlobValidation: false
},
schemaPack = new Converter.SchemaPack({ type: 'string', data: primitiveDataTypeBodySpec }, options);
@@ -770,13 +762,11 @@ describe('VALIDATE FUNCTION TESTS ', function () {
// request body is boolean
resultObj = result.requests[historyRequest[0].id].endpoints[0];
expect(resultObj.mismatches).to.have.lengthOf(0);
const responseId = _.keys(resultObj.responses)[0];
// request body is integer
responseObj = resultObj.responses[responseId];
responseObj = resultObj.responses[_.keys(resultObj.responses)[0]];
expect(responseObj.mismatches).to.have.lengthOf(1);
expect(responseObj.mismatches[0].suggestedFix.suggestedValue).to.be.within(5, 10);
expect(responseObj.mismatches[0].transactionJsonPath).to
.equal(`$.responses[${responseId}].body`);
done();
});
});
@@ -971,37 +961,6 @@ describe('VALIDATE FUNCTION TESTS ', function () {
});
});
});
invalidTypeProperty.forEach((specData) => {
it('Should correctly suggest value and report transactionJsonPath on a body property with incorrect value ' +
specData.version, function (done) {
let invalidTypePropertySpec = fs.readFileSync(specData.path, 'utf-8'),
invalidTypePropertyCollection = fs.readFileSync(path.join(__dirname, VALIDATION_DATA_FOLDER_PATH +
'/invalidTypeProperty.json'), 'utf-8'),
options = { suggestAvailableFixes: true, detailedBlobValidation: true },
resultObj,
historyRequest = [],
schemaPack = new Converter.SchemaPack({ type: 'string', data: invalidTypePropertySpec }, options);
getAllTransactions(JSON.parse(invalidTypePropertyCollection), historyRequest);
schemaPack.validateTransaction(historyRequest, (err, result) => {
expect(err).to.be.null;
expect(result).to.be.an('object');
resultObj = result.requests[historyRequest[0].id].endpoints[0];
const responseId = _.keys(resultObj.responses)[0],
responseMissmatches = resultObj.responses[responseId].mismatches;
expect(responseMissmatches).to.have.lengthOf(2);
expect(responseMissmatches[0].transactionJsonPath)
.to.equal(`$.responses[${responseId}].body[0].tag`);
expect(responseMissmatches[0].suggestedFix.key).to.equal('tag');
expect(responseMissmatches[1].transactionJsonPath)
.to.equal(`$.responses[${responseId}].body[1].tag`);
expect(responseMissmatches[1].suggestedFix.key).to.equal('tag');
done();
});
});
});
});
describe('getPostmanUrlSuffixSchemaScore function', function () {