From 79000ff0dff7976284d107b4773b945ce39f3306 Mon Sep 17 00:00:00 2001 From: John Boyes Date: Mon, 20 Jul 2020 14:50:20 +0700 Subject: [PATCH] Enable tests to run without a GitHub personal access token (#87) * 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] https://github.com/SpectoLabs/hoverfly/issues/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 --- .devcontainer/Dockerfile | 22 + .github/CODEOWNERS | 9 + .../{test.yml => integration_test.yml} | 3 +- .github/workflows/virtual_test.yml | 40 ++ .vscode/settings.json | 1 + .yamllint.yml | 8 + CONTRIBUTING.md | 89 ++++ README.md | 14 +- label_checker_test.go | 53 +- testdata/github_api.json | 463 ++++++++++++++++++ 10 files changed, 697 insertions(+), 5 deletions(-) create mode 100644 .github/CODEOWNERS rename .github/workflows/{test.yml => integration_test.yml} (88%) create mode 100644 .github/workflows/virtual_test.yml create mode 100644 .yamllint.yml create mode 100644 CONTRIBUTING.md create mode 100644 testdata/github_api.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b5f3f899..ebbcc159 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -18,6 +18,8 @@ ARG USER_GID=$USER_UID RUN apt-get update \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ + # Need zip and unzip for the Hoverfly installation + && apt-get -y install --no-install-recommends zip unzip \ # # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed && apt-get -y install --no-install-recommends git openssh-client less iproute2 procps lsb-release \ @@ -63,3 +65,23 @@ RUN apt-get update \ # Updated from "auto" to "on" as we are using Go modules for this project # See https://dev.to/maelvls/why-is-go111module-everywhere-and-everything-about-go-modules-24k ENV GO111MODULE=on + +# Install Hoverfly for virtualised tests: https://hoverfly.readthedocs.io/ +# hadolint ignore=DL3003 +RUN mkdir -p /tmp/hoverfly \ + && cd /tmp/hoverfly || exit \ + && export HOVERFLY_PLATFORM=linux_amd64 \ + && export HOVERFLY_PLATFORM=linux_amd64 \ + && export HOVERFLY_VERSION=v1.3.0 \ + && export HOVERFLY_BUNDLE=hoverfly_bundle_$HOVERFLY_PLATFORM \ + && wget https://github.com/SpectoLabs/hoverfly/releases/download/$HOVERFLY_VERSION/$HOVERFLY_BUNDLE.zip \ + && unzip $HOVERFLY_BUNDLE.zip \ + && mv hoverfly /usr/local/bin/ \ + && mv hoverctl /usr/local/bin/ \ + && chmod +x /usr/local/bin/hoverfly \ + && chmod +x /usr/local/bin/hoverctl \ + # Add the trusted Hoverfly certificate so that Hoverfly SSL calls work + && wget https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem \ + && cp cert.pem /usr/local/share/ca-certificates/hoverfly.crt \ + && update-ca-certificates \ + && rm -rf /tmp/hoverfly diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..c6104b52 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,9 @@ +# See +# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners +# https://github.blog/2017-07-06-introducing-code-owners/ + +# Lines starting with '#' are comments. +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in the repo. +* @johnboyes \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/integration_test.yml similarity index 88% rename from .github/workflows/test.yml rename to .github/workflows/integration_test.yml index 15a3579b..8476924e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/integration_test.yml @@ -3,6 +3,7 @@ on: [push] # yamllint disable-line rule:truthy name: Tests jobs: tests: + name: Integration strategy: matrix: go-version: [1.14.x] @@ -18,4 +19,4 @@ jobs: - name: Tests env: INPUT_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: go test ./... + run: go test -integration -v . diff --git a/.github/workflows/virtual_test.yml b/.github/workflows/virtual_test.yml new file mode 100644 index 00000000..4def9e7e --- /dev/null +++ b/.github/workflows/virtual_test.yml @@ -0,0 +1,40 @@ +--- +on: [push] # yamllint disable-line rule:truthy +name: Tests +jobs: + tests: + name: Virtual + strategy: + matrix: + go-version: [1.14.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Install Hoverfly + working-directory: ${{ runner.temp }} + run: | + mkdir -p $GITHUB_WORKSPACE/bin + export HOVERFLY_PLATFORM=linux_amd64 + export HOVERFLY_VERSION=v1.3.0 + export HOVERFLY_BUNDLE=hoverfly_bundle_$HOVERFLY_PLATFORM + export HOVERFLY_DOWNLOAD_URL=https://github.com/SpectoLabs/hoverfly/releases/download/ + wget $HOVERFLY_DOWNLOAD_URL$HOVERFLY_VERSION/$HOVERFLY_BUNDLE.zip + unzip $HOVERFLY_BUNDLE.zip + mv hoverfly $GITHUB_WORKSPACE/bin/ + mv hoverctl $GITHUB_WORKSPACE/bin/ + echo "::add-path::$GITHUB_WORKSPACE/bin" + chmod +x $GITHUB_WORKSPACE/bin/hoverfly + chmod +x $GITHUB_WORKSPACE/bin/hoverctl + - name: Add and trust Hoverfly default certificate + run: | + wget https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem + sudo mv cert.pem /usr/local/share/ca-certificates/hoverfly.crt + sudo update-ca-certificates + - name: Tests + run: go test -v . diff --git a/.vscode/settings.json b/.vscode/settings.json index 7a4f67d3..d4b4eeec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,6 +21,7 @@ "go.lintOnSave": "file", "go.testTimeout": "240s", "go.testEnvFile": "${workspaceFolder}/.env", + "go.testFlags": ["-v"], // "VSCode will complain about the "gopls" settings, but they will still work. // Once we have a consistent set of settings, we will make the changes in the diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 00000000..49b47998 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +--- +extends: default + +rules: + # 120 chars should be enough, but don't fail if a line is longer + line-length: + max: 120 + level: warning diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..d34cfe71 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,89 @@ +# How to contribute + +Firstly thanks for thinking of contributing - the project is [open source](https://opensource.guide/how-to-contribute/) and all contributions are very welcome :slightly_smiling_face: :boom: :thumbsup: + +[How to report a bug or suggest a new feature](#how-to-report-a-bug-or-suggest-a-new-feature) + +[How to make a contribution](#how-to-make-a-contribution) + +[Local development](#local-development) + * [Visual Studio Code](#visual-studio-code) + * [Codespaces](#codespaces) + * [Local development from scratch](#local-development-from-scratch) + * [Dependencies](#dependencies) + * [Tools and technologies](#tools-and-technologies) + * [GitHub Actions](#github-actions) + * [Go](#go) + * [Mage](#mage) + +[Running the tests](#running-the-tests) + +## How to report a bug or suggest a new feature + +[Create an issue](https://github.com/agilepathway/label-checker/issues), describing the bug or new feature in as much detail as you can. + +## How to make a contribution + + * [Create an issue](https://github.com/agilepathway/label-checker/issues) describing the change you are proposing. + * [Create a pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests). The project uses the _[fork and pull model](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-collaborative-development-models)_: + * [Fork the project](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks) + * Make your changes on your fork + * Write a [good commit message(s)](https://chris.beams.io/posts/git-commit/) for your changes + * [Create the pull request for your changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests) + * [Update the tests or add new tests](#running-the-tests) to cover the new behaviour. + +## Local development + +### Visual Studio Code + +The easiest way to set up your development environment (unless you have [Codespaces](#codespaces), which is even easier) is to use [Visual Studio Code](https://code.visualstudio.com/)'s [Remote Containers](https://code.visualstudio.com/docs/remote/containers) functionality: + * [System requirements](https://code.visualstudio.com/docs/remote/containers#_system-requirements) + * [Fork the project](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks) + * [Open the local project folder in a container](https://code.visualstudio.com/docs/remote/containers#_quick-start-open-an-existing-folder-in-a-container) + * Everything will then be setup for you. You'll be able to run the tests locally. + +### Codespaces + +If you have access to [GitHub Codespaces](https://github.com/features/codespaces/) (which allows full remote +development from within your browser) then all you need to do is [fork the project](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks) and open it in Codespaces - easy! + +### Local development from scratch + +#### Dependencies + +* [Go](https://golang.org/) +* [Hoverfly](https://hoverfly.readthedocs.io) (for [running the tests](#running-the-tests)) + 1. [Download and install Hoverfly](https://docs.hoverfly.io/en/latest/pages/introduction/downloadinstallation.html) + 2. [Download the Hoverfly default cert](https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem) + 3. [Add and trust the Hoverfly default cert](https://docs.hoverfly.io/en/latest/pages/tutorials/advanced/configuressl/configuressl.html) [(how to add and trust + a cert)](https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html) + + +### Tools and technologies + +#### GitHub Actions + * [General documentation](https://docs.github.com/en/actions) + * The Label Checker is a [Docker container action](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action) + +#### Go + +Some reasons we chose [Go](https://golang.org/): + * [readability](https://yourbasic.org/golang/advantages-over-java-python/#code-transparency) + * [ease of deployment](https://hub.packtpub.com/cloud-native-go-programming/) + * [backwards compatibility](https://yourbasic.org/golang/advantages-over-java-python/#compatibility) + +#### Mage + +The application is built using [Mage](https://magefile.org/), which is the Go equivalent of [Make](https://www.gnu.org/software/make/). + +## Running the tests + +As [above](#dependencies), you need [Hoverfly](https://hoverfly.readthedocs.io) to run the tests. + +Run the tests: + +`go test -v .` + +The tests are [table driven](https://dave.cheney.net/2019/05/07/prefer-table-driven-tests), which is an important concept to know when amending them. + +The tests also have an integration mode which makes calls to real external services instead of using Hoverfly to virtualise the service calls. You do not need to run the tests in integration mode when contributing (they will not pass unless you are a [maintainer](.github/CODEOWNERS) of the project who has the designated GitHub permissions). diff --git a/README.md b/README.md index 230c7d0d..fca3929e 100644 --- a/README.md +++ b/README.md @@ -116,10 +116,18 @@ You can have as many of the checks configured in the same YAML file as you like. ``` -## Suggestions / bug reports +## Suggestions / bug reports / contributions -[Suggestions and bug reports](https://github.com/agilepathway/label-checker/issues) -are very welcome :slightly_smiling_face: +The project is [open source](https://opensource.guide/how-to-contribute/) and all contributions are very welcome :slightly_smiling_face: :boom: :thumbsup: + +* [How to report a bug or suggest a new feature](CONTRIBUTING.md#how-to-report-a-bug-or-suggest-a-new-feature) + +* [How to make a contribution](CONTRIBUTING.md#how-to-make-a-contribution) + +* [Local development](CONTRIBUTING.md#local-development) + +* [Running the tests](CONTRIBUTING.md#running-the-tests) + ## Why another label checker? diff --git a/label_checker_test.go b/label_checker_test.go index 5ecc6a39..789324f8 100644 --- a/label_checker_test.go +++ b/label_checker_test.go @@ -2,15 +2,25 @@ package test import ( "bytes" + "flag" "fmt" "io/ioutil" + "log" "os" + "os/exec" "path/filepath" "testing" + "github.com/agilepathway/label-checker/internal/error/panic" "github.com/magefile/mage/mage" ) +//nolint: gochecknoglobals +var integration = flag.Bool( + "integration", + false, + "Make calls to real external services. Requires INPUT_REPO_TOKEN environment variable.") + // nolint: lll const ( EnvGitHubRepository = "GITHUB_REPOSITORY" @@ -19,14 +29,16 @@ const ( EnvRequireNoneOf = "INPUT_NONE_OF" EnvRequireAllOf = "INPUT_ALL_OF" EnvRequireAnyOf = "INPUT_ANY_OF" + EnvHTTPSProxy = "HTTPS_PROXY" GitHubTestRepo = "agilepathway/test-label-checker-consumer" NoLabelsPR = 1 // https://github.com/agilepathway/test-label-checker-consumer/pull/1 OneLabelPR = 2 // https://github.com/agilepathway/test-label-checker-consumer/pull/2 TwoLabelsPR = 3 // https://github.com/agilepathway/test-label-checker-consumer/pull/3 ThreeLabelsPR = 4 // https://github.com/agilepathway/test-label-checker-consumer/pull/4 - GitHubEventJSONDir = "testdata" + GitHubEventJSONDir = "testdata/temp" GitHubEventJSONFilename = "github_event.json" MagefileVerbose = "MAGEFILE_VERBOSE" + HoverflyProxyAddress = "127.0.0.1:8500" NeedNoneGotNone = "Label check successful: required none of major, minor, patch, and found 0.\n" NeedNoneGotOne = "Label check failed: required none of major, minor, patch, but found 1: minor\n" NeedNoneGotTwo = "Label check failed: required none of major, minor, patch, but found 2: minor, patch\n" @@ -119,10 +131,12 @@ func TestSplit(t *testing.T) { } func TestMain(m *testing.M) { + flag.Parse() os.Mkdir(GitHubEventJSONDir, os.ModePerm) //nolint os.Setenv(EnvGitHubRepository, GitHubTestRepo) //nolint os.Setenv(EnvGitHubEventPath, gitHubEventFullPath()) //nolint os.Setenv(MagefileVerbose, "1") //nolint + setupVirtualServicesIfNotInIntegrationMode() os.Exit(testMainWrapper(m)) } @@ -133,11 +147,48 @@ func testMainWrapper(m *testing.M) int { os.Unsetenv(EnvGitHubRepository) os.Unsetenv(EnvGitHubEventPath) os.Unsetenv(MagefileVerbose) + teardownVirtualServicesIfNotInIntegrationMode() }() return m.Run() } +func setupVirtualServicesIfNotInIntegrationMode() { + if !*integration { + startHoverflyInSpyMode() + os.Setenv(EnvHTTPSProxy, HoverflyProxyAddress) //nolint + importGitHubSimulations() + } +} + +func teardownVirtualServicesIfNotInIntegrationMode() { + if !*integration { + os.Unsetenv(EnvHTTPSProxy) //nolint + stopHoverfly() + } +} + +func execHoverCtl(arg ...string) { + // #nosec 204 https://github.com/securego/gosec/issues/343 + cmd := exec.Command("hoverctl", arg...) + stdout, err := cmd.Output() + panic.IfError(err) + log.Println(string(stdout)) +} + +func startHoverflyInSpyMode() { + execHoverCtl("start") + execHoverCtl("mode", "spy") +} + +func importGitHubSimulations() { + execHoverCtl("import", "./testdata/github_api.json") +} + +func stopHoverfly() { + execHoverCtl("stop") +} + func checkLabels() (int, *bytes.Buffer, *bytes.Buffer) { stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} diff --git a/testdata/github_api.json b/testdata/github_api.json new file mode 100644 index 00000000..7543fcff --- /dev/null +++ b/testdata/github_api.json @@ -0,0 +1,463 @@ +{ + "data": { + "pairs": [ + { + "request": { + "path": [ + { + "matcher": "exact", + "value": "/graphql" + } + ], + "method": [ + { + "matcher": "exact", + "value": "POST" + } + ], + "destination": [ + { + "matcher": "exact", + "value": "api.github.com" + } + ], + "scheme": [ + { + "matcher": "exact", + "value": "https" + } + ], + "body": [ + { + "matcher": "json", + "value": "{\"query\":\"query($name:String!$owner:String!$pullRequestNumber:Int!){repository(owner: $owner, name: $name){pullRequest(number: $pullRequestNumber){labels(first: 100){nodes{name}}}}}\",\"variables\":{\"name\":\"test-label-checker-consumer\",\"owner\":\"agilepathway\",\"pullRequestNumber\":1}}\n" + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"repository\":{\"pullRequest\":{\"labels\":{\"nodes\":[]}}}}}", + "encodedBody": false, + "headers": { + "Access-Control-Allow-Origin": [ + "*" + ], + "Access-Control-Expose-Headers": [ + "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset" + ], + "Cache-Control": [ + "no-cache" + ], + "Content-Encoding": [ + "identity" + ], + "Content-Security-Policy": [ + "default-src 'none'" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Tue, 07 Jul 2020 06:01:34 GMT" + ], + "Hoverfly": [ + "Was-Here" + ], + "Referrer-Policy": [ + "origin-when-cross-origin, strict-origin-when-cross-origin" + ], + "Server": [ + "GitHub.com" + ], + "Status": [ + "200 OK" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "Vary": [ + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "X-Accepted-Oauth-Scopes": [ + "repo" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "deny" + ], + "X-Github-Media-Type": [ + "github.v4; format=json" + ], + "X-Github-Request-Id": [ + "DD25:5656:CAF466:106A982:5F040FBE" + ], + "X-Oauth-Scopes": [ + "repo" + ], + "X-Ratelimit-Limit": [ + "5000" + ], + "X-Ratelimit-Remaining": [ + "4996" + ], + "X-Ratelimit-Reset": [ + "1594102919" + ], + "X-Xss-Protection": [ + "1; mode=block" + ] + }, + "templated": false + } + }, + { + "request": { + "path": [ + { + "matcher": "exact", + "value": "/graphql" + } + ], + "method": [ + { + "matcher": "exact", + "value": "POST" + } + ], + "destination": [ + { + "matcher": "exact", + "value": "api.github.com" + } + ], + "scheme": [ + { + "matcher": "exact", + "value": "https" + } + ], + "body": [ + { + "matcher": "json", + "value": "{\"query\":\"query($name:String!$owner:String!$pullRequestNumber:Int!){repository(owner: $owner, name: $name){pullRequest(number: $pullRequestNumber){labels(first: 100){nodes{name}}}}}\",\"variables\":{\"name\":\"test-label-checker-consumer\",\"owner\":\"agilepathway\",\"pullRequestNumber\":2}}\n" + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"repository\":{\"pullRequest\":{\"labels\":{\"nodes\":[{\"name\":\"minor\"}]}}}}}", + "encodedBody": false, + "headers": { + "Access-Control-Allow-Origin": [ + "*" + ], + "Access-Control-Expose-Headers": [ + "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset" + ], + "Cache-Control": [ + "no-cache" + ], + "Content-Encoding": [ + "identity" + ], + "Content-Security-Policy": [ + "default-src 'none'" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Tue, 07 Jul 2020 06:01:37 GMT" + ], + "Hoverfly": [ + "Was-Here" + ], + "Referrer-Policy": [ + "origin-when-cross-origin, strict-origin-when-cross-origin" + ], + "Server": [ + "GitHub.com" + ], + "Status": [ + "200 OK" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "Vary": [ + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "X-Accepted-Oauth-Scopes": [ + "repo" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "deny" + ], + "X-Github-Media-Type": [ + "github.v4; format=json" + ], + "X-Github-Request-Id": [ + "DD25:5656:CAF4F1:106A996:5F040FBE" + ], + "X-Oauth-Scopes": [ + "repo" + ], + "X-Ratelimit-Limit": [ + "5000" + ], + "X-Ratelimit-Remaining": [ + "4995" + ], + "X-Ratelimit-Reset": [ + "1594102919" + ], + "X-Xss-Protection": [ + "1; mode=block" + ] + }, + "templated": false + } + }, + { + "request": { + "path": [ + { + "matcher": "exact", + "value": "/graphql" + } + ], + "method": [ + { + "matcher": "exact", + "value": "POST" + } + ], + "destination": [ + { + "matcher": "exact", + "value": "api.github.com" + } + ], + "scheme": [ + { + "matcher": "exact", + "value": "https" + } + ], + "body": [ + { + "matcher": "json", + "value": "{\"query\":\"query($name:String!$owner:String!$pullRequestNumber:Int!){repository(owner: $owner, name: $name){pullRequest(number: $pullRequestNumber){labels(first: 100){nodes{name}}}}}\",\"variables\":{\"name\":\"test-label-checker-consumer\",\"owner\":\"agilepathway\",\"pullRequestNumber\":3}}\n" + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"repository\":{\"pullRequest\":{\"labels\":{\"nodes\":[{\"name\":\"minor\"},{\"name\":\"patch\"}]}}}}}", + "encodedBody": false, + "headers": { + "Access-Control-Allow-Origin": [ + "*" + ], + "Access-Control-Expose-Headers": [ + "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset" + ], + "Cache-Control": [ + "no-cache" + ], + "Content-Encoding": [ + "identity" + ], + "Content-Security-Policy": [ + "default-src 'none'" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Tue, 07 Jul 2020 06:01:54 GMT" + ], + "Hoverfly": [ + "Was-Here" + ], + "Referrer-Policy": [ + "origin-when-cross-origin, strict-origin-when-cross-origin" + ], + "Server": [ + "GitHub.com" + ], + "Status": [ + "200 OK" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "Vary": [ + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "X-Accepted-Oauth-Scopes": [ + "repo" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "deny" + ], + "X-Github-Media-Type": [ + "github.v4; format=json" + ], + "X-Github-Request-Id": [ + "DD25:5656:CAF87A:106ADC2:5F040FCF" + ], + "X-Oauth-Scopes": [ + "repo" + ], + "X-Ratelimit-Limit": [ + "5000" + ], + "X-Ratelimit-Remaining": [ + "4990" + ], + "X-Ratelimit-Reset": [ + "1594102919" + ], + "X-Xss-Protection": [ + "1; mode=block" + ] + }, + "templated": false + } + }, + { + "request": { + "path": [ + { + "matcher": "exact", + "value": "/graphql" + } + ], + "method": [ + { + "matcher": "exact", + "value": "POST" + } + ], + "destination": [ + { + "matcher": "exact", + "value": "api.github.com" + } + ], + "scheme": [ + { + "matcher": "exact", + "value": "https" + } + ], + "body": [ + { + "matcher": "json", + "value": "{\"query\":\"query($name:String!$owner:String!$pullRequestNumber:Int!){repository(owner: $owner, name: $name){pullRequest(number: $pullRequestNumber){labels(first: 100){nodes{name}}}}}\",\"variables\":{\"name\":\"test-label-checker-consumer\",\"owner\":\"agilepathway\",\"pullRequestNumber\":4}}\n" + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"repository\":{\"pullRequest\":{\"labels\":{\"nodes\":[{\"name\":\"major\"},{\"name\":\"minor\"},{\"name\":\"patch\"}]}}}}}", + "encodedBody": false, + "headers": { + "Access-Control-Allow-Origin": [ + "*" + ], + "Access-Control-Expose-Headers": [ + "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset" + ], + "Cache-Control": [ + "no-cache" + ], + "Content-Encoding": [ + "identity" + ], + "Content-Security-Policy": [ + "default-src 'none'" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Tue, 07 Jul 2020 06:01:41 GMT" + ], + "Hoverfly": [ + "Was-Here" + ], + "Referrer-Policy": [ + "origin-when-cross-origin, strict-origin-when-cross-origin" + ], + "Server": [ + "GitHub.com" + ], + "Status": [ + "200 OK" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "Vary": [ + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "X-Accepted-Oauth-Scopes": [ + "repo" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "deny" + ], + "X-Github-Media-Type": [ + "github.v4; format=json" + ], + "X-Github-Request-Id": [ + "DD25:5656:CAF5A1:106AA4E:5F040FC1" + ], + "X-Oauth-Scopes": [ + "repo" + ], + "X-Ratelimit-Limit": [ + "5000" + ], + "X-Ratelimit-Remaining": [ + "4994" + ], + "X-Ratelimit-Reset": [ + "1594102919" + ], + "X-Xss-Protection": [ + "1; mode=block" + ] + }, + "templated": false + } + } + ], + "globalActions": { + "delays": [], + "delaysLogNormal": [] + } + }, + "meta": { + "schemaVersion": "v5.1", + "hoverflyVersion": "v1.3.0", + "timeExported": "2020-07-07T13:03:21+07:00" + } +}