pact_broker 2.22.0 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +1 -0
- data/db/migrations/20180611_make_webhook_pacticipant_ids_optional.rb +11 -0
- data/example/config.ru +2 -0
- data/lib/pact_broker/api.rb +9 -3
- data/lib/pact_broker/api/contracts/webhook_contract.rb +36 -0
- data/lib/pact_broker/api/decorators/pact_decorator.rb +22 -1
- data/lib/pact_broker/api/decorators/pact_webhooks_status_decorator.rb +1 -26
- data/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb +33 -0
- data/lib/pact_broker/api/decorators/triggered_webhooks_decorator.rb +19 -0
- data/lib/pact_broker/api/decorators/verification_decorator.rb +6 -0
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +32 -18
- data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +27 -0
- data/lib/pact_broker/api/decorators/{webhook_request_decorator.rb → webhook_request_template_decorator.rb} +1 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +21 -1
- data/lib/pact_broker/api/resources/all_webhooks.rb +82 -0
- data/lib/pact_broker/api/resources/base_resource.rb +18 -0
- data/lib/pact_broker/api/resources/error_handler.rb +5 -1
- data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +41 -0
- data/lib/pact_broker/api/resources/pact_webhooks.rb +2 -15
- data/lib/pact_broker/api/resources/pact_webhooks_status.rb +1 -1
- data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +45 -0
- data/lib/pact_broker/api/resources/webhook_execution.rb +1 -5
- data/lib/pact_broker/api/resources/webhooks.rb +69 -6
- data/lib/pact_broker/configuration.rb +5 -2
- data/lib/pact_broker/doc/controllers/app.rb +1 -2
- data/lib/pact_broker/doc/views/pact-webhooks.markdown +3 -0
- data/lib/pact_broker/doc/views/webhooks.markdown +53 -33
- data/lib/pact_broker/domain/pact.rb +4 -0
- data/lib/pact_broker/domain/webhook.rb +19 -3
- data/lib/pact_broker/domain/webhook_execution_result.rb +6 -1
- data/lib/pact_broker/domain/webhook_request.rb +87 -65
- data/lib/pact_broker/locale/en.yml +1 -0
- data/lib/pact_broker/matrix/repository.rb +3 -1
- data/lib/pact_broker/pacts/placeholder_pact.rb +17 -0
- data/lib/pact_broker/pacts/repository.rb +14 -0
- data/lib/pact_broker/pacts/service.rb +6 -2
- data/lib/pact_broker/ui/view_models/index_item.rb +1 -1
- data/lib/pact_broker/verifications/placeholder_verification.rb +23 -0
- data/lib/pact_broker/verifications/repository.rb +9 -0
- data/lib/pact_broker/verifications/service.rb +5 -1
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/repository.rb +54 -4
- data/lib/pact_broker/webhooks/service.rb +37 -2
- data/lib/pact_broker/webhooks/webhook.rb +4 -3
- data/lib/pact_broker/webhooks/webhook_event.rb +8 -0
- data/lib/pact_broker/webhooks/webhook_request_template.rb +72 -0
- data/pact_broker.gemspec +1 -1
- data/script/seed.rb +32 -51
- data/spec/features/create_webhook_spec.rb +85 -36
- data/spec/features/execute_webhook_spec.rb +9 -18
- data/spec/features/get_triggered_webhooks_for_pact_spec.rb +20 -0
- data/spec/features/get_triggered_webhooks_for_verification_spec.rb +21 -0
- data/spec/fixtures/webhook_valid_with_pacticipants.json +23 -0
- data/spec/integration/webhooks/certificate_spec.rb +2 -2
- data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +98 -2
- data/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb +64 -0
- data/spec/lib/pact_broker/api/decorators/triggered_webhooks_decorator_spec.rb +28 -0
- data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +8 -0
- data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +37 -1
- data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +34 -1
- data/spec/lib/pact_broker/api/decorators/{webhook_request_decorator_spec.rb → webhook_request_template_decorator_spec.rb} +7 -9
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +22 -0
- data/spec/lib/pact_broker/api/resources/{pact_webhooks_spec.rb → all_webhooks_spec.rb} +46 -80
- data/spec/lib/pact_broker/api/resources/error_handler_spec.rb +34 -0
- data/spec/lib/pact_broker/api/resources/pact_triggered_webhooks_spec.rb +54 -0
- data/spec/lib/pact_broker/api/resources/pacticipant_spec.rb +1 -6
- data/spec/lib/pact_broker/api/resources/tag_spec.rb +1 -6
- data/spec/lib/pact_broker/api/resources/verification_triggered_webhooks_spec.rb +68 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +2 -8
- data/spec/lib/pact_broker/api/resources/webhooks_spec.rb +216 -21
- data/spec/lib/pact_broker/configuration_spec.rb +30 -0
- data/spec/lib/pact_broker/domain/webhook_request_spec.rb +20 -64
- data/spec/lib/pact_broker/domain/webhook_spec.rb +40 -11
- data/spec/lib/pact_broker/matrix/repository_spec.rb +33 -0
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +1 -0
- data/spec/lib/pact_broker/pacts/repository_spec.rb +39 -1
- data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +1 -1
- data/spec/lib/pact_broker/verifications/repository_spec.rb +37 -0
- data/spec/lib/pact_broker/verifications/service_spec.rb +2 -2
- data/spec/lib/pact_broker/webhooks/render_spec.rb +15 -0
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +149 -30
- data/spec/lib/pact_broker/webhooks/service_spec.rb +84 -7
- data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +81 -0
- data/spec/service_consumers/pact_helper.rb +2 -0
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +8 -0
- data/spec/service_consumers/provider_states_for_pact_ruby.rb +132 -0
- data/spec/support/test_data_builder.rb +30 -7
- metadata +37 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8781ad53ce4869d80b5c2ad87288cd6d6e1561da
|
|
4
|
+
data.tar.gz: e83f9bc9fd4b337ac1d28a210402db80af340a5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c424033d9cb8fa602a2344d11eea58722001df6fc6555e10d51a4af28b29e92f660156650da1b7fd511a7496e5e9b9d01afdec1b4d288569cf49a567ef9a818
|
|
7
|
+
data.tar.gz: f746b17398c51084398b6c4197a4c42b61ea91b7f8b95c210234cb00102fff4f82e9f4ac5e4c26136ee1b375c1147d23909e137ee40e7ec8a21eefbd30432994
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
<a name="v2.23.0"></a>
|
|
2
|
+
### v2.23.0 (2018-06-20)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* include test webhook request in execution response body ([7518098](/../../commit/7518098))
|
|
8
|
+
* use the latest matching pact or verification to test webhook execution, or a placeholder if either is not found ([273078b](/../../commit/273078b))
|
|
9
|
+
* add resource to view the triggered webhooks for a verification result ([c3e8df0](/../../commit/c3e8df0))
|
|
10
|
+
* add resource to view the triggered webhooks for a pact publication ([00f60c1](/../../commit/00f60c1))
|
|
11
|
+
* allow "global" webhooks (matching all consumers and providers) to be triggered by pact or verification publication ([19f7060](/../../commit/19f7060))
|
|
12
|
+
* allow webhook with optional consumer and/or provider to be created by posting to /webhooks ([b15ba85](/../../commit/b15ba85))
|
|
13
|
+
* add consumer and provider objects to webhook resource ([e60460e](/../../commit/e60460e))
|
|
14
|
+
* move $.message to $.error.message in error response body ([803c025](/../../commit/803c025))
|
|
15
|
+
* only show backtrace in error response for non production environments ([665ac23](/../../commit/665ac23))
|
|
16
|
+
* change version ordering to sort by date by default ([6552b46](/../../commit/6552b46))
|
|
17
|
+
* raise explicit error if a matrix query is done for a version with a tag that does not exist ([8f64288](/../../commit/8f64288))
|
|
18
|
+
|
|
19
|
+
* **consumer or provider webhooks**
|
|
20
|
+
* refactor webhooks resource classes and add consumer and provider webhook links to pact resource ([9321c73](/../../commit/9321c73))
|
|
21
|
+
* change pact webhook status URL ([2445b1e](/../../commit/2445b1e))
|
|
22
|
+
* allow a webhook to be defined for either a consumer OR provider ([37a62be](/../../commit/37a62be))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* ensure non utf-8 characters in the webook response do not cause an error in the Pact Broker response body ([a5ae5bf](/../../commit/a5ae5bf))
|
|
28
|
+
* update sintra to >= 2.0.2 to fix css vulnerability ([3023408](/../../commit/3023408))
|
|
29
|
+
|
|
30
|
+
|
|
1
31
|
<a name="v2.22.0"></a>
|
|
2
32
|
### v2.22.0 (2018-06-11)
|
|
3
33
|
|
data/README.md
CHANGED
|
@@ -148,6 +148,7 @@ You can use the [Pact Broker Docker image][docker] or [Terraform on AWS][terrafo
|
|
|
148
148
|
`
|
|
149
149
|
* Please ensure you use `encoding: 'utf8'` in your Sequel options to avoid encoding issues.
|
|
150
150
|
* For production usage, use a web application server like [Phusion Passenger](https://www.phusionpassenger.com) or [Nginx](http://nginx.org/) to serve the Pact Broker application. You'll need to read up on the documentation for these yourself as it is beyond the scope of this documentation. See the [wiki][reverse-proxy-docs] for instructions on using a reverse proxy with SSL.
|
|
151
|
+
* Ensure the environment variable `RACK_ENV` is set to `production`.
|
|
151
152
|
* Deploy to your location of choice.
|
|
152
153
|
|
|
153
154
|
## Upgrading
|
data/example/config.ru
CHANGED
|
@@ -4,6 +4,8 @@ require 'sequel'
|
|
|
4
4
|
# require 'pg' # for postgres
|
|
5
5
|
require 'pact_broker'
|
|
6
6
|
|
|
7
|
+
ENV['RACK_ENV'] ||= 'production'
|
|
8
|
+
|
|
7
9
|
# Create a real database, and set the credentials for it here
|
|
8
10
|
# It is highly recommended to set the encoding to utf8
|
|
9
11
|
DATABASE_CREDENTIALS = {adapter: "sqlite", database: "pact_broker_database.sqlite3", :encoding => 'utf8'}
|
data/lib/pact_broker/api.rb
CHANGED
|
@@ -22,6 +22,7 @@ module PactBroker
|
|
|
22
22
|
# Verifications
|
|
23
23
|
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'pact-version', :pact_version_sha, 'verification-results'], Api::Resources::Verifications, {resource_name: "verification_results"}
|
|
24
24
|
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'pact-version', :pact_version_sha, 'verification-results', :verification_number], Api::Resources::Verification, {resource_name: "verification_result"}
|
|
25
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'pact-version', :pact_version_sha, 'verification-results', :verification_number, 'triggered-webhooks'], Api::Resources::VerificationTriggeredWebhooks, {resource_name: "verification_result_triggered_webhooks"}
|
|
25
26
|
add ['verification-results', 'consumer', :consumer_name, 'version', :consumer_version_number,'latest'], Api::Resources::LatestVerificationsForConsumerVersion, {resource_name: "verification_results_for_consumer_version"}
|
|
26
27
|
|
|
27
28
|
# Badges
|
|
@@ -55,13 +56,18 @@ module PactBroker
|
|
|
55
56
|
add ['pacticipants', :pacticipant_name, 'labels', :label_name], Api::Resources::Label, {resource_name: "pacticipant_label"}
|
|
56
57
|
|
|
57
58
|
# Webhooks
|
|
58
|
-
add ['webhooks', 'provider', :provider_name, 'consumer', :consumer_name ], Api::Resources::
|
|
59
|
-
add ['webhooks', 'provider', :provider_name
|
|
59
|
+
add ['webhooks', 'provider', :provider_name, 'consumer', :consumer_name ], Api::Resources::Webhooks, {resource_name: "consumer_and_provider_webhooks"}
|
|
60
|
+
add ['webhooks', 'provider', :provider_name], Api::Resources::Webhooks, {resource_name: "provider_webhooks"}
|
|
61
|
+
add ['webhooks', 'consumer', :consumer_name], Api::Resources::Webhooks, {resource_name: "consumer_webhooks"}
|
|
62
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'webhooks'], Api::Resources::PactWebhooks, {resource_name: "pact_webhooks"}
|
|
63
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'webhooks', 'status'], Api::Resources::PactWebhooksStatus, {resource_name: "pact_webhooks_status"}
|
|
64
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number, 'triggered-webhooks'], Api::Resources::PactTriggeredWebhooks, {resource_name: "pact_triggered_webhooks"}
|
|
60
65
|
|
|
61
66
|
add ['webhooks', :uuid ], Api::Resources::Webhook, {resource_name: "webhook"}
|
|
62
67
|
add ['webhooks', :uuid, 'trigger', :trigger_uuid, 'logs' ], Api::Resources::TriggeredWebhookLogs, {resource_name: "triggered_webhook_logs"}
|
|
63
68
|
add ['webhooks', :uuid, 'execute' ], Api::Resources::WebhookExecution, {resource_name: "execute_webhook"}
|
|
64
|
-
add ['webhooks'], Api::Resources::
|
|
69
|
+
add ['webhooks'], Api::Resources::AllWebhooks, {resource_name: "webhooks"}
|
|
70
|
+
|
|
65
71
|
|
|
66
72
|
add ['relationships'], Api::Resources::Relationships, {resource_name: "relationships"}
|
|
67
73
|
add ['groups', :pacticipant_name], Api::Resources::Group, {resource_name: "group"}
|
|
@@ -2,6 +2,7 @@ require 'reform'
|
|
|
2
2
|
require 'reform/form'
|
|
3
3
|
require 'pact_broker/webhooks/check_host_whitelist'
|
|
4
4
|
require 'pact_broker/webhooks/render'
|
|
5
|
+
require 'pact_broker/pacticipants/service'
|
|
5
6
|
|
|
6
7
|
module PactBroker
|
|
7
8
|
module Api
|
|
@@ -26,10 +27,45 @@ module PactBroker
|
|
|
26
27
|
config.messages_file = File.expand_path("../../../locale/en.yml", __FILE__)
|
|
27
28
|
end
|
|
28
29
|
|
|
30
|
+
optional(:consumer)
|
|
31
|
+
optional(:provider)
|
|
29
32
|
required(:request).filled
|
|
30
33
|
optional(:events).maybe(min_size?: 1)
|
|
31
34
|
end
|
|
32
35
|
|
|
36
|
+
property :consumer do
|
|
37
|
+
property :name
|
|
38
|
+
|
|
39
|
+
validation do
|
|
40
|
+
configure do
|
|
41
|
+
config.messages_file = File.expand_path("../../../locale/en.yml", __FILE__)
|
|
42
|
+
|
|
43
|
+
def pacticipant_exists?(name)
|
|
44
|
+
!!PactBroker::Pacticipants::Service.find_pacticipant_by_name(name)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
required(:name).filled(:pacticipant_exists?)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
property :provider do
|
|
54
|
+
property :name
|
|
55
|
+
|
|
56
|
+
validation do
|
|
57
|
+
configure do
|
|
58
|
+
config.messages_file = File.expand_path("../../../locale/en.yml", __FILE__)
|
|
59
|
+
|
|
60
|
+
def pacticipant_exists?(name)
|
|
61
|
+
!!PactBroker::Pacticipants::Service.find_pacticipant_by_name(name)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
required(:name).filled(:pacticipant_exists?)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
33
69
|
property :request do
|
|
34
70
|
property :url
|
|
35
71
|
property :http_method
|
|
@@ -102,7 +102,21 @@ module PactBroker
|
|
|
102
102
|
link :'pb:pact-webhooks' do | options |
|
|
103
103
|
{
|
|
104
104
|
title: "Webhooks for the pact between #{represented.consumer.name} and #{represented.provider.name}",
|
|
105
|
-
href:
|
|
105
|
+
href: webhooks_for_consumer_and_provider_url(represented.consumer, represented.provider, options.fetch(:base_url))
|
|
106
|
+
}
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
link :'pb:consumer-webhooks' do | options |
|
|
110
|
+
{
|
|
111
|
+
title: "Webhooks for all pacts with consumer #{represented.consumer.name}",
|
|
112
|
+
href: consumer_webhooks_url(represented.consumer, options.fetch(:base_url))
|
|
113
|
+
}
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
link :'pb:consumer-webhooks' do | options |
|
|
117
|
+
{
|
|
118
|
+
title: "Webhooks for all pacts with provider #{represented.provider.name}",
|
|
119
|
+
href: consumer_webhooks_url(represented.provider, options.fetch(:base_url))
|
|
106
120
|
}
|
|
107
121
|
end
|
|
108
122
|
|
|
@@ -127,6 +141,13 @@ module PactBroker
|
|
|
127
141
|
}
|
|
128
142
|
end
|
|
129
143
|
|
|
144
|
+
link :'pb:triggered-webhooks' do | options |
|
|
145
|
+
{
|
|
146
|
+
title: "Webhooks triggered by the publication of this pact",
|
|
147
|
+
href: pact_triggered_webhooks_url(represented, options.fetch(:base_url))
|
|
148
|
+
}
|
|
149
|
+
end
|
|
150
|
+
|
|
130
151
|
curies do | options |
|
|
131
152
|
[{
|
|
132
153
|
name: :pb,
|
|
@@ -1,37 +1,12 @@
|
|
|
1
1
|
require_relative 'base_decorator'
|
|
2
2
|
require_relative 'timestamps'
|
|
3
3
|
require_relative 'pact_version_decorator'
|
|
4
|
+
require_relative 'triggered_webhook_decorator'
|
|
4
5
|
|
|
5
6
|
module PactBroker
|
|
6
7
|
module Api
|
|
7
8
|
module Decorators
|
|
8
9
|
|
|
9
|
-
class TriggeredWebhookDecorator < BaseDecorator
|
|
10
|
-
property :request_description, as: :name
|
|
11
|
-
property :status
|
|
12
|
-
property :number_of_attempts_made, as: :attemptsMade
|
|
13
|
-
property :number_of_attempts_remaining, as: :attemptsRemaining
|
|
14
|
-
property :trigger_type, as: :triggerType
|
|
15
|
-
|
|
16
|
-
property :created_at, as: :triggeredAt
|
|
17
|
-
|
|
18
|
-
link :logs do | context |
|
|
19
|
-
{
|
|
20
|
-
href: triggered_webhook_logs_url(represented, context[:base_url]),
|
|
21
|
-
title: "Webhook execution logs",
|
|
22
|
-
name: represented.request_description
|
|
23
|
-
}
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
link :'pb:webhook' do | context |
|
|
27
|
-
{
|
|
28
|
-
href: webhook_url(represented.webhook_uuid, context[:base_url]),
|
|
29
|
-
title: "Webhook",
|
|
30
|
-
name: represented.request_description
|
|
31
|
-
}
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
10
|
class PactWebhooksStatusDecorator < BaseDecorator
|
|
36
11
|
|
|
37
12
|
property :summary, exec_context: :decorator do
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require_relative 'base_decorator'
|
|
2
|
+
|
|
3
|
+
module PactBroker
|
|
4
|
+
module Api
|
|
5
|
+
module Decorators
|
|
6
|
+
class TriggeredWebhookDecorator < BaseDecorator
|
|
7
|
+
property :request_description, as: :name
|
|
8
|
+
property :status
|
|
9
|
+
property :number_of_attempts_made, as: :attemptsMade
|
|
10
|
+
property :number_of_attempts_remaining, as: :attemptsRemaining
|
|
11
|
+
property :trigger_type, as: :triggerType
|
|
12
|
+
|
|
13
|
+
property :created_at, as: :triggeredAt
|
|
14
|
+
|
|
15
|
+
link :logs do | context |
|
|
16
|
+
{
|
|
17
|
+
href: triggered_webhook_logs_url(represented, context[:base_url]),
|
|
18
|
+
title: "Webhook execution logs",
|
|
19
|
+
name: represented.request_description
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
link :'pb:webhook' do | context |
|
|
24
|
+
{
|
|
25
|
+
href: webhook_url(represented.webhook_uuid, context[:base_url]),
|
|
26
|
+
title: "Webhook",
|
|
27
|
+
name: represented.request_description
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'pact_broker/api/decorators/base_decorator'
|
|
2
|
+
require 'pact_broker/api/decorators/triggered_webhook_decorator'
|
|
3
|
+
|
|
4
|
+
module PactBroker
|
|
5
|
+
module Api
|
|
6
|
+
module Decorators
|
|
7
|
+
class TriggeredWebhooksDecorator < BaseDecorator
|
|
8
|
+
collection :entries, as: :triggeredWebhooks, embedded: true, :extend => PactBroker::Api::Decorators::TriggeredWebhookDecorator
|
|
9
|
+
|
|
10
|
+
link :self do | options |
|
|
11
|
+
{
|
|
12
|
+
title: options.fetch(:resource_title),
|
|
13
|
+
href: options.fetch(:resource_url)
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -28,6 +28,12 @@ module PactBroker
|
|
|
28
28
|
}
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
link 'pb:triggered-webhooks' do | options |
|
|
32
|
+
{
|
|
33
|
+
title: 'Webhooks triggered by the publication of this verification result',
|
|
34
|
+
href: verification_triggered_webhooks_url(represented, options.fetch(:base_url))
|
|
35
|
+
}
|
|
36
|
+
end
|
|
31
37
|
end
|
|
32
38
|
end
|
|
33
39
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require_relative 'base_decorator'
|
|
2
|
-
require 'pact_broker/api/decorators/
|
|
2
|
+
require 'pact_broker/api/decorators/webhook_request_template_decorator'
|
|
3
3
|
require 'pact_broker/api/decorators/timestamps'
|
|
4
|
-
require 'pact_broker/
|
|
4
|
+
require 'pact_broker/webhooks/webhook_request_template'
|
|
5
5
|
require 'pact_broker/webhooks/webhook_event'
|
|
6
6
|
require 'pact_broker/api/decorators/basic_pacticipant_decorator'
|
|
7
7
|
require_relative 'pact_pacticipant_decorator'
|
|
@@ -16,7 +16,15 @@ module PactBroker
|
|
|
16
16
|
property :name
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
property :
|
|
19
|
+
property :consumer, :class => PactBroker::Domain::Pacticipant do
|
|
20
|
+
property :name
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
property :provider, :class => PactBroker::Domain::Pacticipant do
|
|
24
|
+
property :name
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
property :request, :class => PactBroker::Webhooks::WebhookRequestTemplate, extend: WebhookRequestTemplateDecorator
|
|
20
28
|
collection :events, :class => PactBroker::Webhooks::WebhookEvent, extend: WebhookEventDecorator
|
|
21
29
|
|
|
22
30
|
include Timestamps
|
|
@@ -31,33 +39,39 @@ module PactBroker
|
|
|
31
39
|
|
|
32
40
|
link :'pb:execute' do | options |
|
|
33
41
|
{
|
|
34
|
-
title: "Test the execution of the webhook by sending a POST request to this URL",
|
|
42
|
+
title: "Test the execution of the webhook with the latest matching pact or verification by sending a POST request to this URL",
|
|
35
43
|
href: webhook_execution_url(represented, options[:base_url])
|
|
36
44
|
}
|
|
37
45
|
end
|
|
38
46
|
|
|
39
47
|
|
|
40
48
|
link :'pb:consumer' do | options |
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
if represented.consumer
|
|
50
|
+
{
|
|
51
|
+
title: "Consumer",
|
|
52
|
+
name: represented.consumer.name,
|
|
53
|
+
href: pacticipant_url(options.fetch(:base_url), represented.consumer)
|
|
54
|
+
}
|
|
55
|
+
end
|
|
46
56
|
end
|
|
47
57
|
|
|
48
58
|
link :'pb:provider' do | options |
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
if represented.provider
|
|
60
|
+
{
|
|
61
|
+
title: "Provider",
|
|
62
|
+
name: represented.provider.name,
|
|
63
|
+
href: pacticipant_url(options.fetch(:base_url), represented.provider)
|
|
64
|
+
}
|
|
65
|
+
end
|
|
54
66
|
end
|
|
55
67
|
|
|
56
68
|
link :'pb:pact-webhooks' do | options |
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
if represented.consumer && represented.provider
|
|
70
|
+
{
|
|
71
|
+
title: "All webhooks for consumer #{represented.consumer.name} and provider #{represented.provider.name}",
|
|
72
|
+
href: webhooks_for_consumer_and_provider_url(represented.consumer, represented.provider, options[:base_url])
|
|
73
|
+
}
|
|
74
|
+
end
|
|
61
75
|
end
|
|
62
76
|
|
|
63
77
|
link :'pb:webhooks' do | options |
|
|
@@ -11,6 +11,32 @@ module PactBroker
|
|
|
11
11
|
property :backtrace
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
class HTTPRequestDecorator < BaseDecorator
|
|
15
|
+
property :headers, exec_context: :decorator
|
|
16
|
+
property :body, exec_context: :decorator
|
|
17
|
+
property :url, exec_context: :decorator
|
|
18
|
+
|
|
19
|
+
def headers
|
|
20
|
+
headers_hash = represented.to_hash
|
|
21
|
+
headers_hash.keys.each_with_object({}) do | name, new_headers_hash|
|
|
22
|
+
new_headers_hash[name] = headers_hash[name].join(", ")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def body
|
|
27
|
+
begin
|
|
28
|
+
::JSON.parse(represented.body)
|
|
29
|
+
rescue StandardError => e
|
|
30
|
+
represented.body
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def url
|
|
35
|
+
(represented.uri || represented.path).to_s
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
14
40
|
class HTTPResponseDecorator < BaseDecorator
|
|
15
41
|
property :status, :getter => lambda { |_| code.to_i }
|
|
16
42
|
property :headers, exec_context: :decorator
|
|
@@ -33,6 +59,7 @@ module PactBroker
|
|
|
33
59
|
end
|
|
34
60
|
|
|
35
61
|
property :error, :extend => ErrorDecorator, if: lambda { |context| context[:options][:user_options][:show_response] }
|
|
62
|
+
property :request, :extend => HTTPRequestDecorator
|
|
36
63
|
property :response, :extend => HTTPResponseDecorator, if: lambda { |context| context[:options][:user_options][:show_response] }
|
|
37
64
|
property :response_hidden_message, as: :message, exec_context: :decorator, if: lambda { |context| !context[:options][:user_options][:show_response] }
|
|
38
65
|
|
|
@@ -120,6 +120,10 @@ module PactBroker
|
|
|
120
120
|
"#{base_url}/verification-results/consumer/#{url_encode(version.pacticipant.name)}/version/#{version.number}/latest"
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
+
def verification_triggered_webhooks_url verification, base_url = ''
|
|
124
|
+
"#{verification_url(verification, base_url)}/triggered-webhooks"
|
|
125
|
+
end
|
|
126
|
+
|
|
123
127
|
def verification_publication_url pact, base_url
|
|
124
128
|
"#{pactigration_base_url(base_url, pact)}/pact-version/#{pact.pact_version_sha}/verification-results"
|
|
125
129
|
end
|
|
@@ -152,14 +156,30 @@ module PactBroker
|
|
|
152
156
|
"#{base_url}/webhooks/#{webhook.uuid}/execute"
|
|
153
157
|
end
|
|
154
158
|
|
|
155
|
-
def
|
|
159
|
+
def webhooks_for_consumer_and_provider_url consumer, provider, base_url = ''
|
|
156
160
|
"#{base_url}/webhooks/provider/#{url_encode(provider.name)}/consumer/#{url_encode(consumer.name)}"
|
|
157
161
|
end
|
|
158
162
|
|
|
163
|
+
def consumer_webhooks_url consumer, base_url = ''
|
|
164
|
+
"#{base_url}/webhooks/consumer/#{url_encode(consumer.name)}"
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def provider_webhooks_url provider, base_url = ''
|
|
168
|
+
"#{base_url}/webhooks/provider/#{url_encode(provider.name)}"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def webhooks_for_pact_url consumer, provider, base_url = ''
|
|
172
|
+
"#{base_url}/pacts/provider/#{url_encode(provider.name)}/consumer/#{url_encode(consumer.name)}/webhooks"
|
|
173
|
+
end
|
|
174
|
+
|
|
159
175
|
def webhooks_status_url consumer, provider, base_url = ''
|
|
160
176
|
"#{webhooks_for_pact_url(consumer, provider, base_url)}/status"
|
|
161
177
|
end
|
|
162
178
|
|
|
179
|
+
def pact_triggered_webhooks_url pact, base_url = ''
|
|
180
|
+
"#{pact_url(base_url, pact)}/triggered-webhooks"
|
|
181
|
+
end
|
|
182
|
+
|
|
163
183
|
def triggered_webhook_logs_url triggered_webhook, base_url
|
|
164
184
|
"#{base_url}/webhooks/#{triggered_webhook.webhook_uuid}/trigger/#{triggered_webhook.trigger_uuid}/logs"
|
|
165
185
|
end
|