pact_broker 2.32.0 → 2.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +3 -0
  3. data/CHANGELOG.md +18 -0
  4. data/config/database.yml +5 -8
  5. data/db/migrations/20190510_set_version_sequence.rb +1 -0
  6. data/db/migrations/20190602_add_headers_column_to_webhooks.rb +6 -0
  7. data/db/migrations/20190603_migrate_webhook_headers.rb +10 -0
  8. data/lib/pact_broker/api/resources/index.rb +12 -0
  9. data/lib/pact_broker/api/resources/pact.rb +1 -1
  10. data/lib/pact_broker/api/resources/verifications.rb +1 -1
  11. data/lib/pact_broker/api/resources/webhook_execution.rb +1 -1
  12. data/lib/pact_broker/certificates/certificate.rb +1 -1
  13. data/lib/pact_broker/config/setting.rb +1 -1
  14. data/lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb +30 -0
  15. data/lib/pact_broker/domain/pacticipant.rb +1 -1
  16. data/lib/pact_broker/domain/verification.rb +1 -1
  17. data/lib/pact_broker/domain/version.rb +1 -1
  18. data/lib/pact_broker/domain/webhook.rb +27 -1
  19. data/lib/pact_broker/domain/webhook_request.rb +9 -146
  20. data/lib/pact_broker/integrations/integration.rb +7 -0
  21. data/lib/pact_broker/matrix/repository.rb +0 -1
  22. data/lib/pact_broker/matrix/row.rb +58 -17
  23. data/lib/pact_broker/pacts/pact_publication.rb +8 -1
  24. data/lib/pact_broker/pacts/pact_version.rb +1 -1
  25. data/lib/pact_broker/pacts/repository.rb +5 -8
  26. data/lib/pact_broker/repositories/helpers.rb +5 -4
  27. data/lib/pact_broker/test/test_data_builder.rb +2 -2
  28. data/lib/pact_broker/version.rb +1 -1
  29. data/lib/pact_broker/versions/latest_version.rb +10 -0
  30. data/lib/pact_broker/webhooks/execution.rb +1 -1
  31. data/lib/pact_broker/webhooks/http_request_with_redacted_headers.rb +21 -0
  32. data/lib/pact_broker/webhooks/http_response_with_utf_8_safe_body.rb +21 -0
  33. data/lib/pact_broker/webhooks/job.rb +2 -2
  34. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +86 -0
  35. data/lib/pact_broker/webhooks/render.rb +10 -71
  36. data/lib/pact_broker/webhooks/repository.rb +2 -9
  37. data/lib/pact_broker/webhooks/service.rb +5 -5
  38. data/lib/pact_broker/webhooks/triggered_webhook.rb +1 -1
  39. data/lib/pact_broker/webhooks/webhook.rb +9 -30
  40. data/lib/pact_broker/webhooks/webhook_event.rb +1 -1
  41. data/lib/pact_broker/{domain → webhooks}/webhook_execution_result.rb +6 -5
  42. data/lib/pact_broker/webhooks/webhook_request_logger.rb +105 -0
  43. data/lib/pact_broker/webhooks/webhook_request_template.rb +7 -6
  44. data/pact_broker.gemspec +1 -0
  45. data/script/docker/db-restore.sh +5 -0
  46. data/script/docker/db-rm.sh +3 -0
  47. data/script/docker/db-start.sh +7 -0
  48. data/script/import-pg-database.sh +5 -0
  49. data/script/seed.rb +1 -1
  50. data/spec/features/execute_webhook_spec.rb +1 -1
  51. data/spec/features/publish_verification_spec.rb +1 -1
  52. data/spec/integration/webhooks/certificate_spec.rb +4 -6
  53. data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +1 -1
  54. data/spec/lib/pact_broker/api/resources/verifications_spec.rb +1 -1
  55. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +1 -1
  56. data/spec/lib/pact_broker/db/data_migrations/migrate_webhook_headers_spec.rb +78 -0
  57. data/spec/lib/pact_broker/domain/webhook_request_spec.rb +8 -163
  58. data/spec/lib/pact_broker/domain/webhook_spec.rb +45 -8
  59. data/spec/lib/pact_broker/matrix/repository_spec.rb +24 -0
  60. data/spec/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names_spec.rb +4 -4
  61. data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +60 -0
  62. data/spec/lib/pact_broker/webhooks/job_spec.rb +3 -3
  63. data/spec/lib/pact_broker/webhooks/render_spec.rb +22 -7
  64. data/spec/lib/pact_broker/webhooks/repository_spec.rb +24 -24
  65. data/spec/lib/pact_broker/webhooks/service_spec.rb +5 -5
  66. data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +197 -0
  67. data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +13 -4
  68. data/spec/support/database.rb +1 -1
  69. data/spec/support/ssl_pact_broker_server.rb +46 -0
  70. data/tasks/database.rb +12 -0
  71. data/tasks/db.rake +26 -6
  72. data/tasks/docker_database.rb +25 -0
  73. metadata +35 -3
