vcloud-edge_gateway 0.2.2 → 0.2.3

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 (34) hide show
  1. data/CHANGELOG.md +11 -0
  2. data/README.md +219 -11
  3. data/examples/firewall-rules.yaml +50 -0
  4. data/examples/loadbalancer-rules.yaml +55 -0
  5. data/examples/nat-rules.yaml +58 -0
  6. data/lib/vcloud/edge_gateway.rb +2 -3
  7. data/lib/vcloud/edge_gateway/configuration_differ.rb +13 -1
  8. data/lib/vcloud/edge_gateway/configuration_generator/nat_service.rb +10 -10
  9. data/lib/vcloud/edge_gateway/edge_gateway_configuration.rb +2 -2
  10. data/lib/vcloud/edge_gateway/firewall_configuration_differ.rb +18 -0
  11. data/lib/vcloud/edge_gateway/load_balancer_configuration_differ.rb +3 -13
  12. data/lib/vcloud/edge_gateway/nat_configuration_differ.rb +18 -0
  13. data/lib/vcloud/edge_gateway/version.rb +1 -1
  14. data/lib/vcloud/edge_gateway_services.rb +1 -1
  15. data/spec/integration/edge_gateway/edge_gateway_services_spec.rb +7 -13
  16. data/spec/integration/edge_gateway/firewall_service_spec.rb +2 -12
  17. data/spec/integration/edge_gateway/load_balancer_service_spec.rb +4 -4
  18. data/spec/integration/edge_gateway/nat_service_spec.rb +4 -4
  19. data/spec/spec_helper.rb +2 -2
  20. data/spec/vcloud/edge_gateway/configuration_differ_shared_examples.rb +132 -0
  21. data/spec/vcloud/edge_gateway/configuration_differ_spec.rb +5 -122
  22. data/spec/vcloud/edge_gateway/configuration_generator/firewall_service_spec.rb +46 -52
  23. data/spec/vcloud/edge_gateway/firewall_configuration_differ_spec.rb +65 -0
  24. data/spec/vcloud/edge_gateway/firewall_schema_validation_spec.rb +2 -2
  25. data/spec/vcloud/edge_gateway/load_balancer_configuration_differ_spec.rb +32 -147
  26. data/spec/vcloud/edge_gateway/load_balancer_schema_validation_spec.rb +7 -7
  27. data/spec/vcloud/edge_gateway/nat_configuration_differ_spec.rb +65 -0
  28. data/spec/vcloud/edge_gateway/nat_schema_validation_spec.rb +4 -4
  29. data/vcloud-edge_gateway.gemspec +2 -2
  30. metadata +18 -13
  31. data/lib/vcloud/config_loader.rb +0 -27
  32. data/lib/vcloud/config_validator.rb +0 -207
  33. data/spec/vcloud/config_loader_spec.rb +0 -112
  34. data/spec/vcloud/config_validator_spec.rb +0 -570
@@ -1,131 +1,14 @@
1
1
  require 'spec_helper'
2
+ require_relative 'configuration_differ_shared_examples'
2
3
 
3
4
  module Vcloud
4
5
  module EdgeGateway
5
- describe ConfigurationDiffer do
6
-
7
- test_cases = [
8
- {
9
- title: 'should return an empty array for two identical empty Hashes',
10
- src: { },
11
- dest: { },
12
- output: [],
13
- },
14
-
15
- {
16
- title: 'should return an empty array for two identical simple Hashes',
17
- src: { testing: 'testing', one: 1, two: 'two', three: "3" },
18
- dest: { testing: 'testing', one: 1, two: 'two', three: "3" },
19
- output: [],
20
- },
21
-
22
- {
23
- title: 'should return an empty array for two identical deep Hashes',
24
- src: { testing: 'testing', one: 1, deep: [
25
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
26
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
27
- ]},
28
- dest: { testing: 'testing', one: 1, deep: [
29
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
30
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
31
- ]},
32
- output: [],
33
- },
34
-
35
- {
36
- title: 'should highlight a simple addition',
37
- src: { foo: '1' },
38
- dest: { foo: '1', bar: '2' },
39
- output: [["+", "bar", "2"]],
40
- },
41
-
42
- {
43
- title: 'should highlight a simple subtraction',
44
- src: { foo: '1', bar: '2' },
45
- dest: { foo: '1' },
46
- output: [["-", "bar", "2"]],
47
- },
48
-
49
- {
50
- title: 'should highlight a deep addition',
51
- src: { testing: 'testing', one: 1, deep: [
52
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
53
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
54
- ]},
55
- dest: { testing: 'testing', one: 1, deep: [
56
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5, 6 ] },
57
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
58
- ]},
59
- output: [["+", "deep[0].deeper[5]", 6]],
60
- },
61
-
62
- {
63
- title: 'should highlight a deep subtraction',
64
- src: { testing: 'testing', one: 1, deep: [
65
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
66
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
67
- ]},
68
- dest: { testing: 'testing', one: 1, deep: [
69
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
70
- { baz: 'bop', deeper: [ 6, 5, 3, 2 ] },
71
- ]},
72
- output: [["-", "deep[1].deeper[2]", 4]],
73
- },
74
6
 
75
- {
76
- title: 'should return an empty array when hash params are reordered',
77
- src: { one: 1, testing: 'testing', deep: [
78
- { deeper: [ 1, 2, 3, 4, 5 ], foo: 'bar' },
79
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
80
- ]},
81
- dest: { testing: 'testing', one: 1, deep: [
82
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
83
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
84
- ]},
85
- output: [],
86
- },
87
-
88
- {
89
- title: 'should highlight when array elements are reordered',
90
- src: { testing: 'testing', one: 1, deep: [
91
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
92
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
93
- ]},
94
- dest: { testing: 'testing', one: 1, deep: [
95
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
96
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
97
- ]},
98
- output: [
99
- ["+", "deep[0]", {:foo=>"bar", :deeper=>[1, 2, 3, 4, 5]}],
100
- ["-", "deep[2]", {:foo=>"bar", :deeper=>[1, 2, 3, 4, 5]}],
101
- ]
102
- },
103
-
104
- {
105
- title: 'should highlight when deep array elements are reordered',
106
- src: { testing: 'testing', one: 1, deep: [
107
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
108
- { baz: 'bop', deeper: [ 5, 6, 4, 3, 2 ] },
109
- ]},
110
- dest: { testing: 'testing', one: 1, deep: [
111
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
112
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
113
- ]},
114
- output: [
115
- ["+", "deep[1].deeper[0]", 6],
116
- ["-", "deep[1].deeper[2]", 6]
117
- ]
118
- },
119
-
120
- ]
121
-
122
- test_cases.each do |test_case|
123
- it "#{test_case[:title]}" do
124
- differ = ConfigurationDiffer.new(test_case[:src], test_case[:dest])
125
- expect(differ.diff).to eq(test_case[:output])
126
- end
7
+ describe ConfigurationDiffer do
8
+ it_behaves_like "a configuration differ" do
9
+ let(:config_differ) { ConfigurationDiffer }
127
10
  end
128
-
129
11
  end
12
+
130
13
  end
131
14
  end
@@ -66,11 +66,8 @@ module Vcloud
66
66
 
67
67
  context "firewall config generation" do
68
68
 
69
- test_cases = [
70
-
71
- {
72
- title: 'disabled firewall with a disabled rule',
73
- input: {
69
+ it 'should have disabled firewall with a disabled rule' do
70
+ input = {
74
71
  enabled: 'false',
75
72
  policy: 'allow',
76
73
  log_default_action: 'true',
@@ -89,8 +86,8 @@ module Vcloud
89
86
  enable_logging: 'true',
90
87
  }
91
88
  ]
92
- },
93
- output: {
89
+ }
90
+ output = {
94
91
  IsEnabled: 'false',
95
92
  DefaultAction: "allow",
96
93
  LogDefaultAction: 'true',
@@ -111,12 +108,13 @@ module Vcloud
111
108
  EnableLogging: 'true',
112
109
  }
113
110
  ]
114
- }
115
- },
111
+ }
112
+ generated_config = FirewallService.new.generate_fog_config(input)
113
+ expect(generated_config).to eq(output)
114
+ end
116
115
 
