test/test_snmp.rb in net-ldap-0.6.1 vs test/test_snmp.rb in net-ldap-0.7.0
- old
+ new
@@ -2,13 +2,18 @@
require 'common'
require 'net/snmp'
class TestSnmp < Test::Unit::TestCase
- SnmpGetRequest = "0'\002\001\000\004\006public\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000"
- SnmpGetResponse = "0+\002\001\000\004\006public\242\036\002\002'\017\002\001\000\002\001\0000\0220\020\006\b+\006\001\002\001\001\001\000\004\004test"
+ def self.raw_string(s)
+ # Conveniently, String#b only needs to be called when it exists
+ s.respond_to?(:b) ? s.b : s
+ end
- SnmpGetRequestXXX = "0'\002\001\000\004\006xxxxxx\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000"
+ SnmpGetRequest = raw_string("0'\002\001\000\004\006public\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000")
+ SnmpGetResponse = raw_string("0+\002\001\000\004\006public\242\036\002\002'\017\002\001\000\002\001\0000\0220\020\006\b+\006\001\002\001\001\001\000\004\004test")
+
+ SnmpGetRequestXXX = raw_string("0'\002\001\000\004\006xxxxxx\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000")
def test_invalid_packet
data = "xxxx"
assert_raise(Net::BER::BerError) {
ary = data.read_ber(Net::SNMP::AsnSyntax)