1
1
require 'pact_broker/error'
2
+ require 'pact_broker/config/space_delimited_string_list'
2
3
3
4
module PactBroker
4
5
@@ -23,15 +24,19 @@ class Configuration
23
24
:check_for_potential_duplicate_pacticipant_names ,
24
25
:webhook_retry_schedule ,
25
26
:semver_formats ,
26
- :disable_ssl_verification
27
+ :disable_ssl_verification ,
28
+ :webhook_http_method_whitelist ,
29
+ :webhook_scheme_whitelist ,
30
+ :webhook_host_whitelist ,
31
+ :base_equality_only_on_content_that_affects_verification_results
27
32
]
28
33
29
34
attr_accessor :log_dir , :database_connection , :auto_migrate_db , :use_hal_browser , :html_pact_renderer
30
35
attr_accessor :validate_database_connection_config , :enable_diagnostic_endpoints , :version_parser , :sha_generator
31
36
attr_accessor :use_case_sensitive_resource_names , :order_versions_by_date
32
37
attr_accessor :check_for_potential_duplicate_pacticipant_names
33
- attr_accessor :webhook_http_method_whitelist , :webhook_scheme_whitelist , :webhook_host_whitelist
34
38
attr_accessor :webhook_retry_schedule
39
+ attr_reader :webhook_http_method_whitelist , :webhook_scheme_whitelist , :webhook_host_whitelist
35
40
attr_accessor :semver_formats
36
41
attr_accessor :enable_public_badge_access , :shields_io_base_url
37
42
attr_accessor :disable_ssl_verification
@@ -68,8 +73,7 @@ def self.default_configuration
68
73
config . version_parser = PactBroker ::Versions ::ParseSemanticVersion
69
74
config . sha_generator = PactBroker ::Pacts ::GenerateSha
70
75
config . base_equality_only_on_content_that_affects_verification_results = false
71
- # Not recommended to set this to true unless there is no way to
72
- # consistently extract an orderable object from the consumer application version number.
76
+ # TODO change this to true
73
77
config . order_versions_by_date = false
74
78
config . semver_formats = [ "%M.%m.%p%s%d" , "%M.%m" , "%M" ]
75
79
config . webhook_retry_schedule = [ 10 , 60 , 120 , 300 , 600 , 1200 ] #10 sec, 1 min, 2 min, 5 min, 10 min, 20 min => 38 minutes
@@ -171,8 +175,29 @@ def load_from_database!
171
175
PactBroker ::Config ::Load . call ( self )
172
176
end
173
177
178
+ def webhook_http_method_whitelist = webhook_http_method_whitelist
179
+ @webhook_http_method_whitelist = parse_space_delimited_string_list_property ( 'webhook_http_method_whitelist' , webhook_http_method_whitelist )
180
+ end
181
+
182
+ def webhook_scheme_whitelist = webhook_scheme_whitelist
183
+ @webhook_scheme_whitelist = parse_space_delimited_string_list_property ( 'webhook_scheme_whitelist' , webhook_scheme_whitelist )
184
+ end
185
+
186
+ def webhook_host_whitelist = webhook_host_whitelist
187
+ @webhook_host_whitelist = parse_space_delimited_string_list_property ( 'webhook_host_whitelist' , webhook_host_whitelist )
188
+ end
189
+
174
190
private
175
191
192
+ def parse_space_delimited_string_list_property property_name , property_value
193
+ case property_value
194
+ when String then Config ::SpaceDelimitedStringList . parse ( property_value )
195
+ when Array then Config ::SpaceDelimitedStringList . new ( property_value )
196
+ else
197
+ raise ConfigurationError . new ( "Pact Broker configuration property `#{ property_name } ` must be a space delimited String or an Array" )
198
+ end
199
+ end
200
+
176
201
def create_logger path
177
202
FileUtils ::mkdir_p File . dirname ( path )
178
203
logger = Logger . new ( path )
0 commit comments