117
- {
118
- title: 'id should be auto generated if not provided',
119
- input: {
116
+ it 'id should be auto generated if not provided' do
117
+ input = {
120
118
  firewall_rules: [
121
119
  {
122
120
  description: "rule 1",
@@ -131,8 +129,8 @@ module Vcloud
131
129
  source_ip: "192.0.2.2",
132
130
  }
133
131
  ]
134
- },
135
- output: {
132
+ }
133
+ output = {
136
134
  IsEnabled: 'true',
137
135
  DefaultAction: "drop",
138
136
  LogDefaultAction: 'false',
@@ -168,12 +166,13 @@ module Vcloud
168
166
  EnableLogging: 'false',
169
167
  }
170
168
  ]
171
- }
172
- },
169
+ }
170
+ generated_config = FirewallService.new.generate_fog_config(input)
171
+ expect(generated_config).to eq(output)
172
+ end
173
173
 
174
- {
175
- title: 'should send port as -1 if destination/source_port_ranges are ranges',
176
- input: {
174
+ it 'should send port as -1 if destination/source_port_ranges are ranges' do
175
+ input = {
177
176
  firewall_rules: [
178
177
  {
179
178
  description: "rule 1",
@@ -183,8 +182,8 @@ module Vcloud
183
182
  source_ip: "192.0.2.2",
184
183
  }
185
184
  ]
186
- },
187
- output: {
185
+ }
186
+ output = {
188
187
  IsEnabled: 'true',
189
188
  DefaultAction: "drop",
190
189
  LogDefaultAction: 'false',
@@ -205,12 +204,13 @@ module Vcloud
205
204
  EnableLogging: 'false',
206
205
  }
207
206
  ]
208
- }
209
- },
207
+ }
208
+ generated_config = FirewallService.new.generate_fog_config(input)
209
+ expect(generated_config).to eq(output)
210
+ end
210
211
 
211
- {
212
- title: 'should send port same as destination/source_port_range if destination/source_port_range are decimals and not ranges',
213
- input: {
212
+ it 'should send port same as destination/source_port_range if destination/source_port_range are decimals and not ranges' do
213
+ input = {
214
214
  firewall_rules: [
215
215
  {
216
216
  description: "rule 1",
@@ -220,8 +220,8 @@ module Vcloud
220
220
  source_ip: "192.0.2.2",
221
221
  }
222
222
  ]
223
- },
224
- output: {
223
+ }
224
+ output = {
225
225
  IsEnabled: 'true',
226
226
  DefaultAction: "drop",
227
227
  LogDefaultAction: 'false',
@@ -242,12 +242,13 @@ module Vcloud
242
242
  EnableLogging: 'false',
243
243
  }
244
244
  ]
245
- },
246
- },
245
+ }
246
+ generated_config = FirewallService.new.generate_fog_config(input)
247
+ expect(generated_config).to eq(output)
248
+ end
247
249
 
248
- {
249
- title: 'should handle a rule specifiying "any" protocols',
250
- input: {
250
+ it 'should handle a rule specifiying "any" protocols' do
251
+ input = {
251
252
  firewall_rules: [
252
253
  {
253
254
  description: "allow any protocol",
@@ -256,8 +257,8 @@ module Vcloud
256
257
  source_ip: "192.0.2.2",
257
258
  }
258
259
  ]
259
- },
260
- output: {
260
+ }
261
+ output = {
261
262
  IsEnabled: 'true',
262
263
  DefaultAction: "drop",
263
264
  LogDefaultAction: 'false',
@@ -278,12 +279,13 @@ module Vcloud
278
279
  EnableLogging: 'false',
279
280
  }
280
281
  ]
281
- },
282
- },
282
+ }
283
+ generated_config = FirewallService.new.generate_fog_config(input)
284
+ expect(generated_config).to eq(output)
285
+ end
283
286
 
