Revision 54ee3a8a
Added by Sean Handley about 10 years ago
test/subnet_test.rb | ||
---|---|---|
assert_equal @subnet.size, counter-1
|
||
end
|
||
|
||
def test_should_reuse_ip_if_from_same_subnet
|
||
@subnet.stubs(:has_mac?).returns(stub(:ip => '192.168.0.10'))
|
||
@subnet.stubs(:icmp_pingable?)
|
||
@subnet.stubs(:tcp_pingable?)
|
||
assert_equal '192.168.0.10', @subnet.unused_ip({:mac => '0'})
|
||
end
|
||
|
||
def test_should_not_reuse_ip_if_from_other_subnet
|
||
@subnet.stubs(:has_mac?).returns(stub(:ip => '10.0.0.10'))
|
||
@subnet.stubs(:icmp_pingable?)
|
||
@subnet.stubs(:tcp_pingable?)
|
||
assert_equal false, @subnet.unused_ip({:mac => '0'}).include?("10.0.0")
|
||
end
|
||
|
||
def test_should_not_reuse_ip_if_from_outside_range
|
||
@subnet.stubs(:has_mac?).returns(stub(:ip => '192.168.0.250'))
|
||
@subnet.stubs(:icmp_pingable?)
|
||
@subnet.stubs(:tcp_pingable?)
|
||
params = {:mac => '0', :from => '192.168.0.1', :to => '192.168.0.30'}
|
||
assert_not_equal '192.168.0.250', @subnet.unused_ip(params)
|
||
end
|
||
|
||
end
|
Also available in: Unified diff
fixes #5123 - IP only from the same subnet and range