Mercurial > hg > soundsoftware-site
comparison vendor/plugins/ruby-net-ldap-0.0.4/tests/testber.rb @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # $Id: testber.rb 57 2006-04-18 00:18:48Z blackhedd $ | |
2 # | |
3 # | |
4 | |
5 | |
6 $:.unshift "lib" | |
7 | |
8 require 'net/ldap' | |
9 require 'stringio' | |
10 | |
11 | |
12 class TestBer < Test::Unit::TestCase | |
13 | |
14 def setup | |
15 end | |
16 | |
17 # TODO: Add some much bigger numbers | |
18 # 5000000000 is a Bignum, which hits different code. | |
19 def test_ber_integers | |
20 assert_equal( "\002\001\005", 5.to_ber ) | |
21 assert_equal( "\002\002\203t", 500.to_ber ) | |
22 assert_equal( "\002\003\203\206P", 50000.to_ber ) | |
23 assert_equal( "\002\005\222\320\227\344\000", 5000000000.to_ber ) | |
24 end | |
25 | |
26 def test_ber_parsing | |
27 assert_equal( 6, "\002\001\006".read_ber( Net::LDAP::AsnSyntax )) | |
28 assert_equal( "testing", "\004\007testing".read_ber( Net::LDAP::AsnSyntax )) | |
29 end | |
30 | |
31 | |
32 def test_ber_parser_on_ldap_bind_request | |
33 s = StringIO.new "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus" | |
34 assert_equal( [1, [3, "Administrator", "ad_is_bogus"]], s.read_ber( Net::LDAP::AsnSyntax )) | |
35 end | |
36 | |
37 | |
38 | |
39 | |
40 end | |
41 | |
42 |