@@ -8,3 +8,10 @@ module PactBroker
8
8
  end
9
9
  end
10
10
  end
11
+
12
+ # Table: integrations
13
+ # Columns:
14
+ # consumer_id | integer |
15
+ # consumer_name | text |
16
+ # provider_id | integer |
17
+ # provider_name | text |
@@ -61,7 +61,6 @@ module PactBroker
61
61
  end
62
62
 
63
63
  integrations = find_integrations_for_specified_selectors(resolved_selectors.select(&:specified?))
64
-
65
64
  QueryResults.new(lines.sort, specified_selectors, options, resolved_selectors, integrations)
66
65
  end
67
66
 
@@ -41,33 +41,74 @@ module PactBroker
41
41
  end
42
42
  end
43
43
 
44
+ # find rows where (the consumer (and optional version) matches any of the selectors)
45
+ # AND
46
+ # the (provider (and optional version) matches any of the selectors OR the provider matches
47
+ # and the verification is missing (and hence the provider version is null))
44
48
  def where_consumer_and_provider_in selectors
45
49
  where{
46
50
  Sequel.&(
47
51
  Sequel.|(
48
- *selectors.collect do |s|
49
- if s[:pacticipant_version_id]
50
- Sequel.&(consumer_id: s[:pacticipant_id], consumer_version_id: s[:pacticipant_version_id])
51
- else
52
- Sequel.&(consumer_id: s[:pacticipant_id])
53
- end
54
- end
52
+ *QueryHelper.consumer_and_maybe_consumer_version_match_any_selector(selectors)
55
53
  ),
56
54
  Sequel.|(
57
- *(selectors.collect do |s|
58
- if s[:pacticipant_version_id]
59
- Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: s[:pacticipant_version_id])
60
- else
61
- Sequel.&(provider_id: s[:pacticipant_id])
62
- end
63
- end + selectors.collect do |s|
64
- Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: nil)
65
- end)
66
- )
55
+ *QueryHelper.provider_and_maybe_provider_version_match_any_selector_or_verification_is_missing(selectors)
56
+ ),
57
+ QueryHelper.either_consumer_or_provider_was_specified_in_query(selectors)
67
58
  )
68
59
  }
69
60
  end
70
61
 
