pact_broker 2.74.1 → 2.75.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/.optic/.gitignore +2 -0
- data/.optic/api/specification.json +1 -0
- data/.optic/ignore +14 -0
- data/CHANGELOG.md +19 -0
- data/DEVELOPER_SETUP.md +9 -0
- data/Dockerfile +1 -0
- data/config/database.yml +1 -1
- data/db/migrations/20210115_add_webhook_foreign_key_indexes.rb +49 -0
- data/db/migrations/20210116_add_context_to_triggered_webhook.rb +11 -0
- data/db/migrations/migration_helper.rb +8 -0
- data/docker-compose-test.yml +4 -4
- data/lib/pact_broker/api.rb +13 -2
- data/lib/pact_broker/api/decorators.rb +3 -7
- data/lib/pact_broker/api/decorators/configuration.rb +33 -0
- data/lib/pact_broker/api/decorators/decorator_context_creator.rb +13 -0
- data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +1 -0
- data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +2 -3
- data/lib/pact_broker/api/decorators/reason_decorator.rb +2 -0
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +2 -2
- data/lib/pact_broker/api/resources/all_webhooks.rb +3 -3
- data/lib/pact_broker/api/resources/can_i_deploy_badge.rb +1 -1
- data/lib/pact_broker/api/resources/dashboard.rb +2 -2
- data/lib/pact_broker/api/resources/default_base_resource.rb +37 -12
- data/lib/pact_broker/api/resources/error_response_body_generator.rb +41 -0
- data/lib/pact_broker/api/resources/group.rb +1 -1
- data/lib/pact_broker/api/resources/integrations.rb +1 -1
- data/lib/pact_broker/api/resources/label.rb +1 -1
- data/lib/pact_broker/api/resources/latest_pact.rb +2 -2
- data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
- data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +2 -2
- data/lib/pact_broker/api/resources/matrix.rb +2 -2
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +1 -1
- data/lib/pact_broker/api/resources/pact.rb +2 -2
- data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +1 -1
- data/lib/pact_broker/api/resources/pact_versions.rb +1 -1
- data/lib/pact_broker/api/resources/pact_webhooks.rb +3 -3
- data/lib/pact_broker/api/resources/pact_webhooks_status.rb +2 -2
- data/lib/pact_broker/api/resources/pacticipant.rb +1 -1
- data/lib/pact_broker/api/resources/pacticipants.rb +3 -3
- data/lib/pact_broker/api/resources/pacticipants_for_label.rb +1 -1
- data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +1 -1
- data/lib/pact_broker/api/resources/provider_pacts.rb +1 -7
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +2 -2
- data/lib/pact_broker/api/resources/relationships.rb +1 -1
- data/lib/pact_broker/api/resources/tag.rb +1 -1
- data/lib/pact_broker/api/resources/tagged_pact_versions.rb +1 -1
- data/lib/pact_broker/api/resources/verification.rb +2 -2
- data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +1 -1
- data/lib/pact_broker/api/resources/verifications.rb +1 -1
- data/lib/pact_broker/api/resources/version.rb +1 -1
- data/lib/pact_broker/api/resources/versions.rb +1 -1
- data/lib/pact_broker/api/resources/webhook.rb +2 -2
- data/lib/pact_broker/api/resources/webhook_execution.rb +4 -4
- data/lib/pact_broker/api/resources/webhook_execution_methods.rb +1 -3
- data/lib/pact_broker/api/resources/webhooks.rb +3 -3
- data/lib/pact_broker/app.rb +8 -3
- data/lib/pact_broker/application_context.rb +41 -0
- data/lib/pact_broker/doc/controllers/app.rb +3 -2
- data/lib/pact_broker/domain/webhook_request.rb +1 -1
- data/lib/pact_broker/error.rb +0 -2
- data/lib/pact_broker/errors.rb +28 -0
- data/lib/pact_broker/errors/error_logger.rb +25 -0
- data/lib/pact_broker/services.rb +106 -31
- data/lib/pact_broker/test/http_test_data_builder.rb +35 -0
- data/lib/pact_broker/test/test_data_builder.rb +3 -2
- data/lib/pact_broker/ui/views/index/_getting-started.haml +1 -1
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +16 -16
- data/lib/pact_broker/ui/views/index/show.haml +6 -6
- data/lib/pact_broker/ui/views/layouts/main.haml +2 -2
- data/lib/pact_broker/ui/views/matrix/show.haml +32 -33
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/execution_configuration.rb +4 -0
- data/lib/pact_broker/webhooks/execution_configuration_creator.rb +14 -0
- data/lib/pact_broker/webhooks/repository.rb +3 -2
- data/lib/pact_broker/webhooks/service.rb +2 -1
- data/lib/pact_broker/webhooks/triggered_webhook.rb +1 -0
- data/optic.yml +5 -0
- data/pact_broker.gemspec +1 -1
- data/public/css/bootstrap-grid.css +3719 -0
- data/public/css/bootstrap-grid.css.map +1 -0
- data/public/css/bootstrap-grid.min.css +7 -0
- data/public/css/bootstrap-grid.min.css.map +1 -0
- data/public/css/bootstrap-reboot.css +331 -0
- data/public/css/bootstrap-reboot.css.map +1 -0
- data/public/css/bootstrap-reboot.min.css +8 -0
- data/public/css/bootstrap-reboot.min.css.map +1 -0
- data/public/css/bootstrap.css +8885 -5604
- data/public/css/bootstrap.css.map +1 -1
- data/public/css/bootstrap.min.css +4 -3
- data/public/css/bootstrap.min.css.map +1 -1
- data/public/images/alert.svg +1 -0
- data/public/images/arrow-switch.svg +1 -0
- data/public/images/check.svg +1 -0
- data/public/images/clock.svg +1 -0
- data/public/images/copy.svg +1 -0
- data/public/images/kebab-horizontal.svg +1 -0
- data/public/javascripts/clipboard.js +3 -3
- data/public/javascripts/{jquery-3.3.1.js → jquery-3.5.1.js} +1150 -642
- data/public/javascripts/jquery-3.5.1.min.js +2 -0
- data/public/javascripts/jquery-3.5.1.min.map +1 -0
- data/public/javascripts/matrix.js +2 -2
- data/public/js/bootstrap.bundle.js +7013 -0
- data/public/js/bootstrap.bundle.js.map +1 -0
- data/public/js/bootstrap.bundle.min.js +7 -0
- data/public/js/bootstrap.bundle.min.js.map +1 -0
- data/public/js/bootstrap.js +3862 -1804
- data/public/js/bootstrap.js.map +1 -0
- data/public/js/bootstrap.min.js +6 -6
- data/public/js/bootstrap.min.js.map +1 -0
- data/public/stylesheets/index.css +56 -3
- data/public/stylesheets/matrix.css +55 -5
- data/public/stylesheets/pact.css +14 -0
- data/regression/.gitignore +1 -0
- data/regression/can_i_deploy_spec.rb +42 -0
- data/regression/regression_helper.rb +37 -0
- data/regression/script/approval-all.sh +6 -0
- data/script/exercise-api-for-optic.sh +3 -0
- data/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +65 -5
- data/spec/lib/pact_broker/api/resources/error_response_body_generator_spec.rb +69 -0
- data/spec/lib/pact_broker/db/log_quietener_spec.rb +1 -1
- data/spec/lib/pact_broker/errors/error_logger_spec.rb +62 -0
- data/spec/lib/pact_broker/errors_spec.rb +55 -0
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +5 -2
- data/spec/lib/pact_broker/webhooks/service_spec.rb +2 -1
- data/tasks/rspec.rake +6 -0
- metadata +54 -17
- data/public/css/bootstrap-theme.css +0 -587
- data/public/css/bootstrap-theme.css.map +0 -1
- data/public/css/bootstrap-theme.min.css +0 -6
- data/public/css/bootstrap-theme.min.css.map +0 -1
- data/public/fonts/glyphicons-halflings-regular.svg +0 -288
- data/public/javascripts/jquery-3.3.1.min.js +0 -2
- data/public/javascripts/jquery-3.3.1.min.map +0 -1
- data/spec/lib/pact_broker/api/resources/error_handler_spec.rb +0 -211
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe978e58a9f4c7e3e190b8fd5b48ce70212bac2dcc4c0ea795565a00db6127e3
|
|
4
|
+
data.tar.gz: 551b0f07b25b75db367cb4a6d16ce114ab64b2541f1a452ab686145d3b5610ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87c8c396ed8dd5aaabd184a7a65a24c7ba641d11a257bfb17d3cf497e4cc9e3e33a2a761143f3c59d511e0d42c3440ea3117f186ee179aff095d917c228dd820
|
|
7
|
+
data.tar.gz: 5d4b9dfc5bab8f3f3671dc10011a11c925bbf2ff2edc8b3a8196c204c6bdace6bc09d8c004e3bbed438a111c202b99b01937163708da591375f8828ef02e81a4
|
data/.optic/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
data/.optic/ignore
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Default Ignore Rules
|
|
2
|
+
# Learn to configure your own at https://useoptic.com/docs
|
|
3
|
+
OPTIONS *
|
|
4
|
+
HEAD *
|
|
5
|
+
GET (.*).htm
|
|
6
|
+
GET (.*).html
|
|
7
|
+
GET (.*).css
|
|
8
|
+
GET (.*).js
|
|
9
|
+
GET (.*).woff
|
|
10
|
+
GET (.*).png
|
|
11
|
+
GET (.*).jpg
|
|
12
|
+
GET (.*).jpeg
|
|
13
|
+
GET (.*).svg
|
|
14
|
+
GET (.*).gif
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
<a name="v2.75.0"></a>
|
|
2
|
+
### v2.75.0 (2021-01-18)
|
|
3
|
+
|
|
4
|
+
#### Features
|
|
5
|
+
|
|
6
|
+
* upgrade bootstrap (#370) ([a457c337](/../../commit/a457c337))
|
|
7
|
+
* add indexes to webhook_executions and triggered_webhooks tables ([b05e7dbe](/../../commit/b05e7dbe))
|
|
8
|
+
|
|
9
|
+
* **webhook**
|
|
10
|
+
* set read and open timeouts ([8b502c44](/../../commit/8b502c44))
|
|
11
|
+
|
|
12
|
+
#### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **ui**
|
|
15
|
+
* upgrade to jquery-3.5.1 to address vulnerabilities in jquery-3.3.1 ([de41b231](/../../commit/de41b231))
|
|
16
|
+
|
|
17
|
+
* **deps**
|
|
18
|
+
* upgrade redcarpet for CVE-2020-26298 ([b57aad32](/../../commit/b57aad32))
|
|
19
|
+
|
|
1
20
|
<a name="v2.74.1"></a>
|
|
2
21
|
### v2.74.1 (2021-01-05)
|
|
3
22
|
|
data/DEVELOPER_SETUP.md
CHANGED
|
@@ -68,6 +68,13 @@ bundle exec rake
|
|
|
68
68
|
# if you don't want to run the whole rake test suite, init the db first
|
|
69
69
|
/home/init-db.sh
|
|
70
70
|
```
|
|
71
|
+
|
|
72
|
+
Running a mysql client in the mysql-tests container:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
mysql -hmysql -upact_broker -ppact_broker
|
|
76
|
+
```
|
|
77
|
+
|
|
71
78
|
## Running the tests
|
|
72
79
|
|
|
73
80
|
* To run everything (specs, pact verifications, vulnerability scan...):
|
|
@@ -87,5 +94,7 @@ bundle exec rake
|
|
|
87
94
|
bundle exec rspec path_to_your_spec.rb
|
|
88
95
|
```
|
|
89
96
|
|
|
97
|
+
NOTE: the spec tasks requires the `db:prepare:test` task to be executed at least once prior to running.
|
|
98
|
+
|
|
90
99
|
[chruby]: https://github.com/postmodern/chruby
|
|
91
100
|
[ruby-install]: https://github.com/postmodern/ruby-install
|
data/Dockerfile
CHANGED
data/config/database.yml
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require_relative 'migration_helper'
|
|
2
|
+
|
|
3
|
+
include PactBroker::MigrationHelper
|
|
4
|
+
|
|
5
|
+
Sequel.migration do
|
|
6
|
+
up do
|
|
7
|
+
if !mysql?
|
|
8
|
+
alter_table(:webhook_executions) do
|
|
9
|
+
add_index([:triggered_webhook_id], name: "webhook_executions_triggered_webhook_id_index")
|
|
10
|
+
end
|
|
11
|
+
# MySQL automatically creates indexes for foreign keys then complains if you
|
|
12
|
+
# re-create it with a different name and try to drop it.
|
|
13
|
+
|
|
14
|
+
# https://stackoverflow.com/a/52274628/832671 - "When there is only one index that can be used
|
|
15
|
+
# for the foreign key, it can't be dropped. If you really wan't to drop it, you either have to drop
|
|
16
|
+
# the foreign key constraint or to create another index for it first."
|
|
17
|
+
|
|
18
|
+
alter_table(:triggered_webhooks) do
|
|
19
|
+
add_index([:webhook_id], name: "triggered_webhooks_webhook_id_index")
|
|
20
|
+
add_index([:consumer_id], name: "triggered_webhooks_consumer_id_index")
|
|
21
|
+
add_index([:provider_id], name: "triggered_webhooks_provider_id_index")
|
|
22
|
+
add_index([:verification_id], name: "triggered_webhooks_verification_id_index")
|
|
23
|
+
add_index([:pact_publication_id], name: "triggered_webhooks_pact_publication_id_index")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
down do
|
|
29
|
+
if !mysql?
|
|
30
|
+
alter_table(:webhook_executions) do
|
|
31
|
+
drop_index([:triggered_webhook_id], name: "webhook_executions_triggered_webhook_id_index")
|
|
32
|
+
end
|
|
33
|
+
# MySQL automatically creates indexes for foreign keys then complains if you
|
|
34
|
+
# re-create it with a different name and try to drop it.
|
|
35
|
+
|
|
36
|
+
# https://stackoverflow.com/a/52274628/832671 - "When there is only one index that can be used
|
|
37
|
+
# for the foreign key, it can't be dropped. If you really wan't to drop it, you either have to drop
|
|
38
|
+
# the foreign key constraint or to create another index for it first."
|
|
39
|
+
|
|
40
|
+
alter_table(:triggered_webhooks) do
|
|
41
|
+
drop_index([:webhook_id], name: "triggered_webhooks_webhook_id_index")
|
|
42
|
+
drop_index([:consumer_id], name: "triggered_webhooks_consumer_id_index")
|
|
43
|
+
drop_index([:provider_id], name: "triggered_webhooks_provider_id_index")
|
|
44
|
+
drop_index([:verification_id], name: "triggered_webhooks_verification_id_index")
|
|
45
|
+
drop_index([:pact_publication_id], name: "triggered_webhooks_pact_publication_id_index")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -30,6 +30,14 @@ module PactBroker
|
|
|
30
30
|
Sequel::Model.db.adapter_scheme.to_s
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
def with_type_hash_if_postgres(options)
|
|
34
|
+
if postgres?
|
|
35
|
+
options.merge(type: "hash")
|
|
36
|
+
else
|
|
37
|
+
options
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
33
41
|
def sqlite_safe string
|
|
34
42
|
if adapter == 'sqlite'
|
|
35
43
|
string.gsub(/(?:\b|")order(?:"|\b)/, '`order`')
|
data/docker-compose-test.yml
CHANGED
|
@@ -6,8 +6,8 @@ services:
|
|
|
6
6
|
image: postgres
|
|
7
7
|
healthcheck:
|
|
8
8
|
test: psql postgres --command "select 1" -U postgres
|
|
9
|
-
ports:
|
|
10
|
-
|
|
9
|
+
# ports:
|
|
10
|
+
# - "5432:5432"
|
|
11
11
|
environment:
|
|
12
12
|
POSTGRES_USER: postgres
|
|
13
13
|
POSTGRES_PASSWORD: postgres
|
|
@@ -58,8 +58,8 @@ services:
|
|
|
58
58
|
MYSQL_DATABASE: pact_broker
|
|
59
59
|
MYSQL_USER: pact_broker
|
|
60
60
|
MYSQL_PASSWORD: pact_broker
|
|
61
|
-
ports:
|
|
62
|
-
|
|
61
|
+
# ports:
|
|
62
|
+
# - "3306:3306"
|
|
63
63
|
|
|
64
64
|
init-mysql:
|
|
65
65
|
build: .
|
data/lib/pact_broker/api.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'webmachine/adapters/rack_mapped'
|
|
2
2
|
require 'webmachine/rack_adapter_monkey_patch'
|
|
3
3
|
require 'pact_broker/api/resources'
|
|
4
|
+
require 'pact_broker/api/decorators'
|
|
5
|
+
require 'pact_broker/application_context'
|
|
4
6
|
require 'pact_broker/feature_toggle'
|
|
5
7
|
|
|
6
8
|
module Webmachine
|
|
@@ -12,8 +14,7 @@ module Webmachine
|
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
module PactBroker
|
|
15
|
-
|
|
16
|
-
API ||= begin
|
|
17
|
+
def self.build_api(application_context = PactBroker::ApplicationContext.default_application_context)
|
|
17
18
|
pact_api = Webmachine::Application.new do |app|
|
|
18
19
|
app.routes do
|
|
19
20
|
add(['trace', :*], Webmachine::Trace::TraceResource) unless ENV['RACK_ENV'] == 'production'
|
|
@@ -111,10 +112,20 @@ module PactBroker
|
|
|
111
112
|
end
|
|
112
113
|
end
|
|
113
114
|
|
|
115
|
+
# naughty, but better than setting each route manually
|
|
116
|
+
pact_api.routes.each do | route |
|
|
117
|
+
route.instance_variable_get(:@bindings)[:application_context] = application_context
|
|
118
|
+
end
|
|
119
|
+
|
|
114
120
|
pact_api.configure do |config|
|
|
115
121
|
config.adapter = :RackMapped
|
|
116
122
|
end
|
|
117
123
|
|
|
118
124
|
pact_api.adapter
|
|
119
125
|
end
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
API ||= begin
|
|
129
|
+
build_api
|
|
130
|
+
end
|
|
120
131
|
end
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
|
|
4
|
-
require 'pact_broker/api/decorators/pact_collection_decorator'
|
|
5
|
-
require 'pact_broker/api/decorators/pact_pacticipant_decorator'
|
|
6
|
-
require 'pact_broker/api/decorators/pact_details_decorator'
|
|
7
|
-
require 'pact_broker/api/decorators/tag_decorator'
|
|
1
|
+
Dir.glob(File.expand_path(File.join(__FILE__, "..", "decorators", "*.rb"))).sort.each do | path |
|
|
2
|
+
require path
|
|
3
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'pact_broker/string_refinements'
|
|
2
|
+
|
|
3
|
+
module PactBroker
|
|
4
|
+
module Api
|
|
5
|
+
module Decorators
|
|
6
|
+
class Configuration
|
|
7
|
+
using PactBroker::StringRefinements
|
|
8
|
+
|
|
9
|
+
def initialize(overrides = {})
|
|
10
|
+
@overrides = overrides
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def class_for(name)
|
|
14
|
+
if overrides[name].is_a?(String)
|
|
15
|
+
Object.const_get(overrides[name])
|
|
16
|
+
elsif overrides[name].is_a?(Class)
|
|
17
|
+
overrides[name]
|
|
18
|
+
else
|
|
19
|
+
Object.const_get("PactBroker::Api::Decorators::#{name.to_s.camelcase(true)}")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.default_configuration
|
|
24
|
+
Configuration.new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
attr_reader :overrides
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'pact_broker/api/decorators/decorator_context'
|
|
2
|
+
|
|
3
|
+
module PactBroker
|
|
4
|
+
module Api
|
|
5
|
+
module Decorators
|
|
6
|
+
class DecoratorContextCreator
|
|
7
|
+
def self.call(resource, options)
|
|
8
|
+
Decorators::DecoratorContext.new(resource.base_url, resource.resource_url, resource.request.env, options)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
require 'roar/json/hal'
|
|
2
2
|
require 'pact_broker/api/pact_broker_urls'
|
|
3
3
|
require_relative 'embedded_version_decorator'
|
|
4
|
+
require 'pact_broker/domain/pacticipant'
|
|
5
|
+
require 'pact_broker/api/decorators/pacticipant_decorator'
|
|
4
6
|
|
|
5
7
|
module PactBroker
|
|
6
|
-
|
|
7
8
|
module Api
|
|
8
|
-
|
|
9
9
|
module Decorators
|
|
10
|
-
|
|
11
10
|
class PacticipantCollectionDecorator < BaseDecorator
|
|
12
11
|
|
|
13
12
|
collection :entries, :as => :pacticipants, :class => PactBroker::Domain::Pacticipant, :extend => PactBroker::Api::Decorators::PacticipantDecorator, embedded: true
|
|
@@ -45,7 +45,7 @@ module PactBroker
|
|
|
45
45
|
<link rel='stylesheet' type='text/css' href='#{base_url}/stylesheets/material-menu.css'>
|
|
46
46
|
<link rel='stylesheet' type='text/css' href='#{base_url}/stylesheets/jquery-confirm.min.css'>
|
|
47
47
|
<script src='#{base_url}/javascripts/highlight.pack.js'></script>
|
|
48
|
-
<script src='#{base_url}/javascripts/jquery-3.
|
|
48
|
+
<script src='#{base_url}/javascripts/jquery-3.5.1.min.js'></script>
|
|
49
49
|
<script src='#{base_url}/js/bootstrap.min.js'></script>
|
|
50
50
|
<script src='#{base_url}/javascripts/material-menu.js'></script>
|
|
51
51
|
<script src='#{base_url}/javascripts/pact.js'></script>
|
|
@@ -80,7 +80,7 @@ module PactBroker
|
|
|
80
80
|
data-provider-name=\"#{provider_name}\"
|
|
81
81
|
data-consumer-version-number=\"#{consumer_version_number}\"
|
|
82
82
|
data-pact-url=\"#{pact_url}\"
|
|
83
|
-
class='more-options
|
|
83
|
+
class='more-options kebab-horizontal'
|
|
84
84
|
aria-hidden='true'></span>
|
|
85
85
|
</li>
|
|
86
86
|
</ul>
|
|
@@ -37,12 +37,12 @@ module PactBroker
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def to_json
|
|
40
|
-
|
|
40
|
+
decorator_class(:webhooks_decorator).new(webhooks).to_json(decorator_options(resource_title: "Webhooks"))
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def from_json
|
|
44
44
|
saved_webhook = webhook_service.create(next_uuid, webhook, consumer, provider)
|
|
45
|
-
response.body =
|
|
45
|
+
response.body = decorator_class(:webhook_decorator).new(saved_webhook).to_json(decorator_options)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def policy_name
|
|
@@ -74,7 +74,7 @@ module PactBroker
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def webhook
|
|
77
|
-
@webhook ||=
|
|
77
|
+
@webhook ||= decorator_class(:webhook_decorator).new(PactBroker::Domain::Webhook.new).from_json(request_body)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def next_uuid
|
|
@@ -55,7 +55,7 @@ module PactBroker
|
|
|
55
55
|
end
|
|
56
56
|
rescue StandardError => e
|
|
57
57
|
# Want to render a badge, even if there's an error
|
|
58
|
-
badge_service.error_badge_url("error",
|
|
58
|
+
badge_service.error_badge_url("error", ErrorResponseBodyGenerator.display_message(e, "reference: #{PactBroker::Errors.generate_error_reference}"))
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -18,11 +18,11 @@ module PactBroker
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def to_json
|
|
21
|
-
|
|
21
|
+
decorator_class(:dashboard_decorator).new(index_items).to_json(decorator_options)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def to_text
|
|
25
|
-
|
|
25
|
+
decorator_class(:dashboard_text_decorator).new(index_items).to_text(decorator_options)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def policy_name
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'webmachine'
|
|
2
|
-
require 'pact_broker/api/resources/error_handler'
|
|
3
3
|
require 'pact_broker/services'
|
|
4
4
|
require 'pact_broker/api/decorators'
|
|
5
5
|
require 'pact_broker/logging'
|
|
6
6
|
require 'pact_broker/api/pact_broker_urls'
|
|
7
|
-
require 'pact_broker/api/decorators/decorator_context'
|
|
8
7
|
require 'pact_broker/json'
|
|
9
8
|
require 'pact_broker/pacts/pact_params'
|
|
10
9
|
require 'pact_broker/api/resources/authentication'
|
|
10
|
+
require 'pact_broker/errors'
|
|
11
11
|
|
|
12
12
|
module PactBroker
|
|
13
13
|
module Api
|
|
@@ -24,6 +24,7 @@ module PactBroker
|
|
|
24
24
|
|
|
25
25
|
def initialize
|
|
26
26
|
PactBroker.configuration.before_resource.call(self)
|
|
27
|
+
application_context.before_resource&.call(self)
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def options
|
|
@@ -35,6 +36,7 @@ module PactBroker
|
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def finish_request
|
|
39
|
+
application_context.after_resource&.call(self)
|
|
38
40
|
PactBroker.configuration.after_resource.call(self)
|
|
39
41
|
end
|
|
40
42
|
|
|
@@ -43,29 +45,39 @@ module PactBroker
|
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
def forbidden?
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
if application_context.resource_authorizer
|
|
49
|
+
!application_context.resource_authorizer.call(self)
|
|
50
|
+
elsif PactBroker.configuration.authorize
|
|
51
|
+
!PactBroker.configuration.authorize.call(self, {})
|
|
52
|
+
else
|
|
53
|
+
false
|
|
54
|
+
end
|
|
48
55
|
end
|
|
49
56
|
|
|
57
|
+
# The path_info segments aren't URL decoded
|
|
50
58
|
def identifier_from_path
|
|
51
|
-
request.path_info.each_with_object({}) do |
|
|
52
|
-
|
|
59
|
+
@identifier_from_path ||= request.path_info.each_with_object({}) do | (key, value), hash|
|
|
60
|
+
if value.is_a?(String)
|
|
61
|
+
hash[key] = URI.decode(value)
|
|
62
|
+
elsif value.is_a?(Symbol) || value.is_a?(Numeric)
|
|
63
|
+
hash[key] = value
|
|
64
|
+
end
|
|
53
65
|
end
|
|
54
66
|
end
|
|
55
67
|
|
|
56
68
|
alias_method :path_info, :identifier_from_path
|
|
57
69
|
|
|
58
70
|
def base_url
|
|
59
|
-
PactBroker.configuration.base_url || request.base_uri.to_s.chomp('/')
|
|
71
|
+
request.env["pactbroker.base_url"] || PactBroker.configuration.base_url || request.base_uri.to_s.chomp('/')
|
|
60
72
|
end
|
|
61
73
|
|
|
62
74
|
# See comments for base_url in lib/pact_broker/doc/controllers/app.rb
|
|
63
75
|
def ui_base_url
|
|
64
|
-
PactBroker.configuration.base_url || ''
|
|
76
|
+
request.env["pactbroker.base_url"] || PactBroker.configuration.base_url || ''
|
|
65
77
|
end
|
|
66
78
|
|
|
67
79
|
def charsets_provided
|
|
68
|
-
[[
|
|
80
|
+
[["utf-8", :encode]]
|
|
69
81
|
end
|
|
70
82
|
|
|
71
83
|
# We only use utf-8 so leave encoding as it is
|
|
@@ -78,15 +90,20 @@ module PactBroker
|
|
|
78
90
|
end
|
|
79
91
|
|
|
80
92
|
def decorator_context options = {}
|
|
81
|
-
|
|
93
|
+
application_context.decorator_context_creator.call(self, options)
|
|
82
94
|
end
|
|
83
95
|
|
|
84
96
|
def decorator_options options = {}
|
|
85
97
|
{ user_options: decorator_context(options) }
|
|
86
98
|
end
|
|
87
99
|
|
|
88
|
-
def handle_exception
|
|
89
|
-
PactBroker::
|
|
100
|
+
def handle_exception(error)
|
|
101
|
+
error_reference = PactBroker::Errors.generate_error_reference
|
|
102
|
+
application_context.error_logger.call(error, error_reference, request)
|
|
103
|
+
if PactBroker::Errors.reportable_error?(error)
|
|
104
|
+
PactBroker::Errors.report(error, error_reference, request)
|
|
105
|
+
end
|
|
106
|
+
response.body = application_context.error_response_body_generator.call(error, error_reference, request)
|
|
90
107
|
end
|
|
91
108
|
|
|
92
109
|
def params(options = {})
|
|
@@ -214,6 +231,14 @@ module PactBroker
|
|
|
214
231
|
def database_connector
|
|
215
232
|
request.env["pactbroker.database_connector"]
|
|
216
233
|
end
|
|
234
|
+
|
|
235
|
+
def application_context
|
|
236
|
+
request.path_info[:application_context]
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def decorator_class(name)
|
|
240
|
+
application_context.decorator_configuration.class_for(name)
|
|
241
|
+
end
|
|
217
242
|
end
|
|
218
243
|
end
|
|
219
244
|
end
|