pact_broker 2.96.0 → 2.99.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/Gemfile +1 -0
  4. data/docs/CONFIGURATION.md +131 -67
  5. data/lib/db.rb +1 -7
  6. data/lib/pact_broker/api/middleware/http_debug_logs.rb +42 -0
  7. data/lib/pact_broker/api/resources/base_resource.rb +4 -0
  8. data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
  9. data/lib/pact_broker/api/resources/pact.rb +0 -8
  10. data/lib/pact_broker/api/resources/pact_content_diff.rb +7 -2
  11. data/lib/pact_broker/api/resources/pact_versions.rb +1 -5
  12. data/lib/pact_broker/api/resources/pact_versions_for_branch.rb +1 -5
  13. data/lib/pact_broker/api/resources/provider_pacts.rb +1 -1
  14. data/lib/pact_broker/api/resources/tagged_pact_versions.rb +1 -5
  15. data/lib/pact_broker/api/resources/verification.rb +0 -4
  16. data/lib/pact_broker/api/resources/verifications.rb +0 -4
  17. data/lib/pact_broker/api/resources/version.rb +8 -0
  18. data/lib/pact_broker/app.rb +3 -7
  19. data/lib/pact_broker/config/runtime_configuration.rb +24 -5
  20. data/lib/pact_broker/config/runtime_configuration_coercion_methods.rb +11 -0
  21. data/lib/pact_broker/config/runtime_configuration_database_methods.rb +2 -2
  22. data/lib/pact_broker/config/runtime_configuration_logging_methods.rb +7 -2
  23. data/lib/pact_broker/configuration.rb +2 -0
  24. data/lib/pact_broker/db/models.rb +2 -2
  25. data/lib/pact_broker/index/service.rb +1 -2
  26. data/lib/pact_broker/integrations/integration.rb +21 -6
  27. data/lib/pact_broker/integrations/service.rb +1 -1
  28. data/lib/pact_broker/matrix/every_row.rb +19 -1
  29. data/lib/pact_broker/matrix/integration.rb +5 -5
  30. data/lib/pact_broker/matrix/quick_row.rb +36 -3
  31. data/lib/pact_broker/matrix/repository.rb +4 -3
  32. data/lib/pact_broker/matrix/service.rb +0 -1
  33. data/lib/pact_broker/metrics/service.rb +2 -2
  34. data/lib/pact_broker/pacts/create_formatted_diff.rb +1 -0
  35. data/lib/pact_broker/pacts/eager_loaders.rb +4 -1
  36. data/lib/pact_broker/pacts/pact_publication.rb +9 -6
  37. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +25 -0
  38. data/lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb +0 -15
  39. data/lib/pact_broker/pacts/pact_version.rb +24 -28
  40. data/lib/pact_broker/pacts/pact_version_association_loaders.rb +36 -0
  41. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +9 -13
  42. data/lib/pact_broker/pacts/repository.rb +29 -27
  43. data/lib/pact_broker/test/http_test_data_builder.rb +11 -2
  44. data/lib/pact_broker/test/test_data_builder.rb +2 -1
  45. data/lib/pact_broker/ui/controllers/matrix.rb +14 -11
  46. data/lib/pact_broker/ui/views/groups/show.html.erb +2 -2
  47. data/lib/pact_broker/version.rb +1 -1
  48. data/pact_broker.gemspec +1 -1
  49. metadata +9 -16
  50. data/lib/pact_broker/matrix/aggregated_row.rb +0 -79
  51. data/lib/pact_broker/matrix/head_row.rb +0 -80
  52. data/lib/pact_broker/matrix/row.rb +0 -287
@@ -19,8 +19,8 @@ variable `PACT_BROKER_CONF` to the full path to the configuration file.
19
19
 
20
20
  The application log level
21
21
 
22
- **YAML configuration key name:** `log_level`<br/>
23
22
  **Environment variable name:** `PACT_BROKER_LOG_LEVEL`<br/>
23
+ **YAML configuration key name:** `log_level`<br/>
24
24
  **Default:** `info`<br/>
25
25
  **Allowed values:** `debug`, `info`, `warn`, `error`, `fatal`<br/>
26
26
 
@@ -28,8 +28,8 @@ The application log level
28
28
 
29
29
  The application log format. Can be any value supported by Semantic Logger.
30
30
 
31
- **YAML configuration key name:** `log_format`<br/>
32
31
  **Environment variable name:** `PACT_BROKER_LOG_FORMAT`<br/>
32
+ **YAML configuration key name:** `log_format`<br/>
33
33
  **Default:** `default`<br/>
34
34
  **Allowed values:** `default`, `json`, `color`<br/>
35
35
  **More information:** https://github.com/rocketjob/semantic_logger/tree/master/lib/semantic_logger/formatters<br/>
@@ -38,8 +38,8 @@ The application log format. Can be any value supported by Semantic Logger.
38
38
 
39
39
  The log file directory
40
40
 
41
- **YAML configuration key name:** `log_dir`<br/>
42
41
  **Environment variable name:** `PACT_BROKER_LOG_DIR`<br/>
42
+ **YAML configuration key name:** `log_dir`<br/>
43
43
  **Default:** `./logs`<br/>
44
44
 
45
45
  ### log_stream
@@ -48,17 +48,29 @@ The stream to which the logs will be sent.
48
48
 
49
49
  While the default is `file` for the Ruby application, it is set to `stdout` on the supported Docker images.
50
50
 
51
- **YAML configuration key name:** `log_stream`<br/>
52
51
  **Environment variable name:** `PACT_BROKER_LOG_STREAM`<br/>
52
+ **YAML configuration key name:** `log_stream`<br/>
53
53
  **Default:** `file`<br/>
