-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/update-readme
- Loading branch information
Showing
6 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]([email protected]). | ||
[this email](mailto:[email protected]). | ||
All complaints will be reviewed and investigated promptly and fairly. | ||
|
||
All community leaders are obligated to respect the privacy and security of the | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]([email protected]) instead. | ||
If you find a security vulnerability, do NOT open an issue. Email [maintainers](mailto:[email protected]) instead. | ||
|
||
|
||
Any security issues should be submitted directly to [maintainers]([email protected]) | ||
Any security issues should be submitted directly to [maintainers](mailto:[email protected]) | ||
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]([email protected]). | ||
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:[email protected]). | ||
|
||
When filing an issue, make sure to answer these five questions: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/test/groovy/com/bisnode/opa/client/OpaClientBuilderSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |