rbeapi 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/CHANGELOG.md +16 -0
  2. data/Gemfile +3 -1
  3. data/Guardfile +2 -2
  4. data/README.md +35 -24
  5. data/Rakefile +48 -18
  6. data/gems/inifile/inifile.spec.tmpl +50 -14
  7. data/gems/net_http_unix/net_http_unix.spec.tmpl +48 -15
  8. data/gems/netaddr/netaddr.spec.tmpl +47 -14
  9. data/lib/rbeapi/api/bgp.rb +100 -4
  10. data/lib/rbeapi/api/interfaces.rb +4 -5
  11. data/lib/rbeapi/api/radius.rb +1 -1
  12. data/lib/rbeapi/api/routemaps.rb +405 -37
  13. data/lib/rbeapi/api/system.rb +21 -0
  14. data/lib/rbeapi/api/users.rb +361 -0
  15. data/lib/rbeapi/api/varp.rb +50 -22
  16. data/lib/rbeapi/api/vrrp.rb +1072 -0
  17. data/lib/rbeapi/client.rb +12 -4
  18. data/lib/rbeapi/eapilib.rb +1 -1
  19. data/lib/rbeapi/version.rb +1 -1
  20. data/rbeapi.spec.tmpl +57 -25
  21. data/spec/system/rbeapi/api/dns_spec.rb +2 -2
  22. data/spec/system/rbeapi/api/routemaps_spec.rb +344 -0
  23. data/spec/system/rbeapi/api/switchports_spec.rb +1 -1
  24. data/spec/system/rbeapi/api/system_spec.rb +44 -4
  25. data/spec/system/{api_varp_interfaces_spec.rb → rbeapi/api/varp_interfaces_spec.rb} +25 -16
  26. data/spec/system/rbeapi/api/varp_spec.rb +76 -0
  27. data/spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb +2 -0
  28. data/spec/unit/rbeapi/api/bgp/bgp_spec.rb +54 -1
  29. data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +1 -1
  30. data/spec/unit/rbeapi/api/routemaps/default_spec.rb +370 -0
  31. data/spec/unit/rbeapi/api/routemaps/fixture_routemaps.text +27 -0
  32. data/spec/unit/rbeapi/api/system/default_spec.rb +102 -0
  33. data/spec/unit/rbeapi/api/system/fixture_system.text +2 -0
  34. data/spec/unit/rbeapi/api/users/default_spec.rb +280 -0
  35. data/spec/unit/rbeapi/api/users/fixture_users.text +4 -0
  36. data/spec/unit/rbeapi/api/vrrp/default_spec.rb +582 -0
  37. data/spec/unit/rbeapi/api/vrrp/fixture_vrrp.text +186 -0
  38. metadata +28 -8
  39. data/spec/system/api_varp_spec.rb +0 -41
data/lib/rbeapi/client.rb CHANGED
@@ -268,6 +268,7 @@ module Rbeapi
268
268
  # for handling both enable mode and config mode commands
269
269
  class Node
270
270
  attr_reader :connection
271
+ attr_accessor :dry_run
271
272
 
272
273
  ##
273
274
  # Save the connection and set autorefresh to true.
@@ -277,6 +278,7 @@ module Rbeapi
277
278
  def initialize(connection)
278
279
  @connection = connection
279
280
  @autorefresh = true
281
+ @dry_run = false
280
282
  end
281
283
 
282
284
  ##
@@ -331,12 +333,18 @@ module Rbeapi
331
333
  commands = [*commands] unless commands.respond_to?('each')
332
334
 
333
335
  commands.insert(0, 'configure')
334
- response = run_commands(commands, opts)
335
336
 
336
- refresh if @autorefresh
337
+ if @dry_run
338
+ puts '[rbeapi dry-run commands]'
339
+ puts commands
340
+ else
341
+ response = run_commands(commands, opts)
337
342
 
338
- response.shift
339
- response
343
+ refresh if @autorefresh
344
+
345
+ response.shift
346
+ response
347
+ end
340
348
  end
341
349
 
342
350
  ##
@@ -301,7 +301,7 @@ module Rbeapi
301
301
  # adds the list of commands to the exception message
302
302
  def execute(commands, opts = {})
303
303
  @error = nil
304
- request = request(commands, opts)
304
+ request = request(commands, opts)
305
305
  response = send(request, opts)
306
306
  return response['result']
307
307
  rescue ConnectionError, CommandError => exc
@@ -33,5 +33,5 @@
33
33
  # #
34
34
  # Rbeapi toplevel namespace
35
35
  module Rbeapi
36
- VERSION = '0.3.0'
36
+ VERSION = '0.4.0'
37
37
  end
data/rbeapi.spec.tmpl CHANGED
@@ -11,31 +11,10 @@ License: New BSD
11
11
  URL: https://github.com/arista-eosplus/rbeapi
12
12
  Source0: %{gem_name}-%{version}.gem
13
13
 
14
- %if 0%{?enterprise:1} == 1
15
- # Use these settings for Puppet Enterprise
16
- %global gem /opt/puppet/bin/gem
17
- Requires: pe-rubygems
18
- Requires: pe-ruby
19
- Requires: pe-rubygem(net-http-unix)
20
- Requires: pe-rubygem(inifile)
21
- Requires: pe-rubygem(netaddr)
22
- Provides: pe-rubygem(%{gem_name}) = %{version}
23
- Provides: pe-rubygem-%{gem_name} = %{version}
24
- %else
25
- # Use these settings for all other installs
26
- %global gem gem
27
- Requires: ruby(abi) = %{rubyabi}
28
- Requires: ruby(net-http-unix)
29
- Requires: ruby(inifile)
30
- Requires: ruby(netaddr)
31
- Provides: ruby(%{gem_name}) = %{version}-%{release}
32
- %endif
33
-
34
-
35
14
  BuildArch: noarch
36
15
 
37
16
  %description
38
- The Ruby Cliet for eAPI provides a native Ruby implementation for programming
17
+ The Ruby Client for eAPI provides a native Ruby implementation for programming
39
18
  Arista EOS network devices using Ruby. The Ruby client provides the ability
40
19
  to build native applications in Ruby that can communicate with EOS either
41
20
  locally via Unix domain sockets (on-box) or remotely over a HTTP/S transport
@@ -52,6 +31,31 @@ The library is freely provided to the open source community for building robust
52
31
  applications using Arista EOS eAPI. Support is provided as best effort through
53
32
  Github iusses.
54
33
 
34
+ %package puppet3
35
+ Summary: Arista eAPI Ruby Library Puppet Enterprise 3.x agents
36
+ Group: Development/Languages
37
+ # Use these settings for Puppet Enterprise
38
+ Requires: pe-rubygems
39
+ Requires: pe-ruby
40
+ Requires: pe-rubygem(net-http-unix)
41
+ Requires: pe-rubygem(inifile)
42
+ Requires: pe-rubygem(netaddr)
43
+ Provides: pe-rubygem(%{gem_name}) = %{version}
44
+ Provides: pe-rubygem-%{gem_name} = %{version}
45
+ %description puppet3
46
+ The Ruby eAPI Client for Puppet Enterprise 3.x agents
47
+
48
+ %package puppet-aio
49
+ Summary: Arista eAPI Ruby Library for Puppet All-In-One (4.x) agents
50
+ Group: Development/Languages
51
+ Requires: puppet >= 4.0.0
52
+ Requires: rubygem-net_http_unix
53
+ Requires: rubygem-inifile
54
+ Requires: rubygem-netaddr
55
+ Provides: rubygem-%{gem_name} = %{version}
56
+ %description puppet-aio
57
+ The Ruby eAPI Client for Puppet All-In-One (4.x) agents
58
+
55
59
  %prep
56
60
  %setup -q -D -T -n .
57
61
 
@@ -62,14 +66,42 @@ install %{SOURCE0} %{buildroot}/
62
66
  %files
63
67
  /%{gem_name}-%{version}.gem
64
68
 
69
+ %files puppet3
70
+ /%{gem_name}-%{version}.gem
71
+
72
+ %files puppet-aio
73
+ /%{gem_name}-%{version}.gem
74
+
65
75
  %post
66
- %{gem} install --local /%{gem_name}-%{version}.gem > /dev/null 2>&1
76
+ GEM_OPTS="--no-document --local"
77
+ gem install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
67
78
 
68
79
  %preun
69
- %{gem} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
80
+ gem uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
81
+
82
+ %post puppet3
83
+ GEM=/opt/puppet/bin/gem
84
+ GEM_OPTS="--no-document --local"
85
+ ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
86
+
87
+ %preun puppet3
88
+ GEM=/opt/puppet/bin/gem
89
+ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
90
+
91
+ %post puppet-aio
92
+ GEM=/opt/puppetlabs/puppet/bin/gem
93
+ GEM_OPTS="--no-document --local"
94
+ ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
95
+
96
+ %preun puppet-aio
97
+ GEM=/opt/puppetlabs/puppet/bin/gem
98
+ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
70
99
 
71
100
  %changelog
72
- * Tue May 21 2015 Jere Julian - 0.1.0-2
101
+ * Fri Oct 30 2015 Jere Julian - 0.4.0-1
102
+ - Detect the location of the puppet-agent's gem install
103
+
104
+ * Thu May 21 2015 Jere Julian - 0.1.0-2
73
105
  - Ubuntu requires we manually create the buildroot
74
106
 
75
107
  * Tue Mar 17 2015 Jere Julian - 0.1.0-1
@@ -44,7 +44,7 @@ describe Rbeapi::Api::Dns do
44
44
  end
45
45
 
46
46
  describe '#set_name_servers' do
47
- let(:servers) { %w(1.2.3.4 5.6.7.8 9.10.11.12) }
47
+ let(:servers) { %w(1.2.3.4 5.6.7.8 9.10.11.12) }
48
48
 
49
49
  before { node.config('no ip name-server') }
50
50
 
@@ -94,7 +94,7 @@ describe Rbeapi::Api::Dns do
94
94
  end
95
95
 
96
96
  describe '#set_domain_list' do
97
- let(:servers) { %w(foo bar baz) }
97
+ let(:servers) { %w(foo bar baz) }
98
98
 
99
99
  before do
100
100
  node.config(['no ip domain-list foo',
@@ -0,0 +1,344 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rbeapi/client'
4
+ require 'rbeapi/api/routemaps'
5
+
6
+ describe Rbeapi::Api::Routemaps do
7
+ subject { described_class.new(node) }
8
+
9
+ let(:node) do
10
+ Rbeapi::Client.config.read(fixture_file('dut.conf'))
11
+ Rbeapi::Client.connect_to('dut')
12
+ end
13
+
14
+ describe '#get' do
15
+ let(:resource) { subject.get }
16
+
17
+ before do
18
+ node.config(['no route-map test', 'no route-map test1',
19
+ 'no route-map test2', 'no route-map test3',
20
+ 'route-map test permit 10',
21
+ 'route-map test permit 20', 'description descript',
22
+ 'match ip address prefix-list MYLOOPBACK',
23
+ 'match interface Loopback0',
24
+ 'set community internet 5555:5555', 'continue 99'])
25
+ end
26
+
27
+ it 'returns a routemap resource instance' do
28
+ expect(subject.get('test')).to be_a_kind_of(Hash)
29
+ end
30
+
31
+ it 'has a key for description' do
32
+ expect(subject.get('test').assoc('permit')[1].assoc(20)[1])
33
+ .to include(:description)
34
+ end
35
+
36
+ it 'has a key for continue' do
37
+ expect(subject.get('test').assoc('permit')[1].assoc(20)[1])
38
+ .to include(:continue)
39
+ end
40
+
41
+ it 'has a key for match' do
42
+ expect(subject.get('test').assoc('permit')[1].assoc(20)[1])
43
+ .to include(:match)
44
+ end
45
+
46
+ it 'has a key for set' do
47
+ expect(subject.get('test').assoc('permit')[1].assoc(20)[1])
48
+ .to include(:set)
49
+ end
50
+ end
51
+
52
+ describe '#getall' do
53
+ let(:resource) { subject.getall }
54
+
55
+ before do
56
+ node.config(['no route-map test', 'no route-map test1',
57
+ 'route-map test1 permit 10', 'continue 99',
58
+ 'route-map test permit 10',
59
+ 'route-map test permit 20', 'description descript',
60
+ 'match ip address prefix-list MYLOOPBACK',
61
+ 'match interface Loopback0',
62
+ 'set community internet 5555:5555', 'continue 99'])
63
+ end
64
+
65
+ let(:test1_entries) do
66
+ {
67
+ 'test1' => {
68
+ 'permit' => {
69
+ 10 => {
70
+ continue: 99
71
+ }
72
+ }
73
+ },
74
+ 'test' => {
75
+ 'permit' => {
76
+ 10 => {},
77
+ 20 => {
78
+ continue: 99,
79
+ description: 'descript',
80
+ match: ['ip address prefix-list MYLOOPBACK',
81
+ 'interface Loopback0'],
82
+ set: ['community internet 5555:5555']
83
+ }
84
+ }
85
+ }
86
+ }
87
+ end
88
+
89
+ it 'returns a routemap resource instance' do
90
+ expect(subject.getall).to be_a_kind_of(Hash)
91
+ end
92
+
93
+ it 'has a key for description' do
94
+ expect(subject.getall.count).to eq(2)
95
+ end
96
+
97
+ it 'returns the routemap collection' do
98
+ expect(subject.getall).to include(test1_entries)
99
+ end
100
+ end
101
+
102
+ describe '#create' do
103
+ let(:test_entry) do
104
+ {
105
+ 'permit' => {
106
+ 20 => {
107
+ continue: 99,
108
+ description: 'descript',
109
+ match: ['ip address prefix-list MYLOOPBACK',
110
+ 'interface Loopback0'],
111
+ set: ['community internet 5555:5555']
112
+ }
113
+ }
114
+ }
115
+ end
116
+
117
+ before do
118
+ node.config(['no route-map test', 'no route-map test1'])
119
+ end
120
+
121
+ it 'creates the routemap with all options' do
122
+ expect(subject.get('test')).to eq(nil)
123
+ expect(subject
124
+ .create('test', 'permit', 20,
125
+ continue: 99, description: 'descript',
126
+ match: ['ip address prefix-list MYLOOPBACK',
127
+ 'interface Loopback0'],
128
+ set: ['community internet 5555:5555'])
129
+ ).to be_truthy
130
+ expect(subject.get('test')).to eq(test_entry)
131
+ end
132
+
133
+ it 'creates the routemap with no options' do
134
+ expect(subject.get('test1')).to eq(nil)
135
+ expect(subject.create('test1', 'permit', 10)).to be_truthy
136
+ expect(subject.get('test1')).to be_truthy
137
+ expect(subject.get('test1').assoc('permit')[0]).to eq('permit')
138
+ expect(
139
+ subject.get('test1').assoc('permit')[1].assoc(10)[0]).to eq(10)
140
+ expect(
141
+ subject.get('test1').assoc('permit')[1].assoc(10)[1][:continue]
142
+ ).to eq(nil)
143
+ expect(
144
+ subject.get('test1').assoc('permit')[1].assoc(10)[1][:description]
145
+ ).to eq(nil)
146
+ expect(
147
+ subject.get('test1').assoc('permit')[1].assoc(10)[1][:match]
148
+ ).to eq(nil)
149
+ expect(
150
+ subject.get('test1').assoc('permit')[1].assoc(10)[1][:set]
151
+ ).to eq(nil)
152
+ end
153
+ end
154
+
155
+ describe '#delete' do
156
+ before do
157
+ node.config(['route-map test',
158
+ 'route-map test1 permit 20',
159
+ 'route-map test1 permit 10',
160
+ 'route-map test2 permit 10',
161
+ 'route-map test2 permit 20'])
162
+ end
163
+
164
+ it 'removes the routemap' do
165
+ expect(subject.get('test')).to eq('permit' => { 10 => {} })
166
+ expect(subject.delete('test', 'permit', 10)).to be_truthy
167
+ expect(subject.get('test')).to eq(nil)
168
+ end
169
+
170
+ it 'removes multiple routemaps with same name' do
171
+ expect(subject.get('test1'))
172
+ .to eq('permit' => { 10 => {}, 20 => {} })
173
+ expect(subject.delete('test1', 'permit', 20)).to be_truthy
174
+ expect(subject.get('test1')).to eq('permit' => { 10 => {} })
175
+ end
176
+ end
177
+
178
+ describe '#delete' do
179
+ before do
180
+ node.config(['route-map test',
181
+ 'route-map test1 permit 20',
182
+ 'route-map test1 permit 10',
183
+ 'route-map test2 permit 10',
184
+ 'route-map test2 permit 20'])
185
+ end
186
+
187
+ it 'removes the routemap' do
188
+ expect(subject.get('test')).to eq('permit' => { 10 => {} })
189
+ expect(subject.delete('test', 'permit', 10)).to be_truthy
190
+ expect(subject.get('test')).to eq(nil)
191
+ end
192
+
193
+ it 'removes multiple routemaps with same name' do
194
+ expect(subject.get('test1'))
195
+ .to eq('permit' => { 10 => {}, 20 => {} })
196
+ expect(subject.delete('test1', 'permit', 20)).to be_truthy
197
+ expect(subject.get('test1')).to eq('permit' => { 10 => {} })
198
+ end
199
+ end
200
+
201
+ describe '#set_match_statements' do
202
+ before do
203
+ node.config(['route-map test permit 10',
204
+ 'no match ip address prefix-list MYLOOPBACK',
205
+ 'no match interface Vlan100',
206
+ 'no match interface Loopback1',
207
+ 'match interface Loopback1',
208
+ 'no route-map test1'])
209
+ end
210
+
211
+ it 'sets match statements on an existing routemap' do
212
+ expect(subject.get('test'))
213
+ .to eq('permit' => { 10 => { match: ['interface Loopback1'] } })
214
+ expect(
215
+ subject.set_match_statements('test', 'permit', 10,
216
+ ['ip address prefix-list MYLOOPBACK',
217
+ 'interface Loopback0'])).to be_truthy
218
+ expect(subject.get('test'))
219
+ .to eq('permit' => { 10 => {
220
+ match: ['ip address prefix-list MYLOOPBACK',
221
+ 'interface Loopback0'] } })
222
+ end
223
+
224
+ it 'adds more match statements' do
225
+ expect(subject.get('test'))
226
+ .to eq('permit' => { 10 => { match: ['interface Loopback1'] } })
227
+ expect(subject.set_match_statements('test', 'permit', 10,
228
+ ['interface Vlan100'])).to be_truthy
229
+ expect(subject.get('test'))
230
+ .to eq('permit' => { 10 => { match: ['interface Vlan100'] } })
231
+ expect(subject
232
+ .set_match_statements('test', 'permit', 10,
233
+ ['interface Vlan100',
234
+ 'ip address prefix-list MYLOOPBACK'])
235
+ ).to be_truthy
236
+ expect(subject.get('test'))
237
+ .to eq('permit' => { 10 => {
238
+ match: ['ip address prefix-list MYLOOPBACK',
239
+ 'interface Vlan100'] } })
240
+ expect(subject
241
+ .set_match_statements('test', 'permit', 10,
242
+ ['interface Vlan100'])).to be_truthy
243
+ expect(subject.get('test'))
244
+ .to eq('permit' => { 10 => { match: ['interface Vlan100'] } })
245
+ end
246
+
247
+ it 'adds match statements to a new seqno' do
248
+ expect(subject.get('test'))
249
+ .to eq('permit' => { 10 => { match: ['interface Loopback1'] } })
250
+ expect(subject.set_match_statements('test', 'permit', 20,
251
+ ['interface Vlan100'])).to be_truthy
252
+ expect(subject.get('test'))
253
+ .to eq('permit' => { 10 => { match: ['interface Loopback1'] },
254
+ 20 => { match: ['interface Vlan100'] } })
255
+ end
256
+
257
+ it 'set match statements on a new routemap' do
258
+ expect(subject.get('test1')).to eq(nil)
259
+ expect(subject.set_match_statements('test1', 'permit', 10,
260
+ ['ip address prefix-list MYLOOPBACK',
261
+ 'interface Loopback0'])).to be_truthy
262
+ expect(subject.get('test1'))
263
+ .to eq('permit' => { 10 => {
264
+ match: ['ip address prefix-list MYLOOPBACK',
265
+ 'interface Loopback0'] } })
266
+ end
267
+ end
268
+
269
+ describe '#set_set_statements' do
270
+ before do
271
+ node.config(['no route-map test', 'no route-map test1',
272
+ 'route-map test permit 10',
273
+ 'set community internet 3333:3333'])
274
+ end
275
+
276
+ it 'set set statements on an existing routemap' do
277
+ expect(subject.get('test'))
278
+ .to eq('permit' => { 10 => { set: ['community internet 3333:3333'] } })
279
+ expect(subject
280
+ .set_set_statements('test', 'permit', 10,
281
+ ['origin igp'])).to be_truthy
282
+ expect(subject.get('test'))
283
+ .to eq('permit' => { 10 => { set: ['origin igp'] } })
284
+ end
285
+
286
+ it 'set set statements on a new routemap' do
287
+ expect(subject.get('test1')).to eq(nil)
288
+ expect(subject
289
+ .set_set_statements('test1', 'permit', 10,
290
+ ['community internet 5555:5555',
291
+ 'community internet 4444:4444'])).to be_truthy
292
+ expect(subject.get('test1'))
293
+ .to eq('permit' => { 10 => {
294
+ set: ['community internet 4444:4444 5555:5555'] } })
295
+ end
296
+ end
297
+
298
+ describe '#set_continue' do
299
+ before do
300
+ node.config(['no route-map test', 'no route-map test1',
301
+ 'route-map test permit 10', 'continue 50'])
302
+ end
303
+
304
+ it 'set continue on an existing routemap' do
305
+ expect(subject.get('test'))
306
+ .to eq('permit' => { 10 => { continue: 50 } })
307
+ expect(subject.set_continue('test', 'permit', 10, 99)).to be_truthy
308
+ expect(subject.get('test'))
309
+ .to eq('permit' => { 10 => { continue: 99 } })
310
+ end
311
+
312
+ it 'set continue on a new routemap' do
313
+ expect(subject.get('test1')).to eq(nil)
314
+ expect(subject.set_continue('test1', 'permit', 10, 99)).to be_truthy
315
+ expect(subject.get('test1'))
316
+ .to eq('permit' => { 10 => { continue: 99 } })
317
+ end
318
+ end
319
+
320
+ describe '#set_description' do
321
+ before do
322
+ node.config(['no route-map test', 'no route-map test1',
323
+ 'route-map test permit 10', 'description temp'])
324
+ end
325
+
326
+ it 'set description on an existing routemap' do
327
+ expect(subject.get('test'))
328
+ .to eq('permit' => { 10 => { description: 'temp' } })
329
+ expect(subject
330
+ .set_description('test', 'permit', 10, 'descript')).to be_truthy
331
+ expect(subject.get('test'))
332
+ .to eq('permit' => { 10 => { description: 'descript' } })
333
+ end
334
+
335
+ it 'set description on a new routemap' do
336
+ expect(subject.get('test1')).to eq(nil)
337
+ expect(subject
338
+ .set_description('test1', 'permit', 10,
339
+ 'descript')).to be_truthy
340
+ expect(subject.get('test1'))
341
+ .to eq('permit' => { 10 => { description: 'descript' } })
342
+ end
343
+ end
344
+ end
@@ -112,7 +112,7 @@ describe Rbeapi::Api::Switchports do
112
112
  end
113
113
 
114
114
  describe '#set_access_vlan' do
115
- before { node.config(['default interface Ethernet1', 'vlan 100']) }
115
+ before { node.config(['default interface Ethernet1', 'vlan 100']) }
116
116
 
117
117
  it 'sets the access vlan value to 100' do
118
118
  expect(subject.get('Ethernet1')[:access_vlan]).to eq('1')
@@ -13,18 +13,18 @@ describe Rbeapi::Api::System do
13
13
 
14
14
  describe '#get' do
15
15
  let(:entity) do
16
- { hostname: 'localhost' }
16
+ { hostname: 'localhost', iprouting: true }
17
17
  end
18
18
 
19
- before { node.config('hostname localhost') }
19
+ before { node.config(['hostname localhost', 'ip routing']) }
20
20
 
21
21
  it 'returns the snmp resource' do
22
22
  expect(subject.get).to eq(entity)
23
23
  end
24
24
  end
25
25
 
26
- describe '#set_system' do
27
- before { node.config('hostname localhost') }
26
+ describe '#set_hostname' do
27
+ before { node.config(['hostname localhost']) }
28
28
 
29
29
  it 'configures the system hostname value' do
30
30
  expect(subject.get[:hostname]).to eq('localhost')
@@ -47,5 +47,45 @@ describe Rbeapi::Api::System do
47
47
  expect(subject.set_hostname(default: true)).to be_truthy
48
48
  expect(subject.get[:hostname]).to be_empty
49
49
  end
50
+
51
+ it 'configures the system hostname value' do
52
+ expect(subject.get[:iprouting]).to eq(true)
53
+ expect(subject.set_iprouting(enable: true)).to be_truthy
54
+ expect(subject.get[:iprouting]).to eq(true)
55
+ end
56
+ end
57
+
58
+ describe '#set_iprouting' do
59
+ describe 'negates ip routing' do
60
+ before { node.config(['ip routing']) }
61
+
62
+ it 'negates ip routing' do
63
+ expect(subject.get[:iprouting]).to eq(true)
64
+ expect(subject.set_iprouting(enable: false)).to be_truthy
65
+ expect(subject.get[:iprouting]).to eq(false)
66
+ end
67
+
68
+ it 'defaults ip routing' do
69
+ expect(subject.get[:iprouting]).to eq(true)
70
+ expect(subject.set_iprouting(default: true)).to be_truthy
71
+ expect(subject.get[:iprouting]).to eq(false)
72
+ end
73
+ end
74
+
75
+ describe 'enables ip routing' do
76
+ before { node.config(['no ip routing']) }
77
+
78
+ it 'negates ip routing' do
79
+ expect(subject.get[:iprouting]).to eq(false)
80
+ expect(subject.set_iprouting(enable: true)).to be_truthy
81
+ expect(subject.get[:iprouting]).to eq(true)
82
+ end
83
+
84
+ it 'defaults ip routing' do
85
+ expect(subject.get[:iprouting]).to eq(false)
86
+ expect(subject.set_iprouting(default: false)).to be_truthy
87
+ expect(subject.get[:iprouting]).to eq(true)
88
+ end
89
+ end
50
90
  end
51
91
  end