annotate .svn/pristine/5b/5ba499ead951b0f7092a76c82d09ab18e9ef0b47.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

Merge from branch "live"
author Chris Cannam
date Tue, 09 Sep 2014 09:34:53 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 # $Id: testber.rb 57 2006-04-18 00:18:48Z blackhedd $
Chris@909 2 #
Chris@909 3 #
Chris@909 4
Chris@909 5
Chris@909 6 $:.unshift "lib"
Chris@909 7
Chris@909 8 require 'net/ldap'
Chris@909 9 require 'stringio'
Chris@909 10
Chris@909 11
Chris@909 12 class TestBer < Test::Unit::TestCase
Chris@909 13
Chris@909 14 def setup
Chris@909 15 end
Chris@909 16
Chris@909 17 # TODO: Add some much bigger numbers
Chris@909 18 # 5000000000 is a Bignum, which hits different code.
Chris@909 19 def test_ber_integers
Chris@909 20 assert_equal( "\002\001\005", 5.to_ber )
Chris@909 21 assert_equal( "\002\002\203t", 500.to_ber )
Chris@909 22 assert_equal( "\002\003\203\206P", 50000.to_ber )
Chris@909 23 assert_equal( "\002\005\222\320\227\344\000", 5000000000.to_ber )
Chris@909 24 end
Chris@909 25
Chris@909 26 def test_ber_parsing
Chris@909 27 assert_equal( 6, "\002\001\006".read_ber( Net::LDAP::AsnSyntax ))
Chris@909 28 assert_equal( "testing", "\004\007testing".read_ber( Net::LDAP::AsnSyntax ))
Chris@909 29 end
Chris@909 30
Chris@909 31
Chris@909 32 def test_ber_parser_on_ldap_bind_request
Chris@909 33 s = StringIO.new "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus"
Chris@909 34 assert_equal( [1, [3, "Administrator", "ad_is_bogus"]], s.read_ber( Net::LDAP::AsnSyntax ))
Chris@909 35 end
Chris@909 36
Chris@909 37
Chris@909 38
Chris@909 39
Chris@909 40 end
Chris@909 41
Chris@909 42