(#2) unstub is_valid_mac_address.
This commit is contained in:
parent
ce48eb6e7a
commit
4080c0534e
2 changed files with 15 additions and 2 deletions
|
@ -12,6 +12,14 @@ module Puppet::Parser::Functions
|
|||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
mac = arguments[0]
|
||||
|
||||
if /^[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}$/.match(mac) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,12 +19,17 @@ describe "the is_valid_mac_address function" do
|
|||
end
|
||||
|
||||
it "should return true if a valid mac address" do
|
||||
result = @scope.function_is_valid_mac_address("00:a0:1f:12:7f:a0")
|
||||
result = @scope.function_is_valid_mac_address(["00:a0:1f:12:7f:a0"])
|
||||
result.should(eq(true))
|
||||
end
|
||||
|
||||
it "should return false if octets are out of range" do
|
||||
result = @scope.function_is_valid_mac_address(["00:a0:1f:12:7f:g0"])
|
||||
result.should(eq(false))
|
||||
end
|
||||
|
||||
it "should return false if not valid" do
|
||||
result = @scope.function_is_valid_mac_address("not valid")
|
||||
result = @scope.function_is_valid_mac_address(["not valid"])
|
||||
result.should(eq(false))
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue