Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check common_headers when running assertion #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export default class Spec {
let customCookies = additionalOptions.cookies || {};

return Object.assign({}, defaultCookies, customCookies);
}
}

addAdditionalRequestOptions(reqOptions) {
const supportedOptions = ['followRedirect', 'followAllRedirects', 'followOriginalHttpMethod', 'encoding', 'gzip'];
Expand All @@ -469,7 +469,7 @@ export default class Spec {

buildRequestBody(additionalOptions, headers, method) {
let bodyData = {};
let requestContentType = headers['content-type'];
let requestContentType = headers['content-type'] || this.suite.commonHeaders['content-type'];
Copy link
Owner

Choose a reason for hiding this comment

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

@matmar10 This is not required here, because the headers passed to this function include common headers too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I raised issue #31 because the current behavior does not include common headers set in config.

If you need, I can create a gist that reproduces this.

let RequestBodyNotFoundError = customError('RequestBodyNotFoundError');
let InvalidRequestSpecificationError = customError('InvalidRequestSpecificationError');
let InvalidRequestHeaderError = customError('InvalidRequestHeaderError');
Expand Down Expand Up @@ -723,7 +723,7 @@ export default class Spec {
}

return true;
}
}

_validateJSONData(response, jsonData) {
let jsonBody;
Expand Down Expand Up @@ -769,7 +769,7 @@ export default class Spec {
if (values[0] !== eachJsonData.value) {
throw new ResponseJSONDataMismatchError(`JSON path evaluated value did not match with expected Boolean value, json path: ${eachJsonData.path}, Actual value: ${values[0]}, Expected value: ${eachJsonData.value}`);
}
}
}
else {
throw new Error(`Unknown json data value type, only Array, Object, RegExp, Number, Boolean & String are allowed`);
}
Expand Down Expand Up @@ -827,4 +827,4 @@ export default class Spec {
}


}
}
4 changes: 2 additions & 2 deletions test/cli/headers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('headers', function () {
expect(reportData.passedSuitesCount).to.equal(0);
expect(reportData.skippedSuitesCount).to.equal(0);
expect(reportData.failedSuitesCount).to.equal(1);
expect(reportData.passedTestsCount).to.equal(7);
expect(reportData.passedTestsCount).to.equal(8);
expect(reportData.skippedTestsCount).to.equal(0);
expect(reportData.failedTestsCount).to.equal(2);
expect(reportData.suites.length).to.equal(1);
Expand Down Expand Up @@ -92,4 +92,4 @@ describe('headers', function () {
expect(test.error).to.be.a('null');
});

});
});
15 changes: 14 additions & 1 deletion test/cli/src/suites/headers.suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ configuration:
common_headers:
- name: customsuiteheader
value: custom-suite-header-value
- name: content-type
value: application/json
specs:
- name: add suite headers to request headers
request:
Expand Down Expand Up @@ -114,4 +116,15 @@ specs:
response:
json_data:
- path: "$.header1"
value: "header2-value"
value: "header2-value"
- name: uses suite-level content-type header
request:
path: /echoJSONBodyResponse
method: post
payload:
body:
type: json
content:
name: Kiran
response:
status_code: 200