62
+ # Can't access other dataset_module methods from inside the Sequel `where{ ... }` block, so make a private class
63
+ # with some helper methods
64
+ class QueryHelper
65
+ def self.consumer_and_maybe_consumer_version_match_any_selector(selectors)
66
+ selectors.collect { |s| consumer_and_maybe_consumer_version_match_selector(s) }
67
+ end
68
+
69
+ def self.consumer_and_maybe_consumer_version_match_selector(s)
70
+ if s[:pacticipant_version_id]
71
+ Sequel.&(consumer_id: s[:pacticipant_id], consumer_version_id: s[:pacticipant_version_id])
72
+ else
73
+ Sequel.&(consumer_id: s[:pacticipant_id])
74
+ end
75
+ end
76
+
77
+ def self.provider_and_maybe_provider_version_match_selector(s)
78
+ if s[:pacticipant_version_id]
79
+ Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: s[:pacticipant_version_id])
80
+ else
81
+ Sequel.&(provider_id: s[:pacticipant_id])
82
+ end
83
+ end
84
+
85
+ # if the pact for a consumer version has never been verified, it exists in the matrix as a row
86
+ # with a blank provider version id
87
+ def self.provider_verification_is_missing_for_matching_selector(s)
88
+ Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: nil)
89
+ end
90
+
91
+ def self.provider_and_maybe_provider_version_match_any_selector_or_verification_is_missing(selectors)
92
+ selectors.collect { |s|
93
+ provider_and_maybe_provider_version_match_selector(s)
94
+ } + selectors.collect { |s|
95
+ provider_verification_is_missing_for_matching_selector(s)
96
+ }
97
+ end
98
+
99
+ # Some selecters are specified in the query, others are implied (when only one pacticipant is specified,
100
+ # the integrations are automatically worked out, and the selectors for these are of type :implied )
101
+ # When there are 3 pacticipants that each have dependencies on each other (A->B, A->C, B->C), the query
102
+ # to deploy C (implied A, implied B, specified C) was returning the A->B row because it matched the
103
+ # implied selectors as well.
104
+ # This extra filter makes sure that every row that is returned actually matches one of the specified
105
+ # selectors.
106
+ def self.either_consumer_or_provider_was_specified_in_query(selectors)
107
+ specified_pacticipant_ids = selectors.select{ |s| s[:type] == :specified }.collect{ |s| s[:pacticipant_id] }
108
+ Sequel.|({ consumer_id: specified_pacticipant_ids } , { provider_id: specified_pacticipant_ids })
109
+ end
110
+ end
111
+
71
112
  def where_consumer_or_provider_is s
72
113
  where{
73
114
  Sequel.|(
@@ -5,6 +5,7 @@ require 'pact_broker/repositories/helpers'
5
5
  module PactBroker
6
6
  module Pacts
7
7
  class PactPublication < Sequel::Model(:pact_publications)
8
+ UNIQUE_CONSTRAINT_KEYS = [:consumer_version_id, :provider_id, :revision_number].freeze
8
9
 
9
10
  extend Forwardable
10
11
 
@@ -57,6 +58,12 @@ module PactBroker
57
58
  OpenStruct.new(number: consumer_version.number, pacticipant: consumer_version.pacticipant, tags: consumer_version.tags, order: consumer_version.order)
58
59
  end
59
60
 
61
+ def upsert
62
+ params = to_hash.merge(created_at: Sequel.datetime_class.now)
63
+ self.id = PactPublication.upsert(params, UNIQUE_CONSTRAINT_KEYS).id
64
+ self.refresh
65
+ end
66
+
60
67
  private
61
68
 
62
69
  def cached_domain_for_delegation
@@ -70,7 +77,7 @@ end
70
77
 
71
78
  # Table: pact_publications
72
79
  # Columns:
73
- # id | integer | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
80
+ # id | integer | PRIMARY KEY DEFAULT nextval('pact_publications_id_seq'::regclass)
74
81
  # consumer_version_id | integer | NOT NULL
75
82
  # provider_id | integer | NOT NULL
76
83
  # revision_number | integer | NOT NULL
@@ -53,7 +53,7 @@ end
53
53
 
54
54
  # Table: pact_versions
55
55
  # Columns:
56
- # id | integer | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
56
+ # id | integer | PRIMARY KEY DEFAULT nextval('pact_versions_id_seq'::regclass)
57
57
  # consumer_id | integer | NOT NULL
58
58
  # provider_id | integer | NOT NULL
59
59
  # sha | text | NOT NULL
@@ -31,8 +31,9 @@ module PactBroker
31
31
  consumer_version_id: params[:version_id],
32
32
  provider_id: params[:provider_id],
33
33
  consumer_id: params[:consumer_id],
34
- pact_version: pact_version
35
- ).save
34
+ pact_version: pact_version,
35
+ revision_number: 1
36
+ ).upsert
36
37
  update_latest_pact_publication_ids(pact_publication)
37
38
  pact_publication.to_domain
38
39
  end
@@ -46,18 +47,14 @@ module PactBroker
46
47
  params.fetch(:json_content)
47
48
  )
48
49
  if existing_model.pact_version_id != pact_version.id
