rbeapi 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +25 -2
  4. data/Gemfile +13 -7
  5. data/Rakefile +8 -7
  6. data/lib/rbeapi/api/alias.rb +160 -0
  7. data/lib/rbeapi/api/bgp.rb +9 -9
  8. data/lib/rbeapi/api/dns.rb +3 -1
  9. data/lib/rbeapi/api/interfaces.rb +194 -32
  10. data/lib/rbeapi/api/ipinterfaces.rb +5 -3
  11. data/lib/rbeapi/api/managementdefaults.rb +119 -0
  12. data/lib/rbeapi/api/mlag.rb +6 -6
  13. data/lib/rbeapi/api/ntp.rb +1 -1
  14. data/lib/rbeapi/api/ospf.rb +171 -12
  15. data/lib/rbeapi/api/prefixlists.rb +19 -9
  16. data/lib/rbeapi/api/radius.rb +5 -5
  17. data/lib/rbeapi/api/routemaps.rb +12 -12
  18. data/lib/rbeapi/api/snmp.rb +6 -4
  19. data/lib/rbeapi/api/stp.rb +24 -24
  20. data/lib/rbeapi/api/switchports.rb +15 -9
  21. data/lib/rbeapi/api/tacacs.rb +1 -1
  22. data/lib/rbeapi/api/users.rb +4 -4
  23. data/lib/rbeapi/api/varp.rb +7 -3
  24. data/lib/rbeapi/api/vlans.rb +2 -2
  25. data/lib/rbeapi/api/vrrp.rb +61 -61
  26. data/lib/rbeapi/client.rb +9 -6
  27. data/lib/rbeapi/eapilib.rb +3 -3
  28. data/lib/rbeapi/netdev/snmp.rb +8 -6
  29. data/lib/rbeapi/switchconfig.rb +9 -10
  30. data/lib/rbeapi/version.rb +1 -1
  31. data/spec/support/fixtures.rb +4 -4
  32. data/spec/support/matchers/switch_config_sections.rb +2 -2
  33. data/spec/system/rbeapi/api/acl_spec.rb +2 -4
  34. data/spec/system/rbeapi/api/alias_spec.rb +168 -0
  35. data/spec/system/rbeapi/api/bgp_spec.rb +1 -2
  36. data/spec/system/rbeapi/api/interfaces_base_spec.rb +7 -8
  37. data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +36 -3
  38. data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +35 -3
  39. data/spec/system/rbeapi/api/interfaces_vlan_spec.rb +90 -0
  40. data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +3 -4
  41. data/spec/system/rbeapi/api/managementdefaults_spec.rb +31 -0
  42. data/spec/system/rbeapi/api/ospf_interfaces_spec.rb +36 -11
  43. data/spec/system/rbeapi/api/ospf_spec.rb +240 -17
  44. data/spec/system/rbeapi/api/prefixlists_spec.rb +105 -89
  45. data/spec/system/rbeapi/api/routemaps_spec.rb +15 -10
  46. data/spec/system/rbeapi/api/users_spec.rb +4 -5
  47. data/spec/system/rbeapi/api/vrrp_spec.rb +2 -5
  48. data/spec/system/rbeapi/client_spec.rb +1 -2
  49. data/spec/unit/rbeapi/api/acl/default_spec.rb +1 -2
  50. data/spec/unit/rbeapi/api/alias/default_spec.rb +119 -0
  51. data/spec/unit/rbeapi/api/alias/fixture_alias.text +3 -0
  52. data/spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb +1 -2
  53. data/spec/unit/rbeapi/api/bgp/bgp_spec.rb +1 -2
  54. data/spec/unit/rbeapi/api/interfaces/base_spec.rb +1 -1
  55. data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +35 -1
  56. data/spec/unit/rbeapi/api/interfaces/fixture_interfaces.text +68 -0
  57. data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +41 -4
  58. data/spec/unit/rbeapi/api/interfaces/vlan_spec.rb +72 -0
  59. data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +2 -2
  60. data/spec/unit/rbeapi/api/managementdefaults/default_spec.rb +50 -0
  61. data/spec/unit/rbeapi/api/managementdefaults/fixture_managementdefaults.yaml +1 -0
  62. data/spec/unit/rbeapi/api/prefixlists/default_spec.rb +98 -80
  63. data/spec/unit/rbeapi/api/prefixlists/fixture_prefixlists.text +9 -4
  64. data/spec/unit/rbeapi/api/users/default_spec.rb +2 -4
  65. data/spec/unit/rbeapi/api/vrrp/default_spec.rb +2 -5
  66. data/spec/unit/rbeapi/client_spec.rb +21 -14
  67. data/spec/unit/rbeapi/switchconfig_spec.rb +10 -3
  68. metadata +49 -59
