-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_names.rb
33 lines (26 loc) · 968 Bytes
/
test_names.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# Test configuring IP to name mappings.
#
ASAConsole::Test.script do |asa|
asa.connect
def reset_test(asa)
rc = asa.running_config('names').select('name', '192.0.2.1')
asa.config_exec!('no name 192.0.2.1') unless rc.nil?
rc = asa.running_config('names').select('name', '192.0.2.2')
asa.config_exec!('no name 192.0.2.2') unless rc.nil?
end
reset_test(asa)
# Are question marks being escaped?
asa.config_exec!("name 192.0.2.1 ASATest1 description What's in a name? That which we call a rose...")
asa.config_exec!("name 192.0.2.2 ASATest2")
asa.running_config('names').select('name') do |rc|
m = /(?<addr>[\d\.]+) (?<name>[\w\-]+)(?: description (?<desc>.*))?/.match(rc.config_data)
if m[:desc]
log "#{m[:addr]} is called \"#{m[:name]}\" and its description is \"#{m[:desc]}\""
else
log "#{m[:addr]} is called \"#{m[:name]}\" and it has no description"
end
end
reset_test(asa)
asa.disconnect
end