Revision 2080b2eb
Added by Greg Sutcliffe about 10 years ago
test/subnet_test.rb | ||
---|---|---|
@netmask = "255.255.255.0"
|
||
@server = Proxy::DHCP::Server.new("testcase")
|
||
@subnet = Proxy::DHCP::Subnet.new @server, @network, @netmask
|
||
@subnet.load
|
||
end
|
||
|
||
def test_subnet_should_have_a_server
|
||
... | ... | |
assert_equal @subnet.range, "192.168.0.1-192.168.0.254"
|
||
end
|
||
|
||
def add_record
|
||
ip = "192.168.0.50"
|
||
mac = "aa:bb:cc:dd:ee:Ff"
|
||
@subnet.add_record Proxy::DHCP::Record.new(:subnet =>@subnet, :ip => ip, :mac => mac)
|
||
def add_record opts = {}
|
||
ip = opts[:ip] || "192.168.0.50"
|
||
mac = opts[:mac] || "aa:bb:cc:dd:ee:ff"
|
||
Proxy::DHCP::Record.new(:subnet =>@subnet, :ip => ip, :mac => mac)
|
||
end
|
||
|
||
def test_should_add_records
|
||
... | ... | |
assert_equal @subnet.size, counter+1
|
||
end
|
||
|
||
def test_should_not_import_the_same_record_twice
|
||
begin
|
||
add_record
|
||
rescue
|
||
nil
|
||
end
|
||
counter = @subnet.size
|
||
add_record
|
||
assert_equal @subnet.size, counter
|
||
end
|
||
|
||
def test_should_clear_records
|
||
add_record
|
||
@subnet.clear
|
||
... | ... | |
assert_kind_of Proxy::DHCP::Record, @subnet["192.168.0.50"]
|
||
end
|
||
|
||
def test_it_should_be_possible_to_find_subnet_record_based_on_mac
|
||
add_record
|
||
assert_kind_of Proxy::DHCP::Record, @subnet["aa:bb:cc:dd:ee:ff"]
|
||
end
|
||
|
||
def test_should_remove_records
|
||
add_record
|
||
counter = @subnet.size
|
Also available in: Unified diff
Fixes #5648 - Match the DHCP specification of last-lease-wins