@@ -0,0 +1,3 @@
1
+ alias Alias1 my command
2
+ alias Alias2 my command 2
3
+ alias Alias3 1 conf\n2 int %1\n3 description %2\n4 end\nend
@@ -67,8 +67,7 @@ describe Rbeapi::Api::BgpNeighbors do
67
67
  shutdown: true, description: nil, next_hop_self: true,
68
68
  route_map_in: nil, route_map_out: nil
69
69
  }
70
- }
71
- }
70
+ } }
72
71
  end
73
72
  let(:bgp_as) { test[:bgp_as] }
74
73
 
@@ -67,8 +67,7 @@ describe Rbeapi::Api::Bgp do
67
67
  shutdown: true, description: nil, next_hop_self: true,
68
68
  route_map_in: nil, route_map_out: nil
69
69
  }
70
- }
71
- }
70
+ } }
72
71
  end
73
72
  let(:bgp_as) { test[:bgp_as] }
74
73
 
@@ -23,7 +23,7 @@ describe Rbeapi::Api::BaseInterface do
23
23
  let(:resource) { subject.get('Loopback0') }
24
24
 
25
25
  let(:keys) do
26
- [:type, :shutdown, :load_interval, :description, :name]
26
+ [:type, :shutdown, :load_interval, :description, :encapsulation, :name]
27
27
  end
28
28
 
29
29
  it 'returns an ethernet resource as a hash' do
@@ -24,7 +24,8 @@ describe Rbeapi::Api::EthernetInterface do
24
24
 
25
25
  let(:keys) do
26
26
  [:type, :speed, :sflow, :flowcontrol_send, :flowcontrol_receive,
27
- :shutdown, :description, :name, :load_interval, :lacp_priority]
27
+ :shutdown, :description, :encapsulation, :name, :load_interval,
28
+ :lacp_priority]
28
29
  end
29
30
 
30
31
  it 'returns an ethernet resource as a hash' do
@@ -86,4 +87,37 @@ describe Rbeapi::Api::EthernetInterface do
86
87
  default: true)).to be_truthy
87
88
  end
88
89
  end
90
+
91
+ describe '#set_encapsulation' do
92
+ it 'sets the interface encapsulation' do
93
+ expect(node).to receive(:config).with(['interface Ethernet1.1',
94
+ 'encapsulation dot1q vlan 10'])
95
+ expect(subject.set_encapsulation('Ethernet1.1', value: '10'))
96
+ .to be_truthy
97
+ end
98
+
99
+ it 'negates the interface encapsulation' do
100
+ expect(node).to receive(:config).with(['interface Ethernet1.1',
101
+ 'no encapsulation dot1q vlan'])
102
+ expect(subject.set_encapsulation('Ethernet1.1',
103
+ enable: false)).to be_truthy
104
+ end
105
+
106
+ it 'defaults the interface encapsulation' do
107
+ expect(node).to receive(:config)
108
+ .with(['interface Ethernet1.1',
109
+ 'default encapsulation dot1q vlan'])
110
+ expect(subject.set_encapsulation('Ethernet1.1',
111
+ default: true)).to be_truthy
112
+ end
113
+
114
+ it 'default is preferred over enable' do
115
+ expect(node).to receive(:config)
116
+ .with(['interface Ethernet1.1',
117
+ 'default encapsulation dot1q vlan'])
118
+ expect(subject.set_encapsulation('Ethernet1.1',
119
+ enable: false,
120
+ default: true)).to be_truthy
121
+ end
122
+ end
89
123
  end
