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

fix(recorder): allow recording req headers when not outputting objects #1617

Merged
merged 2 commits into from Jul 15, 2019

Conversation

mastermatt
Copy link
Member

Fixes #1607 (assuming #1616 is merged in first)
Part of #1404

While this work started out as just an effort to add coverage to recorder.js, I found/fixed a bug so I'm using the fix type.

There was a bug that kept request headers from being added to matchHeader lines in non-object outputs.
enable_reqheaders_recording was only having an affect if output_objects was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
A test was added to cover the flow of wanting the matchHeader as the other flow was already covered.

There are a couple other changes intertwined with the bug fix. It seemed cleaner to PR them together since it's all so tightly coupled. Things to keep in mind:

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.
When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

This looks great. Nice catch, too 👍

@mastermatt mastermatt merged commit a952d9b into nock:beta Jul 15, 2019
@mastermatt mastermatt deleted the recorder-coverage branch July 15, 2019 01:40
@nockbot
Copy link
Collaborator

nockbot commented Jul 15, 2019

🎉 This PR is included in version 11.0.0-beta.24 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nockbot
Copy link
Collaborator

nockbot commented Aug 12, 2019

🎉 This PR is included in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gr2m pushed a commit that referenced this pull request Sep 4, 2019
#1617)

* test: add coverage for logging recorded objects

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.

* fix: allow recording req headers when not outputting objects

When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
gr2m pushed a commit that referenced this pull request Sep 4, 2019
#1617)

* test: add coverage for logging recorded objects

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.

* fix: allow recording req headers when not outputting objects

When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
gr2m pushed a commit that referenced this pull request Sep 5, 2019
#1617)

* test: add coverage for logging recorded objects

There was no test that `output_objects: true`, without also setting
`dont_print: true` so this flow was not covered.

* fix: allow recording req headers when not outputting objects

When exploring coverage gaps a few things were uncovered:
- OutgoingMessage._headers has been deprecated in favor of `getHeaders()`. https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
- IncommingMessage.rawHeaders is never falsy so there isn't a need to fall back to `headers`
- There was a bug that kept request headers from being added to `matchHeader` lines in non-object outputs.
  `enable_reqheaders_recording` was only having an affect if `output_objects` was also true, but headers were never being added despite that because it was looking for headers under the wrong attribute on the request.
  A test was added to cover the flow of wanting the `matchHeader` as the other flow was already covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants