Skip to content

Commit

Permalink
Merge pull request #51 from pact-foundation/bugfix/openssl
Browse files Browse the repository at this point in the history
Bugfix/openssl
  • Loading branch information
nbrink91 authored Mar 5, 2018
2 parents e83f0d3 + aae0842 commit a63bf10
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Table of contents
* [Tips](#tips)
* [Starting API Asynchronously](#starting-api-asynchronously)
* [Set Up Provider State](#set-up-provider-state)
*
* [Examples](#additional-examples)


## Versions
Expand Down Expand Up @@ -200,7 +200,7 @@ Create a single unit test function. This will test a single consumer of the serv

##### Start API

Get an instance of the API up and running. [Click here](#starting-your-api) for some tips.
Get an instance of the API up and running. [Click here](#starting-api-asynchronously) for some tips.

If you need to set up the state of your API before making each request please see [Set Up Provider State](#set-up-provider-state).

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"require": {
"php": "^7.0",
"ext-openssl": "*",
"symfony/process": "^3.0",
"symfony/filesystem": "^3.0",
"guzzlehttp/guzzle": "^6.3",
Expand Down
25 changes: 24 additions & 1 deletion src/PhpPact/Broker/Service/BrokerHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,30 @@ public function tag(string $consumer, string $version, string $tag)
*/
public function getAllConsumerUrls(string $provider, string $version = 'latest'): array
{
$uri = $this->baseUri->withPath("pacts/provider/{$provider}/latest");
$uri = $this->baseUri->withPath("pacts/provider/{$provider}/{$version}");

$response = $this->httpClient->get($uri, [
'headers' => [
'Content-Type' => 'application/json'
]
]);

$json = \json_decode($response->getBody()->getContents(), true);

$urls = [];
foreach ($json['_links']['pacts'] as $pact) {
$urls[] = $pact['href'];
}

return $urls;
}

/**
* @inheritDoc
*/
public function getAllConsumerUrlsForTag(string $provider, string $tag): array
{
$uri = $this->baseUri->withPath("pacts/provider/{$provider}/latest/{$tag}");

$response = $this->httpClient->get($uri, [
'headers' => [
Expand Down
10 changes: 10 additions & 0 deletions src/PhpPact/Broker/Service/BrokerHttpClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@ public function tag(string $consumer, string $version, string $tag);
* @return string[]
*/
public function getAllConsumerUrls(string $provider, string $version = 'latest'): array;

/**
* Get all Pact URLs for a specific tag.
*
* @param string $provider
* @param string $tag
*
* @return array
*/
public function getAllConsumerUrlsForTag(string $provider, string $tag): array;
}
11 changes: 8 additions & 3 deletions src/PhpPact/Standalone/Installer/Service/InstallerLinux.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function install(string $destinationDir): Scripts
$fs = new Filesystem();

if ($fs->exists($destinationDir . DIRECTORY_SEPARATOR . 'pact') === false) {
$version = '1.22.1';
$version = '1.29.2';
$fileName = "pact-{$version}-linux-x86_64.tar.gz";
$tempFilePath = \sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileName;

Expand Down Expand Up @@ -54,13 +54,18 @@ public function install(string $destinationDir): Scripts
*/
private function download(string $fileName, string $tempFilePath): self
{
$uri = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.22.1/{$fileName}";
$uri = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.29.2/{$fileName}";

$data = \file_get_contents($uri);

if ($data === false) {
throw new FileDownloadFailureException('Failed to download binary from Github for Ruby Standalone!');
}

$result = \file_put_contents($tempFilePath, $data);

if ($result === false) {
throw new FileDownloadFailureException('Failed to download file.');
throw new FileDownloadFailureException('Failed to save binaries for Ruby Standalone!');
}

return $this;
Expand Down
11 changes: 8 additions & 3 deletions src/PhpPact/Standalone/Installer/Service/InstallerMac.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function install(string $destinationDir): Scripts
$fs = new Filesystem();

if ($fs->exists($destinationDir . DIRECTORY_SEPARATOR . 'pact') === false) {
$version = '1.22.1';
$version = '1.29.2';
$fileName = "pact-{$version}-osx.tar.gz";
$tempFilePath = \sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileName;

Expand Down Expand Up @@ -54,13 +54,18 @@ public function install(string $destinationDir): Scripts
*/
private function download(string $fileName, string $tempFilePath): self
{
$uri = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.22.1/{$fileName}";
$uri = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.29.2/{$fileName}";

$data = \file_get_contents($uri);

if ($data === false) {
throw new FileDownloadFailureException('Failed to download binary from Github for Ruby Standalone!');
}

$result = \file_put_contents($tempFilePath, $data);

if ($result === false) {
throw new FileDownloadFailureException('Failed to download file.');
throw new FileDownloadFailureException('Failed to save binaries for Ruby Standalone!');
}

return $this;
Expand Down
15 changes: 10 additions & 5 deletions src/PhpPact/Standalone/Installer/Service/InstallerWindows.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function install(string $destinationDir): Scripts
$fs = new Filesystem();

if ($fs->exists($destinationDir . DIRECTORY_SEPARATOR . 'pact') === false) {
$version = '1.22.1';
$version = '1.29.2';
$fileName = "pact-{$version}-win32.zip";
$tempFilePath = \sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileName;
$tempFilePath = __DIR__ . DIRECTORY_SEPARATOR . $fileName;

$this
->download($fileName, $tempFilePath)
Expand All @@ -41,7 +41,7 @@ public function install(string $destinationDir): Scripts

$binDir = $destinationDir . DIRECTORY_SEPARATOR . 'pact' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR;
$scripts = new Scripts(
$binDir . 'pact-mock-service.bat',
$binDir . 'pact-mock-service.bat',
$binDir . 'pact-provider-verifier.bat'
);

Expand All @@ -60,13 +60,18 @@ public function install(string $destinationDir): Scripts
*/
private function download(string $fileName, string $tempFilePath): self
{
$uri = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.22.1/{$fileName}";
$uri = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.29.2/{$fileName}";

$data = \file_get_contents($uri);

if ($data === false) {
throw new FileDownloadFailureException('Failed to download binary from Github for Ruby Standalone!');
}

$result = \file_put_contents($tempFilePath, $data);

if ($result === false) {
throw new FileDownloadFailureException('Failed to download file.');
throw new FileDownloadFailureException('Failed to save binaries for Ruby Standalone!');
}

return $this;
Expand Down
2 changes: 2 additions & 0 deletions src/PhpPact/Standalone/MockService/MockServerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public function getPort(): int
*/
public function setPort(int $port): MockServerConfigInterface
{
$this->port = $port;

return $this;
}

Expand Down
14 changes: 14 additions & 0 deletions src/PhpPact/Standalone/ProviderVerifier/Verifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ public function verifyAll()
$this->verifyAction($arguments);
}

/**
* Verify all PACTs for a given tag.
*
* @param string $tag
*/
public function verifyAllForTag(string $tag)
{
$arguments = $this->getBrokerHttpClient()->getAllConsumerUrlsForTag($this->config->getProviderName(), $tag);

$arguments = \array_merge($arguments, $this->getArguments());

$this->verifyAction($arguments);
}

/**
* Wrapper to add a custom installer.
*
Expand Down

0 comments on commit a63bf10

Please sign in to comment.