@@ -217,3 +217,71 @@ interface Port-Channel1
217
217
  mlag 1
218
218
  spanning-tree portfast
219
219
  !
220
+ interface Vlan1
221
+ no description
222
+ no shutdown
223
+ default load-interval
224
+ mtu 1500
225
+ logging event link-status use-global
226
+ autostate
227
+ snmp trap link-status
228
+ no ip proxy-arp
229
+ no ip local-proxy-arp
230
+ no ip address
231
+ no ip verify unicast
232
+ default arp timeout 14400
233
+ default ipv6 nd cache expire 14400
234
+ bfd interval 300 min_rx 300 multiplier 3
235
+ no bfd echo
236
+ default ip dhcp smart-relay
237
+ no ip helper-address
238
+ no ipv6 dhcp relay destination
239
+ ip dhcp relay information option circuit-id Vlan1
240
+ no ip igmp
241
+ ip igmp version 3
242
+ ip igmp last-member-query-count 2
243
+ ip igmp last-member-query-interval 10
244
+ ip igmp query-max-response-time 100
245
+ ip igmp query-interval 125
246
+ ip igmp startup-query-count 2
247
+ ip igmp startup-query-interval 310
248
+ ip igmp router-alert optional connected
249
+ no ip igmp host-proxy
250
+ no ipv6 enable
251
+ no ipv6 address
252
+ no ipv6 verify unicast
253
+ no ipv6 nd ra suppress
254
+ ipv6 nd ra interval msec 200000
255
+ ipv6 nd ra lifetime 1800
256
+ no ipv6 nd ra mtu suppress
257
+ no ipv6 nd managed-config-flag
258
+ no ipv6 nd other-config-flag
259
+ ipv6 nd reachable-time 0
260
+ ipv6 nd router-preference medium
261
+ ipv6 nd ra dns-servers lifetime 300
262
+ ipv6 nd ra dns-suffixes lifetime 300
263
+ ipv6 nd ra hop-limit 64
264
+ no ip multicast static
265
+ ip mfib fastdrop
266
+ default ntp serve
267
+ default ip ospf bfd
268
+ ip ospf cost 10
269
+ ip ospf dead-interval 40
270
+ ip ospf hello-interval 10
271
+ ip ospf priority 1
272
+ ip ospf retransmit-interval 5
273
+ no ip ospf shutdown
274
+ ip ospf transmit-delay 1
275
+ no ip ospf authentication
276
+ no ip ospf mtu-ignore
277
+ no ip pim sparse-mode
278
+ no ip pim bidirectional
279
+ no ip pim border-router
280
+ ip pim query-interval 30
281
+ ip pim query-count 3.5
282
+ ip pim join-prune-interval 60
283
+ ip pim dr-priority 1
284
+ no ip pim neighbor-filter
285
+ default ip pim bfd-instance
286
+ no ip pim bsr-border
287
+ !
@@ -31,8 +31,8 @@ describe Rbeapi::Api::PortchannelInterface do
31
31
  let(:resource) { subject.get('Port-Channel1') }
32
32
 
33
33
  let(:keys) do
34
- [:type, :shutdown, :load_interval, :description, :name, :members,
35
- :lacp_mode, :minimum_links, :lacp_timeout, :lacp_fallback]
34
+ [:type, :shutdown, :load_interval, :description, :encapsulation, :name,
35
+ :members, :lacp_mode, :minimum_links, :lacp_timeout, :lacp_fallback]
36
36
  end
37
37
 
38
38
  it 'returns an ethernet resource as a hash' do
@@ -111,6 +111,40 @@ describe Rbeapi::Api::PortchannelInterface do
111
111
  end
112
112
  end
113
113
 
