Skip to content

Commit

Permalink
Adding support for monkey patching the ruby core host
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell committed May 12, 2018
1 parent 2d8382a commit 4ad094c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Build/Download-Standalone-Core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ New-Item -ItemType directory -Path $OutputPath | Out-Null

Import-Module -Name $7ZipSnapIn

$StandaloneCoreVersion = '1.33.1'
$StandaloneCoreVersion = '1.43.1'
$StandaloneCoreDownloadBaseUri = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v$StandaloneCoreVersion"

# Download and extract the Windows core
Expand Down
7 changes: 4 additions & 3 deletions PactNet/Core/MockProviderHostConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ internal class MockProviderHostConfig : IPactCoreHostConfig
public MockProviderHostConfig(int port, bool enableSsl, string consumerName, string providerName, PactConfig config, IPAddress host)
{
var logFile = $"{config.LogDir}{providerName.ToLowerSnakeCase()}_mock_service.log";
var sslOption = enableSsl ? " --ssl" : "";
var hostOption = host == IPAddress.Any ? $" --host=0.0.0.0" : "";
var sslOption = enableSsl ? " --ssl" : string.Empty;
var hostOption = host == IPAddress.Any ? " --host=0.0.0.0" : string.Empty;
var monkeyPatchOption = !string.IsNullOrEmpty(config?.MonkeyPatchFile) ? $" --monkeypatch=\"${config.MonkeyPatchFile}\"" : string.Empty;

Script = "pact-mock-service";
Arguments = $"-p {port} -l \"{FixPathForRuby(logFile)}\" --pact-dir \"{FixPathForRuby(config.PactDir)}\" --pact-specification-version \"{config.SpecificationVersion}\" --consumer \"{consumerName}\" --provider \"{providerName}\"{sslOption}{hostOption}";
Arguments = $"-p {port} -l \"{FixPathForRuby(logFile)}\" --pact-dir \"{FixPathForRuby(config.PactDir)}\" --pact-specification-version \"{config.SpecificationVersion}\" --consumer \"{consumerName}\" --provider \"{providerName}\"{sslOption}{hostOption}{monkeyPatchOption}";
WaitForExit = false;
Outputters = config?.Outputters;
}
Expand Down
3 changes: 2 additions & 1 deletion PactNet/Core/PactVerifierHostConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public PactVerifierHostConfig(Uri baseUri, string pactUri, PactUriOptions pactBr
$" --custom-provider-header \"{config.CustomHeader?.Key}:{config.CustomHeader?.Value}\"" :
string.Empty;
var verbose = config?.Verbose == true ? " --verbose true" : string.Empty;
var monkeyPatchOption = !string.IsNullOrEmpty(config?.MonkeyPatchFile) ? $" --monkeypatch=\"${config.MonkeyPatchFile}\"" : string.Empty;

Script = "pact-provider-verifier";
Arguments = $"\"{FixPathForRuby(pactUri)}\" --provider-base-url {baseUri.OriginalString}{providerStateOption}{brokerCredentials}{publishResults}{customHeader}{verbose}";
Arguments = $"\"{FixPathForRuby(pactUri)}\" --provider-base-url {baseUri.OriginalString}{providerStateOption}{brokerCredentials}{publishResults}{customHeader}{verbose}{monkeyPatchOption}";
WaitForExit = true;
Outputters = config?.Outputters;
Environment = new Dictionary<string, string>
Expand Down
2 changes: 2 additions & 0 deletions PactNet/PactConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public string LogDir

internal string LoggerName;

public string MonkeyPatchFile { get; set; }

public PactConfig()
{
PactDir = Constants.DefaultPactDir;
Expand Down
2 changes: 2 additions & 0 deletions PactNet/PactVerifierConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class PactVerifierConfig

public bool Verbose { get; set; }

public string MonkeyPatchFile { get; set; }

public PactVerifierConfig()
{
Outputters = new List<IOutput>
Expand Down

0 comments on commit 4ad094c

Please sign in to comment.