Changeset 221

Show
Ignore:
Timestamp:
08/08/08 22:33:03 (3 months ago)
Author:
pwh
Message:

Fixed a bug in validate_stp_root_bridge_address where the root bridge address and priority weren't checked for length. Also enhanced tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nethorus/lib/nethorus_functions.rb

    r216 r221  
    8080  root_fields = parse_stp_root_bridge_address(stp_root) 
    8181 
    82   if root_fields[1].match(/[0-9A-F]{4}/) and root_fields[2].match(/[0-9A-F]{12}/) 
     82  if stp_root.length == 16 and root_fields[1].match(/^[0-9A-F]{4}/) and root_fields[2].match(/[0-9A-F]{12}$/) 
    8383    return :true 
    8484  else 
  • nethorus/test/functional/common_functions_test.rb

    r216 r221  
    7676 
    7777 
     78  # Test the parse_stp_root_bridge_address function. 
     79   
     80  def test_parse_stp_root_bridge_address 
     81   
     82    root_bridge = "80001234567890AB" 
     83     
     84    root_bridge_components = parse_stp_root_bridge_address(root_bridge) 
     85     
     86    assert(root_bridge_components[1] == "8000", "Root bridge priority for #{root_bridge} should be 8000") 
     87    assert(root_bridge_components[2] == "1234567890AB", "Root bridge address for #{root_bridge} should be 1234567890AB") 
     88   
     89  end 
     90 
     91 
     92  # Test the validate_stp_root_bridge_address function. 
     93   
     94  def test_validate_stp_root_bridge_address 
     95   
     96    assert(validate_stp_root_bridge_address('80001234567890AB') == :true, "Root bridge 80001234567890 should be valid") 
     97    assert(validate_stp_root_bridge_address('0000000000000000') == :true, "Root bridge 00000000000000 should be valid") 
     98    assert(validate_stp_root_bridge_address('000000000000000') == :false, "Root bridge 000000000000000 should not be valid") 
     99    assert(validate_stp_root_bridge_address('00000000000000000') == :false, "Root bridge 00000000000000000 should not be valid") 
     100    assert(validate_stp_root_bridge_address('0') == :false, "Root bridge 0 should not be valid") 
     101   
     102  end 
     103 
     104 
    78105  # Test the validate_ip_address function. 
    79106