49
- key = {
50
+ pact_publication = PactPublication.new(
50
51
  consumer_version_id: existing_model.consumer_version_id,
51
52
  provider_id: existing_model.provider_id,
52
53
  revision_number: next_revision_number(existing_model),
53
- }
54
- new_params = key.merge(
55
54
  consumer_id: existing_model.consumer_id,
56
55
  pact_version_id: pact_version.id,
57
56
  created_at: Sequel.datetime_class.now
58
- )
59
- PactPublication.upsert(new_params, key.keys)
60
- pact_publication = PactPublication.where(key).single_record
57
+ ).upsert
61
58
  update_latest_pact_publication_ids(pact_publication)
62
59
  pact_publication.to_domain
63
60
  else
@@ -36,21 +36,22 @@ module PactBroker
36
36
  end
37
37
  end
38
38
 
39
- def upsert row, key_names, columns_to_update = nil
39
+ def upsert row, unique_key_names, columns_to_update = nil
40
40
  if postgres?
41
- insert_conflict(update: row, target: key_names).insert(row)
41
+ insert_conflict(update: row, target: unique_key_names).insert(row)
42
42
  elsif mysql?
43
- update_cols = columns_to_update || (row.keys - key_names)
43
+ update_cols = columns_to_update || (row.keys - unique_key_names)
44
44
  on_duplicate_key_update(*update_cols).insert(row)
45
45
  else
46
46
  # Sqlite
47
- key = row.reject{ |k, v| !key_names.include?(k) }
47
+ key = row.reject{ |k, v| !unique_key_names.include?(k) }
48
48
  if where(key).count == 0
49
49
  insert(row)
50
50
  else
51
51
  where(key).update(row)
52
52
  end
53
53
  end
54
+ model.find(row.select{ |key, _| unique_key_names.include?(key)} )
54
55
  end
55
56
  end
56
57
  end
@@ -3,7 +3,7 @@ require 'pact_broker/repositories'
3
3
  require 'pact_broker/services'
4
4
  require 'pact_broker/webhooks/repository'
5
5
  require 'pact_broker/webhooks/service'
6
- require 'pact_broker/domain/webhook_execution_result'
6
+ require 'pact_broker/webhooks/webhook_execution_result'
7
7
  require 'pact_broker/pacts/repository'
8
8
  require 'pact_broker/pacts/service'
9
9
  require 'pact_broker/pacts/content'
@@ -267,7 +267,7 @@ module PactBroker
267
267
  def create_webhook_execution params = {}
268
268
  params.delete(:comment)
269
269
  logs = params[:logs] || "logs"
270
- webhook_execution_result = PactBroker::Domain::WebhookExecutionResult.new(nil, OpenStruct.new(code: "200"), logs, nil)
270
+ webhook_execution_result = PactBroker::Webhooks::WebhookExecutionResult.new(nil, OpenStruct.new(code: "200"), logs, nil)
271
271
  @webhook_execution = PactBroker::Webhooks::Repository.new.create_execution @triggered_webhook, webhook_execution_result
272
272
  created_at = params[:created_at] || @pact.created_at + Rational(1, 86400)
273
273
  set_created_at_if_set created_at, :webhook_executions, {id: @webhook_execution.id}
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.32.0'
2
+ VERSION = '2.33.0'
3
3
  end
@@ -9,3 +9,13 @@ module PactBroker
9
9
  end
10
10
  end
11
11
  end
12
+
13
+ # Table: latest_versions
14
+ # Columns:
15
+ # id | integer |
16
+ # number | text |
17
+ # repository_ref | text |
18
+ # pacticipant_id | integer |
19
+ # order | integer |
20
+ # created_at | timestamp without time zone |
21
+ # updated_at | timestamp without time zone |
@@ -41,7 +41,7 @@ end
41
41
 
42
42
  # Table: webhook_executions
43
43
  # Columns:
44
- # id | integer | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
44
+ # id | integer | PRIMARY KEY DEFAULT nextval('webhook_executions_id_seq'::regclass)
45
45
  # triggered_webhook_id | integer |
46
46
  # success | boolean | NOT NULL
47
47
  # logs | text |
