-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: default headers were being added twice to requests to the pact b…
…roker #1242
- Loading branch information
Ronald Holshausen
committed
Nov 6, 2020
1 parent
a648c7a
commit 940fc83
Showing
9 changed files
with
71 additions
and
29 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
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
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
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
20 changes: 20 additions & 0 deletions
20
core/support/src/test/groovy/au/com/dius/pact/core/support/HttpClientSpec.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,20 @@ | ||
package au.com.dius.pact.core.support | ||
|
||
import spock.lang.Specification | ||
|
||
class HttpClientSpec extends Specification { | ||
|
||
def 'when creating a new http client, add any authentication as default headers'() { | ||
given: | ||
URI uri = new URI('http://localhost') | ||
def authentication = ['bearer', '1234abcd'] | ||
|
||
when: | ||
def result = HttpClient.INSTANCE.newHttpClient(authentication, uri, 1, 1) | ||
def defaultHeaders = result.component1().closeables[0].this$0.defaultHeaders | ||
|
||
then: | ||
defaultHeaders[0].name == 'Authorization' | ||
defaultHeaders[0].value == 'Bearer 1234abcd' | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/FooControllerTest.java
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,35 @@ | ||
package au.com.dius.pact.provider.spring.junit5; | ||
|
||
import au.com.dius.pact.provider.junit5.PactVerificationContext; | ||
import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; | ||
import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify; | ||
import au.com.dius.pact.provider.junitsupport.Provider; | ||
import au.com.dius.pact.provider.junitsupport.loader.PactBroker; | ||
import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.TestTemplate; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.web.server.LocalServerPort; | ||
|
||
/* | ||
This is a test for issue https://github.com/pact-foundation/pact-jvm/issues/1242 | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@Provider("Foo Provider") | ||
@PactBroker(scheme="https", host = "test.pactflow.io", port = "443", authentication = @PactBrokerAuth(token = "anyToken")) | ||
@IgnoreNoPactsToVerify(ignoreIoErrors = "true") | ||
class FooControllerTest { | ||
|
||
@LocalServerPort | ||
int port; | ||
|
||
@BeforeEach | ||
void setup(PactVerificationContext context) { | ||
} | ||
|
||
@TestTemplate | ||
@ExtendWith(PactVerificationInvocationContextProvider.class) | ||
void pactVerificationTestTemplate(PactVerificationContext context) { | ||
} | ||
} |