114
+ describe '#set_encapsulation' do
115
+ it 'sets the interface encapsulation' do
116
+ expect(node).to receive(:config)
117
+ .with(['interface Port-Channel1.1', 'encapsulation dot1q vlan 10'])
118
+
119
+ expect(subject.set_encapsulation('Port-Channel1.1', value: '10'))
120
+ .to be_truthy
121
+ end
122
+
123
+ it 'negates the interface encapsulation' do
124
+ expect(node).to receive(:config)
125
+ .with(['interface Port-Channel1.1', 'no encapsulation dot1q vlan'])
126
+
127
+ expect(subject.set_encapsulation('Port-Channel1.1',
128
+ enable: false)).to be_truthy
129
+ end
130
+
131
+ it 'defaults the interface encapsulation' do
132
+ expect(node).to receive(:config)
133
+ .with(['interface Port-Channel1.1', 'default encapsulation dot1q vlan'])
134
+
135
+ expect(subject.set_encapsulation('Port-Channel1.1', default: true))
136
+ .to be_truthy
137
+ end
138
+
139
+ it 'default is preferred over enable' do
140
+ expect(node).to receive(:config)
141
+ .with(['interface Port-Channel1.1', 'default encapsulation dot1q vlan'])
142
+
143
+ opts = { enable: false, default: true }
144
+ expect(subject.set_encapsulation('Port-Channel1.1', opts)).to be_truthy
145
+ end
146
+ end
147
+
114
148
  describe '#set_shutdown' do
115
149
  it 'enables the interface' do
116
150
  expect(node).to receive(:config)
@@ -144,8 +178,11 @@ describe Rbeapi::Api::PortchannelInterface do
144
178
 
145
179
  describe '#set_members' do
146
180
  it 'raises an ArgumentError if members is not an array' do
147
- expect { subject.set_members('Port-Channel1', 'Ethernet3') }.to \
148
- raise_error(ArgumentError)
181
+ expect do
182
+ subject.set_members('Port-Channel1',
183
+ 'Ethernet3')
184
+ end
185
+ .to raise_error(ArgumentError)
149
186
  end
150
187
  end
151
188
  end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rbeapi/api/interfaces'
4
+
5
+ include FixtureHelpers
6
+
7
+ describe Rbeapi::Api::VlanInterface do
8
+ subject { described_class.new(node) }
9
+
10
+ let(:node) { double('node') }
11
+
12
+ def interfaces
13
+ interfaces = Fixtures[:interfaces]
14
+ return interfaces if interfaces
15
+ fixture('interfaces', format: :text, dir: File.dirname(__FILE__))
16
+ end
17
+
18
+ before :each do
19
+ allow(subject.node).to receive(:running_config).and_return(interfaces)
20
+ end
21
+
22
+ describe '#get' do
23
+ let(:resource) { subject.get('Vlan1') }
24
+
25
+ let(:keys) do
26
+ [:type, :shutdown, :load_interval, :description, :name, :autostate,
27
+ :encapsulation]
28
+ end
29
+
30
+ it 'returns the resource as a hash' do
31
+ expect(resource).to be_a_kind_of(Hash)
32
+ end
33
+
34
+ it 'returns an interface type of vlan' do
35
+ expect(resource[:type]).to eq('vlan')
36
+ end
37
+
38
+ it 'has all keys' do
39
+ expect(resource.keys).to match_array(keys)
40
+ end
41
+ end
42
+
43
+ describe '#create' do
44
+ it 'creates the interface in the config' do
45
+ expect(node).to receive(:config).with('interface Vlan1')
46
+ expect(subject.create('Vlan1')).to be_truthy
47
+ end
48
+ end
49
+
50
+ describe '#delete' do
51
+ it 'deletes the interface in the config' do
52
+ expect(node).to receive(:config).with('no interface Vlan1')
53
+ expect(subject.delete('Vlan1')).to be_truthy
54
+ end
55
+ end
56
+
57
+ describe '#default' do
58
+ it 'defaults the interface config' do
59
+ expect(node).to receive(:config).with('default interface Vlan1')
60
+ expect(subject.default('Vlan1')).to be_truthy
61
+ end
62
+ end
63
+
64
+ describe '#set_autostate' do
65
+ it 'sets the autostate' do
66
+ commands = ['interface Vlan1', 'autostate']
67
+ opts = { value: :true }
68
+ expect(node).to receive(:config).with(commands)
69
+ expect(subject.set_autostate('Vlan1', opts)).to be_truthy
70
+ end
71
+ end
72
+ end
@@ -23,8 +23,8 @@ describe Rbeapi::Api::VxlanInterface do
23
23
  let(:resource) { subject.get('Vxlan1') }
