Fixed issue where content-type with wild characters resulted in mismacthes for valid collection headrs

This commit is contained in:
Vishal Shingala
2022-01-19 12:53:15 +05:30
parent ce49559ef2
commit 989cea9ce6
4 changed files with 150 additions and 19 deletions

View File

@@ -556,6 +556,38 @@ describe('VALIDATE FUNCTION TESTS ', function () {
});
});
it('Should correctly match and validate content type headers having wildcard characters' +
' with collection req/res body', function (done) {
let differentContentTypesSpec = fs.readFileSync(path.join(__dirname, VALIDATION_DATA_FOLDER_PATH +
'/differentContentTypesSpec.yaml'), 'utf-8'),
differentContentTypesCollection = fs.readFileSync(path.join(__dirname, VALIDATION_DATA_FOLDER_PATH +
'/differentContentTypesCollection.json'), 'utf-8'),
resultObj,
historyRequest = [],
options = {
showMissingInSchemaErrors: true,
suggestAvailableFixes: true
},
schemaPack = new Converter.SchemaPack({ type: 'string', data: differentContentTypesSpec }, options);
getAllTransactions(JSON.parse(differentContentTypesCollection), historyRequest);
schemaPack.validateTransaction(historyRequest, (err, result) => {
expect(err).to.be.null;
expect(result).to.be.an('object');
resultObj = result.requests[historyRequest[1].id].endpoints[0];
/**
* Both req and res body should have matched content types
*/
expect(resultObj.matched).to.eql(true);
expect(resultObj.mismatches).to.have.lengthOf(0);
expect(resultObj.responses[_.keys(resultObj.responses)[0]].matched).to.eql(true);
expect(resultObj.responses[_.keys(resultObj.responses)[0]].mismatches).to.have.lengthOf(0);
done();
});
});
it('Should be able to validate and suggest correct value for body with primitive data type', function (done) {
let primitiveDataTypeBodySpec = fs.readFileSync(path.join(__dirname, VALIDATION_DATA_FOLDER_PATH +
'/primitiveDataTypeBodySpec.yaml'), 'utf-8'),