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

application/json and gzip #787

Open
phink0 opened this issue Nov 22, 2018 · 2 comments
Open

application/json and gzip #787

phink0 opened this issue Nov 22, 2018 · 2 comments

Comments

@phink0
Copy link

phink0 commented Nov 22, 2018

When a captured response has Content-Type: application/json and Content-Encoding: gzip it is encoded in Base64 in the simulation file.

Uncompressing this response to normal JSON text in the simulation file would enhance readability and understanding, make editing and versioning easier.

In simulate mode such a response could or should be compressed again to be closer to the actual API.

@JohnFDavenport
Copy link
Contributor

Related to #815

@JohnFDavenport JohnFDavenport added this to the v1.1.a milestone Mar 1, 2019
@tommysitu tommysitu removed this from the v1.2 milestone Jul 3, 2019
@GeorgeRadev
Copy link

Could there be an option for hoverctl export to decompress the gzip content ?

I agree that decompressing should be out of the proxy functionality,
and decompression is mostly needed when simulation is going to be edited for creating new simulations.
Thus, if export provide optional decompressing recordings it will be much easier to edit exported simulations and loading them after that.

johnboyes added a commit to agilepathway/label-checker that referenced this issue Jul 7, 2020
The original captured GitHub API responses were gzip encoded, which made
them unreadable (without manually decoding them).

There is a feature request to have Hoverfly to do this translation
automatically when exporting captured simulations, but it is not
available yet[1].

So this commit has manually placed the decoded JSON in the simulated
responses.

[1] SpectoLabs/hoverfly#787
johnboyes added a commit to agilepathway/label-checker that referenced this issue Jul 16, 2020
The original captured GitHub API responses were gzip encoded, which made
them unreadable (without manually decoding them).

There is a feature request to have Hoverfly to do this translation
automatically when exporting captured simulations, but it is not
available yet[1].

So this commit has manually placed the decoded JSON in the simulated
responses.

[1] SpectoLabs/hoverfly#787
johnboyes added a commit to agilepathway/label-checker that referenced this issue Jul 16, 2020
The original captured GitHub API responses were gzip encoded, which made
them unreadable (without manually decoding them).

There is a feature request to have Hoverfly to do this translation
automatically when exporting captured simulations, but it is not
available yet[1].

So this commit has manually placed the decoded JSON in the simulated
responses.

[1] SpectoLabs/hoverfly#787
johnboyes added a commit to agilepathway/label-checker that referenced this issue Jul 16, 2020
The original captured GitHub API responses were gzip encoded, which made
them unreadable (without manually decoding them).

There is a feature request to have Hoverfly to do this translation
automatically when exporting captured simulations, but it is not
available yet[1].

So this commit has manually placed the decoded JSON in the simulated
responses.

[1] SpectoLabs/hoverfly#787
johnboyes added a commit to agilepathway/label-checker that referenced this issue Jul 20, 2020
* Move temporary test files to a temporary directory

This ensures that if/when we have a need to store test data permanently
in the `testdata` directory (e.g. for mocks), the `testdata` directory
won't be inadvertently deleted.

* Enable tests to run without a GitHub token

This means that we no longer need to provide a GitHub `INPUT_REPO_TOKEN`
environment variable when running the tests (fixes #85).

The tests now use Hoverfly[1] by default, which proxies the calls to the
GitHub API and returns simulated responses[2] instead.
Also used Hoverfly to capture[3] these simulated responses.

The tests can also be run with an -integration flag, which means they
will make calls to the real GitHub API, requring a GitHub
`INPUT_REPO_TOKEN` environment variable to have been set.

Steps to install Hoverfly locally (you must do this on your local
machine before you can run the tests):

1. Install Hoverfly[4]
2. Download the Hoverfly default cert[5]
3. Add and trust the Hoverfly default cert[6] (how to add and trust
   a cert)[7]

[1] https://docs.hoverfly.io/
[2] https://docs.hoverfly.io/en/latest/pages/keyconcepts/simulations/simulations.html
[3] https://docs.hoverfly.io/en/latest/pages/keyconcepts/modes/capture.html
[4] https://docs.hoverfly.io/en/latest/pages/introduction/downloadinstallation.html
[5] https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem
[6] https://docs.hoverfly.io/en/latest/pages/tutorials/advanced/configuressl/configuressl.html
[7] https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html

* Use JSON simulated GitHub responses, not gzip

The original captured GitHub API responses were gzip encoded, which made
them unreadable (without manually decoding them).

There is a feature request to have Hoverfly to do this translation
automatically when exporting captured simulations, but it is not
available yet[1].

So this commit has manually placed the decoded JSON in the simulated
responses.

[1] SpectoLabs/hoverfly#787

* Run default and integration tests on commit

Update the GitHub Action to run the tests in both default mode (with
virtualised service calls), and integration mode (with calls to the real
GitHub API).

* Install Hoverfly on devcontainer for virtual tests

Also added and trusted the Hoverfly default certificate[1], so that
Hoverfly https calls work

And also set the tests to run in verbose mode in Visual Studio Code, so
we get more informative output when running them.

[1] https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem

https://hoverfly.readthedocs.io/

* Add contributing guidelines

https://docs.github.com/en/github/building-a-strong-community/setting-guidelines-for-repository-contributors

Closes #78, #85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants