pact_broker 2.72.0 → 2.76.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/.optic/.gitignore +2 -0
- data/.optic/api/specification.json +1 -0
- data/.optic/ignore +14 -0
- data/CHANGELOG.md +66 -0
- data/DEVELOPER_SETUP.md +9 -0
- data/Dockerfile +1 -0
- data/ISSUES.md +3 -3
- data/README.md +1 -1
- 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-issue-repro-with-pact-broker-docker-image.yml +33 -0
- data/docker-compose-test.yml +4 -4
- data/lib/db.rb +1 -0
- 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/extended_pact_decorator.rb +9 -1
- data/lib/pact_broker/api/decorators/extended_verification_decorator.rb +8 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +9 -4
- 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/decorators/tag_decorator.rb +0 -3
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +3 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +4 -4
- data/lib/pact_broker/api/paths.rb +5 -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_handler.rb +1 -1
- 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/metadata_resource_methods.rb +2 -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 +14 -3
- data/lib/pact_broker/application_context.rb +41 -0
- data/lib/pact_broker/configuration.rb +12 -4
- data/lib/pact_broker/doc/controllers/app.rb +3 -2
- data/lib/pact_broker/domain/version.rb +13 -6
- 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/metrics/service.rb +12 -1
- data/lib/pact_broker/pacts/metadata.rb +53 -8
- data/lib/pact_broker/pacts/repository.rb +10 -17
- data/lib/pact_broker/pacts/selector.rb +22 -0
- data/lib/pact_broker/pacts/selectors.rb +4 -0
- data/lib/pact_broker/services.rb +106 -31
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +2 -0
- data/lib/pact_broker/test/http_test_data_builder.rb +83 -21
- 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/lib/rack/pact_broker/hal_browser_redirect.rb +42 -0
- data/lib/rack/pact_broker/set_base_url.rb +22 -0
- data/lib/sequel/extensions/statement_timeout.rb +22 -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/script/reproduce-issue-starting-up.rb +43 -0
- data/script/reproduce-issue.rb +9 -21
- data/spec/lib/pact_broker/api/decorators/extended_pact_decorator_spec.rb +1 -0
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +20 -8
- data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +5 -7
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +10 -6
- 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 +59 -10
- 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/doc/controllers/app_spec.rb +3 -5
- 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/pacts/metadata_spec.rb +73 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +2 -2
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +33 -13
- data/spec/lib/pact_broker/pacts/selected_pact_spec.rb +23 -0
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +5 -2
- data/spec/lib/pact_broker/webhooks/service_spec.rb +2 -1
- data/spec/lib/rack/pact_broker/hal_browser_redirect_spec.rb +27 -0
- data/tasks/rspec.rake +6 -0
- metadata +65 -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 -195
@@ -23,7 +23,7 @@ module PactBroker
|
|
23
23
|
|
24
24
|
def to_json
|
25
25
|
summary = verification_service.verification_summary_for_consumer_version(identifier_from_path)
|
26
|
-
decorator_for(summary).to_json(
|
26
|
+
decorator_for(summary).to_json(decorator_options(identifier_from_path))
|
27
27
|
end
|
28
28
|
|
29
29
|
def policy_name
|
@@ -40,7 +40,7 @@ module PactBroker
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def decorator_for summary
|
43
|
-
|
43
|
+
decorator_class(:verification_summary_decorator).new(summary)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -36,11 +36,11 @@ module PactBroker
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def to_json
|
39
|
-
|
39
|
+
decorator_class(:matrix_decorator).new(results).to_json(decorator_options)
|
40
40
|
end
|
41
41
|
|
42
42
|
def to_text
|
43
|
-
|
43
|
+
decorator_class(:matrix_text_decorator).new(results).to_text(decorator_options)
|
44
44
|
end
|
45
45
|
|
46
46
|
def policy_name
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pact_broker/hash_refinements'
|
2
|
+
require 'pact_broker/pacts/metadata'
|
2
3
|
|
3
4
|
module PactBroker
|
4
5
|
module Api
|
@@ -15,7 +16,7 @@ module PactBroker
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def metadata
|
18
|
-
@metadata ||= PactBrokerUrls.decode_pact_metadata(identifier_from_path[:metadata])
|
19
|
+
@metadata ||= PactBroker::Pacts::Metadata.parse_metadata(PactBrokerUrls.decode_pact_metadata(identifier_from_path[:metadata]))
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -69,11 +69,11 @@ module PactBroker
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def to_json
|
72
|
-
|
72
|
+
decorator_class(:pact_decorator).new(pact).to_json(decorator_options(metadata: identifier_from_path[:metadata]))
|
73
73
|
end
|
74
74
|
|
75
75
|
def to_extended_json
|
76
|
-
|
76
|
+
decorator_class(:extended_pact_decorator).new(pact).to_json(decorator_options(metadata: identifier_from_path[:metadata]))
|
77
77
|
end
|
78
78
|
|
79
79
|
def to_html
|
@@ -18,7 +18,7 @@ module PactBroker
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_json
|
21
|
-
|
21
|
+
decorator_class(:triggered_webhooks_decorator).new(triggered_webhooks).to_json(decorator_options(resource_title: resource_title))
|
22
22
|
end
|
23
23
|
|
24
24
|
def policy_name
|
@@ -19,7 +19,7 @@ module PactBroker
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_json
|
22
|
-
|
22
|
+
decorator_class(:pact_versions_decorator).new(pacts).to_json(decorator_options(identifier_from_path))
|
23
23
|
end
|
24
24
|
|
25
25
|
def pacts
|
@@ -52,11 +52,11 @@ module PactBroker
|
|
52
52
|
|
53
53
|
def from_json
|
54
54
|
saved_webhook = webhook_service.create next_uuid, webhook, consumer, provider
|
55
|
-
response.body =
|
55
|
+
response.body = decorator_class(:webhook_decorator).new(saved_webhook).to_json(decorator_options)
|
56
56
|
end
|
57
57
|
|
58
58
|
def to_json
|
59
|
-
|
59
|
+
decorator_class(:webhooks_decorator).new(webhooks).to_json(decorator_options(resource_title: 'Pact webhooks'))
|
60
60
|
end
|
61
61
|
|
62
62
|
def policy_name
|
@@ -70,7 +70,7 @@ module PactBroker
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def webhook
|
73
|
-
@webhook ||=
|
73
|
+
@webhook ||= decorator_class(:webhook_decorator).new(PactBroker::Domain::Webhook.new).from_json(request_body)
|
74
74
|
end
|
75
75
|
|
76
76
|
def next_uuid
|
@@ -19,7 +19,7 @@ module PactBroker
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_json
|
22
|
-
decorator_for(latest_triggered_webhooks).to_json(
|
22
|
+
decorator_for(latest_triggered_webhooks).to_json(decorator_options(identifier_from_path))
|
23
23
|
end
|
24
24
|
|
25
25
|
def policy_name
|
@@ -41,7 +41,7 @@ module PactBroker
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def decorator_for latest_triggered_webhooks
|
44
|
-
|
44
|
+
decorator_class(:pact_webhooks_status_decorator).new(latest_triggered_webhooks)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -34,7 +34,7 @@ module PactBroker
|
|
34
34
|
|
35
35
|
def from_json
|
36
36
|
created_model = pacticipant_service.create(params.symbolize_keys.snakecase_keys.slice(:name, :repository_url))
|
37
|
-
response.body = decorator_for(created_model).to_json(
|
37
|
+
response.body = decorator_for(created_model).to_json(decorator_options)
|
38
38
|
end
|
39
39
|
|
40
40
|
def create_path
|
@@ -46,11 +46,11 @@ module PactBroker
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def generate_json pacticipants
|
49
|
-
|
49
|
+
decorator_class(:deprecated_pacticipant_collection_decorator).new(pacticipants).to_json(decorator_options)
|
50
50
|
end
|
51
51
|
|
52
52
|
def decorator_for model
|
53
|
-
|
53
|
+
decorator_class(:pacticipant_decorator).new(model)
|
54
54
|
end
|
55
55
|
|
56
56
|
def new_model
|
@@ -19,7 +19,7 @@ module PactBroker
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def generate_json pacticipants
|
22
|
-
|
22
|
+
decorator_class(:pacticipant_collection_decorator).new(pacticipants).to_json(decorator_options)
|
23
23
|
end
|
24
24
|
|
25
25
|
def policy_name
|
@@ -24,7 +24,7 @@ module PactBroker
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def to_json
|
27
|
-
|
27
|
+
decorator_class(:provider_pacts_decorator).new(pacts).to_json(decorator_options(identifier_from_path.merge(title: resource_title)))
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -33,12 +33,6 @@ module PactBroker
|
|
33
33
|
pact_service.find_pact_versions_for_provider provider_name, tag: identifier_from_path[:tag]
|
34
34
|
end
|
35
35
|
|
36
|
-
def to_json_options
|
37
|
-
{
|
38
|
-
user_options: decorator_context(identifier_from_path.merge(title: resource_title))
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
36
|
def resource_title
|
43
37
|
suffix = identifier_from_path[:tag] ? " with consumer version tag '#{identifier_from_path[:tag]}'" : ""
|
44
38
|
"All pact versions for the provider #{identifier_from_path[:provider_name]}#{suffix}"
|
@@ -53,7 +53,7 @@ module PactBroker
|
|
53
53
|
|
54
54
|
def to_json
|
55
55
|
log_request
|
56
|
-
|
56
|
+
decorator_class(:verifiable_pacts_decorator).new(pacts).to_json(
|
57
57
|
decorator_options(
|
58
58
|
include_pending_status: parsed_query_params.include_pending_status,
|
59
59
|
title: "Pacts to be verified by provider #{provider_name}",
|
@@ -71,7 +71,7 @@ module PactBroker
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def parsed_query_params
|
74
|
-
@parsed_query_params ||=
|
74
|
+
@parsed_query_params ||= decorator_class(:verifiable_pacts_query_decorator).new(OpenStruct.new).from_hash(query)
|
75
75
|
end
|
76
76
|
|
77
77
|
def query
|
@@ -22,7 +22,7 @@ module PactBroker
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_json
|
25
|
-
|
25
|
+
decorator_class(:tagged_pact_versions_decorator).new(pacts).to_json(decorator_options(identifier_from_path))
|
26
26
|
end
|
27
27
|
|
28
28
|
def delete_resource
|
@@ -60,11 +60,11 @@ module PactBroker
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def decorator_for model
|
63
|
-
|
63
|
+
decorator_class(:verification_decorator).new(model)
|
64
64
|
end
|
65
65
|
|
66
66
|
def extended_decorator_for model
|
67
|
-
|
67
|
+
decorator_class(:extended_verification_decorator).new(model)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -18,7 +18,7 @@ module PactBroker
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_json
|
21
|
-
|
21
|
+
decorator_class(:triggered_webhooks_decorator).new(triggered_webhooks).to_json(decorator_options(resource_title: resource_title))
|
22
22
|
end
|
23
23
|
|
24
24
|
def policy_name
|
@@ -19,7 +19,7 @@ module PactBroker
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_json
|
22
|
-
|
22
|
+
decorator_class(:versions_decorator).new(versions).to_json(decorator_options(identifier_from_path))
|
23
23
|
end
|
24
24
|
|
25
25
|
def versions
|
@@ -49,7 +49,7 @@ module PactBroker
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def to_json
|
52
|
-
|
52
|
+
decorator_class(:webhook_decorator).new(webhook).to_json(decorator_options)
|
53
53
|
end
|
54
54
|
|
55
55
|
def delete_resource
|
@@ -68,7 +68,7 @@ module PactBroker
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def parsed_webhook
|
71
|
-
@parsed_webhook ||=
|
71
|
+
@parsed_webhook ||= decorator_class(:webhook_decorator).new(PactBroker::Domain::Webhook.new).from_json(request_body)
|
72
72
|
end
|
73
73
|
|
74
74
|
def uuid
|
@@ -55,7 +55,7 @@ module PactBroker
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def post_response_body webhook_execution_result
|
58
|
-
|
58
|
+
decorator_class(:webhook_execution_result_decorator).new(webhook_execution_result).to_json(decorator_options)
|
59
59
|
end
|
60
60
|
|
61
61
|
def webhook
|
@@ -72,15 +72,15 @@ module PactBroker
|
|
72
72
|
identifier_from_path[:uuid]
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
76
|
-
|
75
|
+
def decorator_options
|
76
|
+
super(
|
77
77
|
webhook: webhook,
|
78
78
|
show_response: PactBroker.configuration.show_webhook_response?
|
79
79
|
)
|
80
80
|
end
|
81
81
|
|
82
82
|
def build_unsaved_webhook
|
83
|
-
|
83
|
+
decorator_class(:webhook_decorator).new(PactBroker::Domain::Webhook.new).from_json(request_body)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -3,9 +3,7 @@ module PactBroker
|
|
3
3
|
module Resources
|
4
4
|
module WebhookExecutionMethods
|
5
5
|
def webhook_execution_configuration
|
6
|
-
|
7
|
-
.with_show_response(PactBroker.configuration.show_webhook_response?)
|
8
|
-
.with_webhook_context(base_url: base_url)
|
6
|
+
application_context.webhook_execution_configuration_creator.call(self)
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
@@ -43,11 +43,11 @@ module PactBroker
|
|
43
43
|
|
44
44
|
def from_json
|
45
45
|
saved_webhook = webhook_service.create next_uuid, webhook, consumer, provider
|
46
|
-
response.body =
|
46
|
+
response.body = decorator_class(:webhook_decorator).new(saved_webhook).to_json(decorator_options)
|
47
47
|
end
|
48
48
|
|
49
49
|
def to_json
|
50
|
-
|
50
|
+
decorator_class(:webhooks_decorator).new(webhooks).to_json(decorator_options(resource_title: 'Pact webhooks'))
|
51
51
|
end
|
52
52
|
|
53
53
|
def policy_name
|
@@ -61,7 +61,7 @@ module PactBroker
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def webhook
|
64
|
-
@webhook ||=
|
64
|
+
@webhook ||= decorator_class(:webhook_decorator).new(PactBroker::Domain::Webhook.new).from_json(request_body)
|
65
65
|
end
|
66
66
|
|
67
67
|
def next_uuid
|
data/lib/pact_broker/app.rb
CHANGED
@@ -5,6 +5,8 @@ require 'pact_broker/logging/default_formatter'
|
|
5
5
|
require 'pact_broker/policies'
|
6
6
|
require 'rack-protection'
|
7
7
|
require 'rack/hal_browser'
|
8
|
+
require 'rack/pact_broker/hal_browser_redirect'
|
9
|
+
require 'rack/pact_broker/set_base_url'
|
8
10
|
require 'rack/pact_broker/add_pact_broker_version_header'
|
9
11
|
require 'rack/pact_broker/convert_file_extension_to_accept_header'
|
10
12
|
require 'rack/pact_broker/database_transaction'
|
@@ -32,6 +34,8 @@ module PactBroker
|
|
32
34
|
@cascade_apps = []
|
33
35
|
@make_it_later_api_auth = ::Rack::PactBroker::ConfigurableMakeItLater.new(Rack::PactBroker::NoAuth)
|
34
36
|
@make_it_later_ui_auth = ::Rack::PactBroker::ConfigurableMakeItLater.new(Rack::PactBroker::NoAuth)
|
37
|
+
# Can only be required after database connection has been made because the decorators rely on the Sequel models
|
38
|
+
@create_pact_broker_api_block = ->() { require 'pact_broker/api'; PactBroker::API }
|
35
39
|
@configuration = PactBroker.configuration
|
36
40
|
yield configuration
|
37
41
|
post_configure
|
@@ -68,13 +72,17 @@ module PactBroker
|
|
68
72
|
@custom_api = custom_api
|
69
73
|
end
|
70
74
|
|
75
|
+
def use_to_create_pact_broker_api &block
|
76
|
+
@create_pact_broker_api_block = block
|
77
|
+
end
|
78
|
+
|
71
79
|
def call env
|
72
80
|
running_app.call env
|
73
81
|
end
|
74
82
|
|
75
83
|
private
|
76
84
|
|
77
|
-
attr_reader :custom_ui
|
85
|
+
attr_reader :custom_ui, :create_pact_broker_api_block
|
78
86
|
|
79
87
|
def post_configure
|
80
88
|
configure_logger
|
@@ -126,6 +134,7 @@ module PactBroker
|
|
126
134
|
PactBroker::DB.validate_connection_config if configuration.validate_database_connection_config
|
127
135
|
PactBroker::DB.set_mysql_strict_mode_if_mysql
|
128
136
|
PactBroker::DB.connection.extension(:pagination)
|
137
|
+
PactBroker::DB.connection.extension(:statement_timeout)
|
129
138
|
|
130
139
|
Sequel.datetime_class = DateTime
|
131
140
|
Sequel.database_timezone = :utc # Store all dates in UTC, assume any date without a TZ is UTC
|
@@ -182,10 +191,13 @@ module PactBroker
|
|
182
191
|
@app_builder.use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts", "/images"], :root => PactBroker.project_root.join("public")
|
183
192
|
@app_builder.use Rack::Static, :urls => ["/favicon.ico"], :root => PactBroker.project_root.join("public/images"), header_rules: [[:all, {'Content-Type' => 'image/x-icon'}]]
|
184
193
|
@app_builder.use Rack::PactBroker::ConvertFileExtensionToAcceptHeader
|
194
|
+
# Rack::PactBroker::SetBaseUrl needs to be before the Rack::PactBroker::HalBrowserRedirect
|
195
|
+
@app_builder.use Rack::PactBroker::SetBaseUrl, configuration.base_url
|
185
196
|
|
186
197
|
if configuration.use_hal_browser
|
187
198
|
logger.info "Mounting HAL browser"
|
188
199
|
@app_builder.use Rack::HalBrowser::Redirect
|
200
|
+
@app_builder.use Rack::PactBroker::HalBrowserRedirect
|
189
201
|
else
|
190
202
|
logger.info "Not mounting HAL browser"
|
191
203
|
end
|
@@ -206,8 +218,7 @@ module PactBroker
|
|
206
218
|
|
207
219
|
def build_api
|
208
220
|
logger.info "Mounting PactBroker::API"
|
209
|
-
|
210
|
-
api_apps = [PactBroker::API]
|
221
|
+
api_apps = [create_pact_broker_api_block.call]
|
211
222
|
api_apps.unshift(@custom_api) if @custom_api
|
212
223
|
builder = ::Rack::Builder.new
|
213
224
|
builder.use @make_it_later_api_auth
|