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
require 'httparty' | |
require 'hmac/signer' | |
require 'digest' | |
class SourceSystemClient | |
include HTTParty | |
base_uri 'http://events-service' | |
attr_reader :hmac_secret |
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
require 'httparty' | |
require 'hmac/signer' | |
require 'digest' | |
require 'json' | |
class SourceSystemClient | |
include HTTParty | |
debug_output $stderr | |
base_uri 'http://localhost:9292' | |
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
require 'pact_helper' | |
require_relative '../lib/client' | |
require_relative '../lib/event' | |
describe SourceSystemClient, :pact => true do | |
before do | |
subject.class.base_uri 'http://localhost:1234' | |
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
require 'pact_helper' | |
require_relative '../lib/client' | |
require_relative '../lib/event' | |
describe SourceSystemClient, :pact => true do | |
let!(:now) { Time.now } | |
before do | |
subject.class.base_uri 'http://localhost:1234' |
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
{ | |
"eventId": "13ec9646-a33b-4319-a941-dbb924a60130", | |
"timestamp": "2014-05-13 01:06:38 UTC", | |
"host": "rholshausen.local", | |
"remoteAddress": "0:0:0:0:0:0:0:1%0", | |
"eventType": "LOGIN", | |
"user": "rholshausen" | |
} |
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
require 'securerandom' | |
class Event | |
attr_accessor :event_id, :timestamp, :host, :remote_address, :event_type, :user | |
def initialize | |
@event_id = SecureRandom.uuid | |
@timestamp = Time.now | |
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
POST /events HTTP/1.1 | |
Content-Md5: CHEFLZW9taJ4sH6fxPN82Q== | |
X-Hmac-Date: Tue, 13 May 2014 01:21:17 GMT | |
Authorization: HMAC 1f5ca8529707d870bb993b10fd17ddf53971e4b4 | |
Content-Type: application/json | |
Connection: close | |
Host: localhost:9292 | |
Content-Length: 192 | |
{"eventId":"13ec9646-a33b-4319-a941-dbb924a60130","timestamp":"2014-05-13 01:06:38 UTC","host":"rholshausen.local","remoteAddress":"0:0:0:0:0:0:0:1%0","eventType":"LOGIN","user":"rholshausen"} |
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
{ | |
"provider": { | |
"name": "Event API" | |
}, | |
"consumer": { | |
"name": "Source System" | |
}, | |
"interactions": [ | |
{ | |
"description": "A POST request with an event", |
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
require 'pact/consumer/rspec' # Require the pact rspec helper | |
Pact.service_consumer "Source System" do # register a consumer with pact | |
has_pact_with "Event API" do # register the provider that has the pact | |
mock_service :event_api do # register the mock service that will run and pretend to be the provider | |
port 1234 | |
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
require 'grape' | |
require 'models/event_repository' | |
require 'models/events_decorator' | |
require 'digest/md5' | |
class EventsApi < Grape::API | |
version 'v1', using: :accept_version_header | |
helpers do |
OlderNewer