54
54
  **Allowed values:** `stdout`, `file`<br/>
55
55
 
56
+ ### http_debug_logging_enabled
57
+
58
+ Enable this setting to print the entire request and response to the logs at debug level. Used for troubleshooting issues.
59
+ Do not leave this on permanently, as it will have performance and security issues.
60
+ Ensure the application [`log_level`](#log_level) is set to `debug` when this setting is enabled.
61
+
62
+ **Supported versions:** From v2.98.0<br/>
63
+ **Environment variable name:** `PACT_BROKER_HTTP_DEBUG_LOGGING_ENABLED`<br/>
64
+ **YAML configuration key name:** `http_debug_logging_enabled`<br/>
65
+ **Default:** `false`<br/>
66
+ **Allowed values:** `true`, `false`<br/>
67
+
56
68
  ### hide_pactflow_messages
57
69
 
58
70
  Set to `true` to hide the messages in the logs about Pactflow
59
71
 
60
- **YAML configuration key name:** `hide_pactflow_messages`<br/>
61
72
  **Environment variable name:** `PACT_BROKER_HIDE_PACTFLOW_MESSAGES`<br/>
73
+ **YAML configuration key name:** `hide_pactflow_messages`<br/>
62
74
  **Default:** `true`<br/>
63
75
  **Allowed values:** `true`, `false`<br/>
64
76
  **More information:** https://pactflow.io<br/>
@@ -77,8 +89,8 @@ The database adapter. For production use, Postgres must be used.
77
89
  For investigations/spikes on a development machine, you can use SQlite. It is not supported as a production database, as it does not support
78
90
  concurrent requests.
79
91
 
80
- **YAML configuration key name:** `database_adapter`<br/>
81
92
  **Environment variable name:** `PACT_BROKER_DATABASE_ADAPTER`<br/>
93
+ **YAML configuration key name:** `database_adapter`<br/>
82
94
  **Default:** `postgres`<br/>
83
95
  **Allowed values:** `postgres` (for production use), `sqlite` (for spikes only)<br/>
84
96
 
@@ -86,44 +98,44 @@ concurrent requests.
86
98
 
87
99
  The database username
88
100
 
89
- **YAML configuration key name:** `database_username`<br/>
90
101
  **Environment variable name:** `PACT_BROKER_DATABASE_USERNAME`<br/>
102
+ **YAML configuration key name:** `database_username`<br/>
91
103
 
92
104
  ### database_password
93
105
 
94
106
  The database password
95
107
 
96
- **YAML configuration key name:** `database_password`<br/>
97
108
  **Environment variable name:** `PACT_BROKER_DATABASE_PASSWORD`<br/>
109
+ **YAML configuration key name:** `database_password`<br/>
98
110
 
99
111
  ### database_name
100
112
 
101
113
  The database name. If using the `sqlite` adapter, this will be the path to the database file.
102
114
 
103
- **YAML configuration key name:** `database_name`<br/>
104
115
  **Environment variable name:** `PACT_BROKER_DATABASE_NAME`<br/>
116
+ **YAML configuration key name:** `database_name`<br/>
105
117
  **Examples:** `pact_broker`, `/tmp/pact_broker.sqlite3`, `./tmp/pact_broker.sqlite3`<br/>
106
118
 
107
119
  ### database_host
108
120
 
109
121
  The database host
110
122
 
111
- **YAML configuration key name:** `database_host`<br/>
112
123
  **Environment variable name:** `PACT_BROKER_DATABASE_HOST`<br/>
124
+ **YAML configuration key name:** `database_host`<br/>
113
125
 
114
126
  ### database_port
115
127
 
116
128
  The database port. If ommited, the default port for the adapter will be used.
117
129
 
118
- **YAML configuration key name:** `database_port`<br/>
119
130
  **Environment variable name:** `PACT_BROKER_DATABASE_PORT`<br/>
131
+ **YAML configuration key name:** `database_port`<br/>
120
132
 
121
133
  ### database_url
122
134
 
123
135
  The full database URL may be specified instead of the separate adapter, username, password, name, host and port.
124
136
 
125
- **YAML configuration key name:** `database_url`<br/>
126
137
  **Environment variable name:** `PACT_BROKER_DATABASE_URL`<br/>
138
+ **YAML configuration key name:** `database_url`<br/>
127
139
  **Format:** `{database_adapter}://{database_username}:{database_password}@{database_host}:{database_port}/{database_name}`<br/>
128
140
  **Examples:** `postgres://pact_broker_user:pact_broker_password@pact_broker_db_host/pact_broker`, `sqlite:///tmp/pact_broker.sqlite3` (relative path to working directory), `sqlite:////tmp/pact_broker.sqlite3` (absolute path)<br/>
129
141
 
@@ -131,8 +143,8 @@ The full database URL may be specified instead of the separate adapter, username
131
143
 
132
144
  The Postgresql ssl mode.
133
145
 
134
- **YAML configuration key name:** `database_sslmode`<br/>
135
146
  **Environment variable name:** `PACT_BROKER_DATABASE_SSLMODE`<br/>
147
+ **YAML configuration key name:** `database_sslmode`<br/>
136
148
  **Default:** `prefer`<br/>
137
149
  **Allowed values:** `disable`, `allow`, `prefer`, `require`, `verify-ca`, `verify-full`<br/>
138
150
  **More information:** https://ankane.org/postgres-sslmode-explained<br/>
@@ -143,27 +155,38 @@ The log level that will be used when the SQL query statements are logged.
143
155
 
144
156
  To disable noisy SQL query logging when the application `log_level` is set to `debug` for other reasons, use the value `none`.
145
157
 
146
- **YAML configuration key name:** `sql_log_level`<br/>
147
158
  **Environment variable name:** `PACT_BROKER_SQL_LOG_LEVEL`<br/>
148
- **Default:** `debug`<br/>
159
+ **YAML configuration key name:** `sql_log_level`<br/>
160
+ **Default:** From 2.99+, the default is `none`. In previous versions, the default is `debug`.<br/>
149
161
  **Allowed values:** `none`, `debug`, `info`, `warn`, `error`, `fatal`<br/>
150
162
 
151
163
  ### sql_log_warn_duration
152
164
 
153
165
  The number of seconds after which to log an SQL query at warn level. Use this for detecting slow queries.
154
166
 
155
- **YAML configuration key name:** `sql_log_warn_duration`<br/>
156
167
  **Environment variable name:** `PACT_BROKER_SQL_LOG_WARN_DURATION`<br/>
168
+ **YAML configuration key name:** `sql_log_warn_duration`<br/>
157
169
  **Default:** `5`<br/>
158
170
  **Allowed values:** A positive integer or float, as a string.<br/>
159
171
  **More information:** https://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html#label-General+connection+options<br/>
160
172
 
173
+ ### sql_enable_caller_logging
174
+
175
+ Whether or not to enable caller_logging extension for database connection.
176
+ When enabled it logs source path that caused SQL query.
177
+
178
+ **Environment variable name:** `PACT_BROKER_SQL_ENABLE_CALLER_LOGGING`<br/>
179
+ **YAML configuration key name:** `sql_enable_caller_logging`<br/>
180
+ **Default:** `false`<br/>
181
+ **Allowed values:** `true`, `false`<br/>
182
+ **More information:** https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/caller_logging_rb.html<br/>
183
+
161
184
  ### database_max_connections
162
185
 
163
186
  The maximum size of the connection pool (4 connections by default on most databases)
164
187
 
165
- **YAML configuration key name:** `database_max_connections`<br/>
166
188
  **Environment variable name:** `PACT_BROKER_DATABASE_MAX_CONNECTIONS`<br/>
189
+ **YAML configuration key name:** `database_max_connections`<br/>
167
190
  **Default:** `4`<br/>
168
191
  **Allowed values:** A positive integer value.<br/>
169
192
  **More information:** https://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html#label-General+connection+options<br/>
@@ -172,8 +195,8 @@ The maximum size of the connection pool (4 connections by default on most databa
172
195
 
173
196
  The number of seconds to wait if a connection cannot be acquired before raising an error
174
197
 
175
- **YAML configuration key name:** `database_pool_timeout`<br/>
176
198
  **Environment variable name:** `PACT_BROKER_DATABASE_POOL_TIMEOUT`<br/>
199
+ **YAML configuration key name:** `database_pool_timeout`<br/>
177
200
  **Default:** `5`<br/>
178
201
  **Allowed values:** A positive integer.<br/>
179
202
  **More information:** https://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html#label-General+connection+options<br/>
@@ -185,8 +208,8 @@ the Broker application process may be ready before the database is available for
185
208
  container to exit with an error. Setting the max retries to a non-zero number will allow it to retry the connection the
186
209
  configured number of times, waiting 3 seconds between attempts.
187
210
 
188
- **YAML configuration key name:** `database_connect_max_retries`<br/>
189
211
  **Environment variable name:** `PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES`<br/>
212
+ **YAML configuration key name:** `database_connect_max_retries`<br/>
190
213
  **Default:** `0`<br/>
191
214
  **Allowed values:** A positive integer value.<br/>
192
215
 
@@ -194,8 +217,8 @@ configured number of times, waiting 3 seconds between attempts.
194
217
 
195
218
  Whether or not to run the database schema migrations on start up. It is recommended to set this to `true`.
196
219
 
197
- **YAML configuration key name:** `auto_migrate_db`<br/>
198
220
  **Environment variable name:** `PACT_BROKER_AUTO_MIGRATE_DB`<br/>
221
+ **YAML configuration key name:** `auto_migrate_db`<br/>
199
222
  **Default:** `true`<br/>
200
223
  **Allowed values:** `true`, `false`<br/>
201
224
 
@@ -203,8 +226,8 @@ Whether or not to run the database schema migrations on start up. It is recommen
203
226
 
204
227
  Whether or not to run the database data migrations on start up. It is recommended to set this to `true`.
205
228
 
206
- **YAML configuration key name:** `auto_migrate_db_data`<br/>
207
229
  **Environment variable name:** `PACT_BROKER_AUTO_MIGRATE_DB_DATA`<br/>
230
+ **YAML configuration key name:** `auto_migrate_db_data`<br/>
208
231
  **Default:** `true`<br/>
209
232
  **Allowed values:** `true`, `false`<br/>
210
233
 
@@ -214,8 +237,8 @@ If `true`, will not raise an error if a database migration is recorded in the da
214
237
  equivalent file in the codebase. If this is true, an older version of the code may be used with a newer version of the database,
215
238
  however, data integrity issues may occur.
216
239
 
217
- **YAML configuration key name:** `allow_missing_migration_files`<br/>
218
240
  **Environment variable name:** `PACT_BROKER_ALLOW_MISSING_MIGRATION_FILES`<br/>
241
+ **YAML configuration key name:** `allow_missing_migration_files`<br/>
219
242
  **Default:** `true`<br/>
220
243
  **More information:** https://sequel.jeremyevans.net/rdoc/classes/Sequel/Migrator.html<br/>
221
244
 
@@ -223,8 +246,8 @@ however, data integrity issues may occur.
223
246
 
224
247
  The number of seconds after which an SQL query will be aborted. Only supported for Postgresql connections.
225
248
 
226
- **YAML configuration key name:** `database_statement_timeout`<br/>
227
249
  **Environment variable name:** `PACT_BROKER_DATABASE_STATEMENT_TIMEOUT`<br/>
250
+ **YAML configuration key name:** `database_statement_timeout`<br/>
228
251
  **Default:** `15`<br/>
229
252
  **Allowed values:** A positive integer or float.<br/>
230
253
  **More information:** https://www.postgresql.org/docs/9.3/runtime-config-client.html<br/>
@@ -235,8 +258,8 @@ The number of seconds after which the SQL queries used for the metrics endpoint
235
258
  This is configurable separately from the standard `database_statement_timeout` as it may need to be significantly
236
259
  longer than the desired value for standard queries.
237
260
 
238
- **YAML configuration key name:** `metrics_sql_statement_timeout`<br/>
239
261
  **Environment variable name:** `PACT_BROKER_METRICS_SQL_STATEMENT_TIMEOUT`<br/>
262
+ **YAML configuration key name:** `metrics_sql_statement_timeout`<br/>
240
263
  **Default:** `30`<br/>
241
264
  **Allowed values:** A positive integer.<br/>
242
265
 
@@ -248,8 +271,8 @@ The number of seconds after which to check the health of a connection from a con
248
271
  when databases are restarted and connections are killed. This has a performance
249
272
  penalty, so consider increasing this timeout if building a frequently accessed service.
250
273
 
251
- **YAML configuration key name:** `database_connection_validation_timeout`<br/>
252
274
  **Environment variable name:** `PACT_BROKER_DATABASE_CONNECTION_VALIDATION_TIMEOUT`<br/>
275
+ **YAML configuration key name:** `database_connection_validation_timeout`<br/>
253
276
  **Default:** -1 for v2.85.1 and earlier, 3600 for later versions.<br/>
254
277
  **Allowed values:** -1 or any positive integer.<br/>
255
278
  **More information:** https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/connection_validator_rb.html<br/>
@@ -268,8 +291,8 @@ should be used for CI/CD.
268
291
 
269
292
  Whether to enable basic authorization. This is automatically set to true for the Docker images if the `basic_auth_username` and `basic_auth_password` are set.
270
293
 
271
- **YAML configuration key name:** `basic_auth_enabled`<br/>
272
294
  **Environment variable name:** `PACT_BROKER_BASIC_AUTH_ENABLED`<br/>
295
+ **YAML configuration key name:** `basic_auth_enabled`<br/>
273
296
  **Default:** `false`<br/>
274
297
  **Allowed values:** `true`, `false`<br/>
275
298
 
@@ -277,36 +300,36 @@ Whether to enable basic authorization. This is automatically set to true for the
277
300
 
278
301
  The username for the read/write basic auth user.
279
302
 
280
- **YAML configuration key name:** `basic_auth_username`<br/>
281
303
  **Environment variable name:** `PACT_BROKER_BASIC_AUTH_USERNAME`<br/>
304
+ **YAML configuration key name:** `basic_auth_username`<br/>
282
305
 
283
306
  ### basic_auth_password
284
307
 
285
308
  The password for the read/write basic auth user.
286
309
 
287
- **YAML configuration key name:** `basic_auth_password`<br/>
288
310
  **Environment variable name:** `PACT_BROKER_BASIC_AUTH_PASSWORD`<br/>
311
+ **YAML configuration key name:** `basic_auth_password`<br/>
289
312
 
290
313
  ### basic_auth_read_only_username
291
314
 
292
315
  The username for the read only basic auth user.
293
316
 
294
- **YAML configuration key name:** `basic_auth_read_only_username`<br/>
295
317
  **Environment variable name:** `PACT_BROKER_BASIC_AUTH_READ_ONLY_USERNAME`<br/>
318
+ **YAML configuration key name:** `basic_auth_read_only_username`<br/>
296
319
 
297
320
  ### basic_auth_read_only_password
298
321
 
299
322
  The password for the read only basic auth user.
300
323
 
301
- **YAML configuration key name:** `basic_auth_read_only_password`<br/>
302
324
  **Environment variable name:** `PACT_BROKER_BASIC_AUTH_READ_ONLY_PASSWORD`<br/>
325
+ **YAML configuration key name:** `basic_auth_read_only_password`<br/>
303
326
 
304
327
  ### allow_public_read
305
328
 
306
329
  If you want to allow public read access, but still require credentials for writing, then leave `basic_auth_read_only_username` and `basic_auth_read_only_password` unset, and set `allow_public_read` to `true`.
307
330
 
308
- **YAML configuration key name:** `allow_public_read`<br/>
309
331
  **Environment variable name:** `PACT_BROKER_ALLOW_PUBLIC_READ`<br/>
332
+ **YAML configuration key name:** `allow_public_read`<br/>
310
333
  **Default:** `false`<br/>
311
334
  **Allowed values:** `true`, `false`<br/>
312
335
 
@@ -314,8 +337,8 @@ If you want to allow public read access, but still require credentials for writi
314
337
 
315
338
  If you have enabled basic auth, but require unauthenticated access to the heartbeat URL (eg. for use within an AWS autoscaling group), set `public_heartbeat` to `true`.
316
339
 
317
- **YAML configuration key name:** `public_heartbeat`<br/>
318
340
  **Environment variable name:** `PACT_BROKER_PUBLIC_HEARTBEAT`<br/>
341
+ **YAML configuration key name:** `public_heartbeat`<br/>
319
342
  **Default:** `false`<br/>
320
343
  **Allowed values:** `true`, `false`<br/>
321
344
 
@@ -323,8 +346,8 @@ If you have enabled basic auth, but require unauthenticated access to the heartb
323
346
 
324
347
  Set this to true to allow status badges to be embedded in README files without requiring a hardcoded password.
325
348
 
326
- **YAML configuration key name:** `enable_public_badge_access`<br/>
327
349
  **Environment variable name:** `PACT_BROKER_ENABLE_PUBLIC_BADGE_ACCESS`<br/>
350
+ **YAML configuration key name:** `enable_public_badge_access`<br/>
328
351
  **Default:** `false`<br/>
329
352
  **Allowed values:** `true`, `false`<br/>
330
353
 
@@ -340,8 +363,8 @@ Set this to true to allow status badges to be embedded in README files without r
340
363
  The schedule of seconds to wait between webhook execution attempts.
341
364
  The default schedule is 10 sec, 1 min, 2 min, 5 min, 10 min, 20 min (38 minutes in total).
342
365
 
343
- **YAML configuration key name:** `webhook_retry_schedule`<br/>
344
366
  **Environment variable name:** `PACT_BROKER_WEBHOOK_RETRY_SCHEDULE`<br/>
367
+ **YAML configuration key name:** `webhook_retry_schedule`<br/>
345
368
  **Format:** A space separated list of integers.<br/>
346
369
  **Default:** `10 60 120 300 600 1200`<br/>
347
370
 
@@ -350,8 +373,8 @@ The default schedule is 10 sec, 1 min, 2 min, 5 min, 10 min, 20 min (38 minutes
350
373
  The allowed HTTP methods for webhooks.
351
374
  It is highly recommended that only `POST` requests are allowed to ensure that webhooks cannot be used to retrieve sensitive information from hosts within the same network.
352
375
 
353
- **YAML configuration key name:** `webhook_http_method_whitelist`<br/>
354
376
  **Environment variable name:** `PACT_BROKER_WEBHOOK_HTTP_METHOD_WHITELIST`<br/>
377
+ **YAML configuration key name:** `webhook_http_method_whitelist`<br/>
355
378
  **Format:** A space separated list.<br/>
356
379
  **Default:** `POST`<br/>
357
380
  **Allowed values:** `POST`, `GET` (not recommended), `PUT` (not recommended), `PATCH` (not recommended), `DELETE` (not recommended)<br/>
@@ -364,8 +387,8 @@ considered a success, otherwise the webhook will be re-triggered based on the `w
364
387
  In most cases, configuring this is not necessary, but there are some CI systems that return a non 200 status for a success,
365
388
  which is why this feature exists.
366
389
 
367
- **YAML configuration key name:** `webhook_http_code_success`<br/>
368
390
  **Environment variable name:** `PACT_BROKER_WEBHOOK_HTTP_CODE_SUCCESS`<br/>
391
+ **YAML configuration key name:** `webhook_http_code_success`<br/>
369
392
  **Format:** A space separated list of integers.<br/>
370
393
  **Default:** `200 201 202 203 204 205 206`<br/>
371
394
  **Allowed values:** `Any valid HTTP status code`<br/>
@@ -374,8 +397,8 @@ which is why this feature exists.
374
397
 
375
398
  The allowed URL schemes for webhooks.
376
399
 
377
- **YAML configuration key name:** `webhook_scheme_whitelist`<br/>
378
400
  **Environment variable name:** `PACT_BROKER_WEBHOOK_SCHEME_WHITELIST`<br/>
401
+ **YAML configuration key name:** `webhook_scheme_whitelist`<br/>
379
402
  **Format:** A space delimited list.<br/>
380
403
  **Default:** `https`<br/>
381
404
  **Allowed values:** `https`, `http`<br/>
@@ -387,37 +410,69 @@ Regular expressions should start and end with a `/` to differentiate them from S
387
410
  Note that backslashes need to be escaped with a second backslash when setting via an environment variable.
388
411
  Please read the [Webhook whitelists section](https://docs.pact.io/pact_broker/configuration/features#webhooks) of the Pact Broker configuration documentation to understand how the whitelist is used.
389
412
 
390
- **YAML configuration key name:** `webhook_host_whitelist`<br/>
391
413
  **Environment variable name:** `PACT_BROKER_WEBHOOK_HOST_WHITELIST`<br/>
414
+ **Environment variable format:** A space separated list.<br/>
415
+ **YAML configuration key name:** `webhook_host_whitelist`<br/>
416
+ **YAML format:** A YAML list.<br/>
392
417
  **Examples:** `github.com`, `10.2.3.41/24`, `/.*\\.foo\\.com$/`<br/>
393
418
  **More information:** https://docs.pact.io/pact_broker/configuration/#webhook-whitelists<br/>
394
419
 
395
420
  ### webhook_certificates
396
421
 
397
- A list of SSL certificate configuration objects with the keys `description`, and either `content` or `path`. These
422
+ A list of SSL certificate configuration objects with the key `description`, and either `content` or `path`. These
398
423
  certificates are used when a webhook needs to connect to a server that uses a self signed certificate.
399
424
 
400
425
  Each certificate configuration item accepts a chain of certificates in PEM format - there may be multiple 'BEGIN CERTIFICATE' and 'END CERTIFICATE' in the content of each item.
401
426
 
402
- When setting the content, use the syntax "content: |-" followed by a new line, and then the contents of the certificate
403
- chain in PEM format, indented by 2 more characters.
404
-
405
- When setting the path, the full path to the certificate file in PEM format must be specified.
406
-
407
427
  The certificate configuration is not validated on startup. If any of the configured certificates cannot be loaded during the execution of a webhook, an error
408
428
  will be logged, and they will be ignored. You can check if the configuration is working by testing the execution of
409
429
  a webhook that connects to the server with the self signed certificate by following these instructions https://docs.pact.io/pact_broker/webhooks/debugging_webhooks#testing-webhook-execution
410
430
 
411
- **YAML configuration key name:** `webhook_certificates`<br/>
431
+ When setting the content in the YAML file, use the syntax "content: |-" followed by a new line, and then the contents of the certificate
432
+ chain in PEM format, indented by 2 more characters.
433
+
434
+ When setting the path, the full path to the certificate file in PEM format must be specified. When using Docker, you must ensure the
435
+ certificate file is [mounted into the container](https://docs.docker.com/storage/volumes/).
436
+
437
+ YAML Example:
438
+
439
+ ```yaml
440
+ webhook_certificates:
441
+ - description: "An example self signed certificate with content"
442
+ content: |-
443
+ -----BEGIN CERTIFICATE-----
444
+ MIIDZDCCAkygAwIBAgIBATANBgkqhkiG9w0BAQsFADBCMRMwEQYKCZImiZPyLGQB
445
+ <REST OF CERTIFICATE>
446
+ jHT1Ty2CglM=
447
+ -----END CERTIFICATE-----
448
+ - description: "An example self signed certificate with a path"
449
+ path: "/full/path/to/the/cert.pem"
450
+
451
+ ```
452
+
453
+ Environment variable example:
454
+
455
+ ```shell
456
+ PACT_BROKER_WEBHOOK_CERTIFICATES__0__LABEL="An example self signed certificate with content"
457
+ PACT_BROKER_WEBHOOK_CERTIFICATES__0__CONTENT="-----BEGIN CERTIFICATE-----
458
+ MIIDZDCCAkygAwIBAgIBATANBgkqhkiG9w0BAQsFADBCMRMwEQYKCZImiZPyLGQB
459
+ <REST OF CERTIFICATE>
460
+ jHT1Ty2CglM=
461
+ -----END CERTIFICATE-----"
462
+ PACT_BROKER_WEBHOOK_CERTIFICATES__1__LABEL="An example self signed certificate with a path"
463
+ PACT_BROKER_WEBHOOK_CERTIFICATES__1__PATH="/full/path/to/the/cert.pem"
464
+ ```
465
+
466
+ **Supported versions:** From v2.90.0 for YAML and 2.97.0 for environment variables.<br/>
412
467
  **Environment variable name:** `PACT_BROKER_WEBHOOK_CERTIFICATES`<br/>
413
- **Supported versions:** From v2.90.0<br/>
468
+ **YAML configuration key name:** `webhook_certificates`<br/>
414
469
 
415
470
  ### disable_ssl_verification
416
471
 
417
472
  If set to true, SSL verification will be disabled for the HTTP requests made by the webhooks
418
473
 
419
- **YAML configuration key name:** `disable_ssl_verification`<br/>
420
474
  **Environment variable name:** `PACT_BROKER_DISABLE_SSL_VERIFICATION`<br/>
475
+ **YAML configuration key name:** `disable_ssl_verification`<br/>
421
476
  **Default:** `false`<br/>
422
477
  **Allowed values:** `true`, `false`<br/>
423
478
 
@@ -425,8 +480,8 @@ If set to true, SSL verification will be disabled for the HTTP requests made by
425
480
 
426
481
  The user agent to set when making HTTP requests for webhooks.
427
482
 
428
- **YAML configuration key name:** `user_agent`<br/>
429
483
  **Environment variable name:** `PACT_BROKER_USER_AGENT`<br/>
484
+ **YAML configuration key name:** `user_agent`<br/>
430
485
  **Default:** `Pact Broker v{VERSION}`<br/>
431
486
 
432
487
  <br/>
@@ -442,8 +497,8 @@ The HTTP port that the Pact Broker application will run on. This will only be ho
442
497
  a package that actually reads this property (eg. one of the supported Docker images). If you are running the vanilla Ruby application,
443
498
  the application will run on the port the server has been configured to run on (eg. `bundle exec rackup -p 9393`)
444
499
 
445
- **YAML configuration key name:** `port`<br/>
446
500
  **Environment variable name:** `PACT_BROKER_PORT`<br/>
501
+ **YAML configuration key name:** `port`<br/>
447
502
  **Default:** `9292`<br/>
448
503
 
449
504
  ### base_url
@@ -455,8 +510,8 @@ deploying the Pact Broker to production as it prevents cache poisoning security
455
510
  It is also required when deploying the Broker behind a reverse proxy, and when the application has been mounted at a non-root context.
456
511
  Note that this attribute does not change where the application is actually mounted (that is the concern of the deployment configuration) - it just changes the links.
457
512
 
458
- **YAML configuration key name:** `base_url`<br/>
459
513
  **Environment variable name:** `PACT_BROKER_BASE_URL`<br/>
514
+ **YAML configuration key name:** `base_url`<br/>
460
515
  **Examples:** `https://pact-broker.mycompany.com`, `https://my-company.com:9292/pact-broker`<br/>
461
516
 
462
517
  ### base_urls
@@ -464,8 +519,8 @@ Note that this attribute does not change where the application is actually mount
464
519
  An alias of base_url. From version 2.79.0, multiple base URLs can be configured for architectures that use
465
520
  gateways or proxies that allow the same Pact Broker instance to be addressed with different base URLs.
466
521
 
467
- **YAML configuration key name:** `base_urls`<br/>
468
522
  **Environment variable name:** `PACT_BROKER_BASE_URLS`<br/>
523
+ **YAML configuration key name:** `base_urls`<br/>
469
524
  **Format:** A space separated list.<br/>
470
525
  **Example:** `http://my-internal-pact-broker:9292 https://my-external-pact-broker`<br/>
471
526
 
@@ -473,8 +528,8 @@ gateways or proxies that allow the same Pact Broker instance to be addressed wit
473
528
 
474
529
  The URL of the shields.io server used to generate the README badges.
475
530
 
476
- **YAML configuration key name:** `shields_io_base_url`<br/>
477
531
  **Environment variable name:** `PACT_BROKER_SHIELDS_IO_BASE_URL`<br/>
532
+ **YAML configuration key name:** `shields_io_base_url`<br/>
478
533
  **Default:** `https://img.shields.io`<br/>
479
534
  **More information:** https://shields.io<br/>
480
535
 
@@ -485,8 +540,8 @@ to render the badge from the shields.io server directly in the browser. This is
485
540
  When set to `proxy`, the Pact Broker will make a request directly to the configured shields.io server, and then send the returned file
486
541
  back to the browser. This mode is not recommended for security and performance reasons.
487
542
 
488
- **YAML configuration key name:** `badge_provider_mode`<br/>
489
543
  **Environment variable name:** `PACT_BROKER_BADGE_PROVIDER_MODE`<br/>
544
+ **YAML configuration key name:** `badge_provider_mode`<br/>
490
545
  **Default:** `redirect`<br/>
491
546
  **Allowed values:** `redirect`, `proxy`<br/>
492
547
 
@@ -496,8 +551,8 @@ Whether or not to enable the diagnostic endpoints at `/diagnostic/status/heartbe
496
551
  The heartbeat endpoint is for use by load balancers, and the dependencies endpoint is for checking that the database
497
552
  is available (do not use this for load balancing, as it makes a database connection).
498
553
 
499
- **YAML configuration key name:** `enable_diagnostic_endpoints`<br/>
500
554
  **Environment variable name:** `PACT_BROKER_ENABLE_DIAGNOSTIC_ENDPOINTS`<br/>
555
+ **YAML configuration key name:** `enable_diagnostic_endpoints`<br/>
501
556
  **Default:** `true`<br/>
502
557
  **Allowed values:** `true`, `false`<br/>
503
558
 
@@ -505,8 +560,8 @@ is available (do not use this for load balancing, as it makes a database connect
505
560
 
506
561
  Whether or not to enable the embedded HAL Browser.
507
562
 
508
- **YAML configuration key name:** `use_hal_browser`<br/>
509
563
  **Environment variable name:** `PACT_BROKER_USE_HAL_BROWSER`<br/>
564
+ **YAML configuration key name:** `use_hal_browser`<br/>
510
565
  **Default:** `true`<br/>
511
566
  **Allowed values:** `true`, `false`<br/>
512
567
  **More information:** https://github.com/mikekelly/hal-browser<br/>
@@ -532,8 +587,8 @@ or that the pacticipant should be created manually if it was intended to be a ne
532
587
  To turn this feature off, set `check_for_potential_duplicate_pacticipant_names` to `false`, and make sure everyone is very careful with their naming!
533
588
  The usefulness of the Broker depends on the integrity of the data, which in turn depends on the correctness of the pacticipant names.
534
589
 
535
- **YAML configuration key name:** `check_for_potential_duplicate_pacticipant_names`<br/>
536
590
  **Environment variable name:** `PACT_BROKER_CHECK_FOR_POTENTIAL_DUPLICATE_PACTICIPANT_NAMES`<br/>
591
+ **YAML configuration key name:** `check_for_potential_duplicate_pacticipant_names`<br/>
537
592
  **Default:** `true`<br/>
538
593
  **Allowed values:** `true`, `false`<br/>
539
594
 
@@ -544,9 +599,9 @@ also created for the pacticipant version.
544
599
 
545
600
  This is to assist in the migration from using tags to track deployments to using the deployed and released versions feature.
546
601
 
547
- **YAML configuration key name:** `create_deployed_versions_for_tags`<br/>
548
- **Environment variable name:** `PACT_BROKER_CREATE_DEPLOYED_VERSIONS_FOR_TAGS`<br/>
549
602
  **Supported versions:** From v2.81.0<br/>
603
+ **Environment variable name:** `PACT_BROKER_CREATE_DEPLOYED_VERSIONS_FOR_TAGS`<br/>
604
+ **YAML configuration key name:** `create_deployed_versions_for_tags`<br/>
550
605
  **Default:** `true`<br/>
551
606
  **Allowed values:** `true`, `false`<br/>
552
607
  **More information:** https://docs.pact.io/pact_broker/recording_deployments_and_releases/<br/>
@@ -558,9 +613,9 @@ will be used to populate the `branch` property of the version.
558
613
 
559
614
  This is to assist in the migration from using tags to track branches to using the branches feature.
560
615
 
561
- **YAML configuration key name:** `use_first_tag_as_branch`<br/>
562
- **Environment variable name:** `PACT_BROKER_USE_FIRST_TAG_AS_BRANCH`<br/>
563
616
  **Supported versions:** From v2.82.0<br/>
617
+ **Environment variable name:** `PACT_BROKER_USE_FIRST_TAG_AS_BRANCH`<br/>
618
+ **YAML configuration key name:** `use_first_tag_as_branch`<br/>
564
619
  **Default:** `true`<br/>
565
620
  **Allowed values:** `true`, `false`<br/>
566
621
 
@@ -571,9 +626,9 @@ the `mainBranch` property is set for that pacticipant if it is not already set.
571
626
 
572
627
  This is to assist in the migration from using tags to track branches to using the branches feature.
573
628
 
574
- **YAML configuration key name:** `auto_detect_main_branch`<br/>
575
- **Environment variable name:** `PACT_BROKER_AUTO_DETECT_MAIN_BRANCH`<br/>
576
629
  **Supported versions:** From v2.82.0<br/>
630
+ **Environment variable name:** `PACT_BROKER_AUTO_DETECT_MAIN_BRANCH`<br/>
631
+ **YAML configuration key name:** `auto_detect_main_branch`<br/>
577
632
  **Default:** `true`<br/>
578
633
  **Allowed values:** `true`, `false`<br/>
579
634
 
@@ -581,9 +636,9 @@ This is to assist in the migration from using tags to track branches to using th
581
636
 
582
637
  An array of potential main branch names used when automatically detecting the main branch for a pacticipant.
583
638
 
584
- **YAML configuration key name:** `main_branch_candidates`<br/>
585
- **Environment variable name:** `PACT_BROKER_MAIN_BRANCH_CANDIDATES`<br/>
586
639
  **Supported versions:** From v2.82.0<br/>
640
+ **Environment variable name:** `PACT_BROKER_MAIN_BRANCH_CANDIDATES`<br/>
641
+ **YAML configuration key name:** `main_branch_candidates`<br/>
587
642
  **Format:** A space delimited list.<br/>
588
643
  **Default:** `develop main master`<br/>
589
644
 
@@ -593,13 +648,22 @@ Whether or not to allow the pact content for an existing consumer version to be
593
648
  as allowing modification makes the results of can-i-deploy unreliable. When this is set to false as recommended, each commit must publish pacts
594
649
  with a unique version number.
595
650
 
596
- **YAML configuration key name:** `allow_dangerous_contract_modification`<br/>
597
- **Environment variable name:** `PACT_BROKER_ALLOW_DANGEROUS_CONTRACT_MODIFICATION`<br/>
598
651
  **Supported versions:** From v2.82.0<br/>
652
+ **Environment variable name:** `PACT_BROKER_ALLOW_DANGEROUS_CONTRACT_MODIFICATION`<br/>
653
+ **YAML configuration key name:** `allow_dangerous_contract_modification`<br/>
599
654
  **Default:** For new installations of v2.82.0 and later, this defaults to `false`.<br/>
600
655
  **Allowed values:** `true`, `false`<br/>
601
656
  **More information:** https://docs.pact.io/versioning<br/>
602
657
 
658
+ ### pact_content_diff_timeout
659
+
660
+ The maximum amount of time in seconds to attempt to generate the diff between two pacts before aborting the request. This is required due to performance issues in the underlying diff generation code.
661
+
662
+ **Supported versions:** From 2.99.0<br/>
663
+ **Environment variable name:** `PACT_BROKER_PACT_CONTENT_DIFF_TIMEOUT`<br/>
664
+ **YAML configuration key name:** `pact_content_diff_timeout`<br/>
665
+ **Default:** `15`<br/>
666
+
603
667
  <br/>
604
668
 
605
669
  ## Miscellaneous
@@ -611,7 +675,7 @@ with a unique version number.
611
675
 
612
676
  A list of features to enable in the Pact Broker for beta testing before public release.
613
677
 
614
- **YAML configuration key name:** `features`<br/>
615
678
  **Environment variable name:** `PACT_BROKER_FEATURES`<br/>
679
+ **YAML configuration key name:** `features`<br/>
616
680
  **Format:** A space separated list.<br/>
617
681
 
data/lib/db.rb CHANGED
@@ -38,14 +38,8 @@ module DB
38
38
  con.extension(:connection_validator)
39
39
  con.extension(:pagination)
40
40
  con.extension(:statement_timeout)
41
+ con.extension(:any_not_empty)
41
42
  #con.extension(:caller_logging)
42
- con.extend_datasets do
43
- # rubocop: disable Lint/NestedMethodDefinition
44
- def any?
45
- !empty?
46
- end
47
- # rubocop: enable Lint/NestedMethodDefinition
48
- end
49
43
  con.timezone = :utc
50
44
  con.run("SET sql_mode='STRICT_TRANS_TABLES';") if db_credentials[:adapter].to_s =~ /mysql/
51
45
  con
@@ -0,0 +1,42 @@
1
+ require "pact_broker/logging"
2
+ require "rack/pact_broker/request_target"
3
+
4
+ module PactBroker
5
+ module Api
6
+ module Middleware
7
+ class HttpDebugLogs
8
+ include PactBroker::Logging
9
+ include Rack::PactBroker::RequestTarget
10
+
11
+ EXCLUDE_HEADERS = ["puma.", "rack.", "pactbroker."]
12
+ RACK_SESSION = "rack.session"
13
+
14
+ def initialize(app)
15
+ @app = app
16
+ @logger = logger
17
+ end
18
+
19
+ def call(env)
20
+ if request_for_api?(env)
21
+ env_to_log = env.reject { | header, _ | header.start_with?(*EXCLUDE_HEADERS) }
22
+ env_to_log["rack.session"] = env["rack.session"].to_hash if env["rack.session"]
23
+ env_to_log["rack.input"] = request_body(env) if env["rack.input"]
24
+ logger.debug("env", payload: env_to_log)
25
+ status, headers, body = @app.call(env)
26
+ logger.debug("response", payload: { "status" => status, "headers" => headers, "body" => body })
27
+ [status, headers, body]
28
+ else
29
+ @app.call(env)
30
+ end
31
+ end
32
+
33
+ def request_body(env)
34
+ buffer = env["rack.input"]
35
+ request_body = buffer.read
36
+ buffer.respond_to?(:rewind) && buffer.rewind
37
+ JSON.parse(request_body) rescue request_body
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end