284
- {
285
- title: 'output rule order should be same as the input rule order',
286
- input: {
287
+ it 'output rule order should be same as the input rule order' do
288
+ input = {
287
289
  firewall_rules: [
288
290
  {
289
291
  description: "rule 1",
@@ -316,8 +318,8 @@ module Vcloud
316
318
  source_ip: "Any",
317
319
  },
318
320
  ],
319
- },
320
- output: {
321
+ }
322
+ output = {
321
323
  IsEnabled: 'true',
322
324
  DefaultAction: "drop",
323
325
  LogDefaultAction: 'false',
@@ -398,17 +400,9 @@ module Vcloud
398
400
  EnableLogging: 'false',
399
401
  }
400
402
  ]
401
- }
402
403
  }
403
-
404
- ]
405
-
406
- test_cases.each do |test_case|
407
- it "#{test_case[:title]}" do
408
- generated_config = FirewallService.new.generate_fog_config test_case[:input]
409
- expect(generated_config).to eq(test_case[:output])
410
- end
411
-
404
+ generated_config = FirewallService.new.generate_fog_config(input)
405
+ expect(generated_config).to eq(output)
412
406
  end
413
407
 
414
408
  end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+ require_relative 'configuration_differ_shared_examples.rb'
3
+
4
+ module Vcloud
5
+ module EdgeGateway
6
+ describe FirewallConfigurationDiffer do
7
+
8
+ it_behaves_like "a configuration differ" do
9
+ let(:config_differ) { FirewallConfigurationDiffer }
10
+ end
11
+
12
+ it 'should ignore Id parameters in FirewallRule sections, when showing additions' do
13
+ local = { FirewallRule: [
14
+ { Id: '1', deeper: [ 1, 2, 3, 4, 5 ] },
15
+ { Id: '2', deeper: [ 5, 6, 4, 3, 2 ] },
16
+ ]}
17
+ remote = { FirewallRule: [
18
+ { Id: '1', deeper: [ 1, 1, 1, 1, 1 ] },
19
+ { Id: '2', deeper: [ 1, 2, 3, 4, 5 ] },
20
+ { Id: '3', deeper: [ 5, 6, 4, 3, 2 ] },
21
+ ]}
22
+ output = [
23
+ ["+", "FirewallRule[0]", {:deeper=>[1, 1, 1, 1, 1]}]
24
+ ]
25
+ differ = FirewallConfigurationDiffer.new(local, remote)
26
+ expect(differ.diff).to eq(output)
27
+ end
28
+
29
+ it 'should still highlight a reordering despite ignoring Id' do
30
+ local = { FirewallRule: [
31
+ { Id: '1', deeper: [ 1, 1, 1, 1, 1 ] },
32
+ { Id: '2', deeper: [ 1, 2, 3, 4, 5 ] },
33
+ { Id: '3', deeper: [ 5, 6, 4, 3, 2 ] },
34
+ ]}
35
+ remote = { FirewallRule: [
36
+ { Id: '1', deeper: [ 1, 2, 3, 4, 5 ] },
37
+ { Id: '2', deeper: [ 5, 6, 4, 3, 2 ] },
38
+ { Id: '3', deeper: [ 1, 1, 1, 1, 1 ] },
39
+ ]}
40
+ output = [
41
+ ["-", "FirewallRule[0]", {:deeper=>[1, 1, 1, 1, 1]}],
42
+ ["+", "FirewallRule[2]", {:deeper=>[1, 1, 1, 1, 1]}],
43
+ ]
44
+ differ = FirewallConfigurationDiffer.new(local, remote)
45
+ expect(differ.diff).to eq(output)
46
+ end
47
+
48
+ it 'should not ignore Id parameter outside of a FirewallRule (just in case)' do
49
+ local = {
50
+ FirewallRule: [ { Id: '1', deeper: [ 1, 1, 1, 1, 1 ] } ],
51
+ Id: 'outside of firewall rule'
52
+ }
53
+ remote = {
54
+ FirewallRule: [ { Id: '1', deeper: [ 1, 1, 1, 1, 1 ] } ],
55
+ }
56
+ output = [
57
+ ["-", "Id", 'outside of firewall rule']
58
+ ]
59
+ differ = FirewallConfigurationDiffer.new(local, remote)
60
+ expect(differ.diff).to eq(output)
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -16,7 +16,7 @@ module Vcloud
16
16
  ]
17
17
 
