ruby-net-ldap 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ # $Id: testldif.rb 61 2006-04-18 20:55:55Z blackhedd $
2
+ #
3
+ #
4
+
5
+
6
+ $:.unshift "lib"
7
+
8
+ require 'test/unit'
9
+
10
+ require 'net/ldap'
11
+ require 'net/ldif'
12
+
13
+ require 'sha1'
14
+ require 'base64'
15
+
16
+ class TestLdif < Test::Unit::TestCase
17
+
18
+ TestLdifFilename = "tests/testdata.ldif"
19
+
20
+ def test_empty_ldif
21
+ ds = Net::LDAP::Dataset::read_ldif( StringIO.new )
22
+ assert_equal( true, ds.empty? )
23
+ end
24
+
25
+ def test_ldif_with_comments
26
+ str = ["# Hello from LDIF-land", "# This is an unterminated comment"]
27
+ io = StringIO.new( str[0] + "\r\n" + str[1] )
28
+ ds = Net::LDAP::Dataset::read_ldif( io )
29
+ assert_equal( str, ds.comments )
30
+ end
31
+
32
+ def test_ldif_with_password
33
+ psw = "goldbricks"
34
+ hashed_psw = "{SHA}" + Base64::encode64( SHA1.new(psw).digest ).chomp
35
+
36
+ ldif_encoded = Base64::encode64( hashed_psw ).chomp
37
+ ds = Net::LDAP::Dataset::read_ldif( StringIO.new( "dn: Goldbrick\r\nuserPassword:: #{ldif_encoded}\r\n\r\n" ))
38
+ recovered_psw = ds["Goldbrick"][:userpassword].shift
39
+ assert_equal( hashed_psw, recovered_psw )
40
+ end
41
+
42
+ def test_ldif_with_continuation_lines
43
+ ds = Net::LDAP::Dataset::read_ldif( StringIO.new( "dn: abcdefg\r\n hijklmn\r\n\r\n" ))
44
+ assert_equal( true, ds.has_key?( "abcdefg hijklmn" ))
45
+ end
46
+
47
+ # TODO, INADEQUATE. We need some more tests
48
+ # to verify the content.
49
+ def test_ldif
50
+ File.open( TestLdifFilename, "r" ) {|f|
51
+ ds = Net::LDAP::Dataset::read_ldif( f )
52
+ assert_equal( 13, ds.length )
53
+ }
54
+ end
55
+
56
+ # TODO, need some tests.
57
+ # Must test folded lines and base64-encoded lines as well as normal ones.
58
+ def test_to_ldif
59
+ File.open( TestLdifFilename, "r" ) {|f|
60
+ ds = Net::LDAP::Dataset::read_ldif( f )
61
+ ds.to_ldif
62
+ assert_equal( true, false ) # REMOVE WHEN WE HAVE SOME TESTS HERE.
63
+ }
64
+ end
65
+
66
+
67
+ end
68
+
69
+
@@ -0,0 +1,28 @@
1
+ # $Id: testpsw.rb 72 2006-04-24 21:58:14Z blackhedd $
2
+ #
3
+ #
4
+
5
+
6
+ $:.unshift "lib"
7
+
8
+ require 'net/ldap'
9
+ require 'stringio'
10
+
11
+
12
+ class TestPassword < Test::Unit::TestCase
13
+
14
+ def setup
15
+ end
16
+
17
+
18
+ def test_psw
19
+ assert_equal( "{MD5}xq8jwrcfibi0sZdZYNkSng==", Net::LDAP::Password.generate( :md5, "cashflow" ))
20
+ assert_equal( "{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=", Net::LDAP::Password.generate( :sha, "cashflow" ))
21
+ end
22
+
23
+
24
+
25
+
26
+ end
27
+
28
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: ruby-net-ldap
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2006-05-01 00:00:00 -04:00
8
+ summary: A pure Ruby LDAP client library.
9
+ require_paths:
10
+ - lib
11
+ email: garbagecat10@gmail.com
12
+ homepage: http://rubyforge.org/projects/net-ldap
13
+ rubyforge_project: net-ldap
14
+ description: Net::LDAP is an LDAP support library written in pure Ruby. It supports all LDAP client features, and a subset of server features as well.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Francis Cianfrocca
30
+ files:
31
+ - README
32
+ - LICENCE
33
+ - ChangeLog
34
+ - COPYING
35
+ - tests/testpsw.rb
36
+ - tests/testem.rb
37
+ - tests/testdata.ldif
38
+ - tests/testber.rb
39
+ - tests/testldif.rb
40
+ - tests/testldap.rb
41
+ - lib/net
42
+ - lib/net/ber.rb
43
+ - lib/net/ldap.rb
44
+ - lib/net/ldap
45
+ - lib/net/ldif.rb
46
+ - lib/net/ldap/filter.rb
47
+ - lib/net/ldap/entry.rb
48
+ - lib/net/ldap/psw.rb
49
+ - lib/net/ldap/dataset.rb
50
+ - lib/net/ldap/pdu.rb
51
+ test_files:
52
+ - tests/testem.rb
53
+ rdoc_options:
54
+ - --title
55
+ - Net::LDAP
56
+ - --main
57
+ - README
58
+ - --line-numbers
59
+ extra_rdoc_files:
60
+ - README
61
+ - ChangeLog
62
+ - LICENCE
63
+ - COPYING
64
+ executables: []
65
+
66
+ extensions: []
67
+
68
+ requirements: []
69
+
70
+ dependencies: []
71
+