use of au.com.dius.pact.consumer.junit.PactVerification in project pact-jvm by DiUS.
the class PactProviderHttpsKeystoreTest method testSslHandshakeException.
@Test(expected = SSLHandshakeException.class)
@PactVerification(value = "test_provider")
public void testSslHandshakeException() throws IOException {
testKeystoreHappyPath();
new ConsumerHttpsClient(mockTestProvider.getConfig().url()).getAsMap("/", "");
}
use of au.com.dius.pact.consumer.junit.PactVerification in project pact-jvm by DiUS.
the class PactProviderHttpsKeystoreTest method testMisMatchedTrustStore.
@Test(expected = SSLHandshakeException.class)
@PactVerification(value = "test_provider")
public void testMisMatchedTrustStore() {
testKeystoreHappyPath();
// Used the following command to create jks file:
// keytool -genkeypair -alias localhost -keyalg RSA -validity 36500 -keystore pact-jvm-other.jks
File trustStore = Paths.get("src/test/resources/keystore/pact-jvm-other.jks").toFile();
RestAssured.given().header("testreqheader", "testreqheadervalue").trustStore(trustStore, "bbarkewashere").when().options(mockTestProvider.getConfig().url() + "/second").then().statusCode(200);
}
use of au.com.dius.pact.consumer.junit.PactVerification in project pact-jvm by DiUS.
the class PactProviderHttpsKeystoreTest method testKeystoreHappyPath.
@Test
@PactVerification(value = "test_provider")
public void testKeystoreHappyPath() {
MockHttpsKeystoreProviderConfig config = (MockHttpsKeystoreProviderConfig) mockTestProvider.getConfig();
LOGGER.info("Keystore path: " + config.getKeystore());
RestAssured.given().header("testreqheader", "testreqheadervalue").trustStore(config.getKeystore(), config.getPassword()).when().options(mockTestProvider.getConfig().url() + "/second").then().statusCode(200);
RestAssured.given().header("testreqheader", "testreqheadervalue").trustStore(config.getKeystore(), config.getPassword()).when().get(mockTestProvider.getConfig().url() + "/").then().body("responsetest", Matchers.equalTo(true)).body("name", Matchers.equalTo("harry"));
}
use of au.com.dius.pact.consumer.junit.PactVerification in project pact-jvm by DiUS.
the class PactProviderTest method runTest.
@Test
@PactVerification(value = "test_provider")
public void runTest() throws IOException {
Assert.assertEquals(new ConsumerClient(mockTestProvider.getUrl()).options("/second"), 200);
Map expectedResponse = new HashMap();
expectedResponse.put("responsetest", true);
expectedResponse.put("name", "harry");
assertEquals(new ConsumerClient(mockTestProvider.getUrl()).getAsMap("/", ""), expectedResponse);
}
use of au.com.dius.pact.consumer.junit.PactVerification in project pact-jvm by DiUS.
the class StatusCodeMatcherPactTest method runTest.
@Test
@PactVerification
public void runTest() throws IOException {
Map expectedResponse = Map.of("responsetest", true, "version", "v3");
assertEquals(new ConsumerClient(mockTestProvider.getUrl()).getAsMap("/", ""), expectedResponse);
}
Aggregations