18
18
  }
19
- validator = ConfigValidator.validate(:base, config, Schema::FIREWALL_SERVICE)
19
+ validator = Vcloud::Core::ConfigValidator.validate(:base, config, Schema::FIREWALL_SERVICE)
20
20
  expect(validator.valid?).to be_false
21
21
  expect(validator.errors).to eq([
22
22
  "source_ip: 192.0 is not a valid IP address range. Valid values can be IP address, CIDR, IP range, 'Any','internal' and 'external'.",
@@ -37,7 +37,7 @@ module Vcloud
37
37
  ]
38
38
 
39
39
  }
40
- validator = ConfigValidator.validate(:base, config, Schema::FIREWALL_SERVICE)
40
+ validator = Vcloud::Core::ConfigValidator.validate(:base, config, Schema::FIREWALL_SERVICE)
41
41
  expect(validator.valid?).to be_true
42
42
  end
43
43
  end
@@ -1,158 +1,43 @@
1
1
  require 'spec_helper'
2
+ require_relative 'configuration_differ_shared_examples.rb'
2
3
 
3
4
  module Vcloud
4
5
  module EdgeGateway
5
6
  describe LoadBalancerConfigurationDiffer do
6
7
 
7
- test_cases = [
8
- {
9
- title: 'should return an empty array for two identical empty Hashes',
10
- src: { },
11
- dest: { },
12
- output: [],
13
- },
14
-
15
- {
16
- title: 'should return an empty array for two identical simple Hashes',
17
- src: { testing: 'testing', one: 1, two: 'two', three: "3" },
18
- dest: { testing: 'testing', one: 1, two: 'two', three: "3" },
19
- output: [],
20
- },
21
-
22
- {
23
- title: 'should return an empty array for two identical deep Hashes',
24
- src: { testing: 'testing', one: 1, deep: [
25
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
26
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
27
- ]},
28
- dest: { testing: 'testing', one: 1, deep: [
29
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
30
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
31
- ]},
32
- output: [],
33
- },
34
-
35
- {
36
- title: 'should highlight a simple addition',
37
- src: { foo: '1' },
38
- dest: { foo: '1', bar: '2' },
39
- output: [["+", "bar", "2"]],
40
- },
41
-
42
- {
43
- title: 'should highlight a simple subtraction',
44
- src: { foo: '1', bar: '2' },
45
- dest: { foo: '1' },
46
- output: [["-", "bar", "2"]],
47
- },
48
-
49
- {
50
- title: 'should highlight a deep addition',
51
- src: { testing: 'testing', one: 1, deep: [
52
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
53
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
54
- ]},
55
- dest: { testing: 'testing', one: 1, deep: [
56
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5, 6 ] },
57
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
58
- ]},
59
- output: [["+", "deep[0].deeper[5]", 6]],
60
- },
61
-
62
- {
63
- title: 'should highlight a deep subtraction',
64
- src: { testing: 'testing', one: 1, deep: [
65
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
66
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
67
- ]},
68
- dest: { testing: 'testing', one: 1, deep: [
69
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
70
- { baz: 'bop', deeper: [ 6, 5, 3, 2 ] },
71
- ]},
72
- output: [["-", "deep[1].deeper[2]", 4]],
73
- },
74
-
75
- {
76
- title: 'should return an empty array when hash params are reordered',
77
- src: { one: 1, testing: 'testing', deep: [
78
- { deeper: [ 1, 2, 3, 4, 5 ], foo: 'bar' },
79
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
80
- ]},
81
- dest: { testing: 'testing', one: 1, deep: [
82
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
83
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
84
- ]},
85
- output: [],
86
- },
87
-
88
- {
89
- title: 'should highlight when array elements are reordered',
90
- src: { testing: 'testing', one: 1, deep: [
91
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
92
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
93
- ]},
94
- dest: { testing: 'testing', one: 1, deep: [
95
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
96
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
97
- ]},
98
- output: [
99
- ["+", "deep[0]", {:foo=>"bar", :deeper=>[1, 2, 3, 4, 5]}],
100
- ["-", "deep[2]", {:foo=>"bar", :deeper=>[1, 2, 3, 4, 5]}],
101
- ]
102
- },
103
-
104
- {
105
- title: 'should highlight when deep array elements are reordered',
106
- src: { testing: 'testing', one: 1, deep: [
107
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
108
- { baz: 'bop', deeper: [ 5, 6, 4, 3, 2 ] },
109
- ]},
110
- dest: { testing: 'testing', one: 1, deep: [
111
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
112
- { baz: 'bop', deeper: [ 6, 5, 4, 3, 2 ] },
113
- ]},
114
- output: [
115
- ["+", "deep[1].deeper[0]", 6],
116
- ["-", "deep[1].deeper[2]", 6]
117
- ]
118
- },
119
-
120
- {
121
- title: 'should ignore remote config having additional :Operational keys in :Pool entries',
122
- src: { Pool: [
123
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
124
- { baz: 'bop', deeper: [ 5, 6, 4, 3, 2 ] },
125
- ]},
126
- dest: { Pool: [
127
- { foo: 'bar', Operational: 'wibble', deeper: [ 1, 2, 3, 4, 5 ] },
128
- { baz: 'bop', Operational: 'wobble', deeper: [ 5, 6, 4, 3, 2 ] },
129
- ]},
130
- output: []
131
- },
132
-
133
- {
134
- title: 'should ignore remote config having additional :Operational keys in :Pool entries, yet still report other differences ',
135
- src: { Pool: [
136
- { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
137
- { baz: 'bop', deeper: [ 5, 6, 4, 3, 2 ] },
138
- ]},
139
- dest: { Pool: [
140
- { foo: 'bar', Operational: 'wibble', deeper: [ 1, 2, 3, 4, 5 ] },
141
- { baz: 'bop', Operational: 'wobble', deeper: [ 6, 5, 4, 3, 2 ] },
142
- ]},
143
- output: [
144
- ["+", "Pool[1].deeper[0]", 6],
145
- ["-", "Pool[1].deeper[2]", 6]
146
- ]
147
- },
8
+ it_behaves_like "a configuration differ" do
9
+ let(:config_differ) { LoadBalancerConfigurationDiffer }
10
+ end
148
11
 
149
- ]
12
+ it 'should ignore remote config having additional :Operational keys in :Pool entries' do
13
+ local = { Pool: [
14
+ { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
15
+ { baz: 'bop', deeper: [ 5, 6, 4, 3, 2 ] },
16
+ ]}
17
+ remote = { Pool: [
18
+ { foo: 'bar', Operational: 'wibble', deeper: [ 1, 2, 3, 4, 5 ] },
19
+ { baz: 'bop', Operational: 'wobble', deeper: [ 5, 6, 4, 3, 2 ] },
20
+ ]}
21
+ output = []
22
+ differ = LoadBalancerConfigurationDiffer.new(local, remote)
23
+ expect(differ.diff).to eq(output)
24
+ end
150
25
 
151
- test_cases.each do |test_case|
152
- it "#{test_case[:title]}" do
153
- differ = LoadBalancerConfigurationDiffer.new(test_case[:src], test_case[:dest])
154
- expect(differ.diff).to eq(test_case[:output])
155
- end
26
+ it 'should ignore remote config having additional :Operational keys in :Pool entries, yet still report other differences' do
27
+ local = { Pool: [
28
+ { foo: 'bar', deeper: [ 1, 2, 3, 4, 5 ] },
29
+ { baz: 'bop', deeper: [ 5, 6, 4, 3, 2 ] },
30
+ ]}
31
+ remote = { Pool: [
32
+ { foo: 'bar', Operational: 'wibble', deeper: [ 1, 2, 3, 4, 5 ] },
33
+ { baz: 'bop', Operational: 'wobble', deeper: [ 6, 5, 4, 3, 2 ] },
34
+ ]}
35
+ output = [
36
+ ["+", "Pool[1].deeper[0]", 6],
37
+ ["-", "Pool[1].deeper[2]", 6]
38
+ ]
39
+ differ = LoadBalancerConfigurationDiffer.new(local, remote)
40
+ expect(differ.diff).to eq(output)
156
41
  end
157
42
 
158
43
  end