pact_broker 2.21.0 → 2.22.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 +9 -0
- data/lib/pact_broker/config/load.rb +3 -0
- data/lib/pact_broker/config/save.rb +4 -0
- data/lib/pact_broker/config/space_delimited_string_list.rb +31 -0
- data/lib/pact_broker/configuration.rb +29 -4
- data/lib/pact_broker/version.rb +1 -1
- data/spec/lib/pact_broker/config/load_spec.rb +7 -1
- data/spec/lib/pact_broker/config/save_spec.rb +11 -2
- data/spec/lib/pact_broker/config/space_delimited_string_list_spec.rb +45 -0
- data/spec/lib/pact_broker/configuration_spec.rb +25 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 107e0313842be2bc851feb80d62920c27f320509
|
4
|
+
data.tar.gz: d411b036f55dc4d75544d13f607bcdd156485daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00e5f4e37da0f499641550cae06a874ae384065ab7afe3e0b44901e5ea87218b69715936d704b4701e3d310d1f66239395319ca111bbdca6ba488c57828e78c
|
7
|
+
data.tar.gz: 2beb39b0a6fabee40acd5d7259437262f120ae8c0bf5273c32e79ad66be3fa32fd13b18629cfd94b9877f470c7a6ff2f62c71a478ac9a1a2fcee1baf1e02c123
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pact_broker/configuration'
|
2
2
|
require 'pact_broker/logging'
|
3
3
|
require 'pact_broker/config/setting'
|
4
|
+
require 'pact_broker/config/space_delimited_string_list'
|
4
5
|
|
5
6
|
module PactBroker
|
6
7
|
module Config
|
@@ -49,6 +50,8 @@ module PactBroker
|
|
49
50
|
Integer(setting.value)
|
50
51
|
when 'float'
|
51
52
|
Float(setting.value)
|
53
|
+
when 'space_delimited_string_list'
|
54
|
+
SpaceDelimitedStringList.parse(setting.value)
|
52
55
|
when 'boolean'
|
53
56
|
setting.value == "1"
|
54
57
|
end
|
@@ -49,6 +49,8 @@ module PactBroker
|
|
49
49
|
'boolean'
|
50
50
|
when String, nil
|
51
51
|
'string'
|
52
|
+
when SpaceDelimitedStringList
|
53
|
+
'space_delimited_string_list'
|
52
54
|
when Array, Hash
|
53
55
|
'json'
|
54
56
|
when Integer
|
@@ -69,6 +71,8 @@ module PactBroker
|
|
69
71
|
"1"
|
70
72
|
when FalseClass
|
71
73
|
"0"
|
74
|
+
when SpaceDelimitedStringList
|
75
|
+
val.to_s
|
72
76
|
when Array, Hash
|
73
77
|
val.to_json
|
74
78
|
else
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PactBroker
|
2
|
+
module Config
|
3
|
+
class SpaceDelimitedStringList < Array
|
4
|
+
|
5
|
+
def initialize list
|
6
|
+
super(list)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse(string)
|
10
|
+
array = (string || '').split(' ').collect do | word |
|
11
|
+
if word[0] == '/' and word[-1] == '/'
|
12
|
+
Regexp.new(word[1..-2])
|
13
|
+
else
|
14
|
+
word
|
15
|
+
end
|
16
|
+
end
|
17
|
+
SpaceDelimitedStringList.new(array)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
collect do | word |
|
22
|
+
if word.is_a?(Regexp)
|
23
|
+
"/#{word.source}/"
|
24
|
+
else
|
25
|
+
word
|
26
|
+
end
|
27
|
+
end.join(' ')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,4 +1,5 @@
|
|
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 @@ module PactBroker
|
|
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 @@ module PactBroker
|
|
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
|
-
#
|
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 @@ module PactBroker
|
|
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)
|
data/lib/pact_broker/version.rb
CHANGED
@@ -7,7 +7,7 @@ module PactBroker
|
|
7
7
|
describe ".call" do
|
8
8
|
|
9
9
|
class MockConfig
|
10
|
-
attr_accessor :foo, :bar, :nana, :meep, :lalala, :meow, :peebo
|
10
|
+
attr_accessor :foo, :bar, :nana, :meep, :lalala, :meow, :peebo, :whitelist
|
11
11
|
end
|
12
12
|
|
13
13
|
before do
|
@@ -19,6 +19,7 @@ module PactBroker
|
|
19
19
|
Setting.create(name: 'meow', type: 'boolean', value: "0")
|
20
20
|
Setting.create(name: 'peebo', type: 'string', value: nil)
|
21
21
|
Setting.create(name: 'unknown', type: 'string', value: nil)
|
22
|
+
Setting.create(name: 'whitelist', type: 'space_delimited_string_list', value: 'foo bar')
|
22
23
|
end
|
23
24
|
|
24
25
|
let(:configuration) { MockConfig.new }
|
@@ -60,6 +61,11 @@ module PactBroker
|
|
60
61
|
expect(configuration.peebo).to eq nil
|
61
62
|
end
|
62
63
|
|
64
|
+
it "loads a space_delimited_string_list" do
|
65
|
+
subject
|
66
|
+
expect(configuration.whitelist).to eq ["foo", "bar"]
|
67
|
+
end
|
68
|
+
|
63
69
|
it "does not load a setting where the Configuration object does not have a matching property" do
|
64
70
|
allow(Load.logger).to receive(:warn)
|
65
71
|
expect(Load.logger).to receive(:warn).with("Could not load configuration setting \"unknown\" as there is no matching attribute on the Configuration class")
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'pact_broker/config/save'
|
2
2
|
require 'pact_broker/configuration'
|
3
|
+
require 'pact_broker/config/space_delimited_string_list'
|
3
4
|
|
4
5
|
module PactBroker
|
5
6
|
module Config
|
6
7
|
describe Save do
|
7
8
|
|
8
9
|
describe "#call" do
|
9
|
-
let(:setting_names) { [:foo, :bar, :wiffle, :meep, :flop, :peebo, :lalala, :meow] }
|
10
|
+
let(:setting_names) { [:foo, :bar, :wiffle, :meep, :flop, :peebo, :lalala, :meow, :whitelist] }
|
10
11
|
let(:configuration) do
|
11
12
|
double("PactBroker::Configuration",
|
12
13
|
foo: true,
|
@@ -16,7 +17,8 @@ module PactBroker
|
|
16
17
|
flop: nil,
|
17
18
|
peebo: 1,
|
18
19
|
lalala: 1.2,
|
19
|
-
meow: Object.new
|
20
|
+
meow: Object.new,
|
21
|
+
whitelist: SpaceDelimitedStringList.parse("foo bar"))
|
20
22
|
end
|
21
23
|
|
22
24
|
subject { Save.call(configuration, setting_names) }
|
@@ -70,6 +72,13 @@ module PactBroker
|
|
70
72
|
expect(setting.value).to eq '1.2'
|
71
73
|
end
|
72
74
|
|
75
|
+
it "saves a SpaceDelimitedStringList" do
|
76
|
+
subject
|
77
|
+
setting = Setting.find(name: 'whitelist')
|
78
|
+
expect(setting.type).to eq 'space_delimited_string_list'
|
79
|
+
expect(setting.value).to eq 'foo bar'
|
80
|
+
end
|
81
|
+
|
73
82
|
it "does not save an arbitrary object to the database" do
|
74
83
|
allow(Save.logger).to receive(:warn)
|
75
84
|
expect(Save.logger).to receive(:warn).with("Could not save configuration setting \"meow\" to database as the class Object is not supported.")
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'pact_broker/config/space_delimited_string_list'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Config
|
5
|
+
describe SpaceDelimitedStringList do
|
6
|
+
describe "parse" do
|
7
|
+
subject { SpaceDelimitedStringList.parse(input) }
|
8
|
+
|
9
|
+
context "when input is ''" do
|
10
|
+
let(:input) { "" }
|
11
|
+
|
12
|
+
it { is_expected.to eq [] }
|
13
|
+
|
14
|
+
its(:to_s) { is_expected.to eq input }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when input is 'foo bar'" do
|
18
|
+
let(:input) { "foo bar" }
|
19
|
+
|
20
|
+
it { is_expected.to eq ["foo", "bar"] }
|
21
|
+
|
22
|
+
it { is_expected.to be_a SpaceDelimitedStringList }
|
23
|
+
|
24
|
+
its(:to_s) { is_expected.to eq input }
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when input is '/foo.*/'" do
|
28
|
+
let(:input) { "/foo.*/" }
|
29
|
+
|
30
|
+
it { is_expected.to eq [/foo.*/] }
|
31
|
+
|
32
|
+
its(:to_s) { is_expected.to eq input }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when input is '/foo\\.*/' (note double backslash)" do
|
36
|
+
let(:input) { "/foo\\.*/" }
|
37
|
+
|
38
|
+
it { is_expected.to eq [/foo\.*/] }
|
39
|
+
|
40
|
+
its(:to_s) { is_expected.to eq input }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -16,7 +16,32 @@ module PactBroker
|
|
16
16
|
expect(PactBroker::Api::Renderers::HtmlPactRenderer).to receive(:call).with(pact, options)
|
17
17
|
PactBroker.configuration.html_pact_renderer.call pact, options
|
18
18
|
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "webhook_http_method_whitelist" do
|
22
|
+
it "allows setting the whitelist by a string" do
|
23
|
+
PactBroker.configuration.webhook_http_method_whitelist = "foo"
|
24
|
+
expect(PactBroker.configuration.webhook_http_method_whitelist).to be_a Config::SpaceDelimitedStringList
|
25
|
+
end
|
26
|
+
|
27
|
+
it "allows setting the whitelist by an array" do
|
28
|
+
PactBroker.configuration.webhook_http_method_whitelist = ["foo"]
|
29
|
+
expect(PactBroker.configuration.webhook_http_method_whitelist).to be_a Config::SpaceDelimitedStringList
|
30
|
+
end
|
31
|
+
end
|
19
32
|
|
33
|
+
describe "webhook_scheme_whitelist" do
|
34
|
+
it "allows setting the whitelist by a string" do
|
35
|
+
PactBroker.configuration.webhook_scheme_whitelist = "foo"
|
36
|
+
expect(PactBroker.configuration.webhook_scheme_whitelist).to be_a Config::SpaceDelimitedStringList
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "webhook_host_whitelist" do
|
41
|
+
it "allows setting the whitelist by a string" do
|
42
|
+
PactBroker.configuration.webhook_host_whitelist = "foo"
|
43
|
+
expect(PactBroker.configuration.webhook_host_whitelist).to be_a Config::SpaceDelimitedStringList
|
44
|
+
end
|
20
45
|
end
|
21
46
|
|
22
47
|
describe "SETTING_NAMES" do
|
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.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bethany Skurrie
|
@@ -764,6 +764,7 @@ files:
|
|
764
764
|
- lib/pact_broker/config/load.rb
|
765
765
|
- lib/pact_broker/config/save.rb
|
766
766
|
- lib/pact_broker/config/setting.rb
|
767
|
+
- lib/pact_broker/config/space_delimited_string_list.rb
|
767
768
|
- lib/pact_broker/configuration.rb
|
768
769
|
- lib/pact_broker/constants.rb
|
769
770
|
- lib/pact_broker/dashboard/service.rb
|
@@ -1092,6 +1093,7 @@ files:
|
|
1092
1093
|
- spec/lib/pact_broker/config/load_spec.rb
|
1093
1094
|
- spec/lib/pact_broker/config/save_and_load_spec.rb
|
1094
1095
|
- spec/lib/pact_broker/config/save_spec.rb
|
1096
|
+
- spec/lib/pact_broker/config/space_delimited_string_list_spec.rb
|
1095
1097
|
- spec/lib/pact_broker/configuration_spec.rb
|
1096
1098
|
- spec/lib/pact_broker/db/clean_spec.rb
|
1097
1099
|
- spec/lib/pact_broker/db/validate_encoding_spec.rb
|
@@ -1383,6 +1385,7 @@ test_files:
|
|
1383
1385
|
- spec/lib/pact_broker/config/load_spec.rb
|
1384
1386
|
- spec/lib/pact_broker/config/save_and_load_spec.rb
|
1385
1387
|
- spec/lib/pact_broker/config/save_spec.rb
|
1388
|
+
- spec/lib/pact_broker/config/space_delimited_string_list_spec.rb
|
1386
1389
|
- spec/lib/pact_broker/configuration_spec.rb
|
1387
1390
|
- spec/lib/pact_broker/db/clean_spec.rb
|
1388
1391
|
- spec/lib/pact_broker/db/validate_encoding_spec.rb
|