rbeapi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.gitignore +5 -0
  2. data/.rubocop.yml +21 -0
  3. data/CHANGELOG.md +24 -0
  4. data/Gemfile +3 -1
  5. data/Guardfile +3 -3
  6. data/README.md +92 -17
  7. data/Rakefile +99 -4
  8. data/gems/README.rst +4 -0
  9. data/gems/inifile/.gitignore +2 -0
  10. data/gems/inifile/README.rst +5 -0
  11. data/gems/inifile/inifile.spec.tmpl +84 -0
  12. data/gems/net_http_unix/.gitignore +2 -0
  13. data/gems/net_http_unix/README.rst +5 -0
  14. data/gems/net_http_unix/net_http_unix.spec.tmpl +54 -0
  15. data/gems/netaddr/README.rst +5 -0
  16. data/gems/netaddr/netaddr.spec.tmpl +50 -0
  17. data/lib/rbeapi/api/aaa.rb +14 -17
  18. data/lib/rbeapi/api/acl.rb +276 -0
  19. data/lib/rbeapi/api/dns.rb +7 -4
  20. data/lib/rbeapi/api/interfaces.rb +239 -239
  21. data/lib/rbeapi/api/ipinterfaces.rb +5 -3
  22. data/lib/rbeapi/api/logging.rb +8 -5
  23. data/lib/rbeapi/api/mlag.rb +45 -127
  24. data/lib/rbeapi/api/ntp.rb +1 -4
  25. data/lib/rbeapi/api/ospf.rb +16 -13
  26. data/lib/rbeapi/api/prefixlists.rb +4 -4
  27. data/lib/rbeapi/api/radius.rb +34 -25
  28. data/lib/rbeapi/api/routemaps.rb +16 -10
  29. data/lib/rbeapi/api/snmp.rb +26 -13
  30. data/lib/rbeapi/api/staticroutes.rb +6 -5
  31. data/lib/rbeapi/api/stp.rb +77 -18
  32. data/lib/rbeapi/api/switchports.rb +20 -12
  33. data/lib/rbeapi/api/system.rb +6 -6
  34. data/lib/rbeapi/api/tacacs.rb +9 -6
  35. data/lib/rbeapi/api/varp.rb +15 -10
  36. data/lib/rbeapi/api/vlans.rb +5 -6
  37. data/lib/rbeapi/api.rb +56 -16
  38. data/lib/rbeapi/client.rb +85 -50
  39. data/lib/rbeapi/eapilib.rb +95 -56
  40. data/lib/rbeapi/netdev/snmp.rb +7 -16
  41. data/lib/rbeapi/utils.rb +3 -5
  42. data/lib/rbeapi/version.rb +1 -1
  43. data/rbeapi.gemspec +4 -2
  44. data/rbeapi.spec.tmpl +72 -0
  45. data/spec/support/fixtures.rb +6 -4
  46. data/spec/support/shared_examples_for_api_modules.rb +3 -18
  47. data/spec/system/api_acl_spec.rb +128 -0
  48. data/spec/system/api_ospf_interfaces_spec.rb +17 -14
  49. data/spec/system/api_ospf_spec.rb +8 -8
  50. data/spec/system/api_varp_interfaces_spec.rb +22 -13
  51. data/spec/system/api_varp_spec.rb +1 -4
  52. data/spec/system/rbeapi/api/interfaces_base_spec.rb +3 -4
  53. data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +13 -9
  54. data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +43 -26
  55. data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +7 -6
  56. data/spec/system/rbeapi/api/ipinterfaces_spec.rb +34 -21
  57. data/spec/system/rbeapi/api/mlag_interfaces_spec.rb +15 -38
  58. data/spec/system/rbeapi/api/mlag_spec.rb +26 -30
  59. data/spec/system/rbeapi/api/snmp_spec.rb +0 -3
  60. data/spec/system/rbeapi/api/stp_instances_spec.rb +20 -12
  61. data/spec/system/rbeapi/api/stp_interfaces_spec.rb +1 -3
  62. data/spec/system/rbeapi/api/switchports_spec.rb +14 -12
  63. data/spec/system/rbeapi/api/system_spec.rb +0 -3
  64. data/spec/system/rbeapi/api/vlans_spec.rb +19 -9
  65. data/spec/unit/rbeapi/api/acl/default_spec.rb +158 -0
  66. data/spec/unit/rbeapi/api/acl/fixture_acl_standard.text +22 -0
  67. data/spec/unit/rbeapi/api/interfaces/base_spec.rb +123 -0
  68. data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +89 -0
  69. data/spec/unit/rbeapi/api/interfaces/fixture_interfaces.text +219 -0
  70. data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +149 -0
  71. data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +243 -0
  72. data/spec/unit/rbeapi/api/mlag/default_spec.rb +218 -0
  73. data/spec/unit/rbeapi/api/mlag/fixture_mlag.text +238 -0
  74. data/spec/unit/rbeapi/api/vlans/default_spec.rb +135 -0
  75. data/spec/unit/rbeapi/api/vlans/fixture_vlans.text +5 -0
  76. metadata +79 -4
  77. data/lib/rbeapi/api/radius.rb.old +0 -399
@@ -0,0 +1,218 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rbeapi/api/mlag'
4
+
5
+ include FixtureHelpers
6
+
7
+ describe Rbeapi::Api::Mlag do
8
+ subject { described_class.new(node) }
9
+
10
+ let(:node) { double('node') }
11
+
12
+ def mlag
13
+ mlag = Fixtures[:mlag]
14
+ return mlag if mlag
15
+ fixture('mlag', format: :text, dir: File.dirname(__FILE__))
16
+ end
17
+
18
+ before :each do
19
+ allow(subject.node).to receive(:running_config).and_return(mlag)
20
+ end
21
+
22
+ describe '#get' do
23
+ let(:keys) { [:global, :interfaces] }
24
+
25
+ let(:global_keys) do
26
+ [:domain_id, :local_interface, :peer_address, :peer_link, :shutdown]
27
+ end
28
+
29
+ let(:interface_keys) { [:mlag_id] }
30
+
31
+ it 'returns the mlag resource hash with all keys' do
32
+ expect(subject.get.keys).to match_array(keys)
33
+ end
34
+
35
+ it 'contains the global hash with all keys' do
36
+ expect(subject.get[:global].keys).to match_array(global_keys)
37
+ end
38
+
39
+ it 'contains an entry for Port-Channel100' do
40
+ expect(subject.get[:interfaces].keys).to include('Port-Channel100')
41
+ end
42
+
43
+ it 'does not contain an entry for Port-Channel10' do
44
+ expect(subject.get[:interfaces].keys).not_to include('Port-Channel10')
45
+ end
46
+
47
+ it 'contains all interface keys' do
48
+ interface = subject.get[:interfaces]['Port-Channel100']
49
+ expect(interface.keys).to match_array(interface_keys)
50
+ end
51
+ end
52
+
53
+ describe '#set_domain_id' do
54
+ it 'sets the domain_id to foo' do
55
+ expect(node).to receive(:config).with(['mlag configuration',
56
+ 'domain-id foo'])
57
+ expect(subject.set_domain_id(value: 'foo')).to be_truthy
58
+ end
59
+
60
+ it 'negates the domain_id' do
61
+ expect(node).to receive(:config).with(['mlag configuration',
62
+ 'no domain-id'])
63
+ expect(subject.set_domain_id).to be_truthy
64
+ end
65
+
66
+ it 'defaults the domain_id' do
67
+ expect(node).to receive(:config).with(['mlag configuration',
68
+ 'default domain-id'])
69
+ expect(subject.set_domain_id(default: true)).to be_truthy
70
+ end
71
+
72
+ it 'default option takes precedence' do
73
+ expect(node).to receive(:config).with(['mlag configuration',
74
+ 'default domain-id'])
75
+ expect(subject.set_domain_id(value: 'foo', default: true)).to be_truthy
76
+ end
77
+ end
78
+
79
+ describe '#set_local_interface' do
80
+ it 'sets the local_interface to foo' do
81
+ expect(node).to receive(:config).with(['mlag configuration',
82
+ 'local-interface Port-Channel1'])
83
+ expect(subject.set_local_interface(value: 'Port-Channel1')).to be_truthy
84
+ end
85
+
86
+ it 'negates the local_interface' do
87
+ expect(node).to receive(:config).with(['mlag configuration',
88
+ 'no local-interface'])
89
+ expect(subject.set_local_interface).to be_truthy
90
+ end
91
+
92
+ it 'defaults the local_interface' do
93
+ expect(node).to receive(:config).with(['mlag configuration',
94
+ 'default local-interface'])
95
+ expect(subject.set_local_interface(default: true)).to be_truthy
96
+ end
97
+
98
+ it 'default option takes precedence' do
99
+ expect(node).to receive(:config).with(['mlag configuration',
100
+ 'default local-interface'])
101
+ expect(subject.set_local_interface(value: 'Port-Channel1',
102
+ default: true)).to be_truthy
103
+ end
104
+ end
105
+
106
+ describe '#set_peer_address' do
107
+ it 'sets the peer_address to foo' do
108
+ expect(node).to receive(:config).with(['mlag configuration',
109
+ 'peer-address 1.1.1.1'])
110
+ expect(subject.set_peer_address(value: '1.1.1.1')).to be_truthy
111
+ end
112
+
113
+ it 'negates the peer_address' do
114
+ expect(node).to receive(:config).with(['mlag configuration',
115
+ 'no peer-address'])
116
+ expect(subject.set_peer_address).to be_truthy
117
+ end
118
+
119
+ it 'defaults the peer_address' do
120
+ expect(node).to receive(:config).with(['mlag configuration',
121
+ 'default peer-address'])
122
+ expect(subject.set_peer_address(default: true)).to be_truthy
123
+ end
124
+
125
+ it 'default option takes precedence' do
126
+ expect(node).to receive(:config).with(['mlag configuration',
127
+ 'default peer-address'])
128
+ expect(subject.set_peer_address(value: '1.1.1.1',
129
+ default: true)).to be_truthy
130
+ end
131
+ end
132
+
133
+ describe '#set_peer_link' do
134
+ it 'sets the peer_link to foo' do
135
+ expect(node).to receive(:config).with(['mlag configuration',
136
+ 'peer-link Vlan4094'])
137
+ expect(subject.set_peer_link(value: 'Vlan4094')).to be_truthy
138
+ end
139
+
140
+ it 'negates the peer_link' do
141
+ expect(node).to receive(:config).with(['mlag configuration',
142
+ 'no peer-link'])
143
+ expect(subject.set_peer_link).to be_truthy
144
+ end
145
+
146
+ it 'defaults the peer_link' do
147
+ expect(node).to receive(:config).with(['mlag configuration',
148
+ 'default peer-link'])
149
+ expect(subject.set_peer_link(default: true)).to be_truthy
150
+ end
151
+
152
+ it 'default option takes precedence' do
153
+ expect(node).to receive(:config).with(['mlag configuration',
154
+ 'default peer-link'])
155
+ expect(subject.set_peer_link(value: 'Vlan4094', default: true))
156
+ .to be_truthy
157
+ end
158
+ end
159
+
160
+ describe '#set_mlag_id' do
161
+ it 'sets the mlag_id to 5' do
162
+ expect(node).to receive(:config).with(['interface Port-Channel1',
163
+ 'mlag 5'])
164
+ expect(subject.set_mlag_id('Port-Channel1', value: 5)).to be_truthy
165
+ end
166
+
167
+ it 'negates the mlag_id' do
168
+ expect(node).to receive(:config).with(['interface Port-Channel1',
169
+ 'no mlag'])
170
+ expect(subject.set_mlag_id('Port-Channel1')).to be_truthy
171
+ end
172
+
173
+ it 'defaults the mlag_id' do
174
+ expect(node).to receive(:config).with(['interface Port-Channel1',
175
+ 'default mlag'])
176
+ expect(subject.set_mlag_id('Port-Channel1', default: true)).to be_truthy
177
+ end
178
+
179
+ it 'default option takes precedence' do
180
+ expect(node).to receive(:config).with(['interface Port-Channel1',
181
+ 'default mlag'])
182
+ expect(subject.set_mlag_id('Port-Channel1', value: 'Vlan4094',
183
+ default: true)).to be_truthy
184
+ end
185
+ end
186
+
187
+ describe '#set_shutdown' do
188
+ it 'disables the mlag configuration' do
189
+ expect(node).to receive(:config).with(['mlag configuration',
190
+ 'shutdown'])
191
+ expect(subject.set_shutdown(value: true)).to be_truthy
192
+ end
193
+
194
+ it 'enables the mlag configuration' do
195
+ expect(node).to receive(:config).with(['mlag configuration',
196
+ 'no shutdown'])
197
+ expect(subject.set_shutdown(value: false)).to be_truthy
198
+ end
199
+
200
+ it 'negates the shutdown value' do
201
+ expect(node).to receive(:config).with(['mlag configuration',
202
+ 'no shutdown'])
203
+ expect(subject.set_shutdown).to be_truthy
204
+ end
205
+
206
+ it 'defaults the shutdown value' do
207
+ expect(node).to receive(:config).with(['mlag configuration',
208
+ 'default shutdown'])
209
+ expect(subject.set_shutdown(default: true)).to be_truthy
210
+ end
211
+
212
+ it 'default option takes precedence' do
213
+ expect(node).to receive(:config).with(['mlag configuration',
214
+ 'default shutdown'])
215
+ expect(subject.set_shutdown(value: true, default: true)).to be_truthy
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,238 @@
1
+ interface Port-Channel10
2
+ no description
3
+ no shutdown
4
+ default load-interval
5
+ logging event link-status use-global
6
+ switchport access vlan 1
7
+ switchport trunk native vlan 1
8
+ switchport trunk allowed vlan 1-4094
9
+ switchport mode access
10
+ switchport mac address learning
11
+ no switchport private-vlan mapping
12
+ switchport
13
+ default encapsulation dot1q vlan
14
+ no l2-protocol encapsulation dot1q vlan 0
15
+ snmp trap link-status
16
+ no port-channel min-links
17
+ no port-channel lacp fallback
18
+ port-channel lacp fallback timeout 90
19
+ no l2 mtu
20
+ no mlag
21
+ no switchport port-security
22
+ switchport port-security maximum 1
23
+ default qos trust
24
+ qos cos 5
25
+ qos dscp 2
26
+ no shape rate
27
+ mc-tx-queue 0
28
+ priority strict
29
+ no bandwidth percent
30
+ no shape rate
31
+ no bandwidth guaranteed
32
+ !
33
+ mc-tx-queue 1
34
+ priority strict
35
+ no bandwidth percent
36
+ no shape rate
37
+ no bandwidth guaranteed
38
+ !
39
+ mc-tx-queue 2
40
+ priority strict
41
+ no bandwidth percent
42
+ no shape rate
43
+ no bandwidth guaranteed
44
+ !
45
+ mc-tx-queue 3
46
+ priority strict
47
+ no bandwidth percent
48
+ no shape rate
49
+ no bandwidth guaranteed
50
+ !
51
+ uc-tx-queue 0
52
+ priority strict
53
+ no bandwidth percent
54
+ no shape rate
55
+ no bandwidth guaranteed
56
+ !
57
+ uc-tx-queue 1
58
+ priority strict
59
+ no bandwidth percent
60
+ no shape rate
61
+ no bandwidth guaranteed
62
+ !
63
+ uc-tx-queue 2
64
+ priority strict
65
+ no bandwidth percent
66
+ no shape rate
67
+ no bandwidth guaranteed
68
+ !
69
+ uc-tx-queue 3
70
+ priority strict
71
+ no bandwidth percent
72
+ no shape rate
73
+ no bandwidth guaranteed
74
+ !
75
+ uc-tx-queue 4
76
+ priority strict
77
+ no bandwidth percent
78
+ no shape rate
79
+ no bandwidth guaranteed
80
+ !
81
+ uc-tx-queue 5
82
+ priority strict
83
+ no bandwidth percent
84
+ no shape rate
85
+ no bandwidth guaranteed
86
+ !
87
+ uc-tx-queue 6
88
+ priority strict
89
+ no bandwidth percent
90
+ no shape rate
91
+ no bandwidth guaranteed
92
+ !
93
+ uc-tx-queue 7
94
+ priority strict
95
+ no bandwidth percent
96
+ no shape rate
97
+ no bandwidth guaranteed
98
+ sflow enable
99
+ no spanning-tree portfast
100
+ spanning-tree portfast auto
101
+ no spanning-tree link-type
102
+ no spanning-tree bpduguard
103
+ no spanning-tree bpdufilter
104
+ no spanning-tree cost
105
+ spanning-tree port-priority 128
106
+ no spanning-tree guard
107
+ no spanning-tree bpduguard rate-limit
108
+ logging event spanning-tree use-global
109
+ switchport tap native vlan 1
110
+ no switchport tap identity
111
+ switchport tap allowed vlan 1-4094
112
+ switchport tool allowed vlan 1-4094
113
+ no switchport tool identity
114
+ no switchport tap truncation
115
+ no switchport tool truncation
116
+ no switchport tap default group
117
+ no switchport tool group
118
+ no switchport tool dot1q remove outer
119
+ !
120
+ interface Port-Channel100
121
+ no description
122
+ no shutdown
123
+ default load-interval
124
+ logging event link-status use-global
125
+ switchport access vlan 1
126
+ switchport trunk native vlan 1
127
+ switchport trunk allowed vlan 1-4094
128
+ switchport mode access
129
+ switchport mac address learning
130
+ no switchport private-vlan mapping
131
+ switchport
132
+ default encapsulation dot1q vlan
133
+ no l2-protocol encapsulation dot1q vlan 0
134
+ snmp trap link-status
135
+ no port-channel min-links
136
+ no port-channel lacp fallback
137
+ port-channel lacp fallback timeout 90
138
+ no l2 mtu
139
+ mlag 100
140
+ no switchport port-security
141
+ switchport port-security maximum 1
142
+ default qos trust
143
+ qos cos 5
144
+ qos dscp 2
145
+ no shape rate
146
+ mc-tx-queue 0
147
+ priority strict
148
+ no bandwidth percent
149
+ no shape rate
150
+ no bandwidth guaranteed
151
+ !
152
+ mc-tx-queue 1
153
+ priority strict
154
+ no bandwidth percent
155
+ no shape rate
156
+ no bandwidth guaranteed
157
+ !
158
+ mc-tx-queue 2
159
+ priority strict
160
+ no bandwidth percent
161
+ no shape rate
162
+ no bandwidth guaranteed
163
+ !
164
+ mc-tx-queue 3
165
+ priority strict
166
+ no bandwidth percent
167
+ no shape rate
168
+ no bandwidth guaranteed
169
+ !
170
+ uc-tx-queue 0
171
+ priority strict
172
+ no bandwidth percent
173
+ no shape rate
174
+ no bandwidth guaranteed
175
+ !
176
+ uc-tx-queue 1
177
+ priority strict
178
+ no bandwidth percent
179
+ no shape rate
180
+ no bandwidth guaranteed
181
+ !
182
+ uc-tx-queue 2
183
+ priority strict
184
+ no bandwidth percent
185
+ no shape rate
186
+ no bandwidth guaranteed
187
+ !
188
+ uc-tx-queue 3
189
+ priority strict
190
+ no bandwidth percent
191
+ no shape rate
192
+ no bandwidth guaranteed
193
+ !
194
+ uc-tx-queue 4
195
+ priority strict
196
+ no bandwidth percent
197
+ no shape rate
198
+ no bandwidth guaranteed
199
+ !
200
+ uc-tx-queue 5
201
+ priority strict
202
+ no bandwidth percent
203
+ no shape rate
204
+ no bandwidth guaranteed
205
+ !
206
+ uc-tx-queue 6
207
+ priority strict
208
+ no bandwidth percent
209
+ no shape rate
210
+ no bandwidth guaranteed
211
+ !
212
+ uc-tx-queue 7
213
+ priority strict
214
+ no bandwidth percent
215
+ no shape rate
216
+ no bandwidth guaranteed
217
+ sflow enable
218
+ no spanning-tree portfast
219
+ spanning-tree portfast auto
220
+ no spanning-tree link-type
221
+ no spanning-tree bpduguard
222
+ no spanning-tree bpdufilter
223
+ no spanning-tree cost
224
+ spanning-tree port-priority 128
225
+ no spanning-tree guard
226
+ no spanning-tree bpduguard rate-limit
227
+ logging event spanning-tree use-global
228
+ switchport tap native vlan 1
229
+ no switchport tap identity
230
+ switchport tap allowed vlan 1-4094
231
+ switchport tool allowed vlan 1-4094
232
+ no switchport tool identity
233
+ no switchport tap truncation
234
+ no switchport tool truncation
235
+ no switchport tap default group
236
+ no switchport tool group
237
+ no switchport tool dot1q remove outer
238
+ !
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rbeapi/api/vlans'
4
+
5
+ include FixtureHelpers
6
+
7
+ describe Rbeapi::Api::Vlans do
8
+ subject { described_class.new(node) }
9
+
10
+ let(:node) { double('node') }
11
+
12
+ def vlans
13
+ vlans = Fixtures[:vlans]
14
+ return vlans if vlans
15
+ fixture('vlans', format: :text, dir: File.dirname(__FILE__))
16
+ end
17
+
18
+ before :each do
19
+ allow(subject.node).to receive(:running_config).and_return(vlans)
20
+ end
21
+
22
+ describe '#get' do
23
+ let(:entity) do
24
+ { name: 'default', state: 'active', trunk_groups: [] }
25
+ end
26
+
27
+ it 'returns the vlan resource' do
28
+ expect(subject.get('1')).to eq(entity)
29
+ end
30
+ end
31
+
32
+ describe '#getall' do
33
+ it 'returns the vlan collection' do
34
+ expect(subject.getall).to include('1')
35
+ end
36
+
37
+ it 'returns a hash collection' do
38
+ expect(subject.getall).to be_a_kind_of(Hash)
39
+ end
40
+
41
+ it 'has only one entry' do
42
+ expect(subject.getall.size).to eq(1)
43
+ end
44
+ end
45
+
46
+ describe '#create' do
47
+ it 'creates a new vlan resource' do
48
+ expect(node).to receive(:config).with('vlan 1234')
49
+ expect(subject.create('1234')).to be_truthy
50
+ end
51
+ end
52
+
53
+ describe '#delete' do
54
+ it 'deletes a vlan resource' do
55
+ expect(node).to receive(:config).with('no vlan 1234')
56
+ expect(subject.delete('1234')).to be_truthy
57
+ end
58
+ end
59
+
60
+ describe '#default' do
61
+ it 'sets vlan 1 to default' do
62
+ expect(node).to receive(:config).with('default vlan 1234')
63
+ expect(subject.default('1234')).to be_truthy
64
+ end
65
+ end
66
+
67
+ describe '#set_name' do
68
+ it 'sets vlan 1 name to foo' do
69
+ expect(node).to receive(:config).with(['vlan 1', 'name foo'])
70
+ expect(subject.set_name('1', value: 'foo')).to be_truthy
71
+ end
72
+
73
+ it 'negates vlan name' do
74
+ expect(node).to receive(:config).with(['vlan 1', 'no name'])
75
+ expect(subject.set_name('1')).to be_truthy
76
+ end
77
+
78
+ it 'defaults the vlan name' do
79
+ expect(node).to receive(:config).with(['vlan 1', 'default name'])
80
+ expect(subject.set_name('1', default: true)).to be_truthy
81
+ end
82
+
83
+ it 'default option takes precedence' do
84
+ expect(node).to receive(:config).with(['vlan 1', 'default name'])
85
+ expect(subject.set_name('1', value: 'foo', default: true)).to be_truthy
86
+ end
87
+ end
88
+
89
+ describe '#set_state' do
90
+ it 'sets vlan 1 state to suspend' do
91
+ expect(node).to receive(:config).with(['vlan 1', 'state suspend'])
92
+ expect(subject.set_state('1', value: 'suspend')).to be_truthy
93
+ end
94
+
95
+ it 'sets vlan 1 state to active' do
96
+ expect(node).to receive(:config).with(['vlan 1', 'state active'])
97
+ expect(subject.set_state('1', value: 'active')).to be_truthy
98
+ end
99
+
100
+ it 'negates the state' do
101
+ expect(node).to receive(:config).with(['vlan 1', 'no state'])
102
+ expect(subject.set_state('1')).to be_truthy
103
+ end
104
+
105
+ it 'defaults the state' do
106
+ expect(node).to receive(:config).with(['vlan 1', 'default state'])
107
+ expect(subject.set_state('1', default: true)).to be_truthy
108
+ end
109
+
110
+ it 'default option take precedence' do
111
+ expect(node).to receive(:config).with(['vlan 1', 'default state'])
112
+ expect(subject.set_state('1', value: 'active', default: true)).to \
113
+ be_truthy
114
+ end
115
+
116
+ it 'raises ArgumentError for invalid state' do
117
+ expect { subject.set_state('1', value: 'foo') }.to \
118
+ raise_error ArgumentError
119
+ end
120
+ end
121
+
122
+ describe '#add_trunk_group' do
123
+ it 'adds trunk group foo to vlan 1' do
124
+ expect(node).to receive(:config).with(['vlan 1', 'trunk group foo'])
125
+ expect(subject.add_trunk_group('1', 'foo')).to be_truthy
126
+ end
127
+ end
128
+
129
+ describe '#remove_trunk_group' do
130
+ it 'removes trunk group foo from vlan 1' do
131
+ expect(node).to receive(:config).with(['vlan 1', 'no trunk group foo'])
132
+ expect(subject.remove_trunk_group('1', 'foo')).to be_truthy
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,5 @@
1
+ vlan 1
2
+ name default
3
+ state active
4
+ no private-vlan
5
+ !