fix ipv4 cidr range regexp

This commit is contained in:
vkuklin@mirantis.com 2012-10-02 19:37:04 +04:00 committed by Eugene Kirpichov
parent 3bb769bd30
commit 377b5b4f18
2 changed files with 12 additions and 1 deletions

View File

@ -10,7 +10,7 @@ Puppet::Type.newtype(:nova_network) do
# that determine uniqueness
newparam(:network, :namevar => true) do
desc "IPv4 Network (ie, 192.168.1.0/24)"
newvalues(/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.0\/[0-9]{1,2}$/)
newvalues(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(\d|[1-2]\d|3[0-2]))$/)
end
newparam(:label) do

View File

@ -0,0 +1,11 @@
require 'puppet'
require 'puppet/type/nova_network'
describe 'Puppet::Type.type(:nova_network)' do
it 'should reject an invalid ipv4 CIDR value' do
expect { Puppet::Type.type(:nova_network).new(:network => '192.168.1.0') }.to raise_error(Puppet::Error, /Invalid value/)
expect { Puppet::Type.type(:nova_network).new(:network => '::1/24') }.to raise_error(Puppet::Error, /Invalid value/)
end
it 'should accept a valid ipv4 CIDR value' do
Puppet::Type.type(:nova_network).new(:network => '192.168.1.0/24')
end
end