pact_broker 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ea53ff24e52dedddcfd7dc4ba8972fd7a74c690
4
- data.tar.gz: e03e51d0361af424ad239ccb74051ed63640c32c
3
+ metadata.gz: f919919c73ee62c636f69b79971a8b0f8bb6610d
4
+ data.tar.gz: 0c6208f282a318f57b43719ba10e1d4c77de45c9
5
5
  SHA512:
6
- metadata.gz: da11452f57a5915402445398373e697df1fa59135b99aadc3e5e4d9cddc481fed445328b6f14b52577ed29bbdbf3023417fee328a531b4a834cc4476b1024f30
7
- data.tar.gz: 1da99413c3e602ca6e4d4286c9f8d84a82da08690f34367bfa091b9dbd38ed518171ea09500211d17c4d663f7cbfd257b721ef5c9094318448009e2c4d2dce78
6
+ metadata.gz: 6a5979960c942e3628e37e362054277f8e4708f726395dac807ca5912ec5f2186fad992d7b51da1bb65e8c1015ed66abe2ffff800e6b266044fd50c8fe6ab876
7
+ data.tar.gz: abac02e82dce27c9a8a16a5b073b9b4a6caeee7ac0c9c83bcd7bbbfd063a145079393fe7d892e26818a72b4036f7f0b926b8bd7f20d8db6b16101954ab256a60
data/.gitignore CHANGED
@@ -27,4 +27,5 @@ _yardoc
27
27
  *.sqlite
28
28
  Gemfile.lock
29
29
 
30
- bethtest/
30
+ bethtest/
31
+ bin/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.3
data/.travis.yml CHANGED
@@ -4,3 +4,4 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.1
6
6
  - 2.1.2
7
+ - 2.1.3
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Pact Broker
2
2
 