@@ -0,0 +1,21 @@
1
+ require 'pact_broker/domain/webhook_request'
2
+
3
+ module PactBroker
4
+ module Webhooks
5
+ class HttpRequestWithRedactedHeaders < SimpleDelegator
6
+ def to_hash
7
+ __getobj__().to_hash.each_with_object({}) do | (key, values), new_hash |
8
+ new_hash[key] = redact?(key) ? ["**********"] : values
9
+ end
10
+ end
11
+
12
+ def method
13
+ __getobj__().method
14
+ end
15
+
16
+ def redact? name
17
+ PactBroker::Domain::WebhookRequest::HEADERS_TO_REDACT.any?{ | pattern | name =~ pattern }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module PactBroker
2
+ module Webhooks
3
+ class HttpResponseWithUtf8SafeBody < SimpleDelegator
4
+ def body
5
+ if unsafe_body
6
+ unsafe_body.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
7
+ else
8
+ unsafe_body
9
+ end
10
+ end
11
+
12
+ def unsafe_body
13
+ __getobj__().body
14
+ end
15
+
16
+ def unsafe_body?
17
+ unsafe_body != body
18
+ end
19
+ end
20
+ end
21
+ end
@@ -46,12 +46,12 @@ module PactBroker
46
46
  end
47
47
 
48
48
  def webhook_options(data)
49
- execution_options = data[:execution_options].merge(
49
+ logging_options = data[:logging_options].merge(
50
50
  success_log_message: "Successfully executed webhook",
51
51
  failure_log_message: failure_log_message
52
52
  )
53
53
  {
54
- execution_options: execution_options,
54
+ logging_options: logging_options,
55
55
  webhook_context: data[:webhook_context]
56
56
  }
57
57
  end
@@ -0,0 +1,86 @@
1
+ module PactBroker
2
+ module Webhooks
3
+ class PactAndVerificationParameters
4
+
5
+ def initialize(pact, trigger_verification, webhook_context)
6
+ @pact = pact
7
+ @verification = trigger_verification || (pact && pact.latest_verification)
8
+ @webhook_context = webhook_context
9
+ @base_url = webhook_context.fetch(:base_url)
10
+ end
11
+
12
+ def to_hash
13
+ @hash ||= {
14
+ '${pactbroker.pactUrl}' => pact ? PactBroker::Api::PactBrokerUrls.pact_version_url_with_metadata(pact, base_url) : "",
15
+ '${pactbroker.verificationResultUrl}' => verification_url,
16
+ '${pactbroker.consumerVersionNumber}' => consumer_version_number,
17
+ '${pactbroker.providerVersionNumber}' => verification ? verification.provider_version_number : "",
18
+ '${pactbroker.providerVersionTags}' => provider_version_tags,
19
+ '${pactbroker.consumerVersionTags}' => consumer_version_tags,
20
+ '${pactbroker.consumerName}' => pact ? pact.consumer_name : "",
21
+ '${pactbroker.providerName}' => pact ? pact.provider_name : "",
22
+ '${pactbroker.githubVerificationStatus}' => github_verification_status,
23
+ '${pactbroker.consumerLabels}' => pacticipant_labels(pact && pact.consumer),
24
+ '${pactbroker.providerLabels}' => pacticipant_labels(pact && pact.provider)
25
+ }
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :pact, :verification, :webhook_context, :base_url
31
+
32
+
33
+ def github_verification_status
34
+ if verification
35
+ verification.success ? "success" : "failure"
36
+ else
37
+ "pending"
38
+ end
39
+ end
40
+
41
+ def verification_url
42
+ if verification
43
+ PactBroker::Api::PactBrokerUrls.verification_url(verification, base_url)
44
+ else
45
+ ""
46
+ end
47
+ end
48
+
49
+ def consumer_version_number
50
+ if webhook_context[:consumer_version_number]
51
+ webhook_context[:consumer_version_number]
52
+ else
53
+ pact ? pact.consumer_version_number : ""
54
+ end
55
+ end
56
+
57
+ def consumer_version_tags
58
+ if webhook_context[:consumer_version_tags]
59
+ webhook_context[:consumer_version_tags].join(", ")
60
+ else
61
+ if pact
62
+ pact.consumer_version.tags.collect(&:name).join(", ")
63
+ else
64
+ ""
65
+ end
66
+ end
67
+ end
68
+
69
+ def provider_version_tags
70
+ if webhook_context[:provider_version_tags]
71
+ webhook_context[:provider_version_tags].join(", ")
72
+ else
73
+ if verification
74
+ verification.provider_version.tags.collect(&:name).join(", ")
75
+ else
76
+ ""
77
+ end
78
+ end
79
+ end
80
+
81
+ def pacticipant_labels pacticipant
82
+ pacticipant && pacticipant.labels ? pacticipant.labels.collect(&:name).join(", ") : ""
83
+ end
84
+ end
85
+ end
86
+ end
@@ -1,88 +1,27 @@
1
+ require 'pact_broker/webhooks/pact_and_verification_parameters'
2
+
1
3
  module PactBroker
2
4
  module Webhooks
3
5
  class Render
4
6
 
5
7
  TEMPLATE_PARAMETER_REGEXP = /\$\{pactbroker\.[^\}]+\}/
