pact_broker 2.49.0 → 2.50.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/lib/pact_broker/api/decorators/pact_decorator.rb +7 -0
- data/lib/pact_broker/api/pact_broker_urls.rb +16 -5
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +1 -1
- data/lib/pact_broker/api/resources/latest_pact.rb +6 -2
- data/lib/pact_broker/api/resources/matrix.rb +4 -4
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +5 -2
- data/lib/pact_broker/api/resources/verifications.rb +1 -1
- data/lib/pact_broker/app.rb +1 -1
- data/lib/pact_broker/configuration.rb +2 -1
- data/lib/pact_broker/db/data_migrations/delete_deprecated_webhook_executions.rb +21 -0
- data/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications.rb +2 -0
- data/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value.rb +2 -0
- data/lib/pact_broker/db/data_migrations/set_pacticipant_ids_for_verifications.rb +2 -0
- data/lib/pact_broker/db/delete_overwritten_data.rb +76 -0
- data/lib/pact_broker/db/migrate_data.rb +1 -0
- data/lib/pact_broker/doc/views/pact/all-pact-versions.markdown +1 -0
- data/lib/pact_broker/doc/views/pact/latest-pact-version.markdown +1 -1
- data/lib/pact_broker/doc/views/pact/matrix-for-consumer-version.markdown +7 -0
- data/lib/pact_broker/pacts/metadata.rb +37 -0
- data/lib/pact_broker/tasks.rb +1 -0
- data/lib/pact_broker/tasks/delete_overwritten_data_task.rb +37 -0
- data/lib/pact_broker/test/test_data_builder.rb +1 -14
- data/lib/pact_broker/ui/controllers/groups.rb +6 -3
- data/lib/pact_broker/ui/views/groups/show.html.erb +15 -0
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/execution.rb +2 -10
- data/lib/pact_broker/webhooks/repository.rb +0 -5
- data/lib/pact_broker/webhooks/service.rb +0 -1
- data/pact_broker.gemspec +2 -1
- data/spec/features/delete_pact_spec.rb +0 -1
- data/spec/features/delete_webhook_spec.rb +0 -1
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +14 -3
- data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +18 -2
- data/spec/lib/pact_broker/api/resources/latest_pact_spec.rb +33 -13
- data/spec/lib/pact_broker/api/resources/verifications_spec.rb +2 -2
- data/spec/lib/pact_broker/db/clean_spec.rb +0 -1
- data/spec/lib/pact_broker/db/delete_overwritten_data_spec.rb +101 -0
- data/spec/lib/pact_broker/pacticipants/service_spec.rb +1 -1
- data/spec/lib/pact_broker/pacts/service_spec.rb +0 -1
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +1 -39
- data/spec/lib/pact_broker/webhooks/service_spec.rb +0 -1
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +9 -0
- data/tasks/test_db.rake +7 -0
- metadata +27 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a34b4517981e902118bd7d55699749de020a12e5afcb68d3baed70b65cabe7f4
|
4
|
+
data.tar.gz: 6033d7d9a3cd1d5c767447c5d378e0709a1498cd1fb8b4d62a59288faef34b6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0087b549fee835fc3923fb0c1d50d53aa583661350386ab5033324de56227c308ad01a8f31d6f3d1a173dc877fcb778237faa0dcb96cd23603f868b42f7ed3e8'
|
7
|
+
data.tar.gz: dff10d2c54611d5f92b65de17cc61d249adc7b6d0f08fc4af3432fb48c04e4d36ce5b1e3d459bd49048a885e0cc027f5364455ec8cd9229264b572e9ff72698a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
<a name="v2.50.0"></a>
|
2
|
+
### v2.50.0 (2020-02-27)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* **deps**
|
8
|
+
* upgrade to pact-support 1.14.1 ([47c23b7d](/../../commit/47c23b7d))
|
9
|
+
|
10
|
+
* **ui**
|
11
|
+
* display repository URL on the pacticipant relationships page ([5d285e95](/../../commit/5d285e95))
|
12
|
+
|
13
|
+
* expose configuration option to allow missing migrations files on startup ([58dea9ab](/../../commit/58dea9ab))
|
14
|
+
* add rake task to clean overwritten pact publications and verifications ([942dfbd0](/../../commit/942dfbd0))
|
15
|
+
* include tag and consumer version number in metadata parameter of verification creation URL when verifying latest pact for a tag ([3b59e824](/../../commit/3b59e824))
|
16
|
+
|
17
|
+
* **pact**
|
18
|
+
* add relation to view matrix rows for the consumer version ([13cb20b1](/../../commit/13cb20b1))
|
19
|
+
|
20
|
+
|
1
21
|
<a name="v2.49.0"></a>
|
2
22
|
### v2.49.0 (2020-02-13)
|
3
23
|
|
@@ -159,6 +159,13 @@ module PactBroker
|
|
159
159
|
}
|
160
160
|
end
|
161
161
|
|
162
|
+
link :'pb:matrix-for-consumer-version' do | options |
|
163
|
+
{
|
164
|
+
title: "View matrix rows for the consumer version to which this pact belongs",
|
165
|
+
href: matrix_for_pacticipant_version_url(represented.consumer_version, options.fetch(:base_url))
|
166
|
+
}
|
167
|
+
end
|
168
|
+
|
162
169
|
curies do | options |
|
163
170
|
[{
|
164
171
|
name: :pb,
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'erb'
|
2
|
+
require 'pact_broker/pacts/metadata'
|
2
3
|
|
3
4
|
module PactBroker
|
4
5
|
module Api
|
5
6
|
module PactBrokerUrls
|
6
7
|
|
8
|
+
include PactBroker::Pacts::Metadata
|
7
9
|
# TODO make base_url the last and optional argument for all methods, defaulting to ''
|
8
10
|
|
9
11
|
extend self
|
@@ -59,13 +61,14 @@ module PactBroker
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def build_webhook_metadata(pact)
|
62
|
-
|
63
|
-
consumer_version_number: pact.consumer_version_number,
|
64
|
-
consumer_version_tags: pact.consumer_version_tag_names
|
65
|
-
))
|
64
|
+
encode_webhook_metadata(build_metadata_for_webhook_triggered_by_pact_publication(pact))
|
66
65
|
end
|
67
66
|
|
68
|
-
def
|
67
|
+
def encode_webhook_metadata(metadata)
|
68
|
+
Base64.strict_encode64(Rack::Utils.build_nested_query(metadata))
|
69
|
+
end
|
70
|
+
|
71
|
+
def decode_webhook_metadata(metadata)
|
69
72
|
if metadata
|
70
73
|
Rack::Utils.parse_nested_query(Base64.strict_decode64(metadata)).each_with_object({}) do | (k, v), new_hash |
|
71
74
|
new_hash[k.to_sym] = v
|
@@ -250,6 +253,14 @@ module PactBroker
|
|
250
253
|
"/matrix/provider/#{url_encode(provider_name)}/consumer/#{url_encode(consumer_name)}"
|
251
254
|
end
|
252
255
|
|
256
|
+
def matrix_for_pacticipant_version_url(version, base_url = '')
|
257
|
+
query = {
|
258
|
+
q: [{ pacticipant: version.pacticipant.name, version: version.number }],
|
259
|
+
latestby: 'cvpv'
|
260
|
+
}
|
261
|
+
"#{base_url}/matrix?#{Rack::Utils.build_nested_query(query)}"
|
262
|
+
end
|
263
|
+
|
253
264
|
def matrix_url_from_params params, base_url = ''
|
254
265
|
matrix_url(params.fetch(:consumer_name), params.fetch(:provider_name), base_url)
|
255
266
|
end
|
@@ -137,7 +137,7 @@ module PactBroker
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def matrix_url
|
140
|
-
PactBroker::Api::PactBrokerUrls.
|
140
|
+
PactBroker::Api::PactBrokerUrls.matrix_for_pacticipant_version_url(@pact.consumer_version, base_url)
|
141
141
|
end
|
142
142
|
|
143
143
|
def latest_pact_url
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pact_broker/api/resources/base_resource'
|
2
2
|
require 'pact_broker/configuration'
|
3
3
|
require 'pact_broker/api/decorators/extended_pact_decorator'
|
4
|
+
require 'pact_broker/pacts/metadata'
|
4
5
|
|
5
6
|
module PactBroker
|
6
7
|
module Api
|
@@ -25,11 +26,11 @@ module PactBroker
|
|
25
26
|
|
26
27
|
def to_json
|
27
28
|
response.headers['X-Pact-Consumer-Version'] = pact.consumer_version_number
|
28
|
-
PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options:
|
29
|
+
PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options: decorator_context(metadata: metadata))
|
29
30
|
end
|
30
31
|
|
31
32
|
def to_extended_json
|
32
|
-
PactBroker::Api::Decorators::ExtendedPactDecorator.new(pact).to_json(user_options: decorator_context(metadata:
|
33
|
+
PactBroker::Api::Decorators::ExtendedPactDecorator.new(pact).to_json(user_options: decorator_context(metadata: metadata))
|
33
34
|
end
|
34
35
|
|
35
36
|
def to_html
|
@@ -44,6 +45,9 @@ module PactBroker
|
|
44
45
|
@pact ||= pact_service.find_latest_pact(identifier_from_path)
|
45
46
|
end
|
46
47
|
|
48
|
+
def metadata
|
49
|
+
@metadata ||= encode_webhook_metadata(PactBroker::Pacts::Metadata.build_metadata_for_latest_pact(pact, identifier_from_path))
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -36,15 +36,15 @@ module PactBroker
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def to_json
|
39
|
-
PactBroker::Api::Decorators::MatrixDecorator.new(
|
39
|
+
PactBroker::Api::Decorators::MatrixDecorator.new(results).to_json(user_options: { base_url: base_url })
|
40
40
|
end
|
41
41
|
|
42
42
|
def to_text
|
43
|
-
PactBroker::Api::Decorators::MatrixTextDecorator.new(
|
43
|
+
PactBroker::Api::Decorators::MatrixTextDecorator.new(results).to_text(user_options: { base_url: base_url })
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
@
|
46
|
+
def results
|
47
|
+
@results ||= matrix_service.find(selectors, options)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -24,13 +24,16 @@ module PactBroker
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def to_json
|
27
|
-
|
28
|
-
PactBroker::Api::Decorators::MatrixDecorator.new(lines).to_json(user_options: { base_url: base_url })
|
27
|
+
PactBroker::Api::Decorators::MatrixDecorator.new(results).to_json(user_options: { base_url: base_url })
|
29
28
|
end
|
30
29
|
|
31
30
|
private
|
32
31
|
|
33
32
|
attr_reader :options
|
33
|
+
|
34
|
+
def results
|
35
|
+
@results ||= matrix_service.find_for_consumer_and_provider(identifier_from_path, options)
|
36
|
+
end
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
data/lib/pact_broker/app.rb
CHANGED
@@ -83,7 +83,7 @@ module PactBroker
|
|
83
83
|
def prepare_database
|
84
84
|
if configuration.auto_migrate_db
|
85
85
|
logger.info "Migrating database"
|
86
|
-
PactBroker::DB.run_migrations configuration.database_connection
|
86
|
+
PactBroker::DB.run_migrations configuration.database_connection, allow_missing_migration_files: configuration.allow_missing_migration_files
|
87
87
|
else
|
88
88
|
logger.info "Skipping database migrations"
|
89
89
|
end
|
@@ -34,7 +34,7 @@ module PactBroker
|
|
34
34
|
:badge_provider_mode
|
35
35
|
]
|
36
36
|
|
37
|
-
attr_accessor :base_url, :log_dir, :database_connection, :auto_migrate_db, :auto_migrate_db_data, :example_data_seeder, :seed_example_data, :use_hal_browser, :html_pact_renderer, :use_rack_protection
|
37
|
+
attr_accessor :base_url, :log_dir, :database_connection, :auto_migrate_db, :auto_migrate_db_data, :allow_missing_migration_files, :example_data_seeder, :seed_example_data, :use_hal_browser, :html_pact_renderer, :use_rack_protection
|
38
38
|
attr_accessor :validate_database_connection_config, :enable_diagnostic_endpoints, :version_parser, :sha_generator
|
39
39
|
attr_accessor :use_case_sensitive_resource_names, :order_versions_by_date
|
40
40
|
attr_accessor :check_for_potential_duplicate_pacticipant_names
|
@@ -64,6 +64,7 @@ module PactBroker
|
|
64
64
|
config.log_dir = File.expand_path("./log")
|
65
65
|
config.auto_migrate_db = true
|
66
66
|
config.auto_migrate_db_data = true
|
67
|
+
config.allow_missing_migration_files = false
|
67
68
|
config.use_rack_protection = true
|
68
69
|
config.use_hal_browser = true
|
69
70
|
config.validate_database_connection_config = true
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'pact_broker/db/data_migrations/helpers'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module DB
|
5
|
+
module DataMigrations
|
6
|
+
class DeleteDeprecatedWebhookExecutions
|
7
|
+
extend Helpers
|
8
|
+
|
9
|
+
def self.call(connection)
|
10
|
+
if columns_exist?(connection)
|
11
|
+
connection[:webhook_executions].where(triggered_webhook_id: nil).delete
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.columns_exist?(connection)
|
16
|
+
column_exists?(connection, :webhook_executions, :triggered_webhook_id)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'sequel'
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
module DB
|
6
|
+
class DeleteOverwrittenData
|
7
|
+
def self.call database_connection, options = {}
|
8
|
+
new(database_connection, options).call
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize database_connection, options = {}
|
12
|
+
@db = database_connection
|
13
|
+
@options = options
|
14
|
+
@before = options[:before] || DateTime.now
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
deleted_counts = {}
|
19
|
+
kept_counts = {}
|
20
|
+
|
21
|
+
|
22
|
+
deleted_counts.merge!(delete_overwritten_pact_publications)
|
23
|
+
deleted_counts.merge!(delete_overwritten_verifications)
|
24
|
+
deleted_counts.merge!(delete_orphan_pact_versions)
|
25
|
+
|
26
|
+
kept_counts[:pact_publications] = db[:pact_publications].count
|
27
|
+
kept_counts[:verification_results] = db[:verifications].count
|
28
|
+
kept_counts[:pact_versions] = db[:pact_versions].count
|
29
|
+
|
30
|
+
|
31
|
+
{ deleted: deleted_counts, kept: kept_counts }
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :db, :options, :before
|
37
|
+
|
38
|
+
def delete_webhook_data(triggered_webhook_ids)
|
39
|
+
db[:webhook_executions].where(triggered_webhook_id: triggered_webhook_ids).delete
|
40
|
+
db[:triggered_webhooks].where(id: triggered_webhook_ids).delete
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete_orphan_pact_versions
|
44
|
+
referenced_pact_version_ids = db[:pact_publications].select(:pact_version_id).union(db[:verifications].select(:pact_version_id))
|
45
|
+
pact_version_ids_to_delete = db[:pact_versions].where(id: referenced_pact_version_ids).invert
|
46
|
+
deleted_counts = { pact_versions: pact_version_ids_to_delete.count }
|
47
|
+
pact_version_ids_to_delete.delete
|
48
|
+
deleted_counts
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete_overwritten_pact_publications
|
52
|
+
pact_publication_ids_to_delete = db[:pact_publications]
|
53
|
+
.select(:id)
|
54
|
+
.where(id: db[:latest_pact_publication_ids_for_consumer_versions].select(:pact_publication_id))
|
55
|
+
.invert
|
56
|
+
.where(Sequel.lit('created_at < ?', before))
|
57
|
+
|
58
|
+
deleted_counts = { pact_publications: pact_publication_ids_to_delete.count }
|
59
|
+
delete_webhook_data(db[:triggered_webhooks].where(pact_publication_id: pact_publication_ids_to_delete).select(:id))
|
60
|
+
pact_publication_ids_to_delete.delete
|
61
|
+
deleted_counts
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete_overwritten_verifications
|
65
|
+
verification_ids = db[:verifications].select(:id)
|
66
|
+
.where(id: db[:latest_verification_id_for_pact_version_and_provider_version].select(:verification_id))
|
67
|
+
.invert
|
68
|
+
.where(Sequel.lit('created_at < ?', before))
|
69
|
+
deleted_counts = { verification_results: verification_ids.count }
|
70
|
+
delete_webhook_data(db[:triggered_webhooks].where(verification_id: verification_ids).select(:id))
|
71
|
+
verification_ids.delete
|
72
|
+
deleted_counts
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -18,6 +18,7 @@ module PactBroker
|
|
18
18
|
DataMigrations::SetConsumerIdsForPactPublications.call(database_connection)
|
19
19
|
DataMigrations::SetLatestVersionSequenceValue.call(database_connection)
|
20
20
|
DataMigrations::SetWebhooksEnabled.call(database_connection)
|
21
|
+
DataMigrations::DeleteDeprecatedWebhookExecutions.call(database_connection)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# All versions of a pact between a given consumer and provider
|
2
2
|
|
3
3
|
Allowed methods: `GET`, `DELETE`
|
4
|
+
|
4
5
|
Path: `/pacts/provider/{provider}/consumer/{consumer}/versions`
|
5
6
|
|
6
7
|
This resource returns a history of all the versions of the given pact between a consumer and provider.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module PactBroker
|
2
|
+
module Pacts
|
3
|
+
module Metadata
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# When verifying a pact at /.../latest/TAG, this stores the
|
7
|
+
# tag and the current consumer version number in the
|
8
|
+
# metadata parameter of the URL for publishing the verification results.
|
9
|
+
# This is part of ensuring that verification results webhooks
|
10
|
+
# go back to the correct consumer version number (eg for git statuses)
|
11
|
+
def build_metadata_for_latest_pact(pact, selection_parameters)
|
12
|
+
if selection_parameters[:tag]
|
13
|
+
{
|
14
|
+
consumer_version_tags: selection_parameters[:tag],
|
15
|
+
consumer_version_number: pact.consumer_version_number
|
16
|
+
}
|
17
|
+
else
|
18
|
+
{
|
19
|
+
consumer_version_number: pact.consumer_version_number
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# When a pact is published, and a webhook is triggered, this stores
|
25
|
+
# the current tags and consumer version number in the metadata parameter of the
|
26
|
+
# pact version URL that is made available in the webhook template
|
27
|
+
# parameters. This is part of ensuring that verification results webhooks
|
28
|
+
# go back to the correct consumer version number (eg for git statuses)
|
29
|
+
def build_metadata_for_webhook_triggered_by_pact_publication(pact)
|
30
|
+
{
|
31
|
+
consumer_version_number: pact.consumer_version_number,
|
32
|
+
consumer_version_tags: pact.consumer_version_tag_names
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/pact_broker/tasks.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
module PactBroker
|
2
|
+
module DB
|
3
|
+
class DeleteOverwrittenDataTask < ::Rake::TaskLib
|
4
|
+
attr_accessor :database_connection
|
5
|
+
attr_accessor :age_in_days
|
6
|
+
|
7
|
+
def initialize &block
|
8
|
+
rake_task &block
|
9
|
+
end
|
10
|
+
|
11
|
+
def rake_task &block
|
12
|
+
namespace :pact_broker do
|
13
|
+
namespace :db do
|
14
|
+
desc "Delete overwritten pacts and verifications from database"
|
15
|
+
task :delete_overwritten_data do | t, args |
|
16
|
+
require 'pact_broker/db/delete_overwritten_data'
|
17
|
+
require 'yaml'
|
18
|
+
|
19
|
+
instance_eval(&block)
|
20
|
+
options = {}
|
21
|
+
|
22
|
+
if age_in_days
|
23
|
+
options[:before] = (Date.today - age_in_days.to_i).to_datetime
|
24
|
+
$stdout.puts "Deleting overwritten pact publications and verifications older than #{age_in_days} days"
|
25
|
+
else
|
26
|
+
$stdout.puts "Deleting overwritten pact publications and verifications"
|
27
|
+
end
|
28
|
+
|
29
|
+
report = PactBroker::DB::DeleteOverwrittenData.call(database_connection, options)
|
30
|
+
$stdout.puts report.to_yaml
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -111,7 +111,7 @@ module PactBroker
|
|
111
111
|
|
112
112
|
def create_pacticipant pacticipant_name, params = {}
|
113
113
|
params.delete(:comment)
|
114
|
-
@pacticipant = PactBroker::Domain::Pacticipant.create({ :name => pacticipant_name }.merge(params))
|
114
|
+
@pacticipant = PactBroker::Domain::Pacticipant.create({ :name => pacticipant_name, repository_url: "https://github.com/example-organization/#{pacticipant_name}" }.merge(params))
|
115
115
|
self
|
116
116
|
end
|
117
117
|
|
@@ -307,19 +307,6 @@ module PactBroker
|
|
307
307
|
self
|
308
308
|
end
|
309
309
|
|
310
|
-
def create_deprecated_webhook_execution params = {}
|
311
|
-
params.delete(:comment)
|
312
|
-
create_webhook_execution params
|
313
|
-
Sequel::Model.db[:webhook_executions].where(id: webhook_execution.id).update(
|
314
|
-
triggered_webhook_id: nil,
|
315
|
-
consumer_id: consumer.id,
|
316
|
-
provider_id: provider.id,
|
317
|
-
webhook_id: PactBroker::Webhooks::Webhook.find(uuid: webhook.uuid).id,
|
318
|
-
pact_publication_id: pact.id
|
319
|
-
)
|
320
|
-
self
|
321
|
-
end
|
322
|
-
|
323
310
|
def create_verification parameters = {}
|
324
311
|
parameters.delete(:comment)
|
325
312
|
tag_names = [parameters.delete(:tag_names), parameters.delete(:tag_name)].flatten.compact
|
@@ -10,10 +10,13 @@ module PactBroker
|
|
10
10
|
include PactBroker::Services
|
11
11
|
|
12
12
|
get ":name" do
|
13
|
+
pacticipant = pacticipant_service.find_pacticipant_by_name(params[:name])
|
13
14
|
erb :'groups/show.html', {
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
locals: {
|
16
|
+
csv_path: "/groups/#{params[:name]}.csv",
|
17
|
+
pacticipant_name: params[:name],
|
18
|
+
repository_url: pacticipant&.repository_url
|
19
|
+
}
|
17
20
|
}, {
|
18
21
|
layout: 'layouts/main'
|
19
22
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<% require 'sanitize' %>
|
2
|
+
|
1
3
|
<!DOCTYPE html>
|
2
4
|
<html lang="en">
|
3
5
|
<head>
|
@@ -30,6 +32,19 @@ body{
|
|
30
32
|
</head>
|
31
33
|
<body>
|
32
34
|
<h1>Network graph of <%= pacticipant_name %> relationships</h1>
|
35
|
+
|
36
|
+
<% if repository_url %>
|
37
|
+
<p>Repository URL:
|
38
|
+
|
39
|
+
<%
|
40
|
+
repository_link = "<a href='#{repository_url}'>#{escape_html(repository_url)}</a>"
|
41
|
+
%>
|
42
|
+
|
43
|
+
<%= Sanitize.fragment(repository_link, Sanitize::Config::BASIC) %>
|
44
|
+
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
|
33
48
|
<script type="text/javascript">
|
34
49
|
var windowWidth, windowHeight, svg;
|
35
50
|
|
data/lib/pact_broker/version.rb
CHANGED
@@ -13,6 +13,8 @@ module PactBroker
|
|
13
13
|
Sequel[:webhook_executions][:created_at])
|
14
14
|
)
|
15
15
|
|
16
|
+
plugin :timestamps
|
17
|
+
|
16
18
|
dataset_module do
|
17
19
|
include PactBroker::Repositories::Helpers
|
18
20
|
end
|
@@ -25,16 +27,6 @@ module PactBroker
|
|
25
27
|
comp
|
26
28
|
end
|
27
29
|
end
|
28
|
-
|
29
|
-
# For a brief time, the code was released with a direct relationship between
|
30
|
-
# webhook and execution. Need to make sure any existing data is handled properly.
|
31
|
-
class DeprecatedExecution < Sequel::Model(:webhook_executions)
|
32
|
-
associate(:many_to_one, :provider, :class => "PactBroker::Domain::Pacticipant", :key => :provider_id, :primary_key => :id)
|
33
|
-
associate(:many_to_one, :consumer, :class => "PactBroker::Domain::Pacticipant", :key => :consumer_id, :primary_key => :id)
|
34
|
-
end
|
35
|
-
|
36
|
-
Execution.plugin :timestamps
|
37
|
-
|
38
30
|
end
|
39
31
|
end
|
40
32
|
|
@@ -136,9 +136,6 @@ module PactBroker
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def delete_executions_by_pacticipant pacticipants
|
139
|
-
# TODO this relationship no longer exists, deprecate in next version
|
140
|
-
DeprecatedExecution.where(consumer: pacticipants).delete
|
141
|
-
DeprecatedExecution.where(provider: pacticipants).delete
|
142
139
|
execution_ids = Execution
|
143
140
|
.join(:triggered_webhooks, {id: :triggered_webhook_id})
|
144
141
|
.where(Sequel.or(
|
@@ -151,7 +148,6 @@ module PactBroker
|
|
151
148
|
def delete_triggered_webhooks_by_webhook_uuid uuid
|
152
149
|
triggered_webhook_ids = TriggeredWebhook.where(webhook: Webhook.where(uuid: uuid)).select_for_subquery(:id)
|
153
150
|
delete_triggered_webhooks_and_executions(triggered_webhook_ids)
|
154
|
-
DeprecatedExecution.where(webhook_id: Webhook.where(uuid: uuid).select_for_subquery(:id)).delete
|
155
151
|
end
|
156
152
|
|
157
153
|
def delete_triggered_webhooks_by_version_id version_id
|
@@ -166,7 +162,6 @@ module PactBroker
|
|
166
162
|
def delete_triggered_webhooks_by_pact_publication_ids pact_publication_ids
|
167
163
|
triggered_webhook_ids = TriggeredWebhook.where(pact_publication_id: pact_publication_ids).select_for_subquery(:id)
|
168
164
|
delete_triggered_webhooks_and_executions(triggered_webhook_ids)
|
169
|
-
DeprecatedExecution.where(pact_publication_id: pact_publication_ids).delete
|
170
165
|
end
|
171
166
|
|
172
167
|
def find_latest_triggered_webhooks_for_pact pact
|
@@ -14,7 +14,6 @@ require 'pact_broker/hash_refinements'
|
|
14
14
|
require 'pact_broker/webhooks/execution_configuration'
|
15
15
|
require 'pact_broker/messages'
|
16
16
|
require 'pact_broker/webhooks/pact_and_verification_parameters'
|
17
|
-
require 'reform/contract/errors'
|
18
17
|
|
19
18
|
module PactBroker
|
20
19
|
module Webhooks
|
data/pact_broker.gemspec
CHANGED
@@ -53,7 +53,7 @@ Gem::Specification.new do |gem|
|
|
53
53
|
gem.add_runtime_dependency 'semver2', '~> 3.4.2'
|
54
54
|
gem.add_runtime_dependency 'rack', '>= 2.0.8', '~>2.0'
|
55
55
|
gem.add_runtime_dependency 'redcarpet', '>=3.3.2', '~>3.3'
|
56
|
-
gem.add_runtime_dependency 'pact-support', '~> 1.
|
56
|
+
gem.add_runtime_dependency 'pact-support', '~> 1.14', '>= 1.14.1'
|
57
57
|
gem.add_runtime_dependency 'padrino-core', '>= 0.14.3', '~> 0.14'
|
58
58
|
gem.add_runtime_dependency 'sinatra', '>= 2.0.8.1', '< 3.0'
|
59
59
|
gem.add_runtime_dependency 'haml', '~>5.0'
|
@@ -63,6 +63,7 @@ Gem::Specification.new do |gem|
|
|
63
63
|
gem.add_runtime_dependency 'dry-logic', '0.4.2' # Later version cases ArgumentError: wrong number of arguments
|
64
64
|
gem.add_runtime_dependency 'table_print', '~> 1.5'
|
65
65
|
gem.add_runtime_dependency 'semantic_logger', '~> 4.3'
|
66
|
+
gem.add_runtime_dependency 'sanitize', '~> 5.1'
|
66
67
|
|
67
68
|
gem.add_development_dependency 'pact', '~>1.14'
|
68
69
|
gem.add_development_dependency 'rspec-pact-matchers', '~>0.1'
|
@@ -27,6 +27,11 @@ module PactBroker
|
|
27
27
|
pact_version_sha: "1234",
|
28
28
|
number: "1")
|
29
29
|
end
|
30
|
+
let(:version) do
|
31
|
+
double('version',
|
32
|
+
pacticipant: consumer,
|
33
|
+
number: "2")
|
34
|
+
end
|
30
35
|
|
31
36
|
matcher :match_route_in_api do |api|
|
32
37
|
match do |url|
|
@@ -102,14 +107,14 @@ module PactBroker
|
|
102
107
|
end
|
103
108
|
|
104
109
|
it "builds the webhook metadata" do
|
105
|
-
expect(PactBrokerUrls.
|
110
|
+
expect(PactBrokerUrls.decode_webhook_metadata(PactBrokerUrls.build_webhook_metadata(pact))).to eq (expected_metadata)
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
109
|
-
describe "
|
114
|
+
describe "decode_webhook_metadata" do
|
110
115
|
context "when the metadata is nil" do
|
111
116
|
it "returns an empty hash" do
|
112
|
-
expect(PactBrokerUrls.
|
117
|
+
expect(PactBrokerUrls.decode_webhook_metadata(nil)).to eq({})
|
113
118
|
end
|
114
119
|
end
|
115
120
|
end
|
@@ -127,6 +132,12 @@ module PactBroker
|
|
127
132
|
it { is_expected.to eq "http://example.org/pacts/provider/Bar%2FBar/consumer/Foo%2FFoo/version/123%2F456/verification-results/latest" }
|
128
133
|
end
|
129
134
|
end
|
135
|
+
|
136
|
+
describe "matrix_for_pacticipant_version_url" do
|
137
|
+
subject { PactBrokerUrls.matrix_for_pacticipant_version_url(version, base_url) }
|
138
|
+
|
139
|
+
it { is_expected.to eq "http://example.org/matrix?q[][pacticipant]=Foo%2FFoo&q[][version]=2&latestby=cvpv" }
|
140
|
+
end
|
130
141
|
end
|
131
142
|
end
|
132
143
|
end
|
@@ -12,6 +12,7 @@ module PactBroker
|
|
12
12
|
ENV['TZ'] = "Australia/Melbourne"
|
13
13
|
PactBroker.configuration.enable_public_badge_access = true
|
14
14
|
allow(PactBroker::Api::PactBrokerUrls).to receive(:pact_url).with('http://base', pact).and_return(pact_url)
|
15
|
+
allow(PactBroker::Api::PactBrokerUrls).to receive(:matrix_for_pacticipant_version_url).with(consumer_version, 'http://base').and_return(matrix_url)
|
15
16
|
allow_any_instance_of(HtmlPactRenderer).to receive(:logger).and_return(logger)
|
16
17
|
|
17
18
|
Timecop.freeze(created_at + 3)
|
@@ -24,10 +25,22 @@ module PactBroker
|
|
24
25
|
|
25
26
|
let(:consumer) { double('consumer', name: 'Consumer')}
|
26
27
|
let(:provider) { double('provider', name: 'Provider')}
|
28
|
+
let(:consumer_version) { double('consumer version') }
|
27
29
|
let(:created_at) { DateTime.new(2014, 02, 27) }
|
28
30
|
let(:json_content) { load_fixture('renderer_pact.json') }
|
29
|
-
let(:pact)
|
31
|
+
let(:pact) do
|
32
|
+
double('pact',
|
33
|
+
json_content: json_content,
|
34
|
+
consumer_version_number: '1.2.3',
|
35
|
+
consumer: consumer,
|
36
|
+
provider: provider,
|
37
|
+
consumer_version_tag_names: ['prod', 'master'],
|
38
|
+
created_at: created_at,
|
39
|
+
consumer_version: consumer_version
|
40
|
+
)
|
41
|
+
end
|
30
42
|
let(:pact_url) { '/pact/url' }
|
43
|
+
let(:matrix_url) { '/matrix/url' }
|
31
44
|
let(:options) do
|
32
45
|
{
|
33
46
|
base_url: 'http://base',
|
@@ -64,6 +77,10 @@ module PactBroker
|
|
64
77
|
expect(subject).to include "[![Consumer/Provider Pact Status](http://badge)](http://base)"
|
65
78
|
end
|
66
79
|
|
80
|
+
it "includes the matrix URL" do
|
81
|
+
expect(subject).to include matrix_url
|
82
|
+
end
|
83
|
+
|
67
84
|
context "when enable_public_badge_access is false" do
|
68
85
|
before do
|
69
86
|
PactBroker.configuration.enable_public_badge_access = false
|
@@ -99,7 +116,6 @@ module PactBroker
|
|
99
116
|
end
|
100
117
|
end
|
101
118
|
end
|
102
|
-
|
103
119
|
end
|
104
120
|
end
|
105
121
|
end
|
@@ -3,32 +3,27 @@ require 'pact_broker/api/resources/latest_pact'
|
|
3
3
|
require 'rack/test'
|
4
4
|
|
5
5
|
module PactBroker::Api
|
6
|
-
|
7
6
|
module Resources
|
8
|
-
|
9
7
|
describe LatestPact do
|
10
|
-
|
11
8
|
include Rack::Test::Methods
|
12
|
-
|
13
|
-
let(:app) { PactBroker::API }
|
14
|
-
|
15
9
|
describe "GET" do
|
16
|
-
|
17
10
|
context "Accept: text/html" do
|
18
11
|
|
19
|
-
let(:path) { "/pacts/provider/provider_name/consumer/consumer_name/latest" }
|
12
|
+
let(:path) { "/pacts/provider/provider_name/consumer/consumer_name/latest/prod" }
|
20
13
|
let(:json_content) { 'json_content' }
|
21
|
-
let(:pact) { double("pact", json_content: json_content)}
|
14
|
+
let(:pact) { double("pact", json_content: json_content, consumer_version_number: '1') }
|
22
15
|
let(:html) { 'html' }
|
23
16
|
let(:pact_id_params) { {provider_name: "provider_name", consumer_name: "consumer_name"} }
|
24
17
|
let(:html_options) { { base_url: 'http://example.org', badge_url: "http://example.org#{path}/badge.svg" } }
|
18
|
+
let(:metadata) { double('metadata') }
|
19
|
+
let(:accept) { "text/html" }
|
25
20
|
|
26
21
|
before do
|
27
22
|
allow(PactBroker::Pacts::Service).to receive(:find_latest_pact).and_return(pact)
|
28
23
|
allow(PactBroker.configuration.html_pact_renderer).to receive(:call).and_return(html)
|
29
24
|
end
|
30
25
|
|
31
|
-
subject { get
|
26
|
+
subject { get(path, nil, 'HTTP_ACCEPT' => accept) }
|
32
27
|
|
33
28
|
it "find the pact" do
|
34
29
|
expect(PactBroker::Pacts::Service).to receive(:find_latest_pact).with(hash_including(pact_id_params))
|
@@ -36,10 +31,11 @@ module PactBroker::Api
|
|
36
31
|
end
|
37
32
|
|
38
33
|
it "uses the configured HTML renderer" do
|
39
|
-
expect(PactBroker.configuration.html_pact_renderer).to receive(:call).with(pact, html_options)
|
34
|
+
expect(PactBroker.configuration.html_pact_renderer).to receive(:call).with(pact, hash_including(html_options))
|
40
35
|
subject
|
41
36
|
end
|
42
37
|
|
38
|
+
|
43
39
|
it "returns a HTML body" do
|
44
40
|
subject
|
45
41
|
expect(last_response.body).to eq html
|
@@ -50,10 +46,34 @@ module PactBroker::Api
|
|
50
46
|
expect(last_response.headers['Content-Type']).to eq 'text/html;charset=utf-8'
|
51
47
|
end
|
52
48
|
|
49
|
+
context "when Accept is application/hal+json" do
|
50
|
+
let(:accept) { "application/hal+json" }
|
51
|
+
let(:decorator) { instance_double(PactBroker::Api::Decorators::PactDecorator, to_json: pact_json)}
|
52
|
+
let(:pact_json) { { some: 'json' }.to_json }
|
53
|
+
|
54
|
+
before do
|
55
|
+
allow(PactBroker::Api::Decorators::PactDecorator).to receive(:new).and_return(decorator)
|
56
|
+
allow(PactBroker::Pacts::Metadata).to receive(:build_metadata_for_latest_pact).and_return(metadata)
|
57
|
+
allow_any_instance_of(LatestPact).to receive(:encode_webhook_metadata).and_return('encoded metadata')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "builds the metadata" do
|
61
|
+
expect(PactBroker::Pacts::Metadata).to receive(:build_metadata_for_latest_pact).with(pact, hash_including(tag: 'prod'))
|
62
|
+
subject
|
63
|
+
end
|
64
|
+
|
65
|
+
it "encodes the metadata" do
|
66
|
+
expect_any_instance_of(LatestPact).to receive(:encode_webhook_metadata).with(metadata)
|
67
|
+
subject
|
68
|
+
end
|
69
|
+
|
70
|
+
it "renders the pact in JSON" do
|
71
|
+
expect(decorator).to receive(:to_json).with(user_options: hash_including(metadata: 'encoded metadata'))
|
72
|
+
expect(subject.body).to eq pact_json
|
73
|
+
end
|
74
|
+
end
|
53
75
|
end
|
54
76
|
end
|
55
|
-
|
56
77
|
end
|
57
78
|
end
|
58
|
-
|
59
79
|
end
|
@@ -24,7 +24,7 @@ module PactBroker
|
|
24
24
|
before do
|
25
25
|
allow(PactBroker::Verifications::Service).to receive(:create).and_return(verification)
|
26
26
|
allow(PactBroker::Verifications::Service).to receive(:errors).and_return(double(:errors, messages: ['errors'], empty?: errors_empty))
|
27
|
-
allow(PactBrokerUrls).to receive(:
|
27
|
+
allow(PactBrokerUrls).to receive(:decode_webhook_metadata).and_return(parsed_metadata)
|
28
28
|
allow_any_instance_of(Verifications).to receive(:webhook_execution_configuration).and_return(webhook_execution_configuration)
|
29
29
|
allow(webhook_execution_configuration).to receive(:with_webhook_context).and_return(webhook_execution_configuration)
|
30
30
|
end
|
@@ -65,7 +65,7 @@ module PactBroker
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it "parses the webhook metadata" do
|
68
|
-
expect(PactBrokerUrls).to receive(:
|
68
|
+
expect(PactBrokerUrls).to receive(:decode_webhook_metadata).with("abcd")
|
69
69
|
subject
|
70
70
|
end
|
71
71
|
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'pact_broker/db/delete_overwritten_data'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module DB
|
5
|
+
describe DeleteOverwrittenData, pending: IS_MYSQL do
|
6
|
+
describe ".call" do
|
7
|
+
let(:db) { PactBroker::DB.connection }
|
8
|
+
subject { DeleteOverwrittenData.call(db, before: before_date) }
|
9
|
+
let(:before_date) { nil }
|
10
|
+
|
11
|
+
context "when a pact is overwritten" do
|
12
|
+
let!(:pact_to_delete) { td.create_everything_for_an_integration.and_return(:pact) }
|
13
|
+
let!(:pact_to_keep) { td.revise_pact.and_return(:pact) }
|
14
|
+
|
15
|
+
|
16
|
+
it "deletes the overwritten pact" do
|
17
|
+
expect { subject }.to change{ db[:pact_publications].where(id: pact_to_delete.id).count }.by(-1)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does not delete the most recent pact" do
|
21
|
+
expect { subject }.to_not change{ db[:pact_publications].where(id: pact_to_keep.id).count }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns a report" do
|
25
|
+
expect(subject[:deleted][:pact_publications]).to eq 1
|
26
|
+
expect(subject[:kept][:pact_publications]).to eq 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when a pact has multiple verifications" do
|
31
|
+
let!(:verification_to_delete) do
|
32
|
+
td.create_pact_with_hierarchy
|
33
|
+
.create_verification(provider_version: "1", success: false)
|
34
|
+
.and_return(:verification)
|
35
|
+
end
|
36
|
+
|
37
|
+
let!(:verification_to_keep) { td.create_verification(provider_version: "1", number: 2, success: true).and_return(:verification) }
|
38
|
+
|
39
|
+
it "deletes the overwritten verification" do
|
40
|
+
expect { subject }.to change{ db[:verifications].where(id: verification_to_delete.id).count }.by(-1)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "does not delete the most recent verification" do
|
44
|
+
expect { subject }.to_not change{ db[:verifications].where(id: verification_to_keep.id).count }
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns a report" do
|
48
|
+
expect(subject[:deleted][:verification_results]).to eq 1
|
49
|
+
expect(subject[:kept][:verification_results]).to eq 1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when a pact version is orphaned" do
|
54
|
+
before do
|
55
|
+
td.create_pact_with_verification.comment("this one will still have the verification, so can't be deleted")
|
56
|
+
.revise_pact.comment("this one can be deleted")
|
57
|
+
.revise_pact.comment("this one will still have a pact publication, so can't be deleted")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "is deleted" do
|
61
|
+
expect { subject }.to change{ db[:pact_versions].count }.by(-1)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns a report" do
|
65
|
+
expect(subject[:deleted][:pact_versions]).to eq 1
|
66
|
+
expect(subject[:kept][:pact_versions]).to eq 2
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when the pact publication is created after the before date" do
|
71
|
+
before do
|
72
|
+
td.set_now(before_date + 1)
|
73
|
+
.create_pact_with_hierarchy
|
74
|
+
.revise_pact
|
75
|
+
end
|
76
|
+
|
77
|
+
let(:before_date) { DateTime.new(2010, 2, 5) }
|
78
|
+
|
79
|
+
it "doesn't delete the data" do
|
80
|
+
expect { subject }.to_not change { db[:pact_publications].count }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when the verification is created after the before date" do
|
85
|
+
before do
|
86
|
+
td.set_now(before_date + 1)
|
87
|
+
.create_pact_with_hierarchy
|
88
|
+
.create_verification(provider_version: "1", success: false)
|
89
|
+
.create_verification(provider_version: "1", success: true, number: 2)
|
90
|
+
end
|
91
|
+
|
92
|
+
let(:before_date) { DateTime.new(2010, 2, 5) }
|
93
|
+
|
94
|
+
it "doesn't delete the data" do
|
95
|
+
expect { subject }.to_not change { db[:verifications].count }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -469,11 +469,9 @@ module PactBroker
|
|
469
469
|
.create_pact
|
470
470
|
.create_webhook
|
471
471
|
.create_triggered_webhook
|
472
|
-
.create_deprecated_webhook_execution
|
473
472
|
.create_webhook_execution
|
474
473
|
.create_webhook
|
475
474
|
.create_triggered_webhook
|
476
|
-
.create_deprecated_webhook_execution
|
477
475
|
.create_webhook_execution
|
478
476
|
end
|
479
477
|
let(:webhook_id) { Webhook.find(uuid: td.webhook.uuid).id }
|
@@ -492,16 +490,10 @@ module PactBroker
|
|
492
490
|
}
|
493
491
|
end
|
494
492
|
|
495
|
-
it "deletes the related deprecated webhook executions" do
|
496
|
-
expect { subject }.to change {
|
497
|
-
DeprecatedExecution.count
|
498
|
-
}.by(-2)
|
499
|
-
end
|
500
|
-
|
501
493
|
it "deletes the related webhook executions" do
|
502
494
|
expect { subject }.to change {
|
503
495
|
Execution.count
|
504
|
-
}.by(-
|
496
|
+
}.by(-1)
|
505
497
|
end
|
506
498
|
end
|
507
499
|
|
@@ -534,29 +526,6 @@ module PactBroker
|
|
534
526
|
.to change { Execution.count }.by(0)
|
535
527
|
end
|
536
528
|
end
|
537
|
-
|
538
|
-
context "with deprecated executions (before the triggered webhook table was introduced)" do
|
539
|
-
before do
|
540
|
-
Sequel::Model.db[:webhook_executions].update(triggered_webhook_id: nil, consumer_id: td.consumer.id, provider_id: td.provider.id)
|
541
|
-
TriggeredWebhook.select_all.delete
|
542
|
-
end
|
543
|
-
|
544
|
-
it "deletes the execution by consumer" do
|
545
|
-
expect { Repository.new.delete_executions_by_pacticipant td.consumer }
|
546
|
-
.to change { Execution.count }.by(-1)
|
547
|
-
end
|
548
|
-
|
549
|
-
it "deletes the execution by provider" do
|
550
|
-
expect { Repository.new.delete_executions_by_pacticipant td.provider }
|
551
|
-
.to change { Execution.count }.by(-1)
|
552
|
-
end
|
553
|
-
|
554
|
-
it "does not delete executions for non related pacticipants" do
|
555
|
-
another_consumer = td.create_consumer.and_return(:consumer)
|
556
|
-
expect { Repository.new.delete_executions_by_pacticipant another_consumer }
|
557
|
-
.to change { Execution.count }.by(0)
|
558
|
-
end
|
559
|
-
end
|
560
529
|
end
|
561
530
|
|
562
531
|
describe "find_latest_triggered_webhooks" do
|
@@ -707,7 +676,6 @@ module PactBroker
|
|
707
676
|
.create_webhook
|
708
677
|
.create_triggered_webhook
|
709
678
|
.create_webhook_execution
|
710
|
-
.create_deprecated_webhook_execution
|
711
679
|
end
|
712
680
|
|
713
681
|
subject { Repository.new.delete_triggered_webhooks_by_pact_publication_ids [td.pact.id] }
|
@@ -723,12 +691,6 @@ module PactBroker
|
|
723
691
|
Execution.exclude(triggered_webhook_id: nil).count
|
724
692
|
}.by(-1)
|
725
693
|
end
|
726
|
-
|
727
|
-
it "deletes the deprecated webhook_execution" do
|
728
|
-
expect { subject }.to change {
|
729
|
-
Execution.exclude(consumer_id: nil).count
|
730
|
-
}.by(-1)
|
731
|
-
end
|
732
694
|
end
|
733
695
|
|
734
696
|
describe "delete_triggered_webhooks_by_version_id" do
|
@@ -235,4 +235,13 @@ Pact.provider_states_for "Pact Broker Client" do
|
|
235
235
|
.create_pact
|
236
236
|
end
|
237
237
|
end
|
238
|
+
|
239
|
+
provider_state "a webhook with the uuid 696c5f93-1b7f-44bc-8d03-59440fcaa9a0 exists" do
|
240
|
+
set_up do
|
241
|
+
TestDataBuilder.new
|
242
|
+
.create_consumer("Condor")
|
243
|
+
.create_provider("Pricing Service")
|
244
|
+
.create_webhook(uuid: "696c5f93-1b7f-44bc-8d03-59440fcaa9a0")
|
245
|
+
end
|
246
|
+
end
|
238
247
|
end
|
data/tasks/test_db.rake
CHANGED
@@ -23,3 +23,10 @@ PactBroker::DB::CleanTask.new do | task |
|
|
23
23
|
require 'db'
|
24
24
|
task.database_connection = DB::PACT_BROKER_DB
|
25
25
|
end
|
26
|
+
|
27
|
+
PactBroker::DB::DeleteOverwrittenDataTask.new do | task |
|
28
|
+
ENV['RACK_ENV'] ||= 'test'
|
29
|
+
require 'db'
|
30
|
+
task.database_connection = DB::PACT_BROKER_DB
|
31
|
+
task.age_in_days = 7
|
32
|
+
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: 2.
|
4
|
+
version: 2.50.0
|
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: 2020-02-
|
13
|
+
date: 2020-02-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -176,20 +176,20 @@ dependencies:
|
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: '1.
|
179
|
+
version: '1.14'
|
180
180
|
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 1.
|
182
|
+
version: 1.14.1
|
183
183
|
type: :runtime
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - "~>"
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: '1.
|
189
|
+
version: '1.14'
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: 1.
|
192
|
+
version: 1.14.1
|
193
193
|
- !ruby/object:Gem::Dependency
|
194
194
|
name: padrino-core
|
195
195
|
requirement: !ruby/object:Gem::Requirement
|
@@ -334,6 +334,20 @@ dependencies:
|
|
334
334
|
- - "~>"
|
335
335
|
- !ruby/object:Gem::Version
|
336
336
|
version: '4.3'
|
337
|
+
- !ruby/object:Gem::Dependency
|
338
|
+
name: sanitize
|
339
|
+
requirement: !ruby/object:Gem::Requirement
|
340
|
+
requirements:
|
341
|
+
- - "~>"
|
342
|
+
- !ruby/object:Gem::Version
|
343
|
+
version: '5.1'
|
344
|
+
type: :runtime
|
345
|
+
prerelease: false
|
346
|
+
version_requirements: !ruby/object:Gem::Requirement
|
347
|
+
requirements:
|
348
|
+
- - "~>"
|
349
|
+
- !ruby/object:Gem::Version
|
350
|
+
version: '5.1'
|
337
351
|
- !ruby/object:Gem::Dependency
|
338
352
|
name: pact
|
339
353
|
requirement: !ruby/object:Gem::Requirement
|
@@ -934,12 +948,14 @@ files:
|
|
934
948
|
- lib/pact_broker/date_helper.rb
|
935
949
|
- lib/pact_broker/db.rb
|
936
950
|
- lib/pact_broker/db/clean.rb
|
951
|
+
- lib/pact_broker/db/data_migrations/delete_deprecated_webhook_executions.rb
|
937
952
|
- lib/pact_broker/db/data_migrations/helpers.rb
|
938
953
|
- lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb
|
939
954
|
- lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications.rb
|
940
955
|
- lib/pact_broker/db/data_migrations/set_latest_version_sequence_value.rb
|
941
956
|
- lib/pact_broker/db/data_migrations/set_pacticipant_ids_for_verifications.rb
|
942
957
|
- lib/pact_broker/db/data_migrations/set_webhooks_enabled.rb
|
958
|
+
- lib/pact_broker/db/delete_overwritten_data.rb
|
943
959
|
- lib/pact_broker/db/log_quietener.rb
|
944
960
|
- lib/pact_broker/db/migrate.rb
|
945
961
|
- lib/pact_broker/db/migrate_data.rb
|
@@ -980,6 +996,7 @@ files:
|
|
980
996
|
- lib/pact_broker/doc/views/pact/diff-previous-distinct.markdown
|
981
997
|
- lib/pact_broker/doc/views/pact/diff.markdown
|
982
998
|
- lib/pact_broker/doc/views/pact/latest-pact-version.markdown
|
999
|
+
- lib/pact_broker/doc/views/pact/matrix-for-consumer-version.markdown
|
983
1000
|
- lib/pact_broker/doc/views/pact/pact-webhooks.markdown
|
984
1001
|
- lib/pact_broker/doc/views/pact/publish-verification-results.markdown
|
985
1002
|
- lib/pact_broker/doc/views/pact/tag-prod-version.markdown
|
@@ -1051,6 +1068,7 @@ files:
|
|
1051
1068
|
- lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb
|
1052
1069
|
- lib/pact_broker/pacts/latest_tagged_pact_publications.rb
|
1053
1070
|
- lib/pact_broker/pacts/merger.rb
|
1071
|
+
- lib/pact_broker/pacts/metadata.rb
|
1054
1072
|
- lib/pact_broker/pacts/order_hash_keys.rb
|
1055
1073
|
- lib/pact_broker/pacts/pact_params.rb
|
1056
1074
|
- lib/pact_broker/pacts/pact_publication.rb
|
@@ -1079,6 +1097,7 @@ files:
|
|
1079
1097
|
- lib/pact_broker/tasks.rb
|
1080
1098
|
- lib/pact_broker/tasks/clean_task.rb
|
1081
1099
|
- lib/pact_broker/tasks/data_migration_task.rb
|
1100
|
+
- lib/pact_broker/tasks/delete_overwritten_data_task.rb
|
1082
1101
|
- lib/pact_broker/tasks/migration_task.rb
|
1083
1102
|
- lib/pact_broker/tasks/version_task.rb
|
1084
1103
|
- lib/pact_broker/test/test_data_builder.rb
|
@@ -1413,6 +1432,7 @@ files:
|
|
1413
1432
|
- spec/lib/pact_broker/db/data_migrations/migrate_webhook_headers_spec.rb
|
1414
1433
|
- spec/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications_spec.rb
|
1415
1434
|
- spec/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value_spec.rb
|
1435
|
+
- spec/lib/pact_broker/db/delete_overwritten_data_spec.rb
|
1416
1436
|
- spec/lib/pact_broker/db/log_quietener_spec.rb
|
1417
1437
|
- spec/lib/pact_broker/db/validate_encoding_spec.rb
|
1418
1438
|
- spec/lib/pact_broker/diagnostic/resources/dependencies_spec.rb
|
@@ -1792,6 +1812,7 @@ test_files:
|
|
1792
1812
|
- spec/lib/pact_broker/db/data_migrations/migrate_webhook_headers_spec.rb
|
1793
1813
|
- spec/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications_spec.rb
|
1794
1814
|
- spec/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value_spec.rb
|
1815
|
+
- spec/lib/pact_broker/db/delete_overwritten_data_spec.rb
|
1795
1816
|
- spec/lib/pact_broker/db/log_quietener_spec.rb
|
1796
1817
|
- spec/lib/pact_broker/db/validate_encoding_spec.rb
|
1797
1818
|
- spec/lib/pact_broker/diagnostic/resources/dependencies_spec.rb
|