Skip to content
New issue

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

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

Already on GitHub? # to your account

Remove github token test dependency #85

Closed
johnboyes opened this issue Jul 7, 2020 · 1 comment
Closed

Remove github token test dependency #85

johnboyes opened this issue Jul 7, 2020 · 1 comment

Comments

@johnboyes
Copy link
Contributor

johnboyes commented Jul 7, 2020

At the moment running the tests requires a GitHub personal access token with access to the agilepathway/test-label-checker-consumer repo.

This means that other contributors will not be able to run the tests without a token, which is problematic.

@johnboyes
Copy link
Contributor Author

johnboyes commented Jul 7, 2020

Hoverfly seems like a good solution, as it allows black box testing (through setting HTTP_PROXY and HTTPS_PROXY environment variables.

johnboyes added a commit that referenced this issue Jul 7, 2020
Used Hoverfly[1] to capture[2] these simulations[3]

Now if we run the tests as below[4], Hoverfly will intercept the
requests to the GitHub API and return the simulated responses.
This means that we no longer need to provide a GitHub `INPUT_REPO_TOKEN`
when running the tests (fixes #85).

Local setup of Hoverfly to get the tests to run is as simple as

1. Install Hoverfly[5]
2. Download the Hoverfly default cert[6]
3. Install and trust the Hoverfly default cert[7]

[1] https://docs.hoverfly.io/
[2] https://docs.hoverfly.io/en/latest/pages/keyconcepts/modes/capture.html
[3] https://docs.hoverfly.io/en/latest/pages/keyconcepts/simulations/simulations.html
[4] HTTPS_PROXY=localhost:8500 go test ./...
[5] https://docs.hoverfly.io/en/latest/pages/introduction/downloadinstallation.html
[6] https://github.com/SpectoLabs/hoverfly/blob/master/core/cert.pem
[7] https://docs.hoverfly.io/en/latest/pages/tutorials/advanced/configuressl/configuressl.html
johnboyes added a commit that referenced this issue Jul 16, 2020
Used Hoverfly[1] to capture[2] these simulations[3]

Now if we run the tests as below[4], Hoverfly will intercept the
requests to the GitHub API and return the simulated responses.
This means that we no longer need to provide a GitHub `INPUT_REPO_TOKEN`
when running the tests (fixes #85).

Local setup of Hoverfly to get the tests to run is as simple as

1. Install Hoverfly[5]
2. Download the Hoverfly default cert[6]
3. Install and trust the Hoverfly default cert[7]

[1] https://docs.hoverfly.io/
[2] https://docs.hoverfly.io/en/latest/pages/keyconcepts/modes/capture.html
[3] https://docs.hoverfly.io/en/latest/pages/keyconcepts/simulations/simulations.html
[4] HTTPS_PROXY=localhost:8500 go test ./...
[5] https://docs.hoverfly.io/en/latest/pages/introduction/downloadinstallation.html
[6] https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem
[7] https://docs.hoverfly.io/en/latest/pages/tutorials/advanced/configuressl/configuressl.html
johnboyes added a commit that referenced this issue Jul 16, 2020
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.
Used Hoverfly to capture[3] and then simulate these responses.

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

Steps to install Hoverfly locally (you must do this on your 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
johnboyes added a commit that referenced this issue Jul 16, 2020
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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant