From 8493eda4d4d249fee977a116eaea255413e435ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Fri, 18 Aug 2023 11:36:07 +0200 Subject: [PATCH 01/35] fix: remove duplicate `method()` calls in GHContent class --- src/main/java/org/kohsuke/github/GHContent.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHContent.java b/src/main/java/org/kohsuke/github/GHContent.java index 9a0e38c2ab..c476a89d8c 100644 --- a/src/main/java/org/kohsuke/github/GHContent.java +++ b/src/main/java/org/kohsuke/github/GHContent.java @@ -321,12 +321,11 @@ public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessa String encodedContent = Base64.getEncoder().encodeToString(newContentBytes); Requester requester = root().createRequest() - .method("POST") + .method("PUT") .with("path", path) .with("message", commitMessage) .with("sha", sha) - .with("content", encodedContent) - .method("PUT"); + .with("content", encodedContent); if (branch != null) { requester.with("branch", branch); @@ -368,11 +367,10 @@ public GHContentUpdateResponse delete(String message) throws IOException { */ public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException { Requester requester = root().createRequest() - .method("POST") + .method("DELETE") .with("path", path) .with("message", commitMessage) - .with("sha", sha) - .method("DELETE"); + .with("sha", sha); if (branch != null) { requester.with("branch", branch); From 701495b22e5cd2835af25de1479d311c4435570b Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 21 Aug 2023 14:07:54 -0700 Subject: [PATCH 02/35] [maven-release-plugin] prepare release github-api-1.316 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index da69a65c61..4b4e52e523 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.kohsuke github-api - 1.316-SNAPSHOT + 1.316 GitHub API for Java https://github-api.kohsuke.org/ GitHub API for Java @@ -11,7 +11,7 @@ scm:git:git@github.com/hub4j/${project.artifactId}.git scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git https://github.com/hub4j/github-api/ - HEAD + github-api-1.316 From ae0c29e1ba464b474f3b14103fadee2b9eb7f8cc Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 21 Aug 2023 14:07:58 -0700 Subject: [PATCH 03/35] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4b4e52e523..154f516e0b 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.kohsuke github-api - 1.316 + 1.317-SNAPSHOT GitHub API for Java https://github-api.kohsuke.org/ GitHub API for Java @@ -11,7 +11,7 @@ scm:git:git@github.com/hub4j/${project.artifactId}.git scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git https://github.com/hub4j/github-api/ - github-api-1.316 + HEAD From 7f885546cc9218159deec06c05f22a0d7a324329 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 02:50:58 +0000 Subject: [PATCH 04/35] Chore(deps): Bump org.apache.maven.plugins:maven-source-plugin Bumps [org.apache.maven.plugins:maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.2.1 to 3.3.0. - [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.2.1...maven-source-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-source-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 154f516e0b..7615182c5c 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.0 org.apache.maven.plugins From 49bf7b6f98998485bd07e21d7bc76424cb8cb704 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 02:51:13 +0000 Subject: [PATCH 05/35] Chore(deps-dev): Bump org.slf4j:slf4j-simple from 2.0.3 to 2.0.7 Bumps [org.slf4j:slf4j-simple](https://github.com/qos-ch/slf4j) from 2.0.3 to 2.0.7. - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.3...v_2.0.7) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 154f516e0b..0333cdad9c 100644 --- a/pom.xml +++ b/pom.xml @@ -597,7 +597,7 @@ org.slf4j slf4j-simple - 2.0.3 + 2.0.7 test From 282272954d46e73d8eb0dfbbec197a50b54f9fba Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 7 Sep 2023 12:06:32 -0700 Subject: [PATCH 06/35] Drop support for Building on Java 8 --- .github/workflows/maven-build.yml | 36 ++++++++++++------------------- pom.xml | 5 +++-- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 2ef600e1ec..1c2055d40e 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -55,28 +55,7 @@ jobs: - name: Maven Site env: MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} - run: mvn -B clean site -D enable-ci --file pom.xml - test-8: - name: test (${{ matrix.os }}, Java 8) - runs-on: ${{ matrix.os }}-latest - strategy: - fail-fast: false - matrix: - os: [ ubuntu ] - java: [ 8 ] - steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - cache: 'maven' - # JDK 8 - - name: Maven Install with Code Coverage - run: mvn -B clean install -D enable-ci -Djapicmp.skip --file pom.xml - - name: Codecov Report - uses: codecov/codecov-action@v3.1.4 + run: mvn -B clean site -D enable-ci --file pom.xml test: name: test (${{ matrix.os }}, Java ${{ matrix.java }}) runs-on: ${{ matrix.os }}-latest @@ -104,3 +83,16 @@ jobs: env: MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} run: mvn -B clean install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED" + - name: Codecov Report + if: matrix.os == 'ubuntu' && matrix.java == '17' + uses: codecov/codecov-action@v3.1.4 + - name: Set up JDK + if: matrix.os == 'ubuntu' && matrix.java == '17' + uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: 'temurin' + cache: 'maven' + - name: Maven Test (no build) Java 8 + if: matrix.os == 'ubuntu' && matrix.java == '17' + run: mvn -B surefire:test -Dsurefire.excludesFile=src/test/resources/slow-or-flaky-tests.txt diff --git a/pom.xml b/pom.xml index e2e018d310..801e3b9c85 100644 --- a/pom.xml +++ b/pom.xml @@ -304,12 +304,14 @@ maven-surefire-plugin + + @{jacoco.surefire.argLine} ${surefire.argLine} + default-test src/test/resources/slow-or-flaky-tests.txt - @{jacoco.surefire.argLine} ${surefire.argLine} @@ -651,7 +653,6 @@ src/test/resources/slow-or-flaky-tests.txt - @{jacoco.surefire.argLine} ${surefire.argLine} From e6aaf1631909d355cbba6f19ccbe113864840078 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 7 Sep 2023 13:54:59 -0700 Subject: [PATCH 07/35] Test Java 8 in parallel --- .github/workflows/maven-build.yml | 76 ++++++++------ pom.xml | 161 +++++++++++------------------- 2 files changed, 104 insertions(+), 133 deletions(-) diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 1c2055d40e..d61e2c0fcc 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -19,43 +19,44 @@ permissions: jobs: build: - name: build-only (Java ${{ matrix.java }}) + name: build-only (Java 17) runs-on: ubuntu-latest strategy: - fail-fast: false - matrix: - java: [ 17 ] + fail-fast: true steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - cache: 'maven' - - name: Maven Install (skipTests) - env: - MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} - run: mvn -B clean install -DskipTests --file pom.xml + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + - name: Maven Install (skipTests) + env: + MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} + run: mvn -B clean install -DskipTests --file pom.xml + - uses: actions/upload-artifact@v3 + with: + name: maven-target-directory + path: target/ + retention-days: 3 site: - name: site (Java ${{ matrix.java }}) + name: site (Java 17) runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - java: [ 17 ] steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - cache: 'maven' - - name: Maven Site - env: - MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} - run: mvn -B clean site -D enable-ci --file pom.xml + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + - name: Maven Site + env: + MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} + run: mvn -B clean site -D enable-ci --file pom.xml test: name: test (${{ matrix.os }}, Java ${{ matrix.java }}) runs-on: ${{ matrix.os }}-latest @@ -86,13 +87,22 @@ jobs: - name: Codecov Report if: matrix.os == 'ubuntu' && matrix.java == '17' uses: codecov/codecov-action@v3.1.4 + + test-java-8: + name: test Java 8 (no-build) + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: maven-target-directory + path: target - name: Set up JDK - if: matrix.os == 'ubuntu' && matrix.java == '17' uses: actions/setup-java@v3 with: java-version: 8 distribution: 'temurin' - cache: 'maven' + cache: 'maven' - name: Maven Test (no build) Java 8 - if: matrix.os == 'ubuntu' && matrix.java == '17' - run: mvn -B surefire:test -Dsurefire.excludesFile=src/test/resources/slow-or-flaky-tests.txt + run: mvn -B surefire:test -DfailIfNoTests -Dsurefire.excludesFile=src/test/resources/slow-or-flaky-tests.txt diff --git a/pom.xml b/pom.xml index 801e3b9c85..ae25ea25c8 100644 --- a/pom.xml +++ b/pom.xml @@ -241,6 +241,9 @@ java18 1.0 + + java.net.http.* + @@ -301,6 +304,24 @@ + + + compile-java-11 + compile + + compile + + + 11 + 11 + 11 + + ${project.basedir}/src/main/java11 + + true + + + maven-surefire-plugin @@ -316,6 +337,19 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + org.kohsuke.github.api + true + + + + org.codehaus.mojo animal-sniffer-maven-plugin @@ -618,7 +652,7 @@ - slow-or-flaky-test + test-slow-multireleasejar-flaky !test @@ -641,6 +675,32 @@ @{jacoco.surefire.argLine} ${surefire.argLine} -Dtest.github.connector=okhttp + + java11-test + integration-test + + test + + + ${project.basedir}/target/github-api-${project.version}.jar + false + src/test/resources/slow-or-flaky-tests.txt + @{jacoco.surefire.argLine} ${surefire.argLine} -Dtest.github.connector=httpclient + + + + java11-urlconnection-test + integration-test + + test + + + ${project.basedir}/target/github-api-${project.version}.jar + false + src/test/resources/slow-or-flaky-tests.txt + @{jacoco.surefire.argLine} ${surefire.argLine} -Dtest.github.connector=urlconnection + + slow-or-flaky-test integration-test @@ -783,105 +843,6 @@ - - multirelease - - [11,) - - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - - - java.net.http.* - - - - - maven-compiler-plugin - 3.10.1 - - - compile-java-11 - compile - - compile - - - 11 - 11 - 11 - - ${project.basedir}/src/main/java11 - - true - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - org.kohsuke.github.api - true - - - - - - - - - multirelease-test - - [11,) - - !test - - - - - - maven-surefire-plugin - - - java11-test - integration-test - - test - - - ${project.basedir}/target/github-api-${project.version}.jar - false - src/test/resources/slow-or-flaky-tests.txt - @{jacoco.surefire.argLine} ${surefire.argLine} -Dtest.github.connector=httpclient - - - - java11-urlconnection-test - integration-test - - test - - - ${project.basedir}/target/github-api-${project.version}.jar - false - src/test/resources/slow-or-flaky-tests.txt - @{jacoco.surefire.argLine} ${surefire.argLine} -Dtest.github.connector=urlconnection - - - - - - - - From 8f8e34fcf43cd763f028e0e940ac45c903bd6cbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:22:56 +0000 Subject: [PATCH 08/35] Chore(deps-dev): Bump com.github.tomakehurst:wiremock-jre8-standalone Bumps [com.github.tomakehurst:wiremock-jre8-standalone](https://github.com/wiremock/wiremock) from 2.35.0 to 2.35.1. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/2.35.0...2.35.1) --- updated-dependencies: - dependency-name: com.github.tomakehurst:wiremock-jre8-standalone dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae25ea25c8..7a8b952a87 100644 --- a/pom.xml +++ b/pom.xml @@ -621,7 +621,7 @@ com.github.tomakehurst wiremock-jre8-standalone - 2.35.0 + 2.35.1 test From 9f5f4ef47cf98dd80164051a3653e312b39f5b42 Mon Sep 17 00:00:00 2001 From: panilya Date: Sun, 17 Sep 2023 18:59:00 +0300 Subject: [PATCH 09/35] Add allow_forking flag for a GHRepository --- .../java/org/kohsuke/github/GHRepository.java | 23 +++++++++++++++++++ .../kohsuke/github/GHRepositoryBuilder.java | 13 +++++++++++ .../github/AbstractGitHubWireMockTest.java | 2 +- .../org/kohsuke/github/GHRepositoryTest.java | 3 +++ ...pos_hub4j-test-org_temp-testgetters-2.json | 3 ++- ...-test-org_temp-testupdaterepository-2.json | 3 ++- ...-test-org_temp-testupdaterepository-3.json | 3 ++- ...-test-org_temp-testupdaterepository-4.json | 3 ++- ...-test-org_temp-testupdaterepository-5.json | 3 ++- ...-test-org_temp-testupdaterepository-3.json | 4 ++-- 10 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index deaf4aeaff..a20aac28eb 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -103,6 +103,8 @@ public class GHRepository extends GHObject { private boolean allow_rebase_merge; + private boolean allow_forking; + private boolean delete_branch_on_merge; @JsonProperty("private") @@ -715,6 +717,15 @@ public boolean isAllowRebaseMerge() { return allow_rebase_merge; } + /** + * Is allow private forks + * + * @return the boolean + */ + public boolean isAllowForking() { + return allow_forking; + } + /** * Automatically deleting head branches when pull requests are merged. * @@ -1461,6 +1472,18 @@ public void allowRebaseMerge(boolean value) throws IOException { set().allowRebaseMerge(value); } + /** + * Allow private fork. + * + * @param value + * the value + * @throws IOException + * the io exception + */ + public void allowForking(boolean value) throws IOException { + set().allowForking(value); + } + /** * After pull requests are merged, you can have head branches deleted automatically. * diff --git a/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java b/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java index 1d8602a044..a7b5b11a72 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryBuilder.java @@ -76,6 +76,19 @@ public S allowRebaseMerge(boolean enabled) throws IOException { return with("allow_rebase_merge", enabled); } + /** + * Allow or disallow private forks + * + * @param enabled + * true if enabled + * @return a builder to continue with building + * @throws IOException + * In case of any networking error or error from the server. + */ + public S allowForking(boolean enabled) throws IOException { + return with("allow_forking", enabled); + } + /** * After pull requests are merged, you can have head branches deleted automatically. * diff --git a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java index 990583c945..044a7122ec 100644 --- a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java +++ b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java @@ -226,7 +226,7 @@ protected GHRepository getTempRepository() throws IOException { * Creates a temporary repository that will be deleted at the end of the test. * * @param name - * string name of the the repository + * string name of the repository * * @return a temporary repository * @throws IOException diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index d0ff0f73e1..61ca35c9c8 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -98,6 +98,7 @@ public void testGetters() throws IOException { assertThat(r.isAllowMergeCommit(), is(true)); assertThat(r.isAllowRebaseMerge(), is(true)); assertThat(r.isAllowSquashMerge(), is(true)); + assertThat(r.isAllowForking(), is(false)); String httpTransport = "https://github.com/hub4j-test-org/temp-testGetters.git"; assertThat(r.getHttpTransportUrl(), equalTo(httpTransport)); @@ -380,6 +381,7 @@ public void testUpdateRepository() throws Exception { GHRepository updated = builder.allowRebaseMerge(false) .allowSquashMerge(false) .deleteBranchOnMerge(true) + .allowForking(true) .description(description) .downloads(false) .downloads(false) @@ -394,6 +396,7 @@ public void testUpdateRepository() throws Exception { assertThat(updated.isAllowRebaseMerge(), is(false)); assertThat(updated.isAllowSquashMerge(), is(false)); assertThat(updated.isDeleteBranchOnMerge(), is(true)); + assertThat(updated.isAllowForking(), is(true)); assertThat(updated.isPrivate(), is(true)); assertThat(updated.hasDownloads(), is(false)); assertThat(updated.hasIssues(), is(false)); diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json index f8d16217fc..dac8e119fa 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testGetters/__files/repos_hub4j-test-org_temp-testgetters-2.json @@ -101,6 +101,7 @@ "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": false, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -123,4 +124,4 @@ }, "network_count": 0, "subscribers_count": 7 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json index a6f5e84b2c..b35dc8ffd7 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-2.json @@ -101,6 +101,7 @@ "allow_merge_commit": true, "allow_rebase_merge": true, "delete_branch_on_merge": false, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -123,4 +124,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json index d62845bc50..ed4894e9e9 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-3.json @@ -100,6 +100,7 @@ "allow_merge_commit": true, "allow_rebase_merge": false, "delete_branch_on_merge": true, + "allow_forking": true, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -122,4 +123,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json index 8c2ad19854..8e4d6e85ba 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-4.json @@ -100,6 +100,7 @@ "allow_merge_commit": false, "allow_rebase_merge": true, "delete_branch_on_merge": true, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -122,4 +123,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json index 3ce310fccf..88ad46243c 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/__files/repos_hub4j-test-org_temp-testupdaterepository-5.json @@ -100,6 +100,7 @@ "allow_merge_commit": false, "allow_rebase_merge": true, "delete_branch_on_merge": true, + "allow_forking": false, "organization": { "login": "hub4j-test-org", "id": 7544739, @@ -122,4 +123,4 @@ }, "network_count": 0, "subscribers_count": 9 -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json index 8596d7744c..38d758a008 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testUpdateRepository/mappings/repos_hub4j-test-org_temp-testupdaterepository-3.json @@ -11,7 +11,7 @@ }, "bodyPatterns": [ { - "equalToJson": "{\"name\":\"temp-testUpdateRepository\",\"has_projects\":false,\"allow_squash_merge\":false,\"private\":true,\"has_downloads\":false,\"has_wiki\":false,\"description\":\"A test repository for update testing via the github-api project\",\"delete_branch_on_merge\":true,\"allow_rebase_merge\":false,\"has_issues\":false,\"homepage\":\"https://github-api.kohsuke.org/apidocs/index.html\"}", + "equalToJson": "{\"name\":\"temp-testUpdateRepository\",\"has_projects\":false,\"allow_squash_merge\":false,\"allow_forking\":true,\"private\":true,\"has_downloads\":false,\"has_wiki\":false,\"description\":\"A test repository for update testing via the github-api project\",\"delete_branch_on_merge\":true,\"allow_rebase_merge\":false,\"has_issues\":false,\"homepage\":\"https://github-api.kohsuke.org/apidocs/index.html\"}", "ignoreArrayOrder": true, "ignoreExtraElements": false } @@ -51,4 +51,4 @@ "uuid": "d0036ebb-64a8-4c4c-bed3-697870892d5f", "persistent": true, "insertionIndex": 3 -} \ No newline at end of file +} From 0a935ff00f71b8e1aa75cb4c813f65b43181b7d8 Mon Sep 17 00:00:00 2001 From: Ulises <0xTlaloc@gmail.com> Date: Tue, 19 Sep 2023 15:00:49 -0700 Subject: [PATCH 10/35] Github docs change the documentation url --- .../java/org/kohsuke/github/WireMockStatusReporterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java index f2033f5ae2..07eab6a2f0 100644 --- a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java +++ b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java @@ -147,7 +147,7 @@ public void BasicBehaviors_whenProxying() throws Exception { assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); assertThat(e.getMessage(), containsString( - "{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest/reference/repos#get-a-repository\"}")); + "{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest/repos/repos#get-a-repository\"}")); } /** From 720861e3835556a5f06b86af4385fdc24be7d465 Mon Sep 17 00:00:00 2001 From: Ulises <0xTlaloc@gmail.com> Date: Wed, 20 Sep 2023 12:16:22 -0700 Subject: [PATCH 11/35] Adding new enums for verification reasons using X.509 certificate signatures --- .../org/kohsuke/github/GHVerification.java | 43 ++++-- .../github/GHVerificationReasonTest.java | 84 +++++++++++ .../__files/repos_hub4j_github-api-2.json | 130 ++++++++++++++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 98 +++++++++++++ .../wiremock/testBadCert/__files/user-1.json | 45 ++++++ .../mappings/repos_hub4j_github-api-2.json | 48 +++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 48 +++++++ .../wiremock/testBadCert/mappings/user-1.json | 48 +++++++ .../__files/repos_hub4j_github-api-2.json | 130 ++++++++++++++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 98 +++++++++++++ .../testMalformedSig/__files/user-1.json | 45 ++++++ .../mappings/repos_hub4j_github-api-2.json | 48 +++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 48 +++++++ .../testMalformedSig/mappings/user-1.json | 48 +++++++ .../__files/repos_hub4j_github-api-2.json | 130 ++++++++++++++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 98 +++++++++++++ .../testOcspError/__files/user-1.json | 45 ++++++ .../mappings/repos_hub4j_github-api-2.json | 48 +++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 48 +++++++ .../testOcspError/mappings/user-1.json | 48 +++++++ .../__files/repos_hub4j_github-api-2.json | 130 ++++++++++++++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 98 +++++++++++++ .../testOscpPending/__files/user-1.json | 45 ++++++ .../mappings/repos_hub4j_github-api-2.json | 48 +++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 48 +++++++ .../testOscpPending/mappings/user-1.json | 48 +++++++ .../__files/repos_hub4j_github-api-2.json | 130 ++++++++++++++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 98 +++++++++++++ .../testOscpRevoked/__files/user-1.json | 45 ++++++ .../mappings/repos_hub4j_github-api-2.json | 48 +++++++ ...245aa6d71d54923655066049d9e21a15f01-3.json | 48 +++++++ .../testOscpRevoked/mappings/user-1.json | 48 +++++++ 32 files changed, 2198 insertions(+), 14 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/user-1.json diff --git a/src/main/java/org/kohsuke/github/GHVerification.java b/src/main/java/org/kohsuke/github/GHVerification.java index 382d39a26e..ce92905730 100644 --- a/src/main/java/org/kohsuke/github/GHVerification.java +++ b/src/main/java/org/kohsuke/github/GHVerification.java @@ -66,43 +66,58 @@ public String getPayload() { */ public enum Reason { - /** The expired key. */ + /** Signing key expired. */ EXPIRED_KEY, - /** The not signing key. */ + /** The usage flags for the key that signed this don't allow signing. */ NOT_SIGNING_KEY, - /** The gpgverify error. */ + /** The GPG verification service misbehaved. */ GPGVERIFY_ERROR, - /** The gpgverify unavailable. */ + /** The GPG verification service is unavailable at the moment. */ GPGVERIFY_UNAVAILABLE, - /** The unsigned. */ + /** Unsigned. */ UNSIGNED, - /** The unknown signature type. */ + /** Unknown signature type. */ UNKNOWN_SIGNATURE_TYPE, - /** The no user. */ + /** Email used for signing not known to GitHub. */ NO_USER, - /** The unverified email. */ + /** Email used for signing unverified on GitHub. */ UNVERIFIED_EMAIL, - /** The bad email. */ + /** Invalid email used for signing. */ BAD_EMAIL, - /** The unknown key. */ + /** Key used for signing not known to GitHub. */ UNKNOWN_KEY, - /** The malformed signature. */ + /** Malformed signature. */ MALFORMED_SIGNATURE, - /** The invalid. */ + /** Invalid signature. */ INVALID, - /** The valid. */ - VALID + /** Valid signature and verified by GitHub. */ + VALID, + + /** The signing certificate or its chain could not be verified. */ + BAD_CERT, + + /** Malformed signature. (Returned by graphQL) */ + MALFORMED_SIG, + + /** Valid signature, though certificate revocation check failed. */ + OCSP_ERROR, + + /** Valid signature, pending certificate revocation checking. */ + OCSP_PENDING, + + /** One or more certificates in chain has been revoked. */ + OCSP_REVOKED } } diff --git a/src/test/java/org/kohsuke/github/GHVerificationReasonTest.java b/src/test/java/org/kohsuke/github/GHVerificationReasonTest.java index 73977ef1d4..42b3292c72 100644 --- a/src/test/java/org/kohsuke/github/GHVerificationReasonTest.java +++ b/src/test/java/org/kohsuke/github/GHVerificationReasonTest.java @@ -217,4 +217,88 @@ public void testValid() throws Exception { assertThat(commit.getCommitShortInfo().getVerification().getPayload(), notNullValue()); assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue()); } + + /** + * Test bad cert. + * + * @throws Exception + * the exception + */ + @Test + public void testBadCert() throws Exception { + GHRepository r = gitHub.getRepository("hub4j/github-api"); + GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01"); + assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala")); + assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue()); + assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false)); + assertThat(commit.getCommitShortInfo().getVerification().getReason(), equalTo(GHVerification.Reason.BAD_CERT)); + } + + /** + * Test malformed sig. + * + * @throws Exception + * the exception + */ + @Test + public void testMalformedSig() throws Exception { + GHRepository r = gitHub.getRepository("hub4j/github-api"); + GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01"); + assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala")); + assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue()); + assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false)); + assertThat(commit.getCommitShortInfo().getVerification().getReason(), + equalTo(GHVerification.Reason.MALFORMED_SIG)); + } + + /** + * Test OSCP error. + * + * @throws Exception + * the exception + */ + @Test + public void testOcspError() throws Exception { + GHRepository r = gitHub.getRepository("hub4j/github-api"); + GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01"); + assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala")); + assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue()); + assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false)); + assertThat(commit.getCommitShortInfo().getVerification().getReason(), + equalTo(GHVerification.Reason.OCSP_ERROR)); + } + + /** + * Test OSCP pending. + * + * @throws Exception + * the exception + */ + @Test + public void testOscpPending() throws Exception { + GHRepository r = gitHub.getRepository("hub4j/github-api"); + GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01"); + assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala")); + assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue()); + assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false)); + assertThat(commit.getCommitShortInfo().getVerification().getReason(), + equalTo(GHVerification.Reason.OCSP_PENDING)); + } + + /** + * Test OCSP revoked. + * + * @throws Exception + * the exception + */ + @Test + public void testOscpRevoked() throws Exception { + GHRepository r = gitHub.getRepository("hub4j/github-api"); + GHCommit commit = r.getCommit("86a2e245aa6d71d54923655066049d9e21a15f01"); + assertThat(commit.getCommitShortInfo().getAuthor().getName(), equalTo("Sourabh Parkala")); + assertThat(commit.getCommitShortInfo().getVerification().getSignature(), notNullValue()); + assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false)); + assertThat(commit.getCommitShortInfo().getVerification().getReason(), + equalTo(GHVerification.Reason.OCSP_REVOKED)); + } } diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..43ee270874 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api-2.json @@ -0,0 +1,130 @@ +{ + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "hub4j/github-api", + "private": false, + "owner": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/hub4j/github-api", + "forks_url": "https://api.github.com/repos/hub4j/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-10-25T01:32:16Z", + "pushed_at": "2019-10-25T16:41:09Z", + "git_url": "git://github.com/hub4j/github-api.git", + "ssh_url": "git@github.com:hub4j/github-api.git", + "clone_url": "https://github.com/hub4j/github-api.git", + "svn_url": "https://github.com/hub4j/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 13494, + "stargazers_count": 565, + "watchers_count": 565, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 433, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 64, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 433, + "open_issues": 64, + "watchers": 565, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 433, + "subscribers_count": 48 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..77895afe2c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,98 @@ +{ + "sha": "86a2e245aa6d71d54923655066049d9e21a15f01", + "node_id": "MDY6Q29tbWl0NjE3MjEwOjg2YTJlMjQ1YWE2ZDcxZDU0OTIzNjU1MDY2MDQ5ZDllMjFhMTVmMjM=", + "commit": { + "author": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "committer": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "message": "doc", + "tree": { + "sha": "17ed4173aeb2e98c93216e8b6e16138dc7f8cd91", + "url": "https://api.github.com/repos/hub4j/github-api/git/trees/17ed4173aeb2e98c93216e8b6e16138dc7f8cd91" + }, + "url": "https://api.github.com/repos/hub4j/github-api/git/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "bad_cert", + "signature": "-----BEGIN SIGNED MESSAGE-----\nMIIFdQYJKoZIhvcNAQcCoIIFZjCCBWICAQExDTALBglghkgBZQMEAgEwCwYJKoZI\nhvcNAQcBoIIDejCCA3YwggJeoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwKjEbMBkG\nA1UEAwwSQXN0cm9UbGFsb2PigJlzIENBMQswCQYDVQQGEwJVUzAeFw0yMzA5MTgy\nMzI2MDlaFw0yNDA5MTcyMzI2MDlaMEYxFDASBgNVBAMMC0FzdHJvVGxhbG9jMQsw\nCQYDVQQGEwJVUzEhMB8GCSqGSIb3DQEJARYSMHhUbGFsb2NAZ21haWwuY29tMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Zq+N5v68htABs4ZLPORns/F\nzixnI+6L+WaVGeQFzxIBs9zsm9IRGJ4xoMBPSg1BuoilRXzsQoCH6+5zyQ4jaHMa\nHBBEijVM7kor3Um+35KdYh79nIY7ZQoDRypLF02FiqfNjhN8Nm8ciNf2EUkiGIcj\n/+TPhVFMxnwlZ2SmSJoMBE5pkDBllb/8kfxgenSoVLXaOigYJ1It6AqH2L8Ju9pa\nJ1zJGu2edjN6xi/0yjzZ7CmPFbnWcY5flJfMqdaj0Po3dMwYKYK07rE7KQHc8wFT\ngAUtQNtJkGBjEcTBh1B7SUsnJ/x4XcSQwOMxPNSm4Esn2RWanJYunez75eCWlwID\nAQABo4GKMIGHMA4GA1UdDwEB/wQEAwIFoDAWBgNVHSUBAf8EDDAKBggrBgEFBQcD\nBDAdBgNVHQ4EFgQUSi5d7oqzSYNhpeG4I2VNF9j881UwHwYDVR0jBBgwFoAULCWl\nbibBiKOX/6M3RWgIlSPM7dcwHQYDVR0RBBYwFIESMHhUbGFsb2NAZ21haWwuY29t\nMA0GCSqGSIb3DQEBCwUAA4IBAQDSn3caORjlSXCSm8ZY1uAbG+IngvEooIJvbl+y\n0yglPA3pkWybXxLfvayJVRGtNgLambnPpulzZmdwjj7qSTzd9K/+OIsI2qjNrZZ+\napXJLhlfabNHzydj0y0DUWgbtKzQ1SVhWgglHaCp440UmVAi0PtsMy3F1S5S0HlZ\n80V1CE3r7UYsC64GG3CmyXVf5MB+pzPriE729Gglig5z6rq8F+GNk5hJW7tOKBRb\nCyXFkqbkMWHPJ/CP5wrFjrEITsn8fIhlJsYRIAGzTnffCOs9i3rMpUTXRBOwSVMB\nI1I3VPm+WxVE7O9NY7TGBDe7010D4DorTNUPYo8xsPtKYyrpMYIBwTCCAb0CAQEw\nLzAqMRswGQYDVQQDDBJBc3Ryb1RsYWxvY+KAmXMgQ0ExCzAJBgNVBAYTAlVTAgEC\nMAsGCWCGSAFlAwQCAaBpMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZI\nhvcNAQkFMQ8XDTIzMDkxODIzMjg1MFowLwYJKoZIhvcNAQkEMSIEIIFHI8Ick3Tu\nBlnfTU6v24ls8D+jGkpQoDK+MF4rk5iTMAsGCSqGSIb3DQEBCwSCAQC4nIUEB/bR\ngeXnO7KdtqRFn/slCNTKZaQObsyL7C7cmNYAlgQAYj/qOBhKGMd3ZAFHRUroCiCy\n5GPs1sEnPKT1Bh7E7HJbpfdMXZINxoiRBrwQpAD/UKxk6etF5qvtAwDJaFMZiTMh\nd6tPNVBcThhUglSqqQFT3BKE9z5KTGwonMeqZlyf/EpXRBn0YcaoWvcAzaahMBQw\nUPwwEtU3FVyYBbLQee0SoYDsddEjdaNN/37auMVIltYmKNq/A4KhJWduTGFcaD/k\nfcXIzhzBi4vk1No6y2ftDgbivxP3MVQyf1tIfD1fv9cw/55JnDRA3IXkQRc+yyUG\nGmHXpKHhqNKm\n-----END SIGNED MESSAGE-----", + "payload": null + } + }, + "url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "html_url": "https://github.com/hub4j/github-api/commit/86a2e245aa6d71d54923655066049d9e21a15f01", + "comments_url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01/comments", + "author": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + { + "sha": "ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "url": "https://api.github.com/repos/hub4j/github-api/commits/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "html_url": "https://github.com/hub4j/github-api/commit/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396" + } + ], + "stats": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "files": [ + { + "sha": "2a2e1f77fd77bd03273946d893d25a455f696be0", + "filename": "README", + "status": "added", + "additions": 3, + "deletions": 0, + "changes": 3, + "blob_url": "https://github.com/hub4j/github-api/blob/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "raw_url": "https://github.com/hub4j/github-api/raw/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/README?ref=86a2e245aa6d71d54923655066049d9e21a15f01", + "patch": "@@ -0,0 +1,3 @@\n+Java API for GitHub\n+\n+See http://kohsuke.org/github-api/ for more details" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/user-1.json new file mode 100644 index 0000000000..a4b576e8a7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/__files/user-1.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 169, + "public_gists": 7, + "followers": 139, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..80fb7dfa4e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api-2.json @@ -0,0 +1,48 @@ +{ + "id": "441cdfd7-a44a-42b4-b732-57e674227760", + "name": "repos_hub4j_github-api", + "request": { + "url": "/repos/hub4j/github-api", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api-2.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4295", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"c1a01d01a6354d93b3cc6098e0b2d047\"", + "Last-Modified": "Fri, 25 Oct 2019 01:32:16 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B56:C4A050:5DB3A147" + } + }, + "uuid": "441cdfd7-a44a-42b4-b732-57e674227760", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..6b5904361c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,48 @@ +{ + "id": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "name": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01", + "request": { + "url": "/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4294", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"0a8c453e4290ce879ea09578e06a5961\"", + "Last-Modified": "Mon, 19 Apr 2010 04:12:41 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B5F:C4A064:5DB3A148" + } + }, + "uuid": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/user-1.json new file mode 100644 index 0000000000..7c0606ff2f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testBadCert/mappings/user-1.json @@ -0,0 +1,48 @@ +{ + "id": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:39 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4297", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8c3d3dcf6fc5f9edaf26c902295396e5\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B49:C4A046:5DB3A147" + } + }, + "uuid": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..43ee270874 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api-2.json @@ -0,0 +1,130 @@ +{ + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "hub4j/github-api", + "private": false, + "owner": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/hub4j/github-api", + "forks_url": "https://api.github.com/repos/hub4j/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-10-25T01:32:16Z", + "pushed_at": "2019-10-25T16:41:09Z", + "git_url": "git://github.com/hub4j/github-api.git", + "ssh_url": "git@github.com:hub4j/github-api.git", + "clone_url": "https://github.com/hub4j/github-api.git", + "svn_url": "https://github.com/hub4j/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 13494, + "stargazers_count": 565, + "watchers_count": 565, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 433, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 64, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 433, + "open_issues": 64, + "watchers": 565, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 433, + "subscribers_count": 48 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..8ec18c631d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,98 @@ +{ + "sha": "86a2e245aa6d71d54923655066049d9e21a15f01", + "node_id": "MDY6Q29tbWl0NjE3MjEwOjg2YTJlMjQ1YWE2ZDcxZDU0OTIzNjU1MDY2MDQ5ZDllMjFhMTVmMjM=", + "commit": { + "author": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "committer": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "message": "doc", + "tree": { + "sha": "17ed4173aeb2e98c93216e8b6e16138dc7f8cd91", + "url": "https://api.github.com/repos/hub4j/github-api/git/trees/17ed4173aeb2e98c93216e8b6e16138dc7f8cd91" + }, + "url": "https://api.github.com/repos/hub4j/github-api/git/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "malformed_sig", + "signature": "-----BEGIN SIGNED MESSAGE-----\nMIIFdQYJKoZIhvcNAQcCoIIFZjCCBWICAQExDTALBglghkgBZQMEAgEwCwYJKoZI\nhvcNAQcBoIIDejCCA3YwggJeoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwKjEbMBkG\nA1UEAwwSQXN0cm9UbGFsb2PigJlzIENBMQswCQYDVQQGEwJVUzAeFw0yMzA5MTgy\nMzI2MDlaFw0yNDA5MTcyMzI2MDlaMEYxFDASBgNVBAMMC0FzdHJvVGxhbG9jMQsw\nCQYDVQQGEwJVUzEhMB8GCSqGSIb3DQEJARYSMHhUbGFsb2NAZ21haWwuY29tMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Zq+N5v68htABs4ZLPORns/F\nzixnI+6L+WaVGeQFzxIBs9zsm9IRGJ4xoMBPSg1BuoilRXzsQoCH6+5zyQ4jaHMa\nHBBEijVM7kor3Um+35KdYh79nIY7ZQoDRypLF02FiqfNjhN8Nm8ciNf2EUkiGIcj\n/+TPhVFMxnwlZ2SmSJoMBE5pkDBllb/8kfxgenSoVLXaOigYJ1It6AqH2L8Ju9pa\nJ1zJGu2edjN6xi/0yjzZ7CmPFbnWcY5flJfMqdaj0Po3dMwYKYK07rE7KQHc8wFT\ngAUtQNtJkGBjEcTBh1B7SUsnJ/x4XcSQwOMxPNSm4Esn2RWanJYunez75eCWlwID\nAQABo4GKMIGHMA4GA1UdDwEB/wQEAwIFoDAWBgNVHSUBAf8EDDAKBggrBgEFBQcD\nBDAdBgNVHQ4EFgQUSi5d7oqzSYNhpeG4I2VNF9j881UwHwYDVR0jBBgwFoAULCWl\nbibBiKOX/6M3RWgIlSPM7dcwHQYDVR0RBBYwFIESMHhUbGFsb2NAZ21haWwuY29t\nMA0GCSqGSIb3DQEBCwUAA4IBAQDSn3caORjlSXCSm8ZY1uAbG+IngvEooIJvbl+y\n0yglPA3pkWybXxLfvayJVRGtNgLambnPpulzZmdwjj7qSTzd9K/+OIsI2qjNrZZ+\napXJLhlfabNHzydj0y0DUWgbtKzQ1SVhWgglHaCp440UmVAi0PtsMy3F1S5S0HlZ\n80V1CE3r7UYsC64GG3CmyXVf5MB+pzPriE729Gglig5z6rq8F+GNk5hJW7tOKBRb\nCyXFkqbkMWHPJ/CP5wrFjrEITsn8fIhlJsYRIAGzTnffCOs9i3rMpUTXRBOwSVMB\nI1I3VPm+WxVE7O9NY7TGBDe7010D4DorTNUPYo8xsPtKYyrpMYIBwTCCAb0CAQEw\nLzAqMRswGQYDVQQDDBJBc3Ryb1RsYWxvY+KAmXMgQ0ExCzAJBgNVBAYTAlVTAgEC\nMAsGCWCGSAFlAwQCAaBpMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZI\nhvcNAQkFMQ8XDTIzMDkxODIzMjg1MFowLwYJKoZIhvcNAQkEMSIEIIFHI8Ick3Tu\nBlnfTU6v24ls8D+jGkpQoDK+MF4rk5iTMAsGCSqGSIb3DQEBCwSCAQC4nIUEB/bR\ngeXnO7KdtqRFn/slCNTKZaQObsyL7C7cmNYAlgQAYj/qOBhKGMd3ZAFHRUroCiCy\n5GPs1sEnPKT1Bh7E7HJbpfdMXZINxoiRBrwQpAD/UKxk6etF5qvtAwDJaFMZiTMh\nd6tPNVBcThhUglSqqQFT3BKE9z5KTGwonMeqZlyf/EpXRBn0YcaoWvcAzaahMBQw\nUPwwEtU3FVyYBbLQee0SoYDsddEjdaNN/37auMVIltYmKNq/A4KhJWduTGFcaD/k\nfcXIzhzBi4vk1No6y2ftDgbivxP3MVQyf1tIfD1fv9cw/55JnDRA3IXkQRc+yyUG\nGmHXpKHhqNKm\n-----END SIGNED MESSAGE-----", + "payload": null + } + }, + "url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "html_url": "https://github.com/hub4j/github-api/commit/86a2e245aa6d71d54923655066049d9e21a15f01", + "comments_url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01/comments", + "author": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + { + "sha": "ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "url": "https://api.github.com/repos/hub4j/github-api/commits/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "html_url": "https://github.com/hub4j/github-api/commit/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396" + } + ], + "stats": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "files": [ + { + "sha": "2a2e1f77fd77bd03273946d893d25a455f696be0", + "filename": "README", + "status": "added", + "additions": 3, + "deletions": 0, + "changes": 3, + "blob_url": "https://github.com/hub4j/github-api/blob/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "raw_url": "https://github.com/hub4j/github-api/raw/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/README?ref=86a2e245aa6d71d54923655066049d9e21a15f01", + "patch": "@@ -0,0 +1,3 @@\n+Java API for GitHub\n+\n+See http://kohsuke.org/github-api/ for more details" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/user-1.json new file mode 100644 index 0000000000..a4b576e8a7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/__files/user-1.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 169, + "public_gists": 7, + "followers": 139, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..80fb7dfa4e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api-2.json @@ -0,0 +1,48 @@ +{ + "id": "441cdfd7-a44a-42b4-b732-57e674227760", + "name": "repos_hub4j_github-api", + "request": { + "url": "/repos/hub4j/github-api", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api-2.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4295", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"c1a01d01a6354d93b3cc6098e0b2d047\"", + "Last-Modified": "Fri, 25 Oct 2019 01:32:16 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B56:C4A050:5DB3A147" + } + }, + "uuid": "441cdfd7-a44a-42b4-b732-57e674227760", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..6b5904361c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,48 @@ +{ + "id": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "name": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01", + "request": { + "url": "/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4294", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"0a8c453e4290ce879ea09578e06a5961\"", + "Last-Modified": "Mon, 19 Apr 2010 04:12:41 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B5F:C4A064:5DB3A148" + } + }, + "uuid": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/user-1.json new file mode 100644 index 0000000000..7c0606ff2f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testMalformedSig/mappings/user-1.json @@ -0,0 +1,48 @@ +{ + "id": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:39 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4297", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8c3d3dcf6fc5f9edaf26c902295396e5\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B49:C4A046:5DB3A147" + } + }, + "uuid": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..43ee270874 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api-2.json @@ -0,0 +1,130 @@ +{ + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "hub4j/github-api", + "private": false, + "owner": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/hub4j/github-api", + "forks_url": "https://api.github.com/repos/hub4j/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-10-25T01:32:16Z", + "pushed_at": "2019-10-25T16:41:09Z", + "git_url": "git://github.com/hub4j/github-api.git", + "ssh_url": "git@github.com:hub4j/github-api.git", + "clone_url": "https://github.com/hub4j/github-api.git", + "svn_url": "https://github.com/hub4j/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 13494, + "stargazers_count": 565, + "watchers_count": 565, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 433, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 64, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 433, + "open_issues": 64, + "watchers": 565, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 433, + "subscribers_count": 48 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..4f60cb235f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,98 @@ +{ + "sha": "86a2e245aa6d71d54923655066049d9e21a15f01", + "node_id": "MDY6Q29tbWl0NjE3MjEwOjg2YTJlMjQ1YWE2ZDcxZDU0OTIzNjU1MDY2MDQ5ZDllMjFhMTVmMjM=", + "commit": { + "author": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "committer": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "message": "doc", + "tree": { + "sha": "17ed4173aeb2e98c93216e8b6e16138dc7f8cd91", + "url": "https://api.github.com/repos/hub4j/github-api/git/trees/17ed4173aeb2e98c93216e8b6e16138dc7f8cd91" + }, + "url": "https://api.github.com/repos/hub4j/github-api/git/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "ocsp_error", + "signature": "-----BEGIN SIGNED MESSAGE-----\nMIIFdQYJKoZIhvcNAQcCoIIFZjCCBWICAQExDTALBglghkgBZQMEAgEwCwYJKoZI\nhvcNAQcBoIIDejCCA3YwggJeoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwKjEbMBkG\nA1UEAwwSQXN0cm9UbGFsb2PigJlzIENBMQswCQYDVQQGEwJVUzAeFw0yMzA5MTgy\nMzI2MDlaFw0yNDA5MTcyMzI2MDlaMEYxFDASBgNVBAMMC0FzdHJvVGxhbG9jMQsw\nCQYDVQQGEwJVUzEhMB8GCSqGSIb3DQEJARYSMHhUbGFsb2NAZ21haWwuY29tMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Zq+N5v68htABs4ZLPORns/F\nzixnI+6L+WaVGeQFzxIBs9zsm9IRGJ4xoMBPSg1BuoilRXzsQoCH6+5zyQ4jaHMa\nHBBEijVM7kor3Um+35KdYh79nIY7ZQoDRypLF02FiqfNjhN8Nm8ciNf2EUkiGIcj\n/+TPhVFMxnwlZ2SmSJoMBE5pkDBllb/8kfxgenSoVLXaOigYJ1It6AqH2L8Ju9pa\nJ1zJGu2edjN6xi/0yjzZ7CmPFbnWcY5flJfMqdaj0Po3dMwYKYK07rE7KQHc8wFT\ngAUtQNtJkGBjEcTBh1B7SUsnJ/x4XcSQwOMxPNSm4Esn2RWanJYunez75eCWlwID\nAQABo4GKMIGHMA4GA1UdDwEB/wQEAwIFoDAWBgNVHSUBAf8EDDAKBggrBgEFBQcD\nBDAdBgNVHQ4EFgQUSi5d7oqzSYNhpeG4I2VNF9j881UwHwYDVR0jBBgwFoAULCWl\nbibBiKOX/6M3RWgIlSPM7dcwHQYDVR0RBBYwFIESMHhUbGFsb2NAZ21haWwuY29t\nMA0GCSqGSIb3DQEBCwUAA4IBAQDSn3caORjlSXCSm8ZY1uAbG+IngvEooIJvbl+y\n0yglPA3pkWybXxLfvayJVRGtNgLambnPpulzZmdwjj7qSTzd9K/+OIsI2qjNrZZ+\napXJLhlfabNHzydj0y0DUWgbtKzQ1SVhWgglHaCp440UmVAi0PtsMy3F1S5S0HlZ\n80V1CE3r7UYsC64GG3CmyXVf5MB+pzPriE729Gglig5z6rq8F+GNk5hJW7tOKBRb\nCyXFkqbkMWHPJ/CP5wrFjrEITsn8fIhlJsYRIAGzTnffCOs9i3rMpUTXRBOwSVMB\nI1I3VPm+WxVE7O9NY7TGBDe7010D4DorTNUPYo8xsPtKYyrpMYIBwTCCAb0CAQEw\nLzAqMRswGQYDVQQDDBJBc3Ryb1RsYWxvY+KAmXMgQ0ExCzAJBgNVBAYTAlVTAgEC\nMAsGCWCGSAFlAwQCAaBpMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZI\nhvcNAQkFMQ8XDTIzMDkxODIzMjg1MFowLwYJKoZIhvcNAQkEMSIEIIFHI8Ick3Tu\nBlnfTU6v24ls8D+jGkpQoDK+MF4rk5iTMAsGCSqGSIb3DQEBCwSCAQC4nIUEB/bR\ngeXnO7KdtqRFn/slCNTKZaQObsyL7C7cmNYAlgQAYj/qOBhKGMd3ZAFHRUroCiCy\n5GPs1sEnPKT1Bh7E7HJbpfdMXZINxoiRBrwQpAD/UKxk6etF5qvtAwDJaFMZiTMh\nd6tPNVBcThhUglSqqQFT3BKE9z5KTGwonMeqZlyf/EpXRBn0YcaoWvcAzaahMBQw\nUPwwEtU3FVyYBbLQee0SoYDsddEjdaNN/37auMVIltYmKNq/A4KhJWduTGFcaD/k\nfcXIzhzBi4vk1No6y2ftDgbivxP3MVQyf1tIfD1fv9cw/55JnDRA3IXkQRc+yyUG\nGmHXpKHhqNKm\n-----END SIGNED MESSAGE-----", + "payload": null + } + }, + "url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "html_url": "https://github.com/hub4j/github-api/commit/86a2e245aa6d71d54923655066049d9e21a15f01", + "comments_url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01/comments", + "author": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + { + "sha": "ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "url": "https://api.github.com/repos/hub4j/github-api/commits/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "html_url": "https://github.com/hub4j/github-api/commit/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396" + } + ], + "stats": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "files": [ + { + "sha": "2a2e1f77fd77bd03273946d893d25a455f696be0", + "filename": "README", + "status": "added", + "additions": 3, + "deletions": 0, + "changes": 3, + "blob_url": "https://github.com/hub4j/github-api/blob/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "raw_url": "https://github.com/hub4j/github-api/raw/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/README?ref=86a2e245aa6d71d54923655066049d9e21a15f01", + "patch": "@@ -0,0 +1,3 @@\n+Java API for GitHub\n+\n+See http://kohsuke.org/github-api/ for more details" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/user-1.json new file mode 100644 index 0000000000..a4b576e8a7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/__files/user-1.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 169, + "public_gists": 7, + "followers": 139, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..80fb7dfa4e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api-2.json @@ -0,0 +1,48 @@ +{ + "id": "441cdfd7-a44a-42b4-b732-57e674227760", + "name": "repos_hub4j_github-api", + "request": { + "url": "/repos/hub4j/github-api", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api-2.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4295", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"c1a01d01a6354d93b3cc6098e0b2d047\"", + "Last-Modified": "Fri, 25 Oct 2019 01:32:16 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B56:C4A050:5DB3A147" + } + }, + "uuid": "441cdfd7-a44a-42b4-b732-57e674227760", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..6b5904361c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,48 @@ +{ + "id": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "name": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01", + "request": { + "url": "/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4294", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"0a8c453e4290ce879ea09578e06a5961\"", + "Last-Modified": "Mon, 19 Apr 2010 04:12:41 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B5F:C4A064:5DB3A148" + } + }, + "uuid": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/user-1.json new file mode 100644 index 0000000000..7c0606ff2f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOcspError/mappings/user-1.json @@ -0,0 +1,48 @@ +{ + "id": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:39 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4297", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8c3d3dcf6fc5f9edaf26c902295396e5\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B49:C4A046:5DB3A147" + } + }, + "uuid": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..43ee270874 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api-2.json @@ -0,0 +1,130 @@ +{ + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "hub4j/github-api", + "private": false, + "owner": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/hub4j/github-api", + "forks_url": "https://api.github.com/repos/hub4j/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-10-25T01:32:16Z", + "pushed_at": "2019-10-25T16:41:09Z", + "git_url": "git://github.com/hub4j/github-api.git", + "ssh_url": "git@github.com:hub4j/github-api.git", + "clone_url": "https://github.com/hub4j/github-api.git", + "svn_url": "https://github.com/hub4j/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 13494, + "stargazers_count": 565, + "watchers_count": 565, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 433, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 64, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 433, + "open_issues": 64, + "watchers": 565, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 433, + "subscribers_count": 48 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..c5e2c3995c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,98 @@ +{ + "sha": "86a2e245aa6d71d54923655066049d9e21a15f01", + "node_id": "MDY6Q29tbWl0NjE3MjEwOjg2YTJlMjQ1YWE2ZDcxZDU0OTIzNjU1MDY2MDQ5ZDllMjFhMTVmMjM=", + "commit": { + "author": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "committer": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "message": "doc", + "tree": { + "sha": "17ed4173aeb2e98c93216e8b6e16138dc7f8cd91", + "url": "https://api.github.com/repos/hub4j/github-api/git/trees/17ed4173aeb2e98c93216e8b6e16138dc7f8cd91" + }, + "url": "https://api.github.com/repos/hub4j/github-api/git/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "ocsp_pending", + "signature": "-----BEGIN SIGNED MESSAGE-----\nMIIFdQYJKoZIhvcNAQcCoIIFZjCCBWICAQExDTALBglghkgBZQMEAgEwCwYJKoZI\nhvcNAQcBoIIDejCCA3YwggJeoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwKjEbMBkG\nA1UEAwwSQXN0cm9UbGFsb2PigJlzIENBMQswCQYDVQQGEwJVUzAeFw0yMzA5MTgy\nMzI2MDlaFw0yNDA5MTcyMzI2MDlaMEYxFDASBgNVBAMMC0FzdHJvVGxhbG9jMQsw\nCQYDVQQGEwJVUzEhMB8GCSqGSIb3DQEJARYSMHhUbGFsb2NAZ21haWwuY29tMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Zq+N5v68htABs4ZLPORns/F\nzixnI+6L+WaVGeQFzxIBs9zsm9IRGJ4xoMBPSg1BuoilRXzsQoCH6+5zyQ4jaHMa\nHBBEijVM7kor3Um+35KdYh79nIY7ZQoDRypLF02FiqfNjhN8Nm8ciNf2EUkiGIcj\n/+TPhVFMxnwlZ2SmSJoMBE5pkDBllb/8kfxgenSoVLXaOigYJ1It6AqH2L8Ju9pa\nJ1zJGu2edjN6xi/0yjzZ7CmPFbnWcY5flJfMqdaj0Po3dMwYKYK07rE7KQHc8wFT\ngAUtQNtJkGBjEcTBh1B7SUsnJ/x4XcSQwOMxPNSm4Esn2RWanJYunez75eCWlwID\nAQABo4GKMIGHMA4GA1UdDwEB/wQEAwIFoDAWBgNVHSUBAf8EDDAKBggrBgEFBQcD\nBDAdBgNVHQ4EFgQUSi5d7oqzSYNhpeG4I2VNF9j881UwHwYDVR0jBBgwFoAULCWl\nbibBiKOX/6M3RWgIlSPM7dcwHQYDVR0RBBYwFIESMHhUbGFsb2NAZ21haWwuY29t\nMA0GCSqGSIb3DQEBCwUAA4IBAQDSn3caORjlSXCSm8ZY1uAbG+IngvEooIJvbl+y\n0yglPA3pkWybXxLfvayJVRGtNgLambnPpulzZmdwjj7qSTzd9K/+OIsI2qjNrZZ+\napXJLhlfabNHzydj0y0DUWgbtKzQ1SVhWgglHaCp440UmVAi0PtsMy3F1S5S0HlZ\n80V1CE3r7UYsC64GG3CmyXVf5MB+pzPriE729Gglig5z6rq8F+GNk5hJW7tOKBRb\nCyXFkqbkMWHPJ/CP5wrFjrEITsn8fIhlJsYRIAGzTnffCOs9i3rMpUTXRBOwSVMB\nI1I3VPm+WxVE7O9NY7TGBDe7010D4DorTNUPYo8xsPtKYyrpMYIBwTCCAb0CAQEw\nLzAqMRswGQYDVQQDDBJBc3Ryb1RsYWxvY+KAmXMgQ0ExCzAJBgNVBAYTAlVTAgEC\nMAsGCWCGSAFlAwQCAaBpMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZI\nhvcNAQkFMQ8XDTIzMDkxODIzMjg1MFowLwYJKoZIhvcNAQkEMSIEIIFHI8Ick3Tu\nBlnfTU6v24ls8D+jGkpQoDK+MF4rk5iTMAsGCSqGSIb3DQEBCwSCAQC4nIUEB/bR\ngeXnO7KdtqRFn/slCNTKZaQObsyL7C7cmNYAlgQAYj/qOBhKGMd3ZAFHRUroCiCy\n5GPs1sEnPKT1Bh7E7HJbpfdMXZINxoiRBrwQpAD/UKxk6etF5qvtAwDJaFMZiTMh\nd6tPNVBcThhUglSqqQFT3BKE9z5KTGwonMeqZlyf/EpXRBn0YcaoWvcAzaahMBQw\nUPwwEtU3FVyYBbLQee0SoYDsddEjdaNN/37auMVIltYmKNq/A4KhJWduTGFcaD/k\nfcXIzhzBi4vk1No6y2ftDgbivxP3MVQyf1tIfD1fv9cw/55JnDRA3IXkQRc+yyUG\nGmHXpKHhqNKm\n-----END SIGNED MESSAGE-----", + "payload": null + } + }, + "url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "html_url": "https://github.com/hub4j/github-api/commit/86a2e245aa6d71d54923655066049d9e21a15f01", + "comments_url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01/comments", + "author": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + { + "sha": "ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "url": "https://api.github.com/repos/hub4j/github-api/commits/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "html_url": "https://github.com/hub4j/github-api/commit/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396" + } + ], + "stats": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "files": [ + { + "sha": "2a2e1f77fd77bd03273946d893d25a455f696be0", + "filename": "README", + "status": "added", + "additions": 3, + "deletions": 0, + "changes": 3, + "blob_url": "https://github.com/hub4j/github-api/blob/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "raw_url": "https://github.com/hub4j/github-api/raw/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/README?ref=86a2e245aa6d71d54923655066049d9e21a15f01", + "patch": "@@ -0,0 +1,3 @@\n+Java API for GitHub\n+\n+See http://kohsuke.org/github-api/ for more details" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/user-1.json new file mode 100644 index 0000000000..a4b576e8a7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/__files/user-1.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 169, + "public_gists": 7, + "followers": 139, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..80fb7dfa4e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api-2.json @@ -0,0 +1,48 @@ +{ + "id": "441cdfd7-a44a-42b4-b732-57e674227760", + "name": "repos_hub4j_github-api", + "request": { + "url": "/repos/hub4j/github-api", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api-2.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4295", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"c1a01d01a6354d93b3cc6098e0b2d047\"", + "Last-Modified": "Fri, 25 Oct 2019 01:32:16 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B56:C4A050:5DB3A147" + } + }, + "uuid": "441cdfd7-a44a-42b4-b732-57e674227760", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..6b5904361c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,48 @@ +{ + "id": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "name": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01", + "request": { + "url": "/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4294", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"0a8c453e4290ce879ea09578e06a5961\"", + "Last-Modified": "Mon, 19 Apr 2010 04:12:41 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B5F:C4A064:5DB3A148" + } + }, + "uuid": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/user-1.json new file mode 100644 index 0000000000..7c0606ff2f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpPending/mappings/user-1.json @@ -0,0 +1,48 @@ +{ + "id": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:39 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4297", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8c3d3dcf6fc5f9edaf26c902295396e5\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B49:C4A046:5DB3A147" + } + }, + "uuid": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..43ee270874 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api-2.json @@ -0,0 +1,130 @@ +{ + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "hub4j/github-api", + "private": false, + "owner": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/hub4j/github-api", + "forks_url": "https://api.github.com/repos/hub4j/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-10-25T01:32:16Z", + "pushed_at": "2019-10-25T16:41:09Z", + "git_url": "git://github.com/hub4j/github-api.git", + "ssh_url": "git@github.com:hub4j/github-api.git", + "clone_url": "https://github.com/hub4j/github-api.git", + "svn_url": "https://github.com/hub4j/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 13494, + "stargazers_count": 565, + "watchers_count": 565, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 433, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 64, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 433, + "open_issues": 64, + "watchers": 565, + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 433, + "subscribers_count": 48 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..26aa4fc983 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,98 @@ +{ + "sha": "86a2e245aa6d71d54923655066049d9e21a15f01", + "node_id": "MDY6Q29tbWl0NjE3MjEwOjg2YTJlMjQ1YWE2ZDcxZDU0OTIzNjU1MDY2MDQ5ZDllMjFhMTVmMjM=", + "commit": { + "author": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "committer": { + "name": "Sourabh Parkala", + "email": "sourabh.sarvotham.parkala@sap.com", + "date": "2010-04-19T04:12:41Z" + }, + "message": "doc", + "tree": { + "sha": "17ed4173aeb2e98c93216e8b6e16138dc7f8cd91", + "url": "https://api.github.com/repos/hub4j/github-api/git/trees/17ed4173aeb2e98c93216e8b6e16138dc7f8cd91" + }, + "url": "https://api.github.com/repos/hub4j/github-api/git/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "ocsp_revoked", + "signature": "-----BEGIN SIGNED MESSAGE-----\nMIIFdQYJKoZIhvcNAQcCoIIFZjCCBWICAQExDTALBglghkgBZQMEAgEwCwYJKoZI\nhvcNAQcBoIIDejCCA3YwggJeoAMCAQICAQIwDQYJKoZIhvcNAQELBQAwKjEbMBkG\nA1UEAwwSQXN0cm9UbGFsb2PigJlzIENBMQswCQYDVQQGEwJVUzAeFw0yMzA5MTgy\nMzI2MDlaFw0yNDA5MTcyMzI2MDlaMEYxFDASBgNVBAMMC0FzdHJvVGxhbG9jMQsw\nCQYDVQQGEwJVUzEhMB8GCSqGSIb3DQEJARYSMHhUbGFsb2NAZ21haWwuY29tMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Zq+N5v68htABs4ZLPORns/F\nzixnI+6L+WaVGeQFzxIBs9zsm9IRGJ4xoMBPSg1BuoilRXzsQoCH6+5zyQ4jaHMa\nHBBEijVM7kor3Um+35KdYh79nIY7ZQoDRypLF02FiqfNjhN8Nm8ciNf2EUkiGIcj\n/+TPhVFMxnwlZ2SmSJoMBE5pkDBllb/8kfxgenSoVLXaOigYJ1It6AqH2L8Ju9pa\nJ1zJGu2edjN6xi/0yjzZ7CmPFbnWcY5flJfMqdaj0Po3dMwYKYK07rE7KQHc8wFT\ngAUtQNtJkGBjEcTBh1B7SUsnJ/x4XcSQwOMxPNSm4Esn2RWanJYunez75eCWlwID\nAQABo4GKMIGHMA4GA1UdDwEB/wQEAwIFoDAWBgNVHSUBAf8EDDAKBggrBgEFBQcD\nBDAdBgNVHQ4EFgQUSi5d7oqzSYNhpeG4I2VNF9j881UwHwYDVR0jBBgwFoAULCWl\nbibBiKOX/6M3RWgIlSPM7dcwHQYDVR0RBBYwFIESMHhUbGFsb2NAZ21haWwuY29t\nMA0GCSqGSIb3DQEBCwUAA4IBAQDSn3caORjlSXCSm8ZY1uAbG+IngvEooIJvbl+y\n0yglPA3pkWybXxLfvayJVRGtNgLambnPpulzZmdwjj7qSTzd9K/+OIsI2qjNrZZ+\napXJLhlfabNHzydj0y0DUWgbtKzQ1SVhWgglHaCp440UmVAi0PtsMy3F1S5S0HlZ\n80V1CE3r7UYsC64GG3CmyXVf5MB+pzPriE729Gglig5z6rq8F+GNk5hJW7tOKBRb\nCyXFkqbkMWHPJ/CP5wrFjrEITsn8fIhlJsYRIAGzTnffCOs9i3rMpUTXRBOwSVMB\nI1I3VPm+WxVE7O9NY7TGBDe7010D4DorTNUPYo8xsPtKYyrpMYIBwTCCAb0CAQEw\nLzAqMRswGQYDVQQDDBJBc3Ryb1RsYWxvY+KAmXMgQ0ExCzAJBgNVBAYTAlVTAgEC\nMAsGCWCGSAFlAwQCAaBpMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZI\nhvcNAQkFMQ8XDTIzMDkxODIzMjg1MFowLwYJKoZIhvcNAQkEMSIEIIFHI8Ick3Tu\nBlnfTU6v24ls8D+jGkpQoDK+MF4rk5iTMAsGCSqGSIb3DQEBCwSCAQC4nIUEB/bR\ngeXnO7KdtqRFn/slCNTKZaQObsyL7C7cmNYAlgQAYj/qOBhKGMd3ZAFHRUroCiCy\n5GPs1sEnPKT1Bh7E7HJbpfdMXZINxoiRBrwQpAD/UKxk6etF5qvtAwDJaFMZiTMh\nd6tPNVBcThhUglSqqQFT3BKE9z5KTGwonMeqZlyf/EpXRBn0YcaoWvcAzaahMBQw\nUPwwEtU3FVyYBbLQee0SoYDsddEjdaNN/37auMVIltYmKNq/A4KhJWduTGFcaD/k\nfcXIzhzBi4vk1No6y2ftDgbivxP3MVQyf1tIfD1fv9cw/55JnDRA3IXkQRc+yyUG\nGmHXpKHhqNKm\n-----END SIGNED MESSAGE-----", + "payload": null + } + }, + "url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "html_url": "https://github.com/hub4j/github-api/commit/86a2e245aa6d71d54923655066049d9e21a15f01", + "comments_url": "https://api.github.com/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01/comments", + "author": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "kohsuke", + "id": 50003, + "node_id": "MDQ6VXNlcjUwMDAz", + "avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke", + "html_url": "https://github.com/kohsuke", + "followers_url": "https://api.github.com/users/kohsuke/followers", + "following_url": "https://api.github.com/users/kohsuke/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke/orgs", + "repos_url": "https://api.github.com/users/kohsuke/repos", + "events_url": "https://api.github.com/users/kohsuke/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + { + "sha": "ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "url": "https://api.github.com/repos/hub4j/github-api/commits/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", + "html_url": "https://github.com/hub4j/github-api/commit/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396" + } + ], + "stats": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "files": [ + { + "sha": "2a2e1f77fd77bd03273946d893d25a455f696be0", + "filename": "README", + "status": "added", + "additions": 3, + "deletions": 0, + "changes": 3, + "blob_url": "https://github.com/hub4j/github-api/blob/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "raw_url": "https://github.com/hub4j/github-api/raw/86a2e245aa6d71d54923655066049d9e21a15f01/README", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/README?ref=86a2e245aa6d71d54923655066049d9e21a15f01", + "patch": "@@ -0,0 +1,3 @@\n+Java API for GitHub\n+\n+See http://kohsuke.org/github-api/ for more details" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/user-1.json new file mode 100644 index 0000000000..a4b576e8a7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/__files/user-1.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 169, + "public_gists": 7, + "followers": 139, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api-2.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api-2.json new file mode 100644 index 0000000000..80fb7dfa4e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api-2.json @@ -0,0 +1,48 @@ +{ + "id": "441cdfd7-a44a-42b4-b732-57e674227760", + "name": "repos_hub4j_github-api", + "request": { + "url": "/repos/hub4j/github-api", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api-2.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4295", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"c1a01d01a6354d93b3cc6098e0b2d047\"", + "Last-Modified": "Fri, 25 Oct 2019 01:32:16 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B56:C4A050:5DB3A147" + } + }, + "uuid": "441cdfd7-a44a-42b4-b732-57e674227760", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json new file mode 100644 index 0000000000..6b5904361c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json @@ -0,0 +1,48 @@ +{ + "id": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "name": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01", + "request": { + "url": "/repos/hub4j/github-api/commits/86a2e245aa6d71d54923655066049d9e21a15f01", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api_commits_86a2e245aa6d71d54923655066049d9e21a15f01-3.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4294", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"0a8c453e4290ce879ea09578e06a5961\"", + "Last-Modified": "Mon, 19 Apr 2010 04:12:41 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B5F:C4A064:5DB3A148" + } + }, + "uuid": "d76abea9-c1be-430a-bbd0-28931c58e1e8", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/user-1.json new file mode 100644 index 0000000000..7c0606ff2f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHVerificationReasonTest/wiremock/testOscpRevoked/mappings/user-1.json @@ -0,0 +1,48 @@ +{ + "id": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Sat, 26 Oct 2019 01:28:39 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4297", + "X-RateLimit-Reset": "1572055286", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8c3d3dcf6fc5f9edaf26c902295396e5\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "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", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "CB01:05A2:A65B49:C4A046:5DB3A147" + } + }, + "uuid": "c247f81b-84b8-44e9-820a-0a91dc74ce98", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From b1ae2d34e82b2bbb2858ead5f4ed557679204db0 Mon Sep 17 00:00:00 2001 From: Ulises <0xTlaloc@gmail.com> Date: Wed, 20 Sep 2023 13:13:13 -0700 Subject: [PATCH 12/35] Updating url in documentation --- src/main/java/org/kohsuke/github/GHVerification.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHVerification.java b/src/main/java/org/kohsuke/github/GHVerification.java index ce92905730..367184206a 100644 --- a/src/main/java/org/kohsuke/github/GHVerification.java +++ b/src/main/java/org/kohsuke/github/GHVerification.java @@ -61,8 +61,8 @@ public String getPayload() { * The possible values for reason in verification object from github. * * @author Sourabh Sarvotham Parkala - * @see List of possible - * reason values + * @see List of possible + * reason values. Note graphQL documentation has currently the most updated values. */ public enum Reason { From 7c87ad9f286f4ffc12023748757ccc9a1c6292de Mon Sep 17 00:00:00 2001 From: Ulises <0xTlaloc@gmail.com> Date: Wed, 20 Sep 2023 13:14:18 -0700 Subject: [PATCH 13/35] forgot to run mvn spotless:apply --- src/main/java/org/kohsuke/github/GHVerification.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHVerification.java b/src/main/java/org/kohsuke/github/GHVerification.java index 367184206a..2a759ea5a5 100644 --- a/src/main/java/org/kohsuke/github/GHVerification.java +++ b/src/main/java/org/kohsuke/github/GHVerification.java @@ -61,8 +61,8 @@ public String getPayload() { * The possible values for reason in verification object from github. * * @author Sourabh Sarvotham Parkala - * @see List of possible - * reason values. Note graphQL documentation has currently the most updated values. + * @see List of possible reason + * values. Note graphQL documentation has currently the most updated values. */ public enum Reason { From ca08d7691cbabdcaae843e682afdf435e79c8e1e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 02:10:27 +0000 Subject: [PATCH 14/35] Chore(deps-dev): Bump org.eclipse.jgit:org.eclipse.jgit Bumps org.eclipse.jgit:org.eclipse.jgit from 6.4.0.202211300538-r to 6.7.0.202309050840-r. --- updated-dependencies: - dependency-name: org.eclipse.jgit:org.eclipse.jgit dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae25ea25c8..b5bd4c03cc 100644 --- a/pom.xml +++ b/pom.xml @@ -553,7 +553,7 @@ org.eclipse.jgit org.eclipse.jgit - 6.4.0.202211300538-r + 6.7.0.202309050840-r test From ca70bc36a65250227d34839e6a1e0139b403e2de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 02:14:49 +0000 Subject: [PATCH 15/35] Chore(deps): Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/maven-build.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 038bc93fad..11d644db46 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index d61e2c0fcc..d572259804 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -24,7 +24,7 @@ jobs: strategy: fail-fast: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: @@ -46,7 +46,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: @@ -66,7 +66,7 @@ jobs: os: [ ubuntu, windows ] java: [ 11, 17 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: @@ -93,7 +93,7 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: name: maven-target-directory From a42f54e9f95097fcc6f5fe7671d973c00a743d4c Mon Sep 17 00:00:00 2001 From: Felipe Francisco Date: Fri, 13 Oct 2023 16:38:26 +0100 Subject: [PATCH 16/35] Support merge_group webhooks fired by merge queues. PR created based on #1316 --- src/main/java/org/kohsuke/github/GHEvent.java | 3 +++ src/test/java/org/kohsuke/github/EnumTest.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHEvent.java b/src/main/java/org/kohsuke/github/GHEvent.java index d93411bedf..1170743ac3 100644 --- a/src/main/java/org/kohsuke/github/GHEvent.java +++ b/src/main/java/org/kohsuke/github/GHEvent.java @@ -102,6 +102,9 @@ public enum GHEvent { /** The merge queue entry. */ MERGE_QUEUE_ENTRY, + /** The merge group entry. */ + MERGE_GROUP, + /** The meta. */ META, diff --git a/src/test/java/org/kohsuke/github/EnumTest.java b/src/test/java/org/kohsuke/github/EnumTest.java index 59cf1f4d44..939c6360e3 100644 --- a/src/test/java/org/kohsuke/github/EnumTest.java +++ b/src/test/java/org/kohsuke/github/EnumTest.java @@ -32,7 +32,7 @@ public void touchEnums() { assertThat(GHDirection.values().length, equalTo(2)); - assertThat(GHEvent.values().length, equalTo(64)); + assertThat(GHEvent.values().length, equalTo(65)); assertThat(GHEvent.ALL.symbol(), equalTo("*")); assertThat(GHEvent.PULL_REQUEST.symbol(), equalTo(GHEvent.PULL_REQUEST.toString().toLowerCase())); From 4eec65913bfde5fe4eda1b9758f17157d1ef4ff1 Mon Sep 17 00:00:00 2001 From: D061587 Date: Mon, 16 Oct 2023 13:19:15 +0200 Subject: [PATCH 17/35] Adopt code to newer version of jjwt. Fixes: #1724 --- pom.xml | 2 +- .../github/extras/authorization/JWTTokenProvider.java | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 7a8b952a87..b7b412e40e 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 0.50 false - 0.11.5 + 0.12.3 diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java index 85ed1f69ed..71c05eb789 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java @@ -2,7 +2,6 @@ import io.jsonwebtoken.JwtBuilder; import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.jackson.io.JacksonSerializer; import org.kohsuke.github.authorization.AuthorizationProvider; @@ -173,16 +172,16 @@ private String refreshJWT() { // Let's set the JWT Claims JwtBuilder builder = Jwts.builder() - .setIssuedAt(Date.from(issuedAt)) - .setExpiration(Date.from(expiration)) - .setIssuer(this.applicationId) - .signWith(privateKey, SignatureAlgorithm.RS256); + .issuedAt(Date.from(issuedAt)) + .expiration(Date.from(expiration)) + .issuer(this.applicationId) + .signWith(privateKey, Jwts.SIG.RS256); // Token will refresh 2 minutes before it expires validUntil = expiration.minus(Duration.ofMinutes(2)); // Builds the JWT and serializes it to a compact, URL-safe string - return builder.serializeToJsonWith(new JacksonSerializer<>()).compact(); + return builder.json(new JacksonSerializer<>()).compact(); } Instant getIssuedAt(Instant now) { From 90f22bd679f4cb06496350ce5f5efee2eead5939 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 19 Oct 2023 17:29:59 -0700 Subject: [PATCH 18/35] [maven-release-plugin] prepare release github-api-1.317 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 25b8d3326c..b3ca77640a 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.kohsuke github-api - 1.317-SNAPSHOT + 1.317 GitHub API for Java https://github-api.kohsuke.org/ GitHub API for Java @@ -11,7 +11,7 @@ scm:git:git@github.com/hub4j/${project.artifactId}.git scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git https://github.com/hub4j/github-api/ - HEAD + github-api-1.317 From 38baf5df845a1397522e1e953b84a80fb57a8799 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 19 Oct 2023 17:30:04 -0700 Subject: [PATCH 19/35] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b3ca77640a..56086d0005 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.kohsuke github-api - 1.317 + 1.318-SNAPSHOT GitHub API for Java https://github-api.kohsuke.org/ GitHub API for Java @@ -11,7 +11,7 @@ scm:git:git@github.com/hub4j/${project.artifactId}.git scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git https://github.com/hub4j/github-api/ - github-api-1.317 + HEAD From 63708d14108dee207d2cfdd0b30727a7fa70b8d7 Mon Sep 17 00:00:00 2001 From: Gregor Heine Date: Fri, 20 Oct 2023 16:40:19 +0100 Subject: [PATCH 20/35] Add missing branch protection fields --- .../kohsuke/github/GHBranchProtection.java | 154 +++++++++++++++ .../github/GHBranchProtectionBuilder.java | 187 +++++++++++++++++- 2 files changed, 338 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java index 697686ce2d..70c837678f 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtection.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java @@ -22,9 +22,30 @@ public class GHBranchProtection extends GitHubInteractiveObject { private static final String REQUIRE_SIGNATURES_URI = "/required_signatures"; + @JsonProperty + private AllowDeletions allowDeletions; + + @JsonProperty + private AllowForcePushes allowForcePushes; + + @JsonProperty + private AllowForkSyncing allowForkSyncing; + + @JsonProperty + private BlockCreations blockCreations; + @JsonProperty private EnforceAdmins enforceAdmins; + @JsonProperty + private LockBranch lockBranch; + + @JsonProperty + private RequiredConversationResolution requiredConversationResolution; + + @JsonProperty + private RequiredLinearHistory requiredLinearHistory; + @JsonProperty("required_pull_request_reviews") private RequiredReviews requiredReviews; @@ -120,6 +141,74 @@ private Requester requester() { return root().createRequest().withPreview(ZZZAX); } + /** + * The type AllowDeletions. + */ + public static class AllowDeletions { + @JsonProperty + private boolean enabled; + + /** + * Is enabled boolean. + * + * @return the boolean + */ + public boolean isEnabled() { + return enabled; + } + } + + /** + * The type AllowForcePushes. + */ + public static class AllowForcePushes { + @JsonProperty + private boolean enabled; + + /** + * Is enabled boolean. + * + * @return the boolean + */ + public boolean isEnabled() { + return enabled; + } + } + + /** + * The type AllowForkSyncing. + */ + public static class AllowForkSyncing { + @JsonProperty + private boolean enabled; + + /** + * Is enabled boolean. + * + * @return the boolean + */ + public boolean isEnabled() { + return enabled; + } + } + + /** + * The type BlockCreations. + */ + public static class BlockCreations { + @JsonProperty + private boolean enabled; + + /** + * Is enabled boolean. + * + * @return the boolean + */ + public boolean isEnabled() { + return enabled; + } + } + /** * The type EnforceAdmins. */ @@ -149,6 +238,57 @@ public boolean isEnabled() { } } + /** + * The type LockBranch. + */ + public static class LockBranch { + @JsonProperty + private boolean enabled; + + /** + * Is enabled boolean. + * + * @return the boolean + */ + public boolean isEnabled() { + return enabled; + } + } + + /** + * The type RequiredConversationResolution. + */ + public static class RequiredConversationResolution { + @JsonProperty + private boolean enabled; + + /** + * Is enabled boolean. + * + * @return the boolean + */ + public boolean isEnabled() { + return enabled; + } + } + + /** + * The type RequiredLinearHistory. + */ + public static class RequiredLinearHistory { + @JsonProperty + private boolean enabled; + + /** + * Is enabled boolean. + * + * @return the boolean + */ + public boolean isEnabled() { + return enabled; + } + } + /** * The type RequiredReviews. */ @@ -156,10 +296,15 @@ public static class RequiredReviews { @JsonProperty("dismissal_restrictions") private Restrictions dismissalRestriction; + @JsonProperty private boolean dismissStaleReviews; + @JsonProperty private boolean requireCodeOwnerReviews; + @JsonProperty + private boolean requireLastPushApproval; + @JsonProperty("required_approving_review_count") private int requiredReviewers; @@ -202,6 +347,15 @@ public boolean isRequireCodeOwnerReviews() { return requireCodeOwnerReviews; } + /** + * Is require last push approval boolean. + * + * @return the boolean + */ + public boolean isRequireLastPushApproval() { + return requireLastPushApproval; + } + /** * Gets required reviewers. * diff --git a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java index 9d22703914..70a614894a 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java @@ -27,7 +27,7 @@ public class GHBranchProtectionBuilder { private final GHBranch branch; - private boolean enforceAdmins; + private Map fields = new HashMap(); private Map prReviews; private Restrictions restrictions; private StatusChecks statusChecks; @@ -40,6 +40,7 @@ public class GHBranchProtectionBuilder { */ GHBranchProtectionBuilder(GHBranch branch) { this.branch = branch; + includeAdmins(false); } /** @@ -66,6 +67,95 @@ public GHBranchProtectionBuilder addRequiredChecks(String... checks) { return this; } + /** + * Allow deletion of the protected branch. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder allowDeletions() { + return allowDeletions(true); + } + + /** + * Allows deletion of the protected branch by anyone with write access to the repository. + * Set to true to allow deletion of the protected branch. Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder allowDeletions(boolean v) { + fields.put("allow_deletions", v); + return this; + } + + /** + * Permits force pushes. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder allowForcePushes() { + return allowForcePushes(true); + } + + /** + * Permits force pushes to the protected branch by anyone with write access to the repository. + * Set to true to allow force pushes. Set to false to block force pushes. Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder allowForcePushes(boolean v) { + fields.put("allow_force_pushes", v); + return this; + } + + /** + * Allow fork syncing. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder allowForkSyncing() { + return allowForkSyncing(true); + } + + /** + * Whether users can pull changes from upstream when the branch is locked. Set to true to allow fork syncing. + * Set to true to enable. Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder allowForkSyncing(boolean v) { + fields.put("allow_fork_syncing", v); + return this; + } + + /** + * Restrict new branch creation. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder blockCreations() { + return blockCreations(true); + } + + /** + * If set to true, the restrictions branch protection settings which limits who can push will also block pushes + * which create new branches, unless the push is initiated by a user, team, or app which has the ability to push. + * Set to true to restrict new branch creation. Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder blockCreations(boolean v) { + fields.put("block_creations", v); + return this; + } + /** * Dismiss stale reviews gh branch protection builder. * @@ -96,10 +186,10 @@ public GHBranchProtectionBuilder dismissStaleReviews(boolean v) { */ public GHBranchProtection enable() throws IOException { return requester().method("PUT") + .with(fields) .withNullable("required_status_checks", statusChecks) .withNullable("required_pull_request_reviews", prReviews) .withNullable("restrictions", restrictions) - .withNullable("enforce_admins", enforceAdmins) .withUrlPath(branch.getProtectionUrl().toString()) .fetch(GHBranchProtection.class); } @@ -121,7 +211,29 @@ public GHBranchProtectionBuilder includeAdmins() { * @return the gh branch protection builder */ public GHBranchProtectionBuilder includeAdmins(boolean v) { - enforceAdmins = v; + fields.put("enforce_admins", v); + return this; + } + + /** + * Set the branch as read-only. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder lockBranch() { + return lockBranch(true); + } + + /** + * Whether to set the branch as read-only. If this is true, users will not be able to push to the branch. + * Set to true to enable. Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder lockBranch(boolean v) { + fields.put("lock_branch", v); return this; } @@ -179,6 +291,75 @@ public GHBranchProtectionBuilder requireCodeOwnReviews(boolean v) { return this; } + /** + * Enable the most recent push must be approved by someone other than the person who pushed it. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder requireLastPushApproval() { + return requireLastPushApproval(true); + } + + /** + * Whether the most recent push must be approved by someone other than the person who pushed it. Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder requireLastPushApproval(boolean v) { + getPrReviews().put("require_last_push_approval", v); + return this; + } + + /** + * Require all conversations on code to be resolved before a pull request can be merged into a branch that + * matches this rule. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder requiredConversationResolution() { + return requiredConversationResolution(true); + } + + /** + * Require all conversations on code to be resolved before a pull request can be merged into a branch that + * matches this rule. + * Set to true to enable. Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder requiredConversationResolution(boolean v) { + fields.put("required_conversation_resolution", v); + return this; + } + + /** + * Enforce a linear commit Git history. + * + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder requiredLinearHistory() { + return requiredLinearHistory(true); + } + + /** + * Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to true + * to enforce a linear commit history. Set to false to disable a linear commit Git history. Your repository must + * allow squash merging or rebase merging before you can enable a linear commit history. + * Default: false. + * + * @param v + * the v + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder requiredLinearHistory(boolean v) { + fields.put("required_linear_history", v); + return this; + } + /** * Require reviews gh branch protection builder. * From e87665d6e88148a60fb44ced71903c9c1a366e5e Mon Sep 17 00:00:00 2001 From: Gregor Heine Date: Fri, 20 Oct 2023 19:57:19 +0100 Subject: [PATCH 21/35] Run spotless --- .../github/GHBranchProtectionBuilder.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java index 70a614894a..ec21b3168c 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java @@ -77,8 +77,8 @@ public GHBranchProtectionBuilder allowDeletions() { } /** - * Allows deletion of the protected branch by anyone with write access to the repository. - * Set to true to allow deletion of the protected branch. Default: false. + * Allows deletion of the protected branch by anyone with write access to the repository. Set to true to allow + * deletion of the protected branch. Default: false. * * @param v * the v @@ -99,8 +99,8 @@ public GHBranchProtectionBuilder allowForcePushes() { } /** - * Permits force pushes to the protected branch by anyone with write access to the repository. - * Set to true to allow force pushes. Set to false to block force pushes. Default: false. + * Permits force pushes to the protected branch by anyone with write access to the repository. Set to true to allow + * force pushes. Set to false to block force pushes. Default: false. * * @param v * the v @@ -121,8 +121,8 @@ public GHBranchProtectionBuilder allowForkSyncing() { } /** - * Whether users can pull changes from upstream when the branch is locked. Set to true to allow fork syncing. - * Set to true to enable. Default: false. + * Whether users can pull changes from upstream when the branch is locked. Set to true to allow fork syncing. Set to + * true to enable. Default: false. * * @param v * the v @@ -225,8 +225,8 @@ public GHBranchProtectionBuilder lockBranch() { } /** - * Whether to set the branch as read-only. If this is true, users will not be able to push to the branch. - * Set to true to enable. Default: false. + * Whether to set the branch as read-only. If this is true, users will not be able to push to the branch. Set to + * true to enable. Default: false. * * @param v * the v @@ -313,8 +313,8 @@ public GHBranchProtectionBuilder requireLastPushApproval(boolean v) { } /** - * Require all conversations on code to be resolved before a pull request can be merged into a branch that - * matches this rule. + * Require all conversations on code to be resolved before a pull request can be merged into a branch that matches + * this rule. * * @return the gh branch protection builder */ @@ -323,9 +323,8 @@ public GHBranchProtectionBuilder requiredConversationResolution() { } /** - * Require all conversations on code to be resolved before a pull request can be merged into a branch that - * matches this rule. - * Set to true to enable. Default: false. + * Require all conversations on code to be resolved before a pull request can be merged into a branch that matches + * this rule. Set to true to enable. Default: false. * * @param v * the v @@ -348,8 +347,7 @@ public GHBranchProtectionBuilder requiredLinearHistory() { /** * Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to true * to enforce a linear commit history. Set to false to disable a linear commit Git history. Your repository must - * allow squash merging or rebase merging before you can enable a linear commit history. - * Default: false. + * allow squash merging or rebase merging before you can enable a linear commit history. Default: false. * * @param v * the v From b2226d8a2cd2b02c52f162f5a3351a7a78584feb Mon Sep 17 00:00:00 2001 From: Gregor Heine Date: Sun, 22 Oct 2023 16:35:51 +0100 Subject: [PATCH 22/35] Add accessors --- .../kohsuke/github/GHBranchProtection.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java index 70c837678f..49956c5d70 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtection.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java @@ -80,6 +80,33 @@ public void disableSignedCommits() throws IOException { requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send(); } + /** + * Gets allow deletions. + * + * @return the enforce admins + */ + public AllowDeletions getAllowDeletions() { + return allowDeletions; + } + + /** + * Gets allow force pushes. + * + * @return the enforce admins + */ + public AllowForcePushes getAllowForcePushes() { + return allowForcePushes; + } + + /** + * Gets block creations. + * + * @return the enforce admins + */ + public BlockCreations getBlockCreations() { + return blockCreations; + } + /** * Gets enforce admins. * @@ -89,6 +116,33 @@ public EnforceAdmins getEnforceAdmins() { return enforceAdmins; } + /** + * Gets lock branch. + * + * @return the enforce admins + */ + public LockBranch getLockBranch() { + return lockBranch; + } + + /** + * Gets required conversation resolution. + * + * @return the enforce admins + */ + public RequiredConversationResolution getRequiredConversationResolution() { + return requiredConversationResolution; + } + + /** + * Gets required linear history. + * + * @return the enforce admins + */ + public RequiredLinearHistory getRequiredLinearHistory() { + return requiredLinearHistory; + } + /** * Gets required reviews. * From 5c2fd6cfb5d96f7432c2c89f6a0d083c7a80cc6a Mon Sep 17 00:00:00 2001 From: Gregor Heine Date: Mon, 23 Oct 2023 11:25:57 +0100 Subject: [PATCH 23/35] Coverage --- .../kohsuke/github/GHBranchProtection.java | 9 ++++ .../github/GHBranchProtectionTest.java | 44 +++++++++++++++++++ ...rotections_branches_main_protection-4.json | 29 ++++++++---- ...rotections_branches_main_protection-5.json | 29 ++++++++---- ...rotections_branches_main_protection-4.json | 4 +- 5 files changed, 97 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java index 49956c5d70..834544944f 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtection.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java @@ -98,6 +98,15 @@ public AllowForcePushes getAllowForcePushes() { return allowForcePushes; } + /** + * Gets allow fork syncing. + * + * @return the enforce admins + */ + public AllowForkSyncing getAllowForkSyncing() { + return allowForkSyncing; + } + /** * Gets block creations. * diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 3624068ee5..5254b3a707 100755 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -2,7 +2,14 @@ import org.junit.Before; import org.junit.Test; +import org.kohsuke.github.GHBranchProtection.AllowDeletions; +import org.kohsuke.github.GHBranchProtection.AllowForcePushes; +import org.kohsuke.github.GHBranchProtection.AllowForkSyncing; +import org.kohsuke.github.GHBranchProtection.BlockCreations; import org.kohsuke.github.GHBranchProtection.EnforceAdmins; +import org.kohsuke.github.GHBranchProtection.LockBranch; +import org.kohsuke.github.GHBranchProtection.RequiredConversationResolution; +import org.kohsuke.github.GHBranchProtection.RequiredLinearHistory; import org.kohsuke.github.GHBranchProtection.RequiredReviews; import org.kohsuke.github.GHBranchProtection.RequiredStatusChecks; @@ -45,9 +52,17 @@ public void testEnableBranchProtections() throws Exception { .addRequiredChecks("test-status-check") .requireBranchIsUpToDate() .requireCodeOwnReviews() + .requireLastPushApproval() .dismissStaleReviews() .requiredReviewers(2) + .allowDeletions() + .allowForcePushes() + .allowForkSyncing() + .blockCreations() .includeAdmins() + .lockBranch() + .requiredConversationResolution() + .requiredLinearHistory() .enable(); verifyBranchProtection(protection); @@ -67,11 +82,40 @@ private void verifyBranchProtection(GHBranchProtection protection) { assertThat(requiredReviews, notNullValue()); assertThat(requiredReviews.isDismissStaleReviews(), is(true)); assertThat(requiredReviews.isRequireCodeOwnerReviews(), is(true)); + assertThat(requiredReviews.isRequireLastPushApproval(), is(true)); assertThat(requiredReviews.getRequiredReviewers(), equalTo(2)); + AllowDeletions allowDeletions = protection.getAllowDeletions(); + assertThat(allowDeletions, notNullValue()); + assertThat(allowDeletions.isEnabled(), is(true)); + + AllowForcePushes allowForcePushes = protection.getAllowForcePushes(); + assertThat(allowForcePushes, notNullValue()); + assertThat(allowForcePushes.isEnabled(), is(true)); + + AllowForkSyncing allowForkSyncing = protection.getAllowForkSyncing(); + assertThat(allowForkSyncing, notNullValue()); + assertThat(allowForkSyncing.isEnabled(), is(true)); + + BlockCreations blockCreations = protection.getBlockCreations(); + assertThat(blockCreations, notNullValue()); + assertThat(blockCreations.isEnabled(), is(true)); + EnforceAdmins enforceAdmins = protection.getEnforceAdmins(); assertThat(enforceAdmins, notNullValue()); assertThat(enforceAdmins.isEnabled(), is(true)); + + LockBranch lockBranch = protection.getLockBranch(); + assertThat(lockBranch, notNullValue()); + assertThat(lockBranch.isEnabled(), is(true)); + + RequiredConversationResolution requiredConversationResolution = protection.getRequiredConversationResolution(); + assertThat(requiredConversationResolution, notNullValue()); + assertThat(requiredConversationResolution.isEnabled(), is(true)); + + RequiredLinearHistory requiredLinearHistory = protection.getRequiredLinearHistory(); + assertThat(requiredLinearHistory, notNullValue()); + assertThat(requiredLinearHistory.isEnabled(), is(true)); } /** diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json index ee226bab75..a793b4cefa 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json @@ -12,19 +12,32 @@ "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/required_pull_request_reviews", "dismiss_stale_reviews": true, "require_code_owner_reviews": true, - "required_approving_review_count": 2 + "required_approving_review_count": 2, + "require_last_push_approval": true + }, + "allow_deletions": { + "enabled": true + }, + "allow_force_pushes": { + "enabled": true + }, + "allow_fork_syncing": { + "enabled": true + }, + "block_creations": { + "enabled": true }, "enforce_admins": { "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/enforce_admins", "enabled": true }, - "required_linear_history": { - "enabled": false + "lock_branch": { + "enabled": true }, - "allow_force_pushes": { - "enabled": false + "required_conversation_resolution": { + "enabled": true }, - "allow_deletions": { - "enabled": false + "required_linear_history": { + "enabled": true } -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-5.json index ee226bab75..a793b4cefa 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-5.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-5.json @@ -12,19 +12,32 @@ "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/required_pull_request_reviews", "dismiss_stale_reviews": true, "require_code_owner_reviews": true, - "required_approving_review_count": 2 + "required_approving_review_count": 2, + "require_last_push_approval": true + }, + "allow_deletions": { + "enabled": true + }, + "allow_force_pushes": { + "enabled": true + }, + "allow_fork_syncing": { + "enabled": true + }, + "block_creations": { + "enabled": true }, "enforce_admins": { "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/enforce_admins", "enabled": true }, - "required_linear_history": { - "enabled": false + "lock_branch": { + "enabled": true }, - "allow_force_pushes": { - "enabled": false + "required_conversation_resolution": { + "enabled": true }, - "allow_deletions": { - "enabled": false + "required_linear_history": { + "enabled": true } -} \ No newline at end of file +} diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json index 31a205713a..3dfbbcf036 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection-4.json @@ -11,7 +11,7 @@ }, "bodyPatterns": [ { - "equalToJson": "{\"required_pull_request_reviews\":{\"required_approving_review_count\":2,\"require_code_owner_reviews\":true,\"dismiss_stale_reviews\":true},\"required_status_checks\":{\"contexts\":[\"test-status-check\"],\"strict\":true},\"restrictions\":null,\"enforce_admins\":true}", + "equalToJson": "{\"required_pull_request_reviews\":{\"required_approving_review_count\":2,\"require_code_owner_reviews\":true,\"dismiss_stale_reviews\":true,\"require_last_push_approval\":true},\"required_status_checks\":{\"contexts\":[\"test-status-check\"],\"strict\":true},\"restrictions\":null,\"allow_deletions\":true,\"allow_force_pushes\":true,\"allow_fork_syncing\":true,\"block_creations\":true,\"enforce_admins\":true,\"lock_branch\":true,\"required_conversation_resolution\":true,\"required_linear_history\":true}", "ignoreArrayOrder": true, "ignoreExtraElements": false } @@ -49,4 +49,4 @@ "uuid": "3cdd44cf-a62c-43f6-abad-de7c8b65bfe3", "persistent": true, "insertionIndex": 4 -} \ No newline at end of file +} From 94a8592fc407de2de9488605bcb31c3c30bf1ef7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:20:30 +0000 Subject: [PATCH 24/35] Chore(deps): Bump org.apache.maven.scm:maven-scm-manager-plexus Bumps org.apache.maven.scm:maven-scm-manager-plexus from 1.13.0 to 2.0.1. --- updated-dependencies: - dependency-name: org.apache.maven.scm:maven-scm-manager-plexus dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 56086d0005..bfa2110915 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ org.apache.maven.scm maven-scm-manager-plexus - 1.13.0 + 2.0.1 From c49b667d1edb4871e400c1cca1ef31eab176b3f4 Mon Sep 17 00:00:00 2001 From: D061587 Date: Mon, 6 Nov 2023 09:16:05 +0100 Subject: [PATCH 27/35] Use reflective access to be compatible with older versions of jjwt --- .../authorization/JWTTokenProvider.java | 18 +---- .../extras/authorization/JwtBuilderUtil.java | 73 +++++++++++++++++++ .../JwtReflectiveBuilderException.java | 7 ++ .../extras/authorization/RefreshResult.java | 21 ++++++ 4 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java create mode 100644 src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java create mode 100644 src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java index 71c05eb789..0bc8fe3df6 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java @@ -1,10 +1,5 @@ package org.kohsuke.github.extras.authorization; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.jackson.io.JacksonSerializer; -import org.kohsuke.github.authorization.AuthorizationProvider; - import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -18,10 +13,11 @@ import java.time.Duration; import java.time.Instant; import java.util.Base64; -import java.util.Date; import javax.annotation.Nonnull; +import org.kohsuke.github.authorization.AuthorizationProvider; + /** * A authorization provider that gives valid JWT tokens. These tokens are then used to create a time-based token to * authenticate as an application. This token provider does not provide any kind of caching, and will always request a @@ -170,18 +166,10 @@ private String refreshJWT() { // Setting the issued at to a time in the past to allow for clock skew Instant issuedAt = getIssuedAt(now); - // Let's set the JWT Claims - JwtBuilder builder = Jwts.builder() - .issuedAt(Date.from(issuedAt)) - .expiration(Date.from(expiration)) - .issuer(this.applicationId) - .signWith(privateKey, Jwts.SIG.RS256); - // Token will refresh 2 minutes before it expires validUntil = expiration.minus(Duration.ofMinutes(2)); - // Builds the JWT and serializes it to a compact, URL-safe string - return builder.json(new JacksonSerializer<>()).compact(); + return JwtBuilderUtil.buildJwt(issuedAt, expiration, applicationId, privateKey); } Instant getIssuedAt(Instant now) { diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java new file mode 100644 index 0000000000..5c88dc87b9 --- /dev/null +++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java @@ -0,0 +1,73 @@ +package org.kohsuke.github.extras.authorization; + +import java.lang.reflect.Method; +import java.security.PrivateKey; +import java.time.Instant; +import java.util.Date; + +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.jackson.io.JacksonSerializer; + +final class JwtBuilderUtil { + private static Method getMethod(Object obj, String method, Class... params) throws NoSuchMethodException { + Class type = obj.getClass(); + return type.getMethod(method, params); + } + + private static boolean hasMethod(Object obj, String method, Class... params) { + try { + return JwtBuilderUtil.getMethod(obj, method, params) != null; + } catch (NoSuchMethodException e) { + return false; + } + } + + static String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) { + JwtBuilder jwtBuilder = Jwts.builder(); + if (JwtBuilderUtil.hasMethod(jwtBuilder, "issuedAt", Date.class)) { + jwtBuilder = jwtBuilder.issuedAt(Date.from(issuedAt)) + .expiration(Date.from(expiration)) + .issuer(applicationId) + .signWith(privateKey, Jwts.SIG.RS256); + return jwtBuilder.json(new JacksonSerializer<>()).compact(); + } + + // older jjwt library versions + try { + return JwtBuilderUtil.buildByReflection(jwtBuilder, issuedAt, expiration, applicationId, privateKey); + } catch (ReflectiveOperationException e) { + throw new JwtReflectiveBuilderException( + "Exception building a JWT with reflective access to outdated versions of jjwt. Please consider an update.", + e); + } + } + + private static String buildByReflection(JwtBuilder jwtBuilder, Instant issuedAt, Instant expiration, + String applicationId, + PrivateKey privateKey) throws ReflectiveOperationException { + + Object builderObj = jwtBuilder; + + Method setIssuedAtMethod = JwtBuilderUtil.getMethod(builderObj, "setIssuedAt", Date.class); + builderObj = setIssuedAtMethod.invoke(builderObj, Date.from(issuedAt)); + + Method setExpirationMethod = JwtBuilderUtil.getMethod(builderObj, "setExpiration", Date.class); + builderObj = setExpirationMethod.invoke(builderObj, Date.from(expiration)); + + Method setIssuerMethod = JwtBuilderUtil.getMethod(builderObj, "setIssuer", String.class); + builderObj = setIssuerMethod.invoke(builderObj, applicationId); + + Method signWithMethod = JwtBuilderUtil.getMethod(builderObj, "signWith", PrivateKey.class, + SignatureAlgorithm.class); + builderObj = signWithMethod.invoke(builderObj, privateKey, SignatureAlgorithm.RS256); + + Method serializeToJsonMethod = JwtBuilderUtil.getMethod(builderObj, "serializeToJsonWith", + JacksonSerializer.class); + builderObj = serializeToJsonMethod.invoke(builderObj, new JacksonSerializer<>()); + + JwtBuilder resultBuilder = (JwtBuilder) builderObj; + return resultBuilder.compact(); + } +} diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java new file mode 100644 index 0000000000..2e1c457215 --- /dev/null +++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java @@ -0,0 +1,7 @@ +package org.kohsuke.github.extras.authorization; + +public class JwtReflectiveBuilderException extends RuntimeException { + JwtReflectiveBuilderException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java b/src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java new file mode 100644 index 0000000000..48f5a0e11c --- /dev/null +++ b/src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java @@ -0,0 +1,21 @@ +package org.kohsuke.github.extras.authorization; + +import java.time.Instant; + +class RefreshResult { + private final Instant validUntil; + private final String jwt; + + RefreshResult(Instant validUntil, String jwt) { + this.validUntil = validUntil; + this.jwt = jwt; + } + + Instant getValidUntil() { + return this.validUntil; + } + + String getJwt() { + return this.jwt; + } +} From 462c4dae3e9429166b431cce99d8af0b2debed20 Mon Sep 17 00:00:00 2001 From: D061587 Date: Mon, 6 Nov 2023 09:20:49 +0100 Subject: [PATCH 28/35] Remove unused class --- .../extras/authorization/RefreshResult.java | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java diff --git a/src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java b/src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java deleted file mode 100644 index 48f5a0e11c..0000000000 --- a/src/main/java/org/kohsuke/github/extras/authorization/RefreshResult.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.kohsuke.github.extras.authorization; - -import java.time.Instant; - -class RefreshResult { - private final Instant validUntil; - private final String jwt; - - RefreshResult(Instant validUntil, String jwt) { - this.validUntil = validUntil; - this.jwt = jwt; - } - - Instant getValidUntil() { - return this.validUntil; - } - - String getJwt() { - return this.jwt; - } -} From 3a2db896a538c7ccc898e12bae88207e99d35b9b Mon Sep 17 00:00:00 2001 From: D061587 Date: Tue, 7 Nov 2023 10:44:54 +0100 Subject: [PATCH 29/35] Enhance documentation and add a logging statement for outdated jjwt libraries --- .../extras/authorization/JwtBuilderUtil.java | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java index 5c88dc87b9..608e8db9b5 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java @@ -4,18 +4,48 @@ import java.security.PrivateKey; import java.time.Instant; import java.util.Date; +import java.util.logging.Logger; import io.jsonwebtoken.JwtBuilder; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.jackson.io.JacksonSerializer; +/** + * This is a util to build a JWT. + * + *

+ * This class is used to build a JWT using the jjwt library. It uses reflection + * to support older versions of jjwt. The class may be removed again, once we + * are sure, we do no longer need to support pre-0.12.x versions of jjwt. + *

+ */ final class JwtBuilderUtil { + + private static final Logger LOGGER = Logger.getLogger(JwtBuilderUtil.class.getName()); + + /** + * Get a method from an object. + * + * @param obj object + * @param method method name + * @param params parameters of the method + * @return method + * @throws NoSuchMethodException if the method does not exist + */ private static Method getMethod(Object obj, String method, Class... params) throws NoSuchMethodException { Class type = obj.getClass(); return type.getMethod(method, params); } + /** + * Check if an object has a method. + * + * @param obj object + * @param method method name + * @param params parameters of the method + * @return true if the method exists + */ private static boolean hasMethod(Object obj, String method, Class... params) { try { return JwtBuilderUtil.getMethod(obj, method, params) != null; @@ -24,6 +54,15 @@ private static boolean hasMethod(Object obj, String method, Class... params) } } + /** + * Build a JWT. + * + * @param issuedAt issued at + * @param expiration expiration + * @param applicationId application id + * @param privateKey private key + * @return JWT + */ static String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) { JwtBuilder jwtBuilder = Jwts.builder(); if (JwtBuilderUtil.hasMethod(jwtBuilder, "issuedAt", Date.class)) { @@ -34,16 +73,31 @@ static String buildJwt(Instant issuedAt, Instant expiration, String applicationI return jwtBuilder.json(new JacksonSerializer<>()).compact(); } + LOGGER.warning( + "You are using an outdated version of the io.jsonwebtoken:jjwt-* suite. Please consider an update."); + // older jjwt library versions try { return JwtBuilderUtil.buildByReflection(jwtBuilder, issuedAt, expiration, applicationId, privateKey); } catch (ReflectiveOperationException e) { throw new JwtReflectiveBuilderException( - "Exception building a JWT with reflective access to outdated versions of jjwt. Please consider an update.", + "Exception building a JWT with reflective access to outdated versions of the io.jsonwebtoken:jjwt-* suite. Please consider an update.", e); } } + /** + * This method builds a JWT using older (pre 0.12.x) versions of jjwt library by + * leveraging reflection. + * + * @param jwtBuilder builder object + * @param issuedAt issued at + * @param expiration expiration + * @param applicationId application id + * @param privateKey private key + * @return JWT + * @throws ReflectiveOperationException if reflection fails + */ private static String buildByReflection(JwtBuilder jwtBuilder, Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) throws ReflectiveOperationException { From de6827263cf205e9eb41da0b0064e69094eb05fb Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 8 Nov 2023 01:52:39 -0800 Subject: [PATCH 30/35] Add testing for JWT 0.11.x to pom.xml --- pom.xml | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5f072e86c4..bd9bb94e04 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ maven-surefire-plugin - 2.22.2 + 3.2.2 false @@ -458,6 +458,18 @@ + + + + com.fasterxml.jackson + jackson-bom + 2.15.3 + import + pom + + + + org.apache.commons @@ -510,7 +522,6 @@ com.fasterxml.jackson.core jackson-databind - 2.15.2 commons-io @@ -652,7 +663,7 @@ - test-slow-multireleasejar-flaky + test-jwt-slow-multireleasejar-flaky !test @@ -715,6 +726,40 @@ src/test/resources/slow-or-flaky-tests.txt + + + jwt0.11.x-test + integration-test + + test + + + ${project.basedir}/target/github-api-${project.version}.jar + false + src/test/resources/slow-or-flaky-tests.txt + @{jacoco.surefire.argLine} ${surefire.argLine} -Dtest.github.connector=okhttp + + io.jsonwebtoken:* + + + + io.jsonwebtoken + jjwt-api + 0.11.5 + + + io.jsonwebtoken + jjwt-impl + 0.11.5 + + + io.jsonwebtoken + jjwt-jackson + 0.11.5 + + + +
From 9b0234890fc3ec1f8cd33178623b78ef9a96f754 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 8 Nov 2023 02:12:55 -0800 Subject: [PATCH 31/35] Restructured JwtBuilderUtil based on testing When I went to run tests on the reflection code I ran into a number of errors. A few were straighfoward fixes but not all. The issue requiring the biggest change as that some JWT suite classes were being loaded as the JwtBuilderUtil class was being loaded, or at least before the buildJwt() method started executing. I had to move the JWT calls into a nested class to delay the loading of JWT suite classes until inside a try-catch where I could handle it as expected. --- .../authorization/JWTTokenProvider.java | 4 +- .../extras/authorization/JwtBuilderUtil.java | 198 ++++++++++-------- 2 files changed, 113 insertions(+), 89 deletions(-) diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java index 0bc8fe3df6..cc3f3c4df5 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java @@ -1,5 +1,7 @@ package org.kohsuke.github.extras.authorization; +import org.kohsuke.github.authorization.AuthorizationProvider; + import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -16,8 +18,6 @@ import javax.annotation.Nonnull; -import org.kohsuke.github.authorization.AuthorizationProvider; - /** * A authorization provider that gives valid JWT tokens. These tokens are then used to create a time-based token to * authenticate as an application. This token provider does not provide any kind of caching, and will always request a diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java index 608e8db9b5..665935a74b 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java @@ -1,23 +1,25 @@ package org.kohsuke.github.extras.authorization; +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.io.Serializer; +import io.jsonwebtoken.jackson.io.JacksonSerializer; +import io.jsonwebtoken.security.SignatureAlgorithm; +import org.kohsuke.github.GHException; + import java.lang.reflect.Method; +import java.security.Key; import java.security.PrivateKey; import java.time.Instant; import java.util.Date; import java.util.logging.Logger; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; -import io.jsonwebtoken.jackson.io.JacksonSerializer; - /** * This is a util to build a JWT. * *

- * This class is used to build a JWT using the jjwt library. It uses reflection - * to support older versions of jjwt. The class may be removed again, once we - * are sure, we do no longer need to support pre-0.12.x versions of jjwt. + * This class is used to build a JWT using the jjwt library. It uses reflection to support older versions of jjwt. The + * class may be removed once we are sure we no longer need to support pre-0.12.x versions of jjwt. *

*/ final class JwtBuilderUtil { @@ -25,103 +27,125 @@ final class JwtBuilderUtil { private static final Logger LOGGER = Logger.getLogger(JwtBuilderUtil.class.getName()); /** - * Get a method from an object. + * Build a JWT. * - * @param obj object - * @param method method name - * @param params parameters of the method - * @return method - * @throws NoSuchMethodException if the method does not exist + * @param issuedAt + * issued at + * @param expiration + * expiration + * @param applicationId + * application id + * @param privateKey + * private key + * @return JWT */ - private static Method getMethod(Object obj, String method, Class... params) throws NoSuchMethodException { - Class type = obj.getClass(); - return type.getMethod(method, params); - } + static String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) { - /** - * Check if an object has a method. - * - * @param obj object - * @param method method name - * @param params parameters of the method - * @return true if the method exists - */ - private static boolean hasMethod(Object obj, String method, Class... params) { try { - return JwtBuilderUtil.getMethod(obj, method, params) != null; - } catch (NoSuchMethodException e) { - return false; + return DefaultBuilderImpl.buildJwt(issuedAt, expiration, applicationId, privateKey); + } catch (NoSuchMethodError | NoClassDefFoundError e) { + LOGGER.info( + "You are using an outdated version of the io.jsonwebtoken:jjwt-* suite. v0.12.x or later is recommended."); + } + + // older jjwt library versions + try { + return ReflectionBuilderImpl.buildJwt(issuedAt, expiration, applicationId, privateKey); + } catch (SecurityException | ReflectiveOperationException re) { + throw new GHException( + "Could not build JWT using reflection on io.jsonwebtoken:jjwt-* suite." + + "The minimum supported version is v0.11.x, v0.12.x or later is recommended.", + re); } } /** - * Build a JWT. + * A class to isolate loading of JWT classes allowing us to catch and handle linkage errors. * - * @param issuedAt issued at - * @param expiration expiration - * @param applicationId application id - * @param privateKey private key - * @return JWT + * Without this class, JwtBuilderUtil.buildJwt() immediately throws NoClassDefFoundError when called. With this + * class the error is thrown when DefaultBuilder.build() is called allowing us to catch and handle it. */ - static String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) { - JwtBuilder jwtBuilder = Jwts.builder(); - if (JwtBuilderUtil.hasMethod(jwtBuilder, "issuedAt", Date.class)) { + private static class DefaultBuilderImpl { + + /** + * This method builds a JWT using 0.12.x or later versions of jjwt library + * + * @param issuedAt + * issued at + * @param expiration + * expiration + * @param applicationId + * application id + * @param privateKey + * private key + * @return JWT + */ + private static String buildJwt(Instant issuedAt, + Instant expiration, + String applicationId, + PrivateKey privateKey) { + + // io.jsonwebtoken.security.SignatureAlgorithm is not present in v0.11.x and below. + // Trying to call a method that uses it causes "NoClassDefFoundError" if v0.11.x is being used. + SignatureAlgorithm rs256 = Jwts.SIG.RS256; + + JwtBuilder jwtBuilder = Jwts.builder(); jwtBuilder = jwtBuilder.issuedAt(Date.from(issuedAt)) .expiration(Date.from(expiration)) .issuer(applicationId) - .signWith(privateKey, Jwts.SIG.RS256); - return jwtBuilder.json(new JacksonSerializer<>()).compact(); - } - - LOGGER.warning( - "You are using an outdated version of the io.jsonwebtoken:jjwt-* suite. Please consider an update."); - - // older jjwt library versions - try { - return JwtBuilderUtil.buildByReflection(jwtBuilder, issuedAt, expiration, applicationId, privateKey); - } catch (ReflectiveOperationException e) { - throw new JwtReflectiveBuilderException( - "Exception building a JWT with reflective access to outdated versions of the io.jsonwebtoken:jjwt-* suite. Please consider an update.", - e); + .signWith(privateKey, rs256) + .json(new JacksonSerializer<>()); + return jwtBuilder.compact(); } } /** - * This method builds a JWT using older (pre 0.12.x) versions of jjwt library by - * leveraging reflection. - * - * @param jwtBuilder builder object - * @param issuedAt issued at - * @param expiration expiration - * @param applicationId application id - * @param privateKey private key - * @return JWT - * @throws ReflectiveOperationException if reflection fails + * A class to encapsulate building a JWT using reflection. */ - private static String buildByReflection(JwtBuilder jwtBuilder, Instant issuedAt, Instant expiration, - String applicationId, - PrivateKey privateKey) throws ReflectiveOperationException { - - Object builderObj = jwtBuilder; - - Method setIssuedAtMethod = JwtBuilderUtil.getMethod(builderObj, "setIssuedAt", Date.class); - builderObj = setIssuedAtMethod.invoke(builderObj, Date.from(issuedAt)); - - Method setExpirationMethod = JwtBuilderUtil.getMethod(builderObj, "setExpiration", Date.class); - builderObj = setExpirationMethod.invoke(builderObj, Date.from(expiration)); - - Method setIssuerMethod = JwtBuilderUtil.getMethod(builderObj, "setIssuer", String.class); - builderObj = setIssuerMethod.invoke(builderObj, applicationId); - - Method signWithMethod = JwtBuilderUtil.getMethod(builderObj, "signWith", PrivateKey.class, - SignatureAlgorithm.class); - builderObj = signWithMethod.invoke(builderObj, privateKey, SignatureAlgorithm.RS256); - - Method serializeToJsonMethod = JwtBuilderUtil.getMethod(builderObj, "serializeToJsonWith", - JacksonSerializer.class); - builderObj = serializeToJsonMethod.invoke(builderObj, new JacksonSerializer<>()); + private static class ReflectionBuilderImpl { + /** + * This method builds a JWT using older (pre 0.12.x) versions of jjwt library by leveraging reflection. + * + * @param issuedAt + * issued at + * @param expiration + * expiration + * @param applicationId + * application id + * @param privateKey + * private key + * @return JWTBuilder + * @throws ReflectiveOperationException + * if reflection fails + */ + private static String buildJwt(Instant issuedAt, + Instant expiration, + String applicationId, + PrivateKey privateKey) throws ReflectiveOperationException { + + JwtBuilder jwtBuilder = Jwts.builder(); + Class jwtReflectionClass = jwtBuilder.getClass(); + + Method setIssuedAtMethod = jwtReflectionClass.getMethod("setIssuedAt", Date.class); + Method setIssuerMethod = jwtReflectionClass.getMethod("setIssuer", String.class); + Method setExpirationMethod = jwtReflectionClass.getMethod("setExpiration", Date.class); + Class signatureAlgorithmClass = Class.forName("io.jsonwebtoken.SignatureAlgorithm"); + Enum rs256SignatureAlgorithm = createEnumInstance(signatureAlgorithmClass, "RS256"); + Method signWithMethod = jwtReflectionClass.getMethod("signWith", Key.class, signatureAlgorithmClass); + Method serializeToJsonMethod = jwtReflectionClass.getMethod("serializeToJsonWith", Serializer.class); + + Object builderObj = jwtBuilder; + builderObj = setIssuedAtMethod.invoke(builderObj, Date.from(issuedAt)); + builderObj = setExpirationMethod.invoke(builderObj, Date.from(expiration)); + builderObj = setIssuerMethod.invoke(builderObj, applicationId); + builderObj = signWithMethod.invoke(builderObj, privateKey, rs256SignatureAlgorithm); + builderObj = serializeToJsonMethod.invoke(builderObj, new JacksonSerializer<>()); + return ((JwtBuilder) builderObj).compact(); + } - JwtBuilder resultBuilder = (JwtBuilder) builderObj; - return resultBuilder.compact(); + @SuppressWarnings("unchecked") + private static > T createEnumInstance(Class type, String name) { + return Enum.valueOf((Class) type, name); + } } } From 7dff4b45f26b34f6d5ee3dfbba7056f1dca94888 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 8 Nov 2023 02:18:20 -0800 Subject: [PATCH 32/35] Move some test to the slow test list --- src/test/resources/slow-or-flaky-tests.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/resources/slow-or-flaky-tests.txt b/src/test/resources/slow-or-flaky-tests.txt index e0aa93a72e..5e36cd96d4 100644 --- a/src/test/resources/slow-or-flaky-tests.txt +++ b/src/test/resources/slow-or-flaky-tests.txt @@ -1,5 +1,8 @@ **/extras/** +**/AbuseLimitHandlerTest **/GHRateLimitTest +**/GHPullRequestTest +**/GitHubStaticTest **/RequesterRetryTest **/RateLimitCheckerTest **/RateLimitHandlerTest From 8c51f6b227cf338d9955ccc6d022a8f5ccb2b991 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 8 Nov 2023 02:26:20 -0800 Subject: [PATCH 33/35] Remove JwtReflectiveBuilderException --- .../authorization/JwtReflectiveBuilderException.java | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java deleted file mode 100644 index 2e1c457215..0000000000 --- a/src/main/java/org/kohsuke/github/extras/authorization/JwtReflectiveBuilderException.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.kohsuke.github.extras.authorization; - -public class JwtReflectiveBuilderException extends RuntimeException { - JwtReflectiveBuilderException(String msg, Throwable cause) { - super(msg, cause); - } -} From dbef88278e855f6114cc3c76d053ac72acf18d74 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 8 Nov 2023 02:36:40 -0800 Subject: [PATCH 34/35] Slow test list adjustment for coverage --- src/test/resources/slow-or-flaky-tests.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/resources/slow-or-flaky-tests.txt b/src/test/resources/slow-or-flaky-tests.txt index 5e36cd96d4..6b1b48fe7b 100644 --- a/src/test/resources/slow-or-flaky-tests.txt +++ b/src/test/resources/slow-or-flaky-tests.txt @@ -1,8 +1,6 @@ **/extras/** -**/AbuseLimitHandlerTest **/GHRateLimitTest **/GHPullRequestTest -**/GitHubStaticTest **/RequesterRetryTest **/RateLimitCheckerTest **/RateLimitHandlerTest From ef87bb77f55ca9ae2f70a53d626872fa64189fe8 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 9 Nov 2023 13:22:06 -0800 Subject: [PATCH 35/35] Convert JWTBuildImpl to instances This makes it so we only need to check once for which implementation to use. --- .../extras/authorization/JwtBuilderUtil.java | 117 +++++++++++++----- 1 file changed, 84 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java index 665935a74b..754b2f315c 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java @@ -7,6 +7,7 @@ import io.jsonwebtoken.security.SignatureAlgorithm; import org.kohsuke.github.GHException; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.Key; import java.security.PrivateKey; @@ -26,6 +27,8 @@ final class JwtBuilderUtil { private static final Logger LOGGER = Logger.getLogger(JwtBuilderUtil.class.getName()); + private static IJwtBuilder builder; + /** * Build a JWT. * @@ -40,33 +43,66 @@ final class JwtBuilderUtil { * @return JWT */ static String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) { + if (builder == null) { + createBuilderImpl(issuedAt, expiration, applicationId, privateKey); + } + return builder.buildJwt(issuedAt, expiration, applicationId, privateKey); + } + private static void createBuilderImpl(Instant issuedAt, + Instant expiration, + String applicationId, + PrivateKey privateKey) { + // Figure out which builder to use and cache it. We don't worry about thread safety here because we're fine if + // the builder is assigned multiple times. The end result will be the same. try { - return DefaultBuilderImpl.buildJwt(issuedAt, expiration, applicationId, privateKey); + builder = new DefaultBuilderImpl(); } catch (NoSuchMethodError | NoClassDefFoundError e) { - LOGGER.info( + LOGGER.warning( "You are using an outdated version of the io.jsonwebtoken:jjwt-* suite. v0.12.x or later is recommended."); - } - // older jjwt library versions - try { - return ReflectionBuilderImpl.buildJwt(issuedAt, expiration, applicationId, privateKey); - } catch (SecurityException | ReflectiveOperationException re) { - throw new GHException( - "Could not build JWT using reflection on io.jsonwebtoken:jjwt-* suite." - + "The minimum supported version is v0.11.x, v0.12.x or later is recommended.", - re); + try { + ReflectionBuilderImpl reflectionBuider = new ReflectionBuilderImpl(); + // Build a JWT to eagerly check for any reflection errors. + reflectionBuider.buildJwtWithReflection(issuedAt, expiration, applicationId, privateKey); + + builder = reflectionBuider; + } catch (ReflectiveOperationException re) { + throw new GHException( + "Could not build JWT using reflection on io.jsonwebtoken:jjwt-* suite." + + "The minimum supported version is v0.11.x, v0.12.x or later is recommended.", + re); + } } } + /** + * IJwtBuilder interface to isolate loading of JWT classes allowing us to catch and handle linkage errors. + */ + interface IJwtBuilder { + /** + * Build a JWT. + * + * @param issuedAt + * issued at + * @param expiration + * expiration + * @param applicationId + * application id + * @param privateKey + * private key + * @return JWT + */ + String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey); + } + /** * A class to isolate loading of JWT classes allowing us to catch and handle linkage errors. * * Without this class, JwtBuilderUtil.buildJwt() immediately throws NoClassDefFoundError when called. With this * class the error is thrown when DefaultBuilder.build() is called allowing us to catch and handle it. */ - private static class DefaultBuilderImpl { - + private static class DefaultBuilderImpl implements IJwtBuilder { /** * This method builds a JWT using 0.12.x or later versions of jjwt library * @@ -80,10 +116,7 @@ private static class DefaultBuilderImpl { * private key * @return JWT */ - private static String buildJwt(Instant issuedAt, - Instant expiration, - String applicationId, - PrivateKey privateKey) { + public String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) { // io.jsonwebtoken.security.SignatureAlgorithm is not present in v0.11.x and below. // Trying to call a method that uses it causes "NoClassDefFoundError" if v0.11.x is being used. @@ -102,7 +135,28 @@ private static String buildJwt(Instant issuedAt, /** * A class to encapsulate building a JWT using reflection. */ - private static class ReflectionBuilderImpl { + private static class ReflectionBuilderImpl implements IJwtBuilder { + + private Method setIssuedAtMethod; + private Method setExpirationMethod; + private Method setIssuerMethod; + private Enum rs256SignatureAlgorithm; + private Method signWithMethod; + private Method serializeToJsonMethod; + + ReflectionBuilderImpl() throws ReflectiveOperationException { + JwtBuilder jwtBuilder = Jwts.builder(); + Class jwtReflectionClass = jwtBuilder.getClass(); + + setIssuedAtMethod = jwtReflectionClass.getMethod("setIssuedAt", Date.class); + setIssuerMethod = jwtReflectionClass.getMethod("setIssuer", String.class); + setExpirationMethod = jwtReflectionClass.getMethod("setExpiration", Date.class); + Class signatureAlgorithmClass = Class.forName("io.jsonwebtoken.SignatureAlgorithm"); + rs256SignatureAlgorithm = createEnumInstance(signatureAlgorithmClass, "RS256"); + signWithMethod = jwtReflectionClass.getMethod("signWith", Key.class, signatureAlgorithmClass); + serializeToJsonMethod = jwtReflectionClass.getMethod("serializeToJsonWith", Serializer.class); + } + /** * This method builds a JWT using older (pre 0.12.x) versions of jjwt library by leveraging reflection. * @@ -115,25 +169,22 @@ private static class ReflectionBuilderImpl { * @param privateKey * private key * @return JWTBuilder - * @throws ReflectiveOperationException - * if reflection fails */ - private static String buildJwt(Instant issuedAt, + public String buildJwt(Instant issuedAt, Instant expiration, String applicationId, PrivateKey privateKey) { + + try { + return buildJwtWithReflection(issuedAt, expiration, applicationId, privateKey); + } catch (ReflectiveOperationException e) { + // This should never happen. Reflection errors should have been caught during initialization. + throw new GHException("Reflection errors during JWT creation should have been checked already.", e); + } + } + + private String buildJwtWithReflection(Instant issuedAt, Instant expiration, String applicationId, - PrivateKey privateKey) throws ReflectiveOperationException { - + PrivateKey privateKey) throws IllegalAccessException, InvocationTargetException { JwtBuilder jwtBuilder = Jwts.builder(); - Class jwtReflectionClass = jwtBuilder.getClass(); - - Method setIssuedAtMethod = jwtReflectionClass.getMethod("setIssuedAt", Date.class); - Method setIssuerMethod = jwtReflectionClass.getMethod("setIssuer", String.class); - Method setExpirationMethod = jwtReflectionClass.getMethod("setExpiration", Date.class); - Class signatureAlgorithmClass = Class.forName("io.jsonwebtoken.SignatureAlgorithm"); - Enum rs256SignatureAlgorithm = createEnumInstance(signatureAlgorithmClass, "RS256"); - Method signWithMethod = jwtReflectionClass.getMethod("signWith", Key.class, signatureAlgorithmClass); - Method serializeToJsonMethod = jwtReflectionClass.getMethod("serializeToJsonWith", Serializer.class); - Object builderObj = jwtBuilder; builderObj = setIssuedAtMethod.invoke(builderObj, Date.from(issuedAt)); builderObj = setExpirationMethod.invoke(builderObj, Date.from(expiration));