Skip to content

Commit

Permalink
Fix wiremock mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
egorras committed Jan 31, 2018
1 parent fd4f181 commit 4457b06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
18 changes: 9 additions & 9 deletions features/runner/wiremock_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ def initialize(hostname, port)
def create_new_mapping(config)
request_json = {
request: {
urlPattern: config.endpoint_matches,
url: config.endpoint_equals,
method: config.verb
urlPattern: config[:endpointMatches],
url: config[:endpointEquals],
method: config[:verb]
}
}

if config.accept_header
request_json['request']['headers'] = {
if config[:acceptHeader]
request_json[:request][:headers] = {
accept: {
contains: config.accept_header
contains: config[:acceptHeader]
}
}
end

RestClient.post("#{@base_url}/__admin/mapping/new", )
RestClient.post("#{@base_url}/__admin/mappings/new", request_json.to_json, {content_type: :json, accept: :json})
end

def reset
RestClient.post("#{@base_url}/__admin/reset")
RestClient.post("#{@base_url}/__admin/reset", {})
end

def verify_endpoint_was_hit(endpoint, method_type, body)
Expand Down
8 changes: 5 additions & 3 deletions features/runner_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@challenge_server_stub.reset
end

Given(/^There is a recording server running on "([^"]*)" port (\\d+)$/) do |hostname, port|
Given(/^There is a recording server running on "([^"]*)" port (\d+)$/) do |hostname, port|
@recording_server_stub = WiremockProcess.new(hostname, port)
@recording_server_stub.reset
end
Expand All @@ -34,7 +34,8 @@
end

Given(/^the challenge server returns (\\d+) for all requests$/) do |return_code|
config = Object.new
config = ServerConfig.new

config.endpoint_matches = "^(.*)"
config.status = return_code
config.verb = "ANY"
Expand All @@ -43,7 +44,8 @@
end

Given(/^the challenge server returns (\\d+), response body "([^\"]*)" for all requests$/) do |return_code, body|
config = Object.new
config = ServerConfig.new

config.endpoint_matches = "^(.*)"
config.status = return_code
config.verb = "ANY"
Expand Down

0 comments on commit 4457b06

Please sign in to comment.