pact_broker 2.0.0.beta.4 → 2.0.0.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/lib/pact_broker/api/decorators/pact_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/verification_decorator.rb +8 -2
- data/lib/pact_broker/api/decorators/verifications_decorator.rb +9 -0
- data/lib/pact_broker/api/resources/pacticipants.rb +1 -1
- data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +1 -1
- data/lib/pact_broker/api/resources/webhooks.rb +1 -1
- data/lib/pact_broker/doc/views/publish-verification-results.markdown +14 -0
- data/lib/pact_broker/pacts/all_pact_publications.rb +10 -0
- data/lib/pact_broker/pacts/pact_version.rb +1 -1
- data/lib/pact_broker/version.rb +1 -1
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +1 -1
- data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +2 -1
- data/spec/lib/pact_broker/api/decorators/verifications_decorator_spec.rb +14 -1
- data/spec/lib/pact_broker/api/resources/pacticipants_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/webhooks_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +23 -0
- metadata +4 -4
- data/lib/pact_broker/doc/views/publish-verification-result.markdown +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4416650392293dcec2b6643adfcac1af250c4cd7
|
4
|
+
data.tar.gz: a8ef1ac554a59b0093ee7be152dd0e59eca3d88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b796e57abf4302c523549f6ab23403ea7f3cdc51cde324fc1f8bc03ce7527fa02cd75def279dd18b6a8e6a8a132b86670ffc24776c1152b9bd91c86f6d32a497
|
7
|
+
data.tar.gz: 8032820522881d1c03054d12311d99746733533cc6f7bcadbcaf979212d6a45dcd8dc02fd1bb8c76c40c9794419d1338bd560f5e722d3f80144378e6b50e88ef
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
$ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
|
4
4
|
|
5
|
+
#### 2.0.0.beta.5 (2017-05-08)
|
6
|
+
* 4b88c4d - Add success flag to the resource for the latest verifications for a consumer version to indicate the overall success or failure of the verification results for that version. (Beth Skurrie, Mon May 8 10:54:31 2017 +1000)
|
7
|
+
|
5
8
|
#### 2.0.0.beta.4 (2017-05-02)
|
6
9
|
* e5c14d1 - Renamed verification to verification-result in link relations and URLs (Beth Skurrie, Tue May 2 13:04:01 2017 +1000)
|
7
10
|
* 803ea44 - Add endpoint to show a verification. (Beth Skurrie, Mon May 1 08:52:12 2017 +1000)
|
@@ -26,6 +29,13 @@ Do this to generate your change history
|
|
26
29
|
* 77eaf7b - Added pb:latest-verifications link to version resource. (Beth Skurrie, Tue Apr 11 16:25:45 2017 +1000)
|
27
30
|
* aaf44d9 - Added endpoint to view the latest verifications for a given consumer version. (Beth Skurrie, Tue Apr 11 11:16:03 2017 +1000)
|
28
31
|
|
32
|
+
#### 1.17.2 (2017-05-04)
|
33
|
+
* b8f45e1 - fix issue with pact document link not displaying #94 (Matt Fellows, Wed May 3 11:23:09 2017 +1000)
|
34
|
+
|
35
|
+
#### 1.17.1 (2017-05-02)
|
36
|
+
* 7576bc2 - Fix 500 error in webhooks endpoint. (Beth Skurrie, Tue May 2 14:35:06 2017 +1000)
|
37
|
+
* 7351ec8 - Add restrictions for all gem versions in gemspec. Fix formatting in haml file. (Beth Skurrie, Thu Apr 27 19:55:04 2017 +1000)
|
38
|
+
|
29
39
|
#### 1.17.0 (2017-04-26)
|
30
40
|
* 5cbb9da - Added pb:publish-pact to HAL index (Beth Skurrie, Wed Apr 26 08:39:15 2017 +1000)
|
31
41
|
* 36842d1 - Set database connection timezone to UTC in example config.ru (Beth Skurrie, Tue Apr 25 16:18:58 2017 +1000)
|
data/README.md
CHANGED
@@ -112,5 +112,5 @@ You can use the [Pact Broker Docker container][docker] or [Terraform on AWS][ter
|
|
112
112
|
[pact]: https://github.com/realestate-com-au/pact
|
113
113
|
[nerf]: https://github.com/bethesque/pact_broker/wiki/pact-broker-ci-nerf-gun
|
114
114
|
[different-teams]: https://github.com/realestate-com-au/pact/wiki/Using-pact-where-the-consumer-team-is-different-from-the-provider-team
|
115
|
-
[docker]: https://
|
115
|
+
[docker]: https://hub.docker.com/r/dius/pact-broker
|
116
116
|
[terraform]: https://github.com/nadnerb/terraform-pact-broker
|
@@ -99,9 +99,9 @@ module PactBroker
|
|
99
99
|
}
|
100
100
|
end
|
101
101
|
|
102
|
-
link :'pb:publish-verification-
|
102
|
+
link :'pb:publish-verification-results' do | options |
|
103
103
|
{
|
104
|
-
title: "Publish verification",
|
104
|
+
title: "Publish verification results",
|
105
105
|
href: verification_publication_url(represented, options.fetch(:base_url))
|
106
106
|
}
|
107
107
|
end
|
@@ -5,14 +5,16 @@ module PactBroker
|
|
5
5
|
module Decorators
|
6
6
|
class VerificationDecorator < BaseDecorator
|
7
7
|
|
8
|
-
property :
|
8
|
+
property :provider_name, as: :providerName, writeable: :false
|
9
9
|
property :provider_version, as: :providerApplicationVersion
|
10
|
+
property :success
|
11
|
+
property :execution_date, as: :verificationDate
|
10
12
|
property :build_url, as: :buildUrl
|
11
13
|
|
12
14
|
link :self do | options |
|
13
15
|
{
|
14
16
|
title: 'Verification result',
|
15
|
-
name: represented.number,
|
17
|
+
name: "Verification result #{represented.number} for #{represented.latest_pact_publication.name}",
|
16
18
|
href: verification_url(represented, options.fetch(:base_url), )
|
17
19
|
}
|
18
20
|
end
|
@@ -24,6 +26,10 @@ module PactBroker
|
|
24
26
|
href: pact_url(options.fetch(:base_url), represented.latest_pact_publication)
|
25
27
|
}
|
26
28
|
end
|
29
|
+
|
30
|
+
def provider_name
|
31
|
+
represented.provider_name
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -7,6 +7,7 @@ module PactBroker
|
|
7
7
|
|
8
8
|
class VerificationsDecorator < BaseDecorator
|
9
9
|
|
10
|
+
property :success, exec_context: :decorator, if: :any_verifications?
|
10
11
|
collection :entries, as: :'verification-results', embedded: true, :extend => PactBroker::Api::Decorators::VerificationDecorator
|
11
12
|
|
12
13
|
link :self do | context |
|
@@ -15,6 +16,14 @@ module PactBroker
|
|
15
16
|
title: "Latest verification results for consumer #{context.fetch(:consumer_name)} version #{context.fetch(:consumer_version_number)}"
|
16
17
|
}
|
17
18
|
end
|
19
|
+
|
20
|
+
def success
|
21
|
+
represented.collect(&:success).all?
|
22
|
+
end
|
23
|
+
|
24
|
+
def any_verifications? context
|
25
|
+
represented.any?
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
@@ -33,7 +33,7 @@ module PactBroker
|
|
33
33
|
|
34
34
|
def from_json
|
35
35
|
created_model = pacticipant_service.create params
|
36
|
-
response.body = decorator_for(created_model).to_json(decorator_context)
|
36
|
+
response.body = decorator_for(created_model).to_json(user_options: decorator_context)
|
37
37
|
end
|
38
38
|
|
39
39
|
def create_path
|
@@ -16,7 +16,7 @@ module PactBroker
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def to_json
|
19
|
-
Decorators::WebhooksDecorator.new(webhooks).to_json(decorator_context(resource_title: "Webhooks"))
|
19
|
+
Decorators::WebhooksDecorator.new(webhooks).to_json(user_options: decorator_context(resource_title: "Webhooks"))
|
20
20
|
end
|
21
21
|
|
22
22
|
def webhooks
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Publish pact verification result
|
2
|
+
|
3
|
+
Allowed methods: POST
|
4
|
+
|
5
|
+
Use the `pb:publish-verification-results` link in the pact resource to publish the result (either success or failure) of a pact verification. The body of the request must include the success (true or false) and the provider application version that the pact was verified against. It may also include the build URL to facilitate debugging when failures occur.
|
6
|
+
|
7
|
+
POST http://broker/pacts/provider/Foo/consumer/Bar/pact-version/1234
|
8
|
+
{
|
9
|
+
success: true,
|
10
|
+
providerApplicationVersion: "4.5.6",
|
11
|
+
buildUrl: "http://my-ci.org/build/3456"
|
12
|
+
}
|
13
|
+
|
14
|
+
Multiple verification results may be published for the same pact resource.
|
@@ -9,6 +9,10 @@ module PactBroker
|
|
9
9
|
|
10
10
|
class AllPactPublications < Sequel::Model(:all_pact_publications)
|
11
11
|
|
12
|
+
extend Forwardable
|
13
|
+
|
14
|
+
def_delegators :cached_domain, :name
|
15
|
+
|
12
16
|
set_primary_key :id
|
13
17
|
associate(:one_to_many, :tags, :class => "PactBroker::Domain::Tag", :reciprocal => :version, :key => :version_id, :primary_key => :consumer_version_id)
|
14
18
|
associate(:many_to_one, :pact_version, :key => :pact_version_sha, :primary_key => :sha)
|
@@ -90,6 +94,12 @@ module PactBroker
|
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|
97
|
+
private
|
98
|
+
|
99
|
+
def cached_domain
|
100
|
+
@cached_domain ||= to_domain
|
101
|
+
end
|
102
|
+
|
93
103
|
end
|
94
104
|
|
95
105
|
end
|
@@ -22,7 +22,7 @@ module PactBroker
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def latest_pact_publication
|
25
|
-
|
25
|
+
PactBroker::Pacts::LatestPactPublicationsByConsumerVersion.where(pact_version_id: id).order(:consumer_version_order).last
|
26
26
|
end
|
27
27
|
|
28
28
|
def consumer_versions
|
data/lib/pact_broker/version.rb
CHANGED
@@ -91,7 +91,7 @@ module PactBroker
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it "includes a link to publish a verification" do
|
94
|
-
expect(subject[:_links][:'pb:publish-verification-
|
94
|
+
expect(subject[:_links][:'pb:publish-verification-results'][:href]).to match %r{http://example.org/.*/verification-results}
|
95
95
|
end
|
96
96
|
|
97
97
|
it "includes a curie" do
|
@@ -14,7 +14,8 @@ module PactBroker
|
|
14
14
|
consumer_name: 'Consumer',
|
15
15
|
build_url: 'http://build-url',
|
16
16
|
pact_version: pact_version,
|
17
|
-
latest_pact_publication: pact_publication
|
17
|
+
latest_pact_publication: pact_publication,
|
18
|
+
execution_date: DateTime.now)
|
18
19
|
end
|
19
20
|
|
20
21
|
let(:pact_version) do
|
@@ -13,7 +13,8 @@ module PactBroker
|
|
13
13
|
provider_name: 'provider',
|
14
14
|
consumer_name: 'consumer',
|
15
15
|
pact_version: pact_version,
|
16
|
-
latest_pact_publication: pact
|
16
|
+
latest_pact_publication: pact,
|
17
|
+
execution_date: DateTime.now)
|
17
18
|
end
|
18
19
|
let(:pact_version) do
|
19
20
|
instance_double("PactBroker::Pacts::PactVersion", sha: '1234', name: 'Name')
|
@@ -35,6 +36,18 @@ module PactBroker
|
|
35
36
|
it "includes a link to itself" do
|
36
37
|
expect(subject[:_links][:self][:href]).to eq "http://self"
|
37
38
|
end
|
39
|
+
|
40
|
+
it "includes a flag to indicate the overall success or failure of all the verification results" do
|
41
|
+
expect(subject[:success]).to be true
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when there are no verifications" do
|
45
|
+
let(:verifications) { [] }
|
46
|
+
|
47
|
+
it "does not include a flag to indicate the overall success or failure of all the verification results" do
|
48
|
+
expect(subject).to_not have_key(:success)
|
49
|
+
end
|
50
|
+
end
|
38
51
|
end
|
39
52
|
end
|
40
53
|
end
|
@@ -68,7 +68,7 @@ module PactBroker
|
|
68
68
|
|
69
69
|
it "creates a JSON representation of the new pacticipant" do
|
70
70
|
expect(decorator_class).to receive(:new).with(created_model)
|
71
|
-
expect(decorator).to receive(:to_json).with(instance_of(Decorators::DecoratorContext))
|
71
|
+
expect(decorator).to receive(:to_json).with(user_options: instance_of(Decorators::DecoratorContext))
|
72
72
|
subject
|
73
73
|
end
|
74
74
|
|
@@ -27,7 +27,7 @@ module PactBroker::Api
|
|
27
27
|
|
28
28
|
it "generates a JSON representation of the webhook" do
|
29
29
|
expect(Decorators::WebhooksDecorator).to receive(:new).with(webhooks)
|
30
|
-
expect(decorator).to receive(:to_json).with(instance_of(Decorators::DecoratorContext))
|
30
|
+
expect(decorator).to receive(:to_json).with(user_options: instance_of(Decorators::DecoratorContext))
|
31
31
|
subject
|
32
32
|
end
|
33
33
|
|
@@ -19,7 +19,30 @@ module PactBroker
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#latest_pact_publication" do
|
22
|
+
before do
|
23
|
+
ProviderStateBuilder.new
|
24
|
+
.create_provider("Bar")
|
25
|
+
.create_consumer("Foo")
|
26
|
+
.create_consumer_version("1.2.100")
|
27
|
+
.create_pact
|
28
|
+
.revise_pact
|
29
|
+
.create_consumer_version("1.2.101")
|
30
|
+
.create_pact
|
31
|
+
.create_consumer_version("1.2.102")
|
32
|
+
.create_pact
|
33
|
+
.revise_pact
|
34
|
+
.create_provider("Animals")
|
35
|
+
.create_pact
|
36
|
+
.create_provider("Wiffles")
|
37
|
+
.create_pact
|
38
|
+
end
|
22
39
|
|
40
|
+
it "returns the latest pact publication for the given pact version" do
|
41
|
+
pact = PactBroker::Pacts::Repository.new.find_pact("Foo", "1.2.102", "Animals")
|
42
|
+
pact_version = PactBroker::Pacts::PactVersion.find(sha: pact.pact_version_sha)
|
43
|
+
latest_pact_publication = pact_version.latest_pact_publication
|
44
|
+
expect(latest_pact_publication.id).to eq pact.id
|
45
|
+
end
|
23
46
|
end
|
24
47
|
|
25
48
|
describe "#latest_consumer_version_number" do
|
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: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.5
|
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: 2017-05-
|
13
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -512,7 +512,7 @@ files:
|
|
512
512
|
- lib/pact_broker/doc/views/pacticipants.markdown
|
513
513
|
- lib/pact_broker/doc/views/provider.markdown
|
514
514
|
- lib/pact_broker/doc/views/publish-pact.markdown
|
515
|
-
- lib/pact_broker/doc/views/publish-verification-
|
515
|
+
- lib/pact_broker/doc/views/publish-verification-results.markdown
|
516
516
|
- lib/pact_broker/doc/views/self.markdown
|
517
517
|
- lib/pact_broker/doc/views/tag-prod-version.markdown
|
518
518
|
- lib/pact_broker/doc/views/tag-version.markdown
|
@@ -794,7 +794,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
794
794
|
version: 1.3.1
|
795
795
|
requirements: []
|
796
796
|
rubyforge_project:
|
797
|
-
rubygems_version: 2.
|
797
|
+
rubygems_version: 2.6.11
|
798
798
|
signing_key:
|
799
799
|
specification_version: 4
|
800
800
|
summary: See description
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Publish pact verification result
|
2
|
-
|
3
|
-
Allowed methods: POST
|
4
|
-
|
5
|
-
Use the `pb:publish-verification-result` link in the pact resource to publish the result (either success or failure) of a pact verification. The body of the request must include the success (true or false) and the provider application version that the pact was verified against. It may also include the build URL to facilitate debugging when failures occur.
|
6
|
-
|
7
|
-
POST http://broker/pacts/provider/Foo/consumer/Bar/pact-version/1234
|
8
|
-
{
|
9
|
-
success: true,
|
10
|
-
providerApplicationVersion: "4.5.6",
|
11
|
-
buildUrl: "http://my-ci.org/build/3456"
|
12
|
-
}
|
13
|
-
|
14
|
-
Multiple verification results may be published for the same pact resource.
|