3
+ [![Build Status](https://travis-ci.org/bethesque/pact_broker.svg?branch=master)](https://travis-ci.org/bethesque/pact_broker) [![Join the chat at https://gitter.im/bethesque/pact_broker](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bethesque/pact_broker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+
3
5
  The Pact Broker provides a repository for consumer driven contracts created using the pact gem.
4
6
 
5
7
  It:
data/example/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem "pact_broker", "~>1.4"
4
- gem "sqlite3" # Replace with your choice of database driver eg. mysql2
4
+ gem "sqlite3" # Replace with your choice of database driver eg. gem "pg"
5
5
  gem "thin" # Keep, or replace with your choice of web server
data/example/config.ru CHANGED
@@ -1,11 +1,19 @@
1
1
  require 'fileutils'
2
2
  require 'logger'
3
3
  require 'sequel'
4
+ # require 'pg' # for postgres
4
5
  require 'pact_broker'
5
6
 
6
7
  # Create a real database, and set the credentials for it here
7
8
  # It is highly recommended to set the encoding to utf8 (varchar foreign keys may blow up otherwise)
8
- DATABASE_CREDENTIALS = {database: "pact_broker_database.sqlite3", adapter: "sqlite", :encoding => 'utf8'}
9
+ DATABASE_CREDENTIALS = {adapter: "sqlite", database: "pact_broker_database.sqlite3", :encoding => 'utf8'}
10
+
11
+ # For postgres:
12
+ # $ psql postgres
13
+ # > create database pact_broker;
14
+ # > CREATE USER pact_broker WITH PASSWORD 'pact_broker';
15
+ # > GRANT ALL PRIVILEGES ON DATABASE pact_broker to pact_broker;
16
+ # > DATABASE_CREDENTIALS = {adapter: "postgres", database: "pact_broker", username: 'pact_broker', password: 'pact_broker', :encoding => 'utf8'}
9
17
 
10
18
  # Have a look at the Sequel documentation to make decisions about things like connection pooling
11
19
  # and connection validation.
@@ -27,11 +27,14 @@ module PactBroker
27
27
  ["GET", "PUT", "DELETE"]
28
28
  end
29
29
 
30
+ def is_conflict?
31
+ potential_duplicate_pacticipants?(pact_params.pacticipant_names)
32
+ end
33
+
30
34
  def malformed_request?
31
35
  if request.put?
32
36
  return invalid_json? ||
33
- contract_validation_errors?(Contracts::PutPactParamsContract.new(pact_params)) ||
34
- potential_duplicate_pacticipants?(pact_params.pacticipant_names)
37
+ contract_validation_errors?(Contracts::PutPactParamsContract.new(pact_params))
35
38
  else
36
39
  false
37
40
  end
@@ -35,7 +35,7 @@ module PactBroker
35
35
  end
36
36
 
37
37
  def connected? other
38
- (self.to_a & other.to_a).any?
38
+ include?(other.consumer) || include?(other.provider)
39
39
  end
40
40
 
41
41
  def include? pacticipant
@@ -58,4 +58,4 @@ module PactBroker
58
58
 
59
59
  end
60
60
  end
61
- end
61
+ end
@@ -48,7 +48,6 @@ module PactBroker
48
48
  def execute
49
49
 
50
50
  begin
51
- #TODO make it work with https
52
51
  req = http_request
53
52
 
54
53
  headers.each_pair do | name, value |
@@ -60,7 +59,8 @@ module PactBroker
60
59
  req.body = body
61
60
 
62
61
  logger.info "Making webhook request #{to_s}"
63
- response = Net::HTTP.start(uri.hostname, uri.port) do |http|
62
+ response = Net::HTTP.start(uri.hostname, uri.port,
63
+ :use_ssl => uri.scheme == 'https') do |http|
64
64
  http.request req
65
65
  end
66
66
 
@@ -11,28 +11,34 @@ module PactBroker
11
11
  class Groupify
12
12
 
13
13
  def self.call relationships
14
- recurse_groups([], relationships.dup).collect{ | group | Domain::Group.new(group) }
14
+ recurse_groups([], relationships.dup).collect { |group| Domain::Group.new(group) }
15
15
  end
16
16
 
17
17
  def self.recurse_groups groups, relationship_pool
18
18
  if relationship_pool.empty?
19
19
  groups
20
20
  else
21
- first, *rest = *relationship_pool
22
- group = recurse first, rest
23
- recurse_groups(groups + [group], relationship_pool - group)
24
- end
25
- end
21
+ first, *rest = relationship_pool
22
+ group = [first]
23
+ new_connections = true
24
+ while new_connections
25
+ new_connections = false
26
+ group = rest.inject(group) do |connected, candidate|
27
+ if connected.select { |relationship| relationship.connected?(candidate) }.any?
28
+ new_connections = true
29
+ connected + [candidate]
30
+ else
31
+ connected
32
+ end
33
+ end
34
+
35
+ rest = rest - group
36
+ group.uniq
37
+ end
26
38
 
27
- def self.recurse relationship, relationship_pool
28
- connected_relationships = relationship_pool.select{ | candidate| candidate.connected?(relationship) }
29
- if connected_relationships.empty?
30
- [relationship]
31
- else
32
- ([relationship] + connected_relationships.map{| connected_relationship| recurse(connected_relationship, relationship_pool - connected_relationships)}.flatten).uniq
39
+ recurse_groups(groups + [group], relationship_pool - group)
33
40
  end
34
41
  end
35
-
36
42
  end
37
43
 
38
44
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '1.9.0'
2
+ VERSION = '1.9.1'
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'pact_broker/api/resources/pact'
3
3
  require 'rack/test'
4
+ require 'pact_broker/pacts/service'
4
5
 
5
6
  module PactBroker::Api
6
7
 
@@ -63,8 +64,8 @@ module PactBroker::Api
63
64
  response
64
65
  end
65
66
 
66
- it "returns a 400 response" do
67
- expect(response.status).to eq 400
67
+ it "returns a 409 response" do
68
+ expect(response.status).to eq 409
68
69
  end
69
70
 
70
71
  it "returns a text response" do
@@ -10,11 +10,12 @@ module PactBroker
10
10
 
11
11
  let(:username) { nil }
12
12
  let(:password) { nil }
13
+ let(:url) { 'http://example.org/hook' }
13
14
 
14
15
  subject do
15
16
  WebhookRequest.new(
16
17
  method: 'post',
17
- url: 'http://example.org/hook',
18
+ url: url,
18
19
  headers: {'Content-type' => 'text/plain'},
19
20
  username: username,
20
21
  password: password,
@@ -85,6 +86,22 @@ module PactBroker
85
86
  end
86
87
  end
87
88
 
89
+ context "when the URL has a https scheme" do
90
+ let(:url) { 'https://example.org/hook' }
91
+
92
+ let!(:https_request) do
93
+ # webmock will set the request signature scheme to 'https' _only_ if the use_ssl option is set
94
+ stub_request(:post, "https://example.org/hook").
95
+ with(:headers => {'Content-Type'=>'text/plain'}, :body => 'body').
96
+ to_return(:status => 302, :body => "respbod", :headers => {'Content-Type' => 'text/plain, blah'})
97
+ end
98
+
99
+ it "uses SSL" do
100
+ subject.execute
101
+ expect(https_request).to have_been_made
102
+ end
103
+ end
104
+
88
105
  context "when the request is successful" do
89
106
  it "returns a WebhookExecutionResult with success=true" do
90
107
  expect(subject.execute.success?).to be true
@@ -10,18 +10,18 @@ module PactBroker
10
10
 
11
11
  describe ".call" do
12
12
 
13
- let(:consumer_a) { double('consumer a', name: 'consumer a') }
14
- let(:consumer_b) { double('consumer b', name: 'consumer b') }
15
- let(:consumer_c) { double('consumer c', name: 'consumer c') }
13
+ let(:consumer_a) { double('consumer a', id: 1, name: 'consumer a') }
14
+ let(:consumer_b) { double('consumer b', id: 2, name: 'consumer b') }
15
+ let(:consumer_c) { double('consumer c', id: 3, name: 'consumer c') }
16
16
 
17
- let(:consumer_l) { double('consumer l', name: 'consumer l') }
18
- let(:consumer_m) { double('consumer m', name: 'consumer m') }
17
+ let(:consumer_l) { double('consumer l', id: 4, name: 'consumer l') }
18
+ let(:consumer_m) { double('consumer m', id: 5, name: 'consumer m') }
19
19
 
20
- let(:provider_p) { double('provider p', name: 'provider p') }
20
+ let(:provider_p) { double('provider p', id: 6, name: 'provider p') }
21
21
 
22
- let(:provider_x) { double('provider x', name: 'provider x') }
23
- let(:provider_y) { double('provider y', name: 'provider y') }
24
- let(:provider_z) { double('provider z', name: 'provider z') }
22
+ let(:provider_x) { double('provider x', id: 7, name: 'provider x') }
23
+ let(:provider_y) { double('provider y', id: 8, name: 'provider y') }
24
+ let(:provider_z) { double('provider z', id: 9, name: 'provider z') }
25
25
 
26
26
 
27
27
  let(:relationship_1) { Domain::Relationship.new(consumer_a, provider_x) }
@@ -34,7 +34,7 @@ module PactBroker
34
34
  let(:relationship_5) { Domain::Relationship.new(consumer_l, provider_p) }
35
35
  let(:relationship_6) { Domain::Relationship.new(consumer_m, provider_p) }
36
36
 
37
- let(:relationships) { [relationship_1, relationship_2, relationship_3, relationship_4, relationship_5, relationship_6 ]}
37
+ let(:relationships) { [relationship_1, relationship_2, relationship_3, relationship_4, relationship_5, relationship_6] }
38
38
 
39
39
  it "separates the relationships into isolated groups" do
40
40
  groups = Groupify.call(relationships)
@@ -47,4 +47,4 @@ module PactBroker
47
47
  end
48
48
 
49
49
  end
50
- end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-18 00:00:00.000000000 Z
13
+ date: 2016-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -352,9 +352,11 @@ extra_rdoc_files: []
352
352
  files:
353
353
  - ".gitignore"
354
354
  - ".rspec"
355
+ - ".ruby-version"
355
356
  - ".travis.yml"
356
357
  - CHANGELOG.md
357
358
  - Gemfile
359
+ - LICENSE.txt
358
360
  - README.md
359
361
  - Rakefile
360
362
  - bethtest.rb
@@ -713,7 +715,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
713
715
  version: '0'
714
716
  requirements: []
715
717
  rubyforge_project:
716
- rubygems_version: 2.4.8
718
+ rubygems_version: 2.2.2
717
719
  signing_key:
718
720
  specification_version: 4
719
721
  summary: See description