8
+ DEFAULT_ESCAPER = lambda { |it| it }
6
9
 
7
- def self.call(template, pact, trigger_verification, webhook_context, &escaper)
8
- base_url = webhook_context[:base_url]
9
- verification = trigger_verification || (pact && pact.latest_verification)
10
- params = {
11
- '${pactbroker.pactUrl}' => pact ? PactBroker::Api::PactBrokerUrls.pact_version_url_with_metadata(pact, base_url) : "",
12
- '${pactbroker.verificationResultUrl}' => verification_url(verification, base_url),
13
- '${pactbroker.consumerVersionNumber}' => consumer_version_number(pact, webhook_context),
14
- '${pactbroker.providerVersionNumber}' => verification ? verification.provider_version_number : "",
15
- '${pactbroker.providerVersionTags}' => provider_version_tags(verification, webhook_context),
16
- '${pactbroker.consumerVersionTags}' => consumer_version_tags(pact, webhook_context),
17
- '${pactbroker.consumerName}' => pact ? pact.consumer_name : "",
18
- '${pactbroker.providerName}' => pact ? pact.provider_name : "",
19
- '${pactbroker.githubVerificationStatus}' => github_verification_status(verification),
20
- '${pactbroker.consumerLabels}' => pacticipant_labels(pact && pact.consumer),
21
- '${pactbroker.providerLabels}' => pacticipant_labels(pact && pact.provider)
22
- }
23
-
24
- if escaper
25
- params.keys.each do | key |
26
- params[key] = escaper.call(params[key])
27
- end
28
- end
10
+ def self.call(template, params, &escaper)
11
+ render_template(escape_params(params, escaper || DEFAULT_ESCAPER), template)
12
+ end
29
13
 
14
+ def self.render_template(params, template)
30
15
  params.inject(template) do | template, (key, value) |
31
16
  template.gsub(key, value)
32
17
  end
33
18
  end
34
19
 
35
- def self.github_verification_status verification
36
- if verification
37
- verification.success ? "success" : "failure"
38
- else
39
- "pending"
40
- end
41
- end
42
-
43
- def self.verification_url verification, base_url
44
- if verification
45
- PactBroker::Api::PactBrokerUrls.verification_url(verification, base_url)
46
- else
47
- ""
48
- end
49
- end
50
-
51
- def self.consumer_version_number(pact, webhook_context)
52
- if webhook_context[:consumer_version_number]
53
- webhook_context[:consumer_version_number]
54
- else
55
- pact ? pact.consumer_version_number : ""
20
+ def self.escape_params(params, escaper)
21
+ params.keys.each_with_object({}) do | key, new_params |
22
+ new_params[key] = escaper.call(params[key])
56
23
  end
57
24
  end
58
-
59
- def self.consumer_version_tags pact, webhook_context
60
- if webhook_context[:consumer_version_tags]
61
- webhook_context[:consumer_version_tags].join(", ")
62
- else
63
- if pact
64
- pact.consumer_version.tags.collect(&:name).join(", ")
65
- else
66
- ""
67
- end
68
- end
69
- end
70
-
71
- def self.provider_version_tags verification, webhook_context
72
- if webhook_context[:provider_version_tags]
73
- webhook_context[:provider_version_tags].join(", ")
74
- else
75
- if verification
76
- verification.provider_version.tags.collect(&:name).join(", ")
77
- else
78
- ""
79
- end
80
- end
81
- end
82
-
83
- def self.pacticipant_labels pacticipant
84
- pacticipant && pacticipant.labels ? pacticipant.labels.collect(&:name).join(", ") : ""
85
- end
86
25
  end
87
26
  end
88
27
  end