24
24
 
25
25
  let(:keys) do
26
- [:type, :shutdown, :load_interval, :description, :name, :source_interface,
27
- :multicast_group, :udp_port, :flood_list, :vlans]
26
+ [:type, :shutdown, :load_interval, :description, :encapsulation, :name,
27
+ :source_interface, :multicast_group, :udp_port, :flood_list, :vlans]
28
28
  end
29
29
 
30
30
  it 'returns the resource as a hash' do
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rbeapi/api/managementdefaults'
4
+
5
+ include FixtureHelpers
6
+
7
+ describe Rbeapi::Api::Managementdefaults do
8
+ subject { described_class.new(node) }
9
+
10
+ let(:node) { double('node') }
11
+
12
+ def managementdefaults
13
+ managementdefaults = Fixtures[:managementdefaults]
14
+ return managementdefaults if managementdefaults
15
+ fixture('managementdefaults', format: :text, dir: File.dirname(__FILE__))
16
+ end
17
+
18
+ before :each do
19
+ allow(subject.node).to receive(:running_config)
20
+ .and_return(managementdefaults)
21
+ end
22
+
23
+ describe '#get' do
24
+ let(:keys) { [:secret_hash] }
25
+
26
+ it 'returns the management defaults resource hash with all keys' do
27
+ expect(subject.get.keys).to match_array(keys)
28
+ end
29
+ end
30
+
31
+ describe '#set_secret_hash' do
32
+ it 'sets the secret_hash to sha512' do
33
+ expect(node).to receive(:config).with(['management defaults',
34
+ 'secret hash sha512'])
35
+ expect(subject.set_secret_hash(value: 'sha512')).to be_truthy
36
+ end
37
+
38
+ it 'sets the secret_hash to md5' do
39
+ expect(node).to receive(:config).with(['management defaults',
40
+ 'secret hash md5'])
41
+ expect(subject.set_secret_hash(value: 'md5')).to be_truthy
42
+ end
43
+
44
+ it 'defaults the secret_hash' do
45
+ expect(node).to receive(:config).with(['management defaults',
46
+ 'secret hash '])
47
+ expect(subject.set_secret_hash(default: true)).to be_truthy
48
+ end
49
+ end
50
+ end
@@ -51,43 +51,49 @@ describe Rbeapi::Api::Prefixlists do
51
51
  end
52
52
 
53
53
  describe '#get' do
