forked from pact-foundation/pact-ruby
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A Spike to get dynamic auth tokens in request headers
- Loading branch information
Stefan Leszkiewicz
committed
Nov 27, 2014
1 parent
61fcb38
commit 18c247a
Showing
13 changed files
with
94 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,4 @@ def with_http_prefix header | |
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"consumer": { | ||
"name": "Consumer" | ||
}, | ||
"provider": { | ||
"name": "Provider" | ||
}, | ||
"interactions": [ | ||
{ | ||
"description": "", | ||
"provider_state": "intercepted_request_with_dynamic_auth_token", | ||
"request": { | ||
"method": "get", | ||
"path": "/authorized_call" | ||
}, | ||
"response": { | ||
"status": 200 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'json' | ||
require 'pact/provider/rspec' | ||
require './spec/support/active_support_if_configured' | ||
|
||
class App | ||
|
||
def call env | ||
if env['PATH_INFO'] == '/authorized_call' && env['HTTP_AUTHORIZATION'] == 'some dynamic token' | ||
[200, {'Content-Type' => 'application/json'}, [{message: 'so secure...'}.to_json]] | ||
end | ||
end | ||
|
||
Pact.service_provider "Provider" do | ||
app { App.new } | ||
|
||
honours_pact_with 'Consumer' do | ||
pact_uri './spec/support/intercept_request_headers.json' | ||
end | ||
end | ||
|
||
Pact.provider_state "intercepted_request_with_dynamic_auth_token" do | ||
set_up do | ||
interaction.request.instance_eval('@headers = {}') # hack this in there to create some headers for now. | ||
interaction.request.headers['Authorization'] = 'some dynamic token' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ def self.call env | |
|
||
Pact.service_provider 'Provider' do | ||
app { App } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters