cisco_node_utils 1.6.0 → 1.7.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 +60 -1
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/cisco_node_utils.gemspec +1 -1
- data/docs/README-develop-node-utils-APIs.md +2 -0
- data/docs/README-maintainers.md +45 -80
- data/lib/cisco_node_utils/ace.rb +24 -43
- data/lib/cisco_node_utils/bfd_global.rb +1 -0
- data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +8 -5
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +8 -6
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +40 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +8 -4
- data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +9 -4
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +8 -3
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +2 -1
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +5 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +7 -3
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +3 -3
- data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +13 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +10 -2
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +6 -1
- data/lib/cisco_node_utils/cmd_ref/route_map.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +2 -1
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +22 -3
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +2 -1
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +6 -3
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +48 -4
- data/lib/cisco_node_utils/command_reference.rb +5 -2
- data/lib/cisco_node_utils/feature.rb +14 -1
- data/lib/cisco_node_utils/interface.rb +13 -0
- data/lib/cisco_node_utils/interface_channel_group.rb +33 -25
- data/lib/cisco_node_utils/itd_device_group.rb +17 -37
- data/lib/cisco_node_utils/itd_service.rb +9 -32
- data/lib/cisco_node_utils/node.rb +12 -4
- data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
- data/lib/cisco_node_utils/ntp_config.rb +19 -1
- data/lib/cisco_node_utils/ntp_server.rb +28 -27
- data/lib/cisco_node_utils/route_map.rb +33 -51
- data/lib/cisco_node_utils/snmpuser.rb +2 -2
- data/lib/cisco_node_utils/span_session.rb +149 -0
- data/lib/cisco_node_utils/upgrade.rb +21 -17
- data/lib/cisco_node_utils/version.rb +2 -2
- data/lib/cisco_node_utils/vlan.rb +1 -1
- data/lib/cisco_node_utils/vpc.rb +40 -0
- data/lib/cisco_node_utils/yum.rb +136 -13
- data/spec/schema.yaml +2 -0
- data/tests/ciscotest.rb +36 -0
- data/tests/test_ace.rb +6 -0
- data/tests/test_bfd_global.rb +1 -7
- data/tests/test_bgp_af.rb +2 -2
- data/tests/test_bgp_af_aa.rb +108 -0
- data/tests/test_bgp_neighbor.rb +2 -1
- data/tests/test_bgp_neighbor_af.rb +6 -6
- data/tests/test_dhcp_relay_global.rb +1 -0
- data/tests/test_interface.rb +18 -2
- data/tests/test_interface_channel_group.rb +47 -0
- data/tests/test_interface_svi.rb +1 -1
- data/tests/test_ntp_auth_key.rb +77 -0
- data/tests/test_ntp_config.rb +51 -4
- data/tests/test_ntp_server.rb +69 -9
- data/tests/test_overlay_global.rb +1 -0
- data/tests/test_route_map.rb +13 -24
- data/tests/test_router_bgp.rb +14 -9
- data/tests/test_span_session.rb +155 -0
- data/tests/test_stp_global.rb +1 -0
- data/tests/test_upgrade.rb +2 -3
- data/tests/test_vlan.rb +24 -3
- data/tests/test_vlan_private.rb +1 -1
- data/tests/test_vpc.rb +42 -17
- data/tests/test_vxlan_vtep.rb +1 -0
- data/tests/test_vxlan_vtep_vni.rb +5 -1
- data/tests/test_yum.rb +7 -30
- data/tests/yum_package.yaml +20 -0
- metadata +13 -3
data/tests/test_bgp_neighbor.rb
CHANGED
@@ -315,7 +315,7 @@ class TestBgpNeighbor < CiscoTestCase
|
|
315
315
|
end
|
316
316
|
|
317
317
|
def test_log_neighbor_changes
|
318
|
-
if platform == :ios_xr || node.product_id[/N(5|6
|
318
|
+
if platform == :ios_xr || node.product_id[/N(5|6)/]
|
319
319
|
b = create_neighbor('blue')
|
320
320
|
assert_nil(b.log_neighbor_changes)
|
321
321
|
assert_nil(b.default_log_neighbor_changes)
|
@@ -324,6 +324,7 @@ class TestBgpNeighbor < CiscoTestCase
|
|
324
324
|
end
|
325
325
|
return
|
326
326
|
end
|
327
|
+
skip_incompat_version?('bgp_neighbor', 'log_neighbor_changes')
|
327
328
|
%w(default test_vrf).each do |vrf|
|
328
329
|
neighbor = create_neighbor(vrf)
|
329
330
|
check = [:enable, :disable, :inherit, 'enable', 'disable', 'inherit',
|
@@ -64,10 +64,10 @@ class TestBgpNeighborAF < CiscoTestCase
|
|
64
64
|
asn, vrf, nbr, af = af_args
|
65
65
|
dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af.join('/'))
|
66
66
|
|
67
|
-
obj_nbr = RouterBgpNeighbor.new(asn, vrf, nbr
|
67
|
+
obj_nbr = RouterBgpNeighbor.new(asn, vrf, nbr)
|
68
68
|
obj_nbr.remote_as = ebgp ? asn + 1 : asn
|
69
69
|
|
70
|
-
obj_af = RouterBgpNeighborAF.new(asn, vrf, nbr, af
|
70
|
+
obj_af = RouterBgpNeighborAF.new(asn, vrf, nbr, af)
|
71
71
|
|
72
72
|
# clean up address-family only
|
73
73
|
obj_af.destroy
|
@@ -160,7 +160,7 @@ class TestBgpNeighborAF < CiscoTestCase
|
|
160
160
|
@@matrix.each do |k, v|
|
161
161
|
asn, vrf, nbr, af = v
|
162
162
|
dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af)
|
163
|
-
obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af
|
163
|
+
obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af)
|
164
164
|
# TBD: This flush should not be needed but we see an intermittent problem
|
165
165
|
# with certain rake test seed values, where 'afs' below is not detecting
|
166
166
|
# vrf 'aa' AF.
|
@@ -193,13 +193,13 @@ class TestBgpNeighborAF < CiscoTestCase
|
|
193
193
|
# so make sure to catch the error
|
194
194
|
assert_raises(UnsupportedError,
|
195
195
|
'Neighbors do not support slash notation') do
|
196
|
-
RouterBgpNeighborAF.new(asn, vrf, nbr, af
|
196
|
+
RouterBgpNeighborAF.new(asn, vrf, nbr, af)
|
197
197
|
end
|
198
198
|
next
|
199
199
|
end
|
200
200
|
next if platform == :ios_xr
|
201
201
|
dbg = sprintf('[VRF %s NBR %s AF %s]', vrf, nbr, af.join('/'))
|
202
|
-
obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af
|
202
|
+
obj[k] = RouterBgpNeighborAF.new(asn, vrf, nbr, af)
|
203
203
|
nbr_munged = Utils.process_network_mask(nbr)
|
204
204
|
# TBD: This flush should not be needed but we see an intermittent problem
|
205
205
|
# with certain rake test seed values, where 'afs' below is not detecting
|
@@ -217,7 +217,7 @@ class TestBgpNeighborAF < CiscoTestCase
|
|
217
217
|
if platform == :ios_xr
|
218
218
|
assert_raises(UnsupportedError,
|
219
219
|
'Neighbors do not support slash notation') do
|
220
|
-
RouterBgpNeighborAF.new(asn, vrf, nbr, af
|
220
|
+
RouterBgpNeighborAF.new(asn, vrf, nbr, af)
|
221
221
|
end
|
222
222
|
next
|
223
223
|
end
|
@@ -211,6 +211,7 @@ class TestDhcpRelayGlobal < CiscoTestCase
|
|
211
211
|
end
|
212
212
|
return
|
213
213
|
end
|
214
|
+
skip_incompat_version?('dhcp_relay_global', 'ipv4_sub_option_circuit_id_string')
|
214
215
|
assert_equal(drg.default_ipv4_sub_option_circuit_id_string, drg.ipv4_sub_option_circuit_id_string)
|
215
216
|
str = '%p%p'
|
216
217
|
drg.ipv4_sub_option_circuit_id_string = str
|
data/tests/test_interface.rb
CHANGED
@@ -788,7 +788,7 @@ class TestInterface < CiscoTestCase
|
|
788
788
|
if validate_property_excluded?('interface_channel_group', 'channel_group')
|
789
789
|
member = InterfaceChannelGroup.new(interfaces[0])
|
790
790
|
assert_raises(Cisco::UnsupportedError) do
|
791
|
-
member.
|
791
|
+
member.channel_group_mode_set(10)
|
792
792
|
end
|
793
793
|
return
|
794
794
|
end
|
@@ -1359,7 +1359,7 @@ class TestInterface < CiscoTestCase
|
|
1359
1359
|
# pre-configure
|
1360
1360
|
begin
|
1361
1361
|
interface_ethernet_default(interfaces[1])
|
1362
|
-
InterfaceChannelGroup.new(interfaces[1]).
|
1362
|
+
InterfaceChannelGroup.new(interfaces[1]).channel_group_mode_set(48)
|
1363
1363
|
rescue Cisco::UnsupportedError
|
1364
1364
|
raise unless platform == :ios_xr
|
1365
1365
|
# Some XR platform/version combos don't support port-channels
|
@@ -1764,6 +1764,7 @@ class TestInterface < CiscoTestCase
|
|
1764
1764
|
assert_equal(interface.default_load_interval_counter_1_delay,
|
1765
1765
|
interface.load_interval_counter_1_delay)
|
1766
1766
|
# check nil for subintf and loopback
|
1767
|
+
interface.switchport_mode = :disabled if platform == :nexus
|
1767
1768
|
subif = Interface.new(interfaces[0] + '.1')
|
1768
1769
|
assert_nil(subif.load_interval_counter_1_delay)
|
1769
1770
|
assert_raises(ArgumentError) { subif.load_interval_counter_1_delay = 100 }
|
@@ -1794,6 +1795,7 @@ class TestInterface < CiscoTestCase
|
|
1794
1795
|
assert_equal(interface.default_load_interval_counter_2_delay,
|
1795
1796
|
interface.load_interval_counter_2_delay)
|
1796
1797
|
# check nil for subintf and loopback
|
1798
|
+
interface.switchport_mode = :disabled if platform == :nexus
|
1797
1799
|
subif = Interface.new(interfaces[0] + '.1')
|
1798
1800
|
assert_nil(subif.load_interval_counter_2_delay)
|
1799
1801
|
assert_raises(ArgumentError) { subif.load_interval_counter_2_delay = 100 }
|
@@ -1824,6 +1826,7 @@ class TestInterface < CiscoTestCase
|
|
1824
1826
|
assert_equal(interface.default_load_interval_counter_3_delay,
|
1825
1827
|
interface.load_interval_counter_3_delay)
|
1826
1828
|
# check nil for subintf and loopback
|
1829
|
+
interface.switchport_mode = :disabled if platform == :nexus
|
1827
1830
|
subif = Interface.new(interfaces[0] + '.1')
|
1828
1831
|
assert_nil(subif.load_interval_counter_3_delay)
|
1829
1832
|
assert_raises(ArgumentError) { subif.load_interval_counter_3_delay = 100 }
|
@@ -1833,4 +1836,17 @@ class TestInterface < CiscoTestCase
|
|
1833
1836
|
subif.destroy
|
1834
1837
|
lb.destroy
|
1835
1838
|
end
|
1839
|
+
|
1840
|
+
def test_purge_config
|
1841
|
+
name = interfaces[0]
|
1842
|
+
int = Interface.new(name)
|
1843
|
+
int.switchport_mode = :disabled
|
1844
|
+
|
1845
|
+
int.description = 'destroy_pysical'
|
1846
|
+
int.ipv4_addr_mask_set('192.168.0.1', '24')
|
1847
|
+
refute(int.purge_config)
|
1848
|
+
|
1849
|
+
int.purge_config = true
|
1850
|
+
assert(int.purge_config)
|
1851
|
+
end
|
1836
1852
|
end
|
@@ -32,6 +32,7 @@ class TestInterfaceChanGrp < CiscoTestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_channel_group
|
35
|
+
skip if platform == :nexus
|
35
36
|
i = @intf
|
36
37
|
group = 200
|
37
38
|
i.channel_group = group
|
@@ -49,6 +50,52 @@ class TestInterfaceChanGrp < CiscoTestCase
|
|
49
50
|
skip(e.to_s)
|
50
51
|
end
|
51
52
|
|
53
|
+
def test_channel_group_mode
|
54
|
+
skip if platform == :ios_xr
|
55
|
+
i = @intf
|
56
|
+
group = 55
|
57
|
+
|
58
|
+
# Default Case: group = mode = false
|
59
|
+
refute(i.channel_group)
|
60
|
+
refute(i.channel_group_mode)
|
61
|
+
|
62
|
+
# group = 55, mode = on
|
63
|
+
i.channel_group_mode_set(group)
|
64
|
+
assert_equal(group, i.channel_group)
|
65
|
+
assert_equal(i.default_channel_group_mode, i.channel_group_mode)
|
66
|
+
|
67
|
+
# group = 55, mode = active
|
68
|
+
i.channel_group_mode_set(group, 'active')
|
69
|
+
assert_equal(group, i.channel_group)
|
70
|
+
assert_equal('active', i.channel_group_mode)
|
71
|
+
|
72
|
+
# group = 55, mode = passive
|
73
|
+
i.channel_group_mode_set(group, 'passive')
|
74
|
+
assert_equal(group, i.channel_group)
|
75
|
+
assert_equal('passive', i.channel_group_mode)
|
76
|
+
|
77
|
+
# group = 55, mode = on
|
78
|
+
i.channel_group_mode_set(group, 'on')
|
79
|
+
assert_equal(group, i.channel_group)
|
80
|
+
assert_equal(i.default_channel_group_mode, i.channel_group_mode)
|
81
|
+
|
82
|
+
# group = 66, mode = active
|
83
|
+
group = 66
|
84
|
+
i.channel_group_mode_set(group, 'active')
|
85
|
+
assert_equal(group, i.channel_group)
|
86
|
+
assert_equal('active', i.channel_group_mode)
|
87
|
+
|
88
|
+
# group = 66, mode = on
|
89
|
+
i.channel_group_mode_set(group)
|
90
|
+
assert_equal(group, i.channel_group)
|
91
|
+
assert_equal(i.default_channel_group_mode, i.channel_group_mode)
|
92
|
+
|
93
|
+
# Default Case: group = mode = false
|
94
|
+
i.channel_group_mode_set(i.default_channel_group)
|
95
|
+
refute(i.channel_group)
|
96
|
+
refute(i.channel_group_mode)
|
97
|
+
end
|
98
|
+
|
52
99
|
def test_description
|
53
100
|
i = @intf
|
54
101
|
desc = 'test desc'
|
data/tests/test_interface_svi.rb
CHANGED
@@ -195,7 +195,7 @@ class TestSvi < CiscoTestCase
|
|
195
195
|
|
196
196
|
def test_sys_def_svi_autostate
|
197
197
|
skip_autostate_test?
|
198
|
-
skip_legacy_defect?('8.0.1', 'CSC:
|
198
|
+
skip_legacy_defect?('8.0.1|8.1.1', 'CSC: Behavior change after helsinki')
|
199
199
|
interface = Interface.new(interfaces[0])
|
200
200
|
|
201
201
|
system_default_svi_autostate('no ')
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Minitest for NtpAuthKey class
|
3
|
+
#
|
4
|
+
# Copyright (c) 2014-2017 Cisco and/or its affiliates.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require_relative 'ciscotest'
|
19
|
+
require_relative '../lib/cisco_node_utils/ntp_auth_key'
|
20
|
+
|
21
|
+
# TestNtpAuthKey - Minitest for NtpAuthKey node utility.
|
22
|
+
class TestNtpAuthKey < CiscoTestCase
|
23
|
+
def setup
|
24
|
+
# setup runs at the beginning of each test
|
25
|
+
super
|
26
|
+
no_ntpkey
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
# teardown runs at the end of each test
|
31
|
+
no_ntpkey
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def no_ntpkey
|
36
|
+
# Turn the feature off for a clean test.
|
37
|
+
config('no ntp authentication-key 111 md5 test 7',
|
38
|
+
'no ntp authentication-key 999 md5 test 7')
|
39
|
+
end
|
40
|
+
|
41
|
+
# TESTS
|
42
|
+
|
43
|
+
def test_create_defaults
|
44
|
+
id = '111'
|
45
|
+
options = { 'name' => id, 'password' => 'test' }
|
46
|
+
refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
|
47
|
+
|
48
|
+
key = Cisco::NtpAuthKey.new(options, true)
|
49
|
+
assert_includes(Cisco::NtpAuthKey.ntpkeys, id)
|
50
|
+
assert_equal(key, Cisco::NtpAuthKey.ntpkeys[id])
|
51
|
+
|
52
|
+
assert_equal(id, Cisco::NtpAuthKey.ntpkeys[id].name)
|
53
|
+
assert_equal('md5', Cisco::NtpAuthKey.ntpkeys[id].algorithm)
|
54
|
+
assert_equal('7', Cisco::NtpAuthKey.ntpkeys[id].mode)
|
55
|
+
|
56
|
+
key.destroy
|
57
|
+
refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_create_options
|
61
|
+
id = '999'
|
62
|
+
options = { 'name' => id, 'password' => 'test', 'algorithm' => 'md5',
|
63
|
+
'mode' => '7' }
|
64
|
+
refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
|
65
|
+
|
66
|
+
key = Cisco::NtpAuthKey.new(options, true)
|
67
|
+
assert_includes(Cisco::NtpAuthKey.ntpkeys, id)
|
68
|
+
assert_equal(key, Cisco::NtpAuthKey.ntpkeys[id])
|
69
|
+
|
70
|
+
assert_equal(id, Cisco::NtpAuthKey.ntpkeys[id].name)
|
71
|
+
assert_equal('md5', Cisco::NtpAuthKey.ntpkeys[id].algorithm)
|
72
|
+
assert_equal('7', Cisco::NtpAuthKey.ntpkeys[id].mode)
|
73
|
+
|
74
|
+
key.destroy
|
75
|
+
refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
|
76
|
+
end
|
77
|
+
end
|
data/tests/test_ntp_config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Minitest for NtpConfig class
|
3
3
|
#
|
4
|
-
# Copyright (c) 2015-
|
4
|
+
# Copyright (c) 2015-2017 Cisco and/or its affiliates.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -26,28 +26,75 @@ class TestNtpConfig < CiscoTestCase
|
|
26
26
|
no_ntpconfig
|
27
27
|
end
|
28
28
|
|
29
|
+
def teardown
|
30
|
+
# teardown runs at the end of each test
|
31
|
+
no_ntpconfig
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
29
35
|
def no_ntpconfig
|
30
36
|
# Turn the feature off for a clean test.
|
31
37
|
if platform == :ios_xr
|
32
|
-
config("no ntp source #{interfaces[
|
38
|
+
config("no ntp source #{interfaces[1]}")
|
33
39
|
else
|
34
|
-
config("no ntp source-interface #{interfaces[
|
40
|
+
config("no ntp source-interface #{interfaces[1]}",
|
41
|
+
'no ntp authentication-key 111 md5 test 7',
|
42
|
+
'no ntp authentication-key 999 md5 test 7',
|
43
|
+
'no ntp trusted-key 111',
|
44
|
+
'no ntp trusted-key 999',
|
45
|
+
'no ntp authenticate')
|
35
46
|
end
|
36
47
|
end
|
37
48
|
|
38
49
|
# TESTS
|
39
50
|
|
40
|
-
def
|
51
|
+
def test_source_interface
|
41
52
|
id = 'default'
|
42
53
|
|
43
54
|
ntp = Cisco::NtpConfig.new(id)
|
44
55
|
assert_includes(Cisco::NtpConfig.ntpconfigs, id)
|
45
56
|
assert_equal(Cisco::NtpConfig.ntpconfigs[id], ntp)
|
46
57
|
|
58
|
+
assert_nil(Cisco::NtpConfig.ntpconfigs[id].source_interface)
|
59
|
+
assert_nil(ntp.source_interface)
|
60
|
+
|
47
61
|
ntp.source_interface = interfaces[1]
|
48
62
|
assert_equal(Cisco::NtpConfig.ntpconfigs[id].source_interface,
|
49
63
|
interfaces[1].downcase)
|
50
64
|
assert_equal(Cisco::NtpConfig.ntpconfigs[id].source_interface,
|
51
65
|
ntp.source_interface)
|
66
|
+
|
67
|
+
ntp.source_interface = nil
|
68
|
+
assert_nil(Cisco::NtpConfig.ntpconfigs[id].source_interface)
|
69
|
+
assert_nil(ntp.source_interface)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_authenticate
|
73
|
+
id = 'default'
|
74
|
+
|
75
|
+
ntp = Cisco::NtpConfig.new(id)
|
76
|
+
assert_includes(Cisco::NtpConfig.ntpconfigs, id)
|
77
|
+
assert_equal(Cisco::NtpConfig.ntpconfigs[id], ntp)
|
78
|
+
|
79
|
+
assert_equal(false, Cisco::NtpConfig.ntpconfigs[id].authenticate)
|
80
|
+
|
81
|
+
ntp.authenticate = true
|
82
|
+
assert_equal(true, Cisco::NtpConfig.ntpconfigs[id].authenticate)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_trusted_key
|
86
|
+
id = 'default'
|
87
|
+
|
88
|
+
ntp = Cisco::NtpConfig.new(id)
|
89
|
+
assert_includes(Cisco::NtpConfig.ntpconfigs, id)
|
90
|
+
assert_equal(Cisco::NtpConfig.ntpconfigs[id], ntp)
|
91
|
+
|
92
|
+
assert_nil(Cisco::NtpConfig.ntpconfigs[id].trusted_key)
|
93
|
+
|
94
|
+
config('ntp authentication-key 111 md5 test 7',
|
95
|
+
'ntp authentication-key 999 md5 test 7')
|
96
|
+
ntp.trusted_key_set(true, 111)
|
97
|
+
ntp.trusted_key_set(true, 999)
|
98
|
+
assert_equal(%w(111 999), Cisco::NtpConfig.ntpconfigs[id].trusted_key)
|
52
99
|
end
|
53
100
|
end
|
data/tests/test_ntp_server.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Minitest for NtpServer class
|
3
3
|
#
|
4
|
-
# Copyright (c) 2014-
|
4
|
+
# Copyright (c) 2014-2017 Cisco and/or its affiliates.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -23,28 +23,37 @@ class TestNtpServer < CiscoTestCase
|
|
23
23
|
def setup
|
24
24
|
# setup runs at the beginning of each test
|
25
25
|
super
|
26
|
-
|
26
|
+
no_ntpserver
|
27
27
|
end
|
28
28
|
|
29
29
|
def teardown
|
30
30
|
# teardown runs at the end of each test
|
31
|
-
|
31
|
+
no_ntpserver
|
32
32
|
super
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def no_ntpserver
|
36
36
|
# Turn the feature off for a clean test.
|
37
37
|
config('no ntp server 130.88.203.12',
|
38
|
-
'no ntp server 2003::5'
|
38
|
+
'no ntp server 2003::5',
|
39
|
+
'no ntp server 0.us.pool.ntp.org',
|
40
|
+
'no ntp authentication-key 999 md5 test 7',
|
41
|
+
'no vrf context red')
|
39
42
|
end
|
40
43
|
|
41
44
|
# TESTS
|
42
45
|
|
46
|
+
def test_create_name_invalid
|
47
|
+
assert_raises(ArgumentError) do
|
48
|
+
Cisco::NtpServer.new({ 'name' => '1_com' }, true)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
def test_ipv4
|
44
53
|
id = '130.88.203.12'
|
45
54
|
refute_includes(Cisco::NtpServer.ntpservers, id)
|
46
55
|
|
47
|
-
ntp = Cisco::NtpServer.new(id,
|
56
|
+
ntp = Cisco::NtpServer.new({ 'name' => id }, true)
|
48
57
|
assert_includes(Cisco::NtpServer.ntpservers, id)
|
49
58
|
assert_equal(ntp, Cisco::NtpServer.ntpservers[id])
|
50
59
|
|
@@ -56,7 +65,7 @@ class TestNtpServer < CiscoTestCase
|
|
56
65
|
id = '2003::5'
|
57
66
|
refute_includes(Cisco::NtpServer.ntpservers, id)
|
58
67
|
|
59
|
-
ntp = Cisco::NtpServer.new(id,
|
68
|
+
ntp = Cisco::NtpServer.new({ 'name' => id }, true)
|
60
69
|
assert_includes(Cisco::NtpServer.ntpservers, id)
|
61
70
|
assert_equal(ntp, Cisco::NtpServer.ntpservers[id])
|
62
71
|
|
@@ -70,8 +79,8 @@ class TestNtpServer < CiscoTestCase
|
|
70
79
|
refute_includes(Cisco::NtpServer.ntpservers, id1)
|
71
80
|
refute_includes(Cisco::NtpServer.ntpservers, id2)
|
72
81
|
|
73
|
-
ntp1 = Cisco::NtpServer.new(id1,
|
74
|
-
ntp2 = Cisco::NtpServer.new(id2, true)
|
82
|
+
ntp1 = Cisco::NtpServer.new({ 'name' => id1 }, true)
|
83
|
+
ntp2 = Cisco::NtpServer.new({ 'name' => id2 }, true)
|
75
84
|
refute_equal(ntp1, ntp2)
|
76
85
|
assert_includes(Cisco::NtpServer.ntpservers, id1)
|
77
86
|
assert_includes(Cisco::NtpServer.ntpservers, id2)
|
@@ -83,4 +92,55 @@ class TestNtpServer < CiscoTestCase
|
|
83
92
|
refute_includes(Cisco::NtpServer.ntpservers, id1)
|
84
93
|
refute_includes(Cisco::NtpServer.ntpservers, id2)
|
85
94
|
end
|
95
|
+
|
96
|
+
# This test requires DNS resolution be avaabile - leaving for reference
|
97
|
+
# def test_domain_name
|
98
|
+
# id = '0.us.pool.ntp.org'
|
99
|
+
# refute_includes(Cisco::NtpServer.ntpservers, id)
|
100
|
+
#
|
101
|
+
# ntp = Cisco::NtpServer.new({ 'name' => id }, true)
|
102
|
+
# assert_includes(Cisco::NtpServer.ntpservers, id)
|
103
|
+
# assert_equal(ntp, Cisco::NtpServer.ntpservers[id])
|
104
|
+
#
|
105
|
+
# ntp.destroy
|
106
|
+
# refute_includes(Cisco::NtpServer.ntpservers, id)
|
107
|
+
# end
|
108
|
+
|
109
|
+
def test_defaults
|
110
|
+
id = '130.88.203.12'
|
111
|
+
refute_includes(Cisco::NtpServer.ntpservers, id)
|
112
|
+
|
113
|
+
ntp = Cisco::NtpServer.new({ 'name' => id }, true)
|
114
|
+
assert_includes(Cisco::NtpServer.ntpservers, id)
|
115
|
+
assert_equal('default', Cisco::NtpServer.ntpservers[id].vrf)
|
116
|
+
assert_nil(Cisco::NtpServer.ntpservers[id].key)
|
117
|
+
assert_nil(Cisco::NtpServer.ntpservers[id].maxpoll)
|
118
|
+
assert_nil(Cisco::NtpServer.ntpservers[id].minpoll)
|
119
|
+
refute(Cisco::NtpServer.ntpservers[id].prefer)
|
120
|
+
|
121
|
+
ntp.destroy
|
122
|
+
refute_includes(Cisco::NtpServer.ntpservers, id)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_create_options
|
126
|
+
id = '130.88.203.12'
|
127
|
+
refute_includes(Cisco::NtpServer.ntpservers, id)
|
128
|
+
|
129
|
+
options = { 'name' => id, 'key' => '999', 'prefer' => 'true',
|
130
|
+
'minpoll' => '5', 'maxpoll' => '8', 'vrf' => 'red' }
|
131
|
+
|
132
|
+
config('vrf context red')
|
133
|
+
config('ntp authentication-key 999 md5 test 7')
|
134
|
+
|
135
|
+
ntp = Cisco::NtpServer.new(options, true)
|
136
|
+
assert_includes(Cisco::NtpServer.ntpservers, id)
|
137
|
+
assert_equal('red', Cisco::NtpServer.ntpservers[id].vrf)
|
138
|
+
assert_equal('999', Cisco::NtpServer.ntpservers[id].key)
|
139
|
+
assert_equal('5', Cisco::NtpServer.ntpservers[id].minpoll)
|
140
|
+
assert_equal('8', Cisco::NtpServer.ntpservers[id].maxpoll)
|
141
|
+
assert(Cisco::NtpServer.ntpservers[id].prefer)
|
142
|
+
|
143
|
+
ntp.destroy
|
144
|
+
refute_includes(Cisco::NtpServer.ntpservers, id)
|
145
|
+
end
|
86
146
|
end
|