From fe6c5e840afa07245f94a6328774350c4cd654f2 Mon Sep 17 00:00:00 2001 From: Frank Chiarulli Jr Date: Thu, 21 Apr 2022 15:20:11 -0400 Subject: [PATCH 1/9] Use mailto: for all email links Since the email links do not start with `mailto:` they are treated as relative links. Adding this allows the links to easily be opened in your default mail client. --- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 93ad825..9cc0f85 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -60,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -[this email](nights-watch@bisnode.com). +[this email](mailto:nights-watch@bisnode.com). All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 50fcf6d..be5e3c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,15 +41,15 @@ For something that is bigger than a few line fix: # How to report a bug -If you find a security vulnerability, do NOT open an issue. Email [maintainers](nights-watch@bisnode.com) instead. +If you find a security vulnerability, do NOT open an issue. Email [maintainers](mailto:nights-watch@bisnode.com) instead. -Any security issues should be submitted directly to [maintainers](nights-watch@bisnode.com) +Any security issues should be submitted directly to [maintainers](mailto:nights-watch@bisnode.com) In order to determine whether you are dealing with a security issue, ask yourself these two questions: * Can I access something that's not mine, or something I shouldn't have access to? * Can I disable something for other people? -If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, just [email us](nights-watch@bisnode.com). +If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, just [email us](mailto:nights-watch@bisnode.com). When filing an issue, make sure to answer these five questions: From f2f4cdf807fd28cc501423644dc2583c8cd0c00c Mon Sep 17 00:00:00 2001 From: ian4h Date: Mon, 25 Jul 2022 09:10:00 -0700 Subject: [PATCH 2/9] Allows for configuring a custom ObjectMapper (#47) * Allow for configuring a custom ObjectMapper This change modifies the OpaClient builder to optionally take a custom ObjectMapper. --- build.gradle.kts | 1 + .../com/bisnode/opa/client/OpaClient.java | 12 ++- .../opa/client/OpaClientBuilderSpec.groovy | 78 +++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/test/groovy/com/bisnode/opa/client/OpaClientBuilderSpec.groovy diff --git a/build.gradle.kts b/build.gradle.kts index 6f31f31..b3688b0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,6 +27,7 @@ dependencies { testImplementation("org.codehaus.groovy:groovy-all:2.5.15") testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") testImplementation("com.github.tomakehurst:wiremock-jre8:2.31.0") + testImplementation("net.bytebuddy:byte-buddy:1.12.12") } repositories { diff --git a/src/main/java/com/bisnode/opa/client/OpaClient.java b/src/main/java/com/bisnode/opa/client/OpaClient.java index cfd2411..ffbe7a7 100644 --- a/src/main/java/com/bisnode/opa/client/OpaClient.java +++ b/src/main/java/com/bisnode/opa/client/OpaClient.java @@ -12,10 +12,12 @@ import com.bisnode.opa.client.query.QueryForDocumentRequest; import com.bisnode.opa.client.rest.ObjectMapperFactory; import com.bisnode.opa.client.rest.OpaRestClient; +import com.fasterxml.jackson.databind.ObjectMapper; import java.lang.reflect.ParameterizedType; import java.net.http.HttpClient; import java.util.Objects; +import java.util.Optional; /** * Opa client featuring {@link OpaDataApi}, {@link OpaQueryApi} and {@link OpaPolicyApi} @@ -72,6 +74,7 @@ public void createOrUpdatePolicy(OpaPolicy policy) { */ public static class Builder { private OpaConfiguration opaConfiguration; + private ObjectMapper objectMapper; /** * @param url URL including protocol and port @@ -81,12 +84,19 @@ public Builder opaConfiguration(String url) { return this; } + public Builder objectMapper(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + return this; + } + public OpaClient build() { Objects.requireNonNull(opaConfiguration, "build() called without opaConfiguration provided"); HttpClient httpClient = HttpClient.newBuilder() .version(opaConfiguration.getHttpVersion()) .build(); - OpaRestClient opaRestClient = new OpaRestClient(opaConfiguration, httpClient, ObjectMapperFactory.getInstance().create()); + ObjectMapper objectMapper = Optional.ofNullable(this.objectMapper) + .orElseGet(ObjectMapperFactory.getInstance()::create); + OpaRestClient opaRestClient = new OpaRestClient(opaConfiguration, httpClient, objectMapper); return new OpaClient(new OpaQueryClient(opaRestClient), new OpaDataClient(opaRestClient), new OpaPolicyClient(opaRestClient)); } } diff --git a/src/test/groovy/com/bisnode/opa/client/OpaClientBuilderSpec.groovy b/src/test/groovy/com/bisnode/opa/client/OpaClientBuilderSpec.groovy new file mode 100644 index 0000000..e0024cc --- /dev/null +++ b/src/test/groovy/com/bisnode/opa/client/OpaClientBuilderSpec.groovy @@ -0,0 +1,78 @@ +package com.bisnode.opa.client + + +import com.bisnode.opa.client.query.QueryForDocumentRequest +import com.bisnode.opa.client.rest.ContentType +import com.fasterxml.jackson.databind.ObjectMapper +import com.github.tomakehurst.wiremock.WireMockServer +import spock.lang.Shared +import spock.lang.Specification + +import static com.bisnode.opa.client.rest.ContentType.Values.APPLICATION_JSON +import static com.github.tomakehurst.wiremock.client.WireMock.* + +class OpaClientBuilderSpec extends Specification { + + private static int PORT = 8181 + private static String url = "http://localhost:$PORT" + + @Shared + private WireMockServer wireMockServer = new WireMockServer(PORT) + + def setupSpec() { + wireMockServer.start() + } + + def cleanupSpec() { + wireMockServer.stop() + } + + def 'should configure OpaClient with custom ObjectMapper'() { + + given: + def objectMapper = Spy(ObjectMapper) + def path = 'someDocument' + def endpoint = "/v1/data/$path" + wireMockServer + .stubFor(post(urlEqualTo(endpoint)) + .withHeader(ContentType.HEADER_NAME, equalTo(APPLICATION_JSON)) + .willReturn(aResponse() + .withStatus(200) + .withHeader(ContentType.HEADER_NAME, APPLICATION_JSON) + .withBody('{"result": {"authorized": true}}'))) + def opaClient = OpaClient.builder() + .opaConfiguration(url) + .objectMapper(objectMapper) + .build(); + + when: + opaClient.queryForDocument(new QueryForDocumentRequest([shouldPass: true], path), Object.class) + + then: + 1 * objectMapper.writeValueAsString(_) + } + + def 'should revert to default ObjectMapper if null ObjectMapper supplied'() { + given: + def path = 'someDocument' + def endpoint = "/v1/data/$path" + wireMockServer + .stubFor(post(urlEqualTo(endpoint)) + .withHeader(ContentType.HEADER_NAME, equalTo(APPLICATION_JSON)) + .willReturn(aResponse() + .withStatus(200) + .withHeader(ContentType.HEADER_NAME, APPLICATION_JSON) + .withBody('{"result": {"authorized": true}}'))) + def opaClient = OpaClient.builder() + .opaConfiguration(url) + .objectMapper(null) + .build(); + + when: + def result = opaClient.queryForDocument(new QueryForDocumentRequest([shouldPass: true], path), Map.class) + + then: + result != null + result.get("authorized") == true + } +} From 88e8dba9239492d0e7d03e6e4691e3a84c9a316b Mon Sep 17 00:00:00 2001 From: Igor Rodzik Date: Tue, 26 Jul 2022 09:39:29 +0200 Subject: [PATCH 3/9] Release 0.4.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b3688b0..952b47b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ import org.gradle.api.JavaVersion.VERSION_11 import java.util.* -version = "0.3.1" +version = "0.4.0" group = "com.bisnode.opa" plugins { From ec44326814b3e3cfd63b8552736065f2c3ef76ae Mon Sep 17 00:00:00 2001 From: Igor Rodzik Date: Thu, 21 Sep 2023 13:56:01 +0200 Subject: [PATCH 4/9] Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a35c2aa --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gradle" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From 1ad66633add6dd74c2b67630f247afa3c6c03e2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:09:26 +0200 Subject: [PATCH 5/9] Bump org.junit.vintage:junit-vintage-engine from 5.8.1 to 5.10.0 (#52) Bumps [org.junit.vintage:junit-vintage-engine](https://github.com/junit-team/junit5) from 5.8.1 to 5.10.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.8.1...r5.10.0) --- updated-dependencies: - dependency-name: org.junit.vintage:junit-vintage-engine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 952b47b..ca782b8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,7 +23,7 @@ dependencies { implementation("org.slf4j:slf4j-api:1.7.32") testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") - testImplementation("org.junit.vintage:junit-vintage-engine:5.8.1") + testImplementation("org.junit.vintage:junit-vintage-engine:5.10.0") testImplementation("org.codehaus.groovy:groovy-all:2.5.15") testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") testImplementation("com.github.tomakehurst:wiremock-jre8:2.31.0") From 63218bcdb16a0d3ad8d86e9a156921e0cd206eb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:10:04 +0200 Subject: [PATCH 6/9] Bump net.bytebuddy:byte-buddy from 1.12.12 to 1.14.8 (#51) Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.12.12 to 1.14.8. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.12.12...byte-buddy-1.14.8) --- updated-dependencies: - dependency-name: net.bytebuddy:byte-buddy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index ca782b8..75f9e12 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,7 +27,7 @@ dependencies { testImplementation("org.codehaus.groovy:groovy-all:2.5.15") testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") testImplementation("com.github.tomakehurst:wiremock-jre8:2.31.0") - testImplementation("net.bytebuddy:byte-buddy:1.12.12") + testImplementation("net.bytebuddy:byte-buddy:1.14.8") } repositories { From 38dfdd19f4e84b3316a6b5ca46a702e98b268043 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:10:47 +0200 Subject: [PATCH 7/9] Bump com.fasterxml.jackson.core:jackson-databind from 2.13.0 to 2.15.2 (#50) Bumps [com.fasterxml.jackson.core:jackson-databind](https://github.com/FasterXML/jackson) from 2.13.0 to 2.15.2. - [Commits](https://github.com/FasterXML/jackson/commits) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 75f9e12..d353835 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ java { withSourcesJar() } dependencies { - implementation("com.fasterxml.jackson.core:jackson-databind:2.13.0") + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2") implementation("org.slf4j:slf4j-api:1.7.32") testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") From b617e5f033fd6d9a9bf41bae59b2c35e621ba4ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:13:34 +0200 Subject: [PATCH 8/9] Bump org.junit.jupiter:junit-jupiter-api from 5.8.1 to 5.10.0 (#49) Bumps [org.junit.jupiter:junit-jupiter-api](https://github.com/junit-team/junit5) from 5.8.1 to 5.10.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.8.1...r5.10.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index d353835..5c711dc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2") implementation("org.slf4j:slf4j-api:1.7.32") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") testImplementation("org.junit.vintage:junit-vintage-engine:5.10.0") testImplementation("org.codehaus.groovy:groovy-all:2.5.15") testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") From b59e878ca986752772aa0f9e72ae49b094fa7d05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:25:44 +0200 Subject: [PATCH 9/9] Bump org.codehaus.groovy:groovy-all from 2.5.15 to 3.0.19 (#53) * Bump org.codehaus.groovy:groovy-all from 2.5.15 to 3.0.19 Bumps [org.codehaus.groovy:groovy-all](https://github.com/apache/groovy) from 2.5.15 to 3.0.19. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.codehaus.groovy:groovy-all dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Bump also spock to match groovy version --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Igor Rodzik --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5c711dc..c3c21a6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,8 +24,8 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") testImplementation("org.junit.vintage:junit-vintage-engine:5.10.0") - testImplementation("org.codehaus.groovy:groovy-all:2.5.15") - testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") + testImplementation("org.codehaus.groovy:groovy-all:3.0.19") + testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") testImplementation("com.github.tomakehurst:wiremock-jre8:2.31.0") testImplementation("net.bytebuddy:byte-buddy:1.14.8") }