diff --git a/README.md b/README.md index 37b61a6..ff33246 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,12 @@ Use the [pact][pact] gem if you would like the full Pact DSL, mock service and v Otherwise: $ gem install pact-mock_service - $ pact-mock-service --consumer Foo --provider Bar --port 1234 + $ pact-mock-service --consumer Foo --provider Bar --port 8888 Or add `gem "pact-mock_service"` to your Gemfile then run: $ bundle install - $ bundle exec pact-mock-service --consumer Foo --provider Bar --port 1234 + $ bundle exec pact-mock-service --consumer Foo --provider Bar --port 8888 Run `pact-mock-service help` for command line options. @@ -84,11 +84,11 @@ You can find more documentation for the mock service in the repository [wiki][wi If you need to use the mock service with HTTPS, you can use the built-in SSL mode which relies on and generates a self-signed certificate. - $ pact-mock-service --port 1234 --ssl + $ pact-mock-service --port 8888 --ssl If you need to provide your own certificate and key, use the following syntax. - $ pact-mock-service --port 1234 --ssl --sslcert PATH_TO_CERT --sslkey PATH_TO_KEY + $ pact-mock-service --port 8888 --ssl --sslcert PATH_TO_CERT --sslkey PATH_TO_KEY ### With CORS diff --git a/lib/pact/mock_service/cli.rb b/lib/pact/mock_service/cli.rb index 5aaec32..b0367a8 100755 --- a/lib/pact/mock_service/cli.rb +++ b/lib/pact/mock_service/cli.rb @@ -54,7 +54,7 @@ def control desc 'start', "Start a mock service. If the consumer, provider and pact-dir options are provided, the pact will be written automatically on shutdown (INT)." method_option :consumer, desc: "Consumer name" method_option :provider, desc: "Provider name" - method_option :port, aliases: "-p", default: '1234', desc: "Port on which to run the service" + method_option :port, aliases: "-p", default: '8888', desc: "Port on which to run the service" method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost' method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written" method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite' @@ -76,7 +76,7 @@ def start end desc 'stop', "Stop a Pact mock service" - method_option :port, aliases: "-p", desc: "Port of the service to stop", default: '1234', required: true + method_option :port, aliases: "-p", desc: "Port of the service to stop", default: '8888', required: true method_option :pid_dir, desc: "PID dir, defaults to tmp/pids", default: "tmp/pids" def stop @@ -87,7 +87,7 @@ def stop desc 'restart', "Start or restart a mock service. If the consumer, provider and pact-dir options are provided, the pact will be written automatically on shutdown (INT)." method_option :consumer, desc: "Consumer name" method_option :provider, desc: "Provider name" - method_option :port, aliases: "-p", default: '1234', desc: "Port on which to run the service" + method_option :port, aliases: "-p", default: '8888', desc: "Port on which to run the service" method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost' method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written" method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite' @@ -108,7 +108,7 @@ def restart end desc 'control-start', "Start a Pact mock service control server." - method_option :port, aliases: "-p", desc: "Port on which to run the service", default: '1234' + method_option :port, aliases: "-p", desc: "Port on which to run the service", default: '8888' method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost' method_option :log_dir, aliases: "-l", desc: "File to which to log output", default: "log" method_option :log_level, desc: "Log level. Options are DEBUG INFO WARN ERROR", default: "DEBUG" @@ -129,7 +129,7 @@ def control_start end desc 'control-stop', "Stop a Pact mock service control server." - method_option :port, aliases: "-p", desc: "Port of control server to stop", default: "1234" + method_option :port, aliases: "-p", desc: "Port of control server to stop", default: "8888" method_option :pid_dir, desc: "PID dir, defaults to tmp/pids", default: "tmp/pids" def control_stop @@ -138,7 +138,7 @@ def control_stop end desc 'control-restart', "Start a Pact mock service control server." - method_option :port, aliases: "-p", desc: "Port on which to run the service", default: '1234' + method_option :port, aliases: "-p", desc: "Port on which to run the service", default: '8888' method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost' method_option :log_dir, aliases: "-l", desc: "File to which to log output", default: "log" method_option :log_level, desc: "Log level. Options are DEBUG INFO WARN ERROR", default: "DEBUG" diff --git a/packaging/RELEASE_NOTES.md.template b/packaging/RELEASE_NOTES.md.template index 32f48a0..389e089 100644 --- a/packaging/RELEASE_NOTES.md.template +++ b/packaging/RELEASE_NOTES.md.template @@ -6,7 +6,7 @@ To install and run on OSX: curl -LO https://github.com/bethesque/pact-mock_service/releases/download//pact-mock-service--osx.tar.gz tar xzf pact-mock-service--osx.tar.gz cd pact-mock-service--osx/bin -./pact-mock-service -p 1234 +./pact-mock-service -p 8888 ``` To install and run on Linux 64 bit: @@ -15,7 +15,7 @@ To install and run on Linux 64 bit: curl -LO https://github.com/bethesque/pact-mock_service/releases/download//pact-mock-service--linux-x86_64.tar.gz tar xzf pact-mock-service--linux-x86_64.tar.gz cd pact-mock-service--linux-x86_64/bin -./pact-mock-service -p 1234 +./pact-mock-service -p 8888 ``` To install and run on Linux 32 bit: @@ -24,7 +24,7 @@ To install and run on Linux 32 bit: curl -LO https://github.com/bethesque/pact-mock_service/releases/download//pact-mock-service--linux-x86.tar.gz tar xzf pact-mock-service--linux-x86.tar.gz cd pact-mock-service--linux-x86/bin -./pact-mock-service -p 1234 +./pact-mock-service -p 8888 ``` To install and run on Windows: @@ -32,5 +32,5 @@ To install and run on Windows: Download package, unzip, cd to pact-mock-service--win32 and then run: ``` -$ .\bin\pact-mock-service.bat -p 1234 +$ .\bin\pact-mock-service.bat -p 8888 ``` diff --git a/script/example.sh b/script/example.sh index 4d93934..5e0d989 100755 --- a/script/example.sh +++ b/script/example.sh @@ -3,7 +3,7 @@ # BEFORE SUITE start mock service # invoked by the pact framework bundle exec bin/pact-mock-service service \ - --port 1234 \ + --port 8888 \ --consumer Foo \ --provider Bar \ --pact-specification-version 2 \ @@ -14,37 +14,37 @@ pid=$! # BEFORE SUITE wait for mock service to start up # invoked by the pact framework -while [ "200" -ne "$(curl -H "X-Pact-Mock-Service: true" -s -o /dev/null -w "%{http_code}" localhost:1234)" ]; do sleep 0.5; done +while [ "200" -ne "$(curl -H "X-Pact-Mock-Service: true" -s -o /dev/null -w "%{http_code}" localhost:8888)" ]; do sleep 0.5; done # uncomment this line to see the curl commands interleaved with the responses # set -x # BEFORE EACH TEST clear interactions from previous test # invoked by the pact framework -curl -X DELETE -H "X-Pact-Mock-Service: true" localhost:1234/interactions +curl -X DELETE -H "X-Pact-Mock-Service: true" localhost:8888/interactions # BEFORE A TEST set up interaction(s) just for that test # The contents of this would be written by the developer in the provided pact DSL for # your language eg. mockService.given(...).uponReceiving(...). ... # This can be called mulitple times. Alternatively PUT could be used # with a body of `{interactions: [...]}` which would negate the need to call DELETE. -curl -X POST -H "X-Pact-Mock-Service: true" -d@script/consumer-interaction.json localhost:1234/interactions +curl -X POST -H "X-Pact-Mock-Service: true" -d@script/consumer-interaction.json localhost:8888/interactions # IN A TEST execute interaction(s) # this would be done by the consumer code under test -curl localhost:1234/foo +curl localhost:8888/foo echo '' # AFTER EACH TEST verify interaction(s) took place # This would be done explicitly by the developer or automatically by the framework, # depending on the language -curl -H "X-Pact-Mock-Service: true" localhost:1234/interactions/verification +curl -H "X-Pact-Mock-Service: true" localhost:8888/interactions/verification # AFTER SUITE # write pact # this would be invoked explictly by the developer or automatically framework, # depending on the language -curl -X POST -H "X-Pact-Mock-Service: true" -H "Content-Length: 0" localhost:1234/pact +curl -X POST -H "X-Pact-Mock-Service: true" -H "Content-Length: 0" localhost:8888/pact # AFTER SUITE stop mock service # this would be invoked by the test framework diff --git a/script/stub_example.sh b/script/stub_example.sh index a416669..410b524 100755 --- a/script/stub_example.sh +++ b/script/stub_example.sh @@ -3,17 +3,17 @@ # BEFORE SUITE start mock service # invoked by the pact framework bundle exec pact-stub-service script/foo-bar.json \ - --port 1234 \ + --port 8888 \ --log ./tmp/bar_stub_service.log & pid=$! # BEFORE SUITE wait for mock service to start up # invoked by the pact framework -while [ "200" -ne "$(curl -H "X-Pact-Mock-Service: true" -s -o /dev/null -w "%{http_code}" localhost:1234)" ]; do sleep 0.5; done +while [ "200" -ne "$(curl -H "X-Pact-Mock-Service: true" -s -o /dev/null -w "%{http_code}" localhost:8888)" ]; do sleep 0.5; done # IN A TEST execute interaction(s) # this would be done by the consumer code under test -curl localhost:1234/foo +curl localhost:8888/foo echo '' diff --git a/spec/features/administration_endpoints_cors_spec.rb b/spec/features/administration_endpoints_cors_spec.rb index da23c4a..833f603 100644 --- a/spec/features/administration_endpoints_cors_spec.rb +++ b/spec/features/administration_endpoints_cors_spec.rb @@ -108,8 +108,8 @@ context "when the Origin header is set" do it "sets the Access-Control-Allow-Origin header to be the Origin" do - options '/pact', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'X-Pact-Mock-Service, Content-Type', 'HTTP_ORIGIN' => 'http://localhost:1234' } - expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:1234' + options '/pact', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'X-Pact-Mock-Service, Content-Type', 'HTTP_ORIGIN' => 'http://localhost:8888' } + expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:8888' end end end diff --git a/spec/features/mock_interactions_with_cors_spec.rb b/spec/features/mock_interactions_with_cors_spec.rb index 3bbdd81..ed51ec8 100644 --- a/spec/features/mock_interactions_with_cors_spec.rb +++ b/spec/features/mock_interactions_with_cors_spec.rb @@ -56,21 +56,21 @@ expect(last_response.status).to be 200 # OPTIONS request from the browser for the request under test - options '/alligators/new', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'accept', 'HTTP_ORIGIN' => 'http://localhost:1234' } + options '/alligators/new', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'accept', 'HTTP_ORIGIN' => 'http://localhost:8888' } # Ensure it allows the browser to actually make the request expect(last_response.status).to eq 200 - expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:1234' + expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:8888' expect(last_response.headers['Access-Control-Allow-Credentials']).to eq 'true' expect(last_response.headers['Access-Control-Allow-Headers']).to include 'accept' expect(last_response.headers['Access-Control-Allow-Methods']).to include "DELETE, POST, GET, HEAD, PUT, TRACE, CONNECT" # Make the request - post "/alligators/new", actual_request, { 'HTTP_ACCEPT' => 'application/json', 'HTTP_ORIGIN' => 'http://localhost:1234' } + post "/alligators/new", actual_request, { 'HTTP_ACCEPT' => 'application/json', 'HTTP_ORIGIN' => 'http://localhost:8888' } # Ensure that the response we get back was the one we expected # and includes the CORS header - expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:1234' + expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:8888' expect(last_response.headers['Content-Type']).to eq 'application/json' expect(JSON.parse(last_response.body)).to eq([{ 'name' => 'Mary' }]) end diff --git a/spec/integration/cli_cors_spec.rb b/spec/integration/cli_cors_spec.rb index d985255..30ef58b 100644 --- a/spec/integration/cli_cors_spec.rb +++ b/spec/integration/cli_cors_spec.rb @@ -8,11 +8,11 @@ before :all do clear_dirs - @pid = start_server 1234, '--cors' + @pid = start_server 8888, '--cors' end it "responds to an OPTIONS request for a non administration request" do - response = make_options_request 1234 + response = make_options_request 8888 expect(response.status).to eq 200 expect(response.headers['Access-Control-Allow-Headers']).to_not be nil end diff --git a/spec/integration/cli_spec.rb b/spec/integration/cli_spec.rb index 5bde4fb..104920f 100644 --- a/spec/integration/cli_spec.rb +++ b/spec/integration/cli_spec.rb @@ -7,32 +7,32 @@ before :all do clear_dirs - @pid = start_server 1234, "--pact-specification-version 3.0.0" + @pid = start_server 8888, "--pact-specification-version 3.0.0" end it "starts up and responds with mocked responses" do - response = setup_interaction 1234 + response = setup_interaction 8888 expect(response.status).to eq 200 - response = invoke_expected_request 1234 + response = invoke_expected_request 8888 puts response.body if response.status != 200 expect(response.status).to eq 200 expect(response.body).to eq 'Hello world' - write_pact 1234 + write_pact 8888 expect(response.status).to eq 200 end it "respects headers with underscores" do - setup_interaction_with_underscored_header 1234 - response = invoke_request_with_underscored_header 1234 + setup_interaction_with_underscored_header 8888 + response = invoke_request_with_underscored_header 8888 puts response.body unless response.status == 200 expect(response.status).to eq 200 end it "sets the X-Pact-Mock-Service-Location header" do - response = setup_interaction 1234 - expect(response.headers['X-Pact-Mock-Service-Location']).to eq 'http://0.0.0.0:1234' + response = setup_interaction 8888 + expect(response.headers['X-Pact-Mock-Service-Location']).to eq 'http://0.0.0.0:8888' end it "writes logs to the specified log file" do @@ -40,18 +40,18 @@ end it "writes the pact to the specified directory" do - clear_interactions 1234 - setup_interaction 1234 - invoke_expected_request 1234 + clear_interactions 8888 + setup_interaction 8888 + invoke_expected_request 8888 expect(File.exist?('tmp/pacts/consumer-provider.json')).to be true end it "sets the pact specification version" do - clear_interactions 1234 - setup_interaction 1234 - invoke_expected_request 1234 + clear_interactions 8888 + setup_interaction 8888 + invoke_expected_request 8888 - write_pact 1234 + write_pact 8888 expect(File.read("tmp/pacts/consumer-provider.json")).to include "3.0.0" end diff --git a/spec/integration/control_server_cli_spec.rb b/spec/integration/control_server_cli_spec.rb index d38078b..d18bc78 100644 --- a/spec/integration/control_server_cli_spec.rb +++ b/spec/integration/control_server_cli_spec.rb @@ -22,15 +22,15 @@ def mock_service_headers before :all do clear_dirs - @pid = start_control 1234, "--pact-specification-version 3" + @pid = start_control 8888, "--pact-specification-version 3" end it "starts up and responds with mocked responses" do - response = setup_interaction 1234 + response = setup_interaction 8888 puts response.body unless response.status == 200 expect(response.status).to eq 200 mock_service_port = URI(response.headers['X-Pact-Mock-Service-Location']).port - expect(mock_service_port).to_not eq 1234 + expect(mock_service_port).to_not eq 8888 response = invoke_expected_request mock_service_port expect(response.status).to eq 200 diff --git a/spec/integration/control_server_with_cors_cli_spec.rb b/spec/integration/control_server_with_cors_cli_spec.rb index b1754d8..c041f7d 100644 --- a/spec/integration/control_server_with_cors_cli_spec.rb +++ b/spec/integration/control_server_with_cors_cli_spec.rb @@ -7,11 +7,11 @@ before :all do clear_dirs - @pid = start_control 1234, '--cors' + @pid = start_control 8888, '--cors' end it "responds to an OPTIONS request for a non administration request" do - response = setup_interaction 1234 + response = setup_interaction 8888 expect(response.status).to eq 200 mock_service_port = URI(response.headers['X-Pact-Mock-Service-Location']).port diff --git a/spec/integration/control_server_with_ssl_cli_spec.rb b/spec/integration/control_server_with_ssl_cli_spec.rb index ec04585..a39e2e7 100644 --- a/spec/integration/control_server_with_ssl_cli_spec.rb +++ b/spec/integration/control_server_with_ssl_cli_spec.rb @@ -7,16 +7,16 @@ before :all do clear_dirs - @pid = start_control 1234, '--ssl' + @pid = start_control 8888, '--ssl' end it "sets the X-Pact-Mock-Service-Location with https" do - response = setup_interaction 1234 + response = setup_interaction 8888 expect(response.headers['X-Pact-Mock-Service-Location']).to start_with 'https://localhost:' end it "responds to an OPTIONS request for a non administration request" do - response = setup_interaction 1234 + response = setup_interaction 8888 expect(response.status).to eq 200 mock_service_port = URI(response.headers['X-Pact-Mock-Service-Location']).port response = connect_via_ssl mock_service_port diff --git a/spec/lib/pact/mock_service/app_manager_spec.rb b/spec/lib/pact/mock_service/app_manager_spec.rb index 64dde99..24e0bbd 100644 --- a/spec/lib/pact/mock_service/app_manager_spec.rb +++ b/spec/lib/pact/mock_service/app_manager_spec.rb @@ -17,7 +17,7 @@ module Pact::MockService let(:options) { { pact_specification_version: '3' } } context "for http://localhost" do - let(:url) { 'http://localhost:1234'} + let(:url) { 'http://localhost:8888'} it "starts a mock service at the given port on localhost" do expect_any_instance_of(AppRegistration).to receive(:spawn) @@ -27,7 +27,7 @@ module Pact::MockService it "registers the mock service as running on the given port" do AppManager.instance.register_mock_service_for name, url, options - expect(AppManager.instance.app_registered_on?(1234)).to eq true + expect(AppManager.instance.app_registered_on?(8888)).to eq true end it "reports the metric for pact mock service started" do @@ -50,7 +50,7 @@ module Pact::MockService end context "for https://" do - let(:url) { 'https://localhost:1234'} + let(:url) { 'https://localhost:8888'} it "should throw an unsupported error" do expect { AppManager.instance.register_mock_service_for name, url, options }.to raise_error "Currently only http is supported"