54
- let(:resource) { subject.get('test1') }
55
-
56
- let(:prefixlist) do
57
- [{
58
- 'seq' => '10',
59
- 'action' => 'permit',
60
- 'prefix' => '1.2.3.0/24'
61
- },
62
- {
63
- 'seq' => '20',
64
- 'action' => 'permit',
65
- 'prefix' => '2.3.4.0/24 le 30'
66
- },
67
- {
68
- 'seq' => '30',
69
- 'action' => 'permit',
70
- 'prefix' => '3.4.5.0/24 ge 26 le 30'
71
- }]
72
- end
73
-
74
- let(:keys) { ['seq', 'action', 'prefix'] }
75
-
76
- it 'returns the prefix list for an existing name' do
77
- expect(resource).to eq(prefixlist)
78
- end
79
-
80
- it 'returns an array of prefixes' do
81
- expect(resource).to be_a_kind_of(Array)
82
- end
83
-
84
- it 'has three prefixes' do
85
- expect(resource.size).to eq(3)
86
- end
87
-
88
- it 'has all keys' do
89
- resource.each do |prefix|
90
- expect(prefix.keys).to match_array(keys)
54
+ let(:keys) { %w(seq action prefix) }
55
+
56
+ [
57
+ { title: 'single-line',
58
+ prefix_list: 'test5',
59
+ rules: [{ 'seq' => '10',
60
+ 'action' => 'permit',
61
+ 'prefix' => '10.50.1.0/24' },
62
+ { 'seq' => '20',
63
+ 'action' => 'permit',
64
+ 'prefix' => '10.50.2.0/24' }] },
65
+ { title: 'multi-line',
66
+ prefix_list: 'test1',
67
+ rules: [{ 'seq' => '10',
68
+ 'action' => 'permit',
69
+ 'prefix' => '10.10.1.0/24' },
70
+ { 'seq' => '20',
71
+ 'action' => 'permit',
72
+ 'prefix' => '10.20.1.0/24 le 30' },
73
+ { 'seq' => '30',
74
+ 'action' => 'permit',
75
+ 'prefix' => '10.30.1.0/24 ge 26 le 30' }] }
76
+ ].each do |context|
77
+ context "when prefix list is #{context[:title]}" do
78
+ let(:resource) { subject.get(context[:prefix_list]) }
79
+
80
+ it 'returns the correct rules' do
81
+ expect(resource).to eq(context[:rules])
82
+ end
83
+
84
+ it 'returns an array of rules' do
85
+ expect(resource).to be_a_kind_of(Array)
86
+ end
87
+
88
+ it "has #{context[:rules].size} rules" do
89
+ expect(resource.size).to eq(context[:rules].size)
90
+ end
91
+
92
+ it 'has all keys' do
93
+ resource.each do |rule|
94
+ expect(rule.keys).to match_array(keys)
95
+ end
96
+ end
91
97
  end
92
98
  end
93
99
 
@@ -101,37 +107,40 @@ describe Rbeapi::Api::Prefixlists do
101
107
  let(:resource) { subject.getall }
102
108
 
103
109
  let(:plists) do
