Changeset 216
- Timestamp:
- 08/07/08 22:49:56 (4 months ago)
- Files:
-
- nethorus/app/controllers/application.rb (added)
- nethorus/app/controllers/application_controller.rb (added)
- nethorus/lib/nethorus_functions.rb (added)
- nethorus/test/functional/common_functions_test.rb (moved) (moved from nethorus/test/unit/application_common_functions_test.rb) (2 diffs, 1 prop)
- nethorus/test/unit/application_helper_test.rb (added)
- nethorus/test/unit/bridge_test.rb (modified) (1 diff)
- nethorus/test/unit/device_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nethorus/test/functional/common_functions_test.rb
- Property svn:mergeinfo set
r182 r216 22 22 =begin rdoc 23 23 24 Unit tests for applicationcommon functions.24 Functional tests for common functions. 25 25 26 26 =end 27 27 28 28 require File.dirname(__FILE__) + '/../test_helper' 29 require 'nethorus_functions.rb' 29 30 30 class ApplicationCommonFunctionsTest < ActiveSupport::TestCase31 class CommonFunctionsTest < ActiveSupport::TestCase 31 32 32 33 # Test the purify_mac_address function, which should convert a hexadecimal 33 34 # string, perhaps padded with spaces, dots or dashes, in to a 12-character 34 35 # upper-case hexadecimal string. 35 36 def purify_mac_address_test36 37 def test_purify_mac_address 37 38 38 39 test_address = purify_mac_address("000000000000") … … 74 75 end 75 76 77 78 # Test the validate_ip_address function. 79 80 def test_validate_ip_address 81 82 assert(validate_ip_address("0.0.0.0"), "The IPv4 address 0.0.0.0 should be valid") 83 assert(validate_ip_address("0.0.0.1"), "The IPv4 address 0.0.0.1 should be valid") 84 assert(validate_ip_address("255.255.255.254"), "The IPv4 address 255.255.255.254 should be valid") 85 assert(validate_ip_address("255.255.255.255"), "The IPv4 address 255.255.255.255 should be valid") 86 87 assert(!validate_ip_address("0.0.0.-1"), "The IPv4 address 0.0.0.-1 should not be valid") 88 assert(!validate_ip_address("0.0.-1.0"), "The IPv4 address 0.0.-1.0 should not be valid") 89 assert(!validate_ip_address("0.-1.0.0"), "The IPv4 address 0.-1.0.0 should not be valid") 90 assert(!validate_ip_address("-1.0.0.0"), "The IPv4 address -1.0.0.0 should not be valid") 91 92 assert(validate_ip_address("0"), "The IPv4 address 0 should be valid") 93 assert(!validate_ip_address("0.0"), "The IPv4 address 0.0 should not be valid") 94 assert(!validate_ip_address("0.0.0"), "The IPv4 address 0.0.0 should not be valid") 95 assert(!validate_ip_address("0.0.0.0.0"), "The IPv4 address 0.0.0.0.0 should not be valid") 96 97 end 98 76 99 end nethorus/test/unit/bridge_test.rb
r183 r216 254 254 255 255 256 # Test the bridge hack for devices which return values in seconds rather than centi-seconds 257 258 def test_bridge_values_in_seconds_not_centiseconds_hack 259 260 bridge = @device.create_bridge 261 262 bridge.dot1d_base_bridge_address = "80001234567890AB" 263 bridge.dot1d_base_num_ports = 1 264 bridge.dot1d_base_type = "transparent-only" 265 bridge.dot1d_stp_protocol_specification = "ieee8021d" 266 bridge.dot1d_stp_priority = 32768 267 bridge.dot1d_stp_designated_root = "80001234567890AB" 268 bridge.dot1d_stp_root_cost = 100 269 bridge.dot1d_stp_root_port = 50 270 bridge.dot1d_stp_max_age = 2000 271 bridge.dot1d_stp_hello_time = 200 272 bridge.dot1d_stp_hold_time = 200 273 bridge.dot1d_stp_forward_delay = 1500 274 bridge.dot1d_stp_bridge_max_age = 2000 275 bridge.dot1d_stp_bridge_hello_time = 200 276 bridge.dot1d_stp_bridge_forward_delay = 1500 277 278 assert(bridge.valid?, "A new Bridge should be valid with the minimum required attributes set") 279 280 281 # Test recalculation for low values of dot1d_stp_max_age 282 283 bridge.dot1d_stp_max_age = 1 284 assert(bridge.valid? && bridge_dot1d_stp_max_age = 100, "Specifying dot1d_stp_max_age =< 50 should multiply the value by 100 (centisecond hack) - we used 1") 285 286 bridge.dot1d_stp_max_age = 50 287 assert(bridge.valid? && bridge_dot1d_stp_max_age = 5000, "Specifying dot1d_stp_max_age =< 50 should multiply the value by 100 (centisecond hack) - we used 50") 288 289 bridge.dot1d_stp_max_age = 51 290 assert(bridge.valid? && bridge_dot1d_stp_max_age = 51, "Specifying dot1d_stp_max_age =< 50 should multiply the value by 100 (centisecond hack) - we used 51") 291 292 293 # Test recalculation for low values of dot1d_stp_hello_time 294 295 bridge.dot1d_stp_hello_time = 1 296 assert(bridge.valid? && bridge_dot1d_stp_hello_time = 100, "Specifying dot1d_stp_hello_time =< 50 should multiply the value by 100 (centisecond hack) - we used 1") 297 298 bridge.dot1d_stp_hello_time = 50 299 assert(bridge.valid? && bridge_dot1d_stp_hello_time = 5000, "Specifying dot1d_stp_hello_time =< 50 should multiply the value by 100 (centisecond hack) - we used 50") 300 301 bridge.dot1d_stp_hello_time = 51 302 assert(bridge.valid? && bridge_dot1d_stp_hello_time = 51, "Specifying dot1d_stp_hello_time =< 50 should multiply the value by 100 (centisecond hack) - we used 51") 303 304 end 305 306 256 307 # Test the device/bridge relationship 257 308 nethorus/test/unit/device_test.rb
r168 r216 210 210 211 211 device = Device.new 212 device.hostname = " xample"212 device.hostname = "example" 213 213 device.ipv4_address = "127.0.0.1" 214 214 … … 225 225 assert(device.valid?, "A device should be valid with a nil SNMP version") 226 226 227 device.snmp_version = 4 228 assert(!device.valid?, "A device should not be valid with an SNMP version of 4") 229 230 device.snmp_version = "garbage" 231 assert(!device.valid?, "A device should not be valid with an SNMP version of 'garbage'") 232 227 233 end 228 234