104
- {
105
- "test1" => [
106
- {
107
- "seq" => "10",
108
- "action" => "permit",
109
- "prefix" => "1.2.3.0/24"
110
- },
111
- {
112
- "seq" => "20",
113
- "action" => "permit",
114
- "prefix" => "2.3.4.0/24 le 30"
115
- },
116
- {
117
- "seq" => "30",
118
- "action" => "permit",
119
- "prefix" => "3.4.5.0/24 ge 26 le 30"
120
- }
110
+ {
111
+ 'test1' => [
112
+ { 'seq' => '10',
113
+ 'action' => 'permit',
114
+ 'prefix' => '10.10.1.0/24' },
115
+ { 'seq' => '20',
116
+ 'action' => 'permit',
117
+ 'prefix' => '10.20.1.0/24 le 30' },
118
+ { 'seq' => '30',
119
+ 'action' => 'permit',
120
+ 'prefix' => '10.30.1.0/24 ge 26 le 30' }
121
121
  ],
122
- "test2" => [
123
- {
124
- "seq" => "10",
125
- "action" => "permit",
126
- "prefix" => "10.11.0.0/16"
127
- },
128
- {
129
- "seq" => "20",
130
- "action" => "permit",
131
- "prefix" => "10.12.0.0/16 le 24"
132
- }
122
+ 'test2' => [
123
+ { 'seq' => '10',
124
+ 'action' => 'permit',
125
+ 'prefix' => '10.11.0.0/16' },
126
+ { 'seq' => '20',
127
+ 'action' => 'permit',
128
+ 'prefix' => '10.12.0.0/16 le 24' }
133
129
  ],
134
- "test3" => []
130
+ 'test3' => [],
131
+ 'test4' => [
132
+ { 'seq' => '10',
133
+ 'action' => 'permit',
134
+ 'prefix' => '10.14.0.0/16 le 20' }
135
+ ],
136
+ 'test5' => [
137
+ { 'seq' => '10',
138
+ 'action' => 'permit',
139
+ 'prefix' => '10.50.1.0/24' },
140
+ { 'seq' => '20',
141
+ 'action' => 'permit',
142
+ 'prefix' => '10.50.2.0/24' }
143
+ ]
135
144
  }
136
145
  end
137
146
 
@@ -143,8 +152,8 @@ describe Rbeapi::Api::Prefixlists do
143
152
  expect(resource).to be_a_kind_of(Hash)
144
153
  end
145
154
 
146
- it 'has three prefix lists' do
147
- expect(resource.size).to eq(3)
155
+ it 'has five prefix lists' do
156
+ expect(resource.size).to eq(5)
148
157
  end
149
158
  end
150
159
 
@@ -162,28 +171,38 @@ describe Rbeapi::Api::Prefixlists do
162
171
 
163
172
  describe '#add_rule' do
164
173
  it 'adds rule to existing prefix list' do
165
- expect(node).to receive(:config).with('ip prefix-list test1 seq 25 permit 9.8.7.0/24')
166
- expect(subject.add_rule('test1', 'permit','9.8.7.0/24', '25')).to be_truthy
174
+ expect(node).to receive(:config)
175
+ .with('ip prefix-list test1 seq 25 permit 10.25.1.0/24')
176
+ expect(subject.add_rule('test1', 'permit', '10.25.1.0/24', '25'))
177
+ .to be_truthy
167
178
  end
168
179
 
169
180
  it 'adds rule to existing prefix list w/o seq' do
170
- expect(node).to receive(:config).with('ip prefix-list test1 permit 8.7.6.0/24')
171
- expect(subject.add_rule('test1', 'permit', '8.7.6.0/24')).to be_truthy
181
+ expect(node).to receive(:config)
182
+ .with('ip prefix-list test1 permit 10.25.2.0/24')
183
+ expect(subject.add_rule('test1', 'permit', '10.25.2.0/24'))
184
+ .to be_truthy
172
185
  end
173
186
 
174
187
  it 'adds rule to non-existing prefix list' do
175
- expect(node).to receive(:config).with('ip prefix-list plist2 seq 10 permit 6.5.4.128/25')
176
- expect(subject.add_rule('plist2', 'permit', '6.5.4.128/25', '10')).to be_truthy
188
+ expect(node).to receive(:config)
189
+ .with('ip prefix-list plist2 seq 10 permit 10.25.3.128/25')
190
+ expect(subject.add_rule('plist2', 'permit', '10.25.3.128/25', '10'))
191
+ .to be_truthy
177
192
  end
178
193
 
179
194
  it 'adds rule to non-existing prefix list w/o seq' do
180
- expect(node).to receive(:config).with('ip prefix-list plist2 deny 5.4.3.0/25')
181
- expect(subject.add_rule('plist2', 'deny', '5.4.3.0/25')).to be_truthy
195
+ expect(node).to receive(:config)
196
+ .with('ip prefix-list plist2 deny 10.25.10.0/25')
197
+ expect(subject.add_rule('plist2', 'deny', '10.25.10.0/25'))
198
+ .to be_truthy
182
199
  end
183
200
 
184
201
  it 'overwrites existing rule' do
185
- expect(node).to receive(:config).with('ip prefix-list test1 seq 20 permit 2.3.5.0/24 le 28')
186
- expect(subject.add_rule('test1', 'permit', '2.3.5.0/24 le 28', '20')).to be_truthy
202
+ expect(node).to receive(:config)
203
+ .with('ip prefix-list test1 seq 20 permit 10.25.20.0/24 le 28')
204
+ expect(subject.add_rule('test1', 'permit', '10.25.20.0/24 le 28', '20'))
205
+ .to be_truthy
187
206
  end
188
207
  end
189
208
 
@@ -198,5 +217,4 @@ describe Rbeapi::Api::Prefixlists do
198
217
  expect(subject.delete('test2', '10'))
199
218
  end
200
219
  end
201
-
202
- end
220
+ end