deveo-ruby-ldapserver 0.5.2
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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/COPYING +27 -0
- data/ChangeLog +83 -0
- data/Gemfile +4 -0
- data/README +222 -0
- data/Rakefile +1 -0
- data/examples/README +89 -0
- data/examples/mkcert.rb +31 -0
- data/examples/rbslapd1.rb +111 -0
- data/examples/rbslapd2.rb +161 -0
- data/examples/rbslapd2.sql +11 -0
- data/examples/rbslapd3.rb +172 -0
- data/examples/speedtest.rb +37 -0
- data/lib/ldap/server.rb +4 -0
- data/lib/ldap/server/connection.rb +251 -0
- data/lib/ldap/server/filter.rb +223 -0
- data/lib/ldap/server/match.rb +283 -0
- data/lib/ldap/server/operation.rb +492 -0
- data/lib/ldap/server/preforkserver.rb +92 -0
- data/lib/ldap/server/result.rb +71 -0
- data/lib/ldap/server/schema.rb +592 -0
- data/lib/ldap/server/server.rb +104 -0
- data/lib/ldap/server/syntax.rb +235 -0
- data/lib/ldap/server/tcpserver.rb +89 -0
- data/lib/ldap/server/util.rb +88 -0
- data/lib/ldap/server/version.rb +5 -0
- data/ruby-ldapserver.gemspec +22 -0
- data/test/core.schema +582 -0
- data/test/encoding_test.rb +323 -0
- data/test/filter_test.rb +107 -0
- data/test/match_test.rb +59 -0
- data/test/schema_test.rb +113 -0
- data/test/syntax_test.rb +40 -0
- data/test/test_helper.rb +2 -0
- data/test/util_test.rb +47 -0
- metadata +117 -0
data/test/schema_test.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'ldap/server/schema'
|
3
|
+
require 'ldap/server/match'
|
4
|
+
|
5
|
+
class SchemaTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_parse_attr
|
8
|
+
attr = <<ATTR
|
9
|
+
( 2.5.4.3 NAME 'cn' OBSOLETE EQUALITY 1.2.3 ORDERING 4.5.678 SUBSTR 9.1.1 SYNTAX 4.3.2{58} SINGLE-VALUE COLLECTIVE NO-USER-MODIFICATION USAGE userApplications )
|
10
|
+
ATTR
|
11
|
+
a = LDAP::Server::Schema::AttributeType.new(attr)
|
12
|
+
assert_equal("2.5.4.3", a.oid)
|
13
|
+
assert_equal("cn", a.name)
|
14
|
+
assert_equal(["cn"], a.names)
|
15
|
+
assert(a.obsolete)
|
16
|
+
assert_equal("1.2.3", a.equality)
|
17
|
+
assert_equal("4.5.678", a.ordering)
|
18
|
+
assert_equal("9.1.1", a.substr)
|
19
|
+
assert_equal("4.3.2", a.syntax)
|
20
|
+
assert_equal(58, a.maxlen)
|
21
|
+
assert(a.singlevalue)
|
22
|
+
assert(a.collective)
|
23
|
+
assert(a.nousermod)
|
24
|
+
assert_equal(:userApplications, a.usage)
|
25
|
+
assert_equal(attr.chomp, a.to_def)
|
26
|
+
|
27
|
+
attr = <<ATTR
|
28
|
+
( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC2256: common name(s) for which the entity is known by' SUP name )
|
29
|
+
ATTR
|
30
|
+
a = LDAP::Server::Schema::AttributeType.new(attr)
|
31
|
+
assert_equal("2.5.4.3", a.oid)
|
32
|
+
assert_equal("cn", a.name)
|
33
|
+
assert_equal(["cn", "commonName"], a.names)
|
34
|
+
assert_equal("RFC2256: common name(s) for which the entity is known by", a.desc)
|
35
|
+
assert(! a.obsolete)
|
36
|
+
assert_equal("name", a.sup)
|
37
|
+
assert(! a.singlevalue)
|
38
|
+
assert(! a.collective)
|
39
|
+
assert(! a.nousermod)
|
40
|
+
assert_equal(attr.chomp, a.to_def)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_parse_objectclass
|
44
|
+
oc = <<OC
|
45
|
+
( 0.9.2342.19200300.100.4.19 NAME 'simpleSecurityObject' DESC 'RFC1274: simple security object' SUP top AUXILIARY MUST userPassword )
|
46
|
+
OC
|
47
|
+
a = LDAP::Server::Schema::ObjectClass.new(oc)
|
48
|
+
assert_equal("0.9.2342.19200300.100.4.19", a.oid)
|
49
|
+
assert_equal("simpleSecurityObject", a.name)
|
50
|
+
assert_equal(["simpleSecurityObject"], a.names)
|
51
|
+
assert(! a.obsolete)
|
52
|
+
assert_equal("RFC1274: simple security object", a.desc)
|
53
|
+
assert_equal(["top"], a.sup)
|
54
|
+
assert_equal(:auxiliary, a.struct)
|
55
|
+
assert_equal(["userPassword"], a.must)
|
56
|
+
assert_equal([], a.may)
|
57
|
+
assert_equal(oc.chomp, a.to_def)
|
58
|
+
|
59
|
+
oc = <<OC
|
60
|
+
( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )
|
61
|
+
OC
|
62
|
+
a = LDAP::Server::Schema::ObjectClass.new(oc)
|
63
|
+
assert_equal("2.5.6.6", a.oid)
|
64
|
+
assert_equal("person", a.name)
|
65
|
+
assert_equal(["person"], a.names)
|
66
|
+
assert(! a.obsolete)
|
67
|
+
assert_equal("RFC2256: a person", a.desc)
|
68
|
+
assert_equal(["top"], a.sup)
|
69
|
+
assert_equal(:structural, a.struct)
|
70
|
+
assert_equal(["sn", "cn"], a.must)
|
71
|
+
assert_equal(["userPassword","telephoneNumber","seeAlso","description"], a.may)
|
72
|
+
assert_equal(oc.chomp, a.to_def)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_loadschema
|
76
|
+
s = LDAP::Server::Schema.new
|
77
|
+
s.load_system
|
78
|
+
s.load_file(File.dirname(__FILE__) + "/core.schema")
|
79
|
+
s.resolve_oids
|
80
|
+
a = s.find_attrtype("objectclass")
|
81
|
+
assert_equal("objectClass", a.name)
|
82
|
+
a = s.find_attrtype("COMMONNAME")
|
83
|
+
assert_equal(LDAP::Server::Schema::AttributeType, a.class)
|
84
|
+
assert_equal("caseIgnoreMatch", a.equality.to_s)
|
85
|
+
assert_equal(LDAP::Server::MatchingRule, a.equality.class)
|
86
|
+
assert_equal("caseIgnoreSubstringsMatch", a.substr.to_s)
|
87
|
+
assert_equal(LDAP::Server::MatchingRule, a.substr.class)
|
88
|
+
assert_equal("1.3.6.1.4.1.1466.115.121.1.15", a.syntax.to_s)
|
89
|
+
assert_equal(LDAP::Server::Syntax, a.syntax.class)
|
90
|
+
assert_equal("cn", a.name)
|
91
|
+
a = s.find_attrtype("COUNTRYname")
|
92
|
+
assert_equal("c", a.name)
|
93
|
+
# I modified core.schema so that countryName has the appropriate syntax
|
94
|
+
assert(a.syntax.match("GB"))
|
95
|
+
assert(!a.syntax.match("ABC"))
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_backwards_api
|
99
|
+
s = LDAP::Server::Schema.new
|
100
|
+
s.load_system
|
101
|
+
assert_equal(['subschema','OpenLDAProotDSE','referral','alias','extensibleObject','top'].sort,
|
102
|
+
s.names('objectClasses').sort)
|
103
|
+
assert_equal(['dITStructureRules','nameForms','ditContentRules','objectClasses','attributeTypes','matchingRules','matchingRuleUse'],
|
104
|
+
s.attr('subschema', 'may'))
|
105
|
+
assert_equal([], s.attr('subschema', 'must'))
|
106
|
+
assert_equal(nil, s.attr('foo', 'must'))
|
107
|
+
assert_equal(['top'], s.sup('extensibleObject'))
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_validate
|
111
|
+
# FIXME
|
112
|
+
end
|
113
|
+
end
|
data/test/syntax_test.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'ldap/server/syntax'
|
3
|
+
|
4
|
+
class SyntaxTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_integer
|
7
|
+
s = LDAP::Server::Syntax.find("1.3.6.1.4.1.1466.115.121.1.27")
|
8
|
+
assert_equal(LDAP::Server::Syntax, s.class)
|
9
|
+
assert_equal("Integer", s.desc)
|
10
|
+
assert_equal("( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )", s.to_def)
|
11
|
+
assert(!s.nhr)
|
12
|
+
assert(s.match("123"))
|
13
|
+
assert(!s.match("12A"))
|
14
|
+
assert_equal(123, s.value_from_s("123"))
|
15
|
+
assert_equal("456", s.value_to_s(456))
|
16
|
+
assert_equal("789", s.value_to_s("789"))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_unknown
|
20
|
+
s = LDAP::Server::Syntax.find("1.4.7.1")
|
21
|
+
assert_equal(LDAP::Server::Syntax, s.class)
|
22
|
+
assert_equal("1.4.7.1", s.oid)
|
23
|
+
assert_equal("1.4.7.1", s.to_s)
|
24
|
+
assert_equal("( 1.4.7.1 )", s.to_def)
|
25
|
+
assert_equal("false", s.value_to_s(false)) # generic value_to_s
|
26
|
+
assert_equal("true", s.value_from_s("true")) # generic value_from_s
|
27
|
+
assert(s.match("123")) # match anything
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_nil
|
31
|
+
s = LDAP::Server::Syntax.find(nil)
|
32
|
+
assert_equal(nil, s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_from_def
|
36
|
+
s = LDAP::Server::Syntax.from_def("( 1.2.3 DESC 'foobar' )")
|
37
|
+
assert_equal("1.2.3", s.oid)
|
38
|
+
assert_equal("foobar", s.desc)
|
39
|
+
end
|
40
|
+
end
|
data/test/test_helper.rb
ADDED
data/test/util_test.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'ldap/server/util'
|
3
|
+
|
4
|
+
class TestLdapUtil < Test::Unit::TestCase
|
5
|
+
def test_split_dn
|
6
|
+
# examples from RFC 2253
|
7
|
+
assert_equal(
|
8
|
+
[{"cn"=>"Steve Kille"},{"o"=>"Isode Limited"},{"c"=>"GB"}],
|
9
|
+
LDAP::Server::Operation.split_dn("CN=Steve Kille , O=Isode Limited;C=GB")
|
10
|
+
)
|
11
|
+
assert_equal(
|
12
|
+
[{"ou"=>"Sales","cn"=>"J. Smith"},{"o"=>"Widget Inc."},{"c"=>"US"}],
|
13
|
+
LDAP::Server::Operation.split_dn("OU=Sales+CN=J. Smith,O=Widget Inc.,C=US")
|
14
|
+
)
|
15
|
+
assert_equal(
|
16
|
+
[{"cn"=>"L. Eagle"},{"o"=>"Sue, Grabbit and Runn"},{"c"=>"GB"}],
|
17
|
+
LDAP::Server::Operation.split_dn("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB")
|
18
|
+
)
|
19
|
+
assert_equal(
|
20
|
+
[{"cn"=>"Before\rAfter"},{"o"=>"Test"},{"c"=>"GB"}],
|
21
|
+
LDAP::Server::Operation.split_dn("CN=Before\\0DAfter,O=Test,C=GB")
|
22
|
+
)
|
23
|
+
res = LDAP::Server::Operation.split_dn("SN=Lu\\C4\\8Di\\C4\\87")
|
24
|
+
assert_equal([{"sn"=>"Lu\xc4\x8di\xc4\x87"}], res)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_join_dn
|
28
|
+
# examples from RFC 2253
|
29
|
+
assert_equal(
|
30
|
+
"cn=Steve Kille,o=Isode Limited,c=GB",
|
31
|
+
LDAP::Server::Operation.join_dn([{"cn"=>"Steve Kille"},{"o"=>"Isode Limited"},{"c"=>"GB"}])
|
32
|
+
)
|
33
|
+
# These are equivalent
|
34
|
+
d1 = "ou=Sales+cn=J. Smith,o=Widget Inc.,c=US"
|
35
|
+
d2 = "cn=J. Smith+ou=Sales,o=Widget Inc.,c=US"
|
36
|
+
assert_equal(d1,
|
37
|
+
LDAP::Server::Operation.join_dn([[["ou","Sales"],["cn","J. Smith"]],[["o","Widget Inc."]],["c","US"]])
|
38
|
+
)
|
39
|
+
r = LDAP::Server::Operation.join_dn([{"ou"=>"Sales","cn"=>"J. Smith"},{"o"=>"Widget Inc."},{"c"=>"US"}])
|
40
|
+
assert(r == d1 || r == d2, "got #{r.inspect}, expected #{d1.inspect} or #{d2.inspect}")
|
41
|
+
assert_equal(
|
42
|
+
"cn=L. Eagle,o=Sue\\, Grabbit and Runn,c=GB",
|
43
|
+
LDAP::Server::Operation.join_dn([{"cn"=>"L. Eagle"},{"o"=>"Sue, Grabbit and Runn"},{"c"=>"GB"}])
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deveo-ruby-ldapserver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Candler
|
8
|
+
- Juha-Pekka Laiho
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
description: ruby-ldapserver is a lightweight, pure-Ruby skeleton for implementing
|
43
|
+
LDAP server applications.
|
44
|
+
email: "<jp@deveo.com"
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- COPYING
|
51
|
+
- ChangeLog
|
52
|
+
- Gemfile
|
53
|
+
- README
|
54
|
+
- Rakefile
|
55
|
+
- examples/README
|
56
|
+
- examples/mkcert.rb
|
57
|
+
- examples/rbslapd1.rb
|
58
|
+
- examples/rbslapd2.rb
|
59
|
+
- examples/rbslapd2.sql
|
60
|
+
- examples/rbslapd3.rb
|
61
|
+
- examples/speedtest.rb
|
62
|
+
- lib/ldap/server.rb
|
63
|
+
- lib/ldap/server/connection.rb
|
64
|
+
- lib/ldap/server/filter.rb
|
65
|
+
- lib/ldap/server/match.rb
|
66
|
+
- lib/ldap/server/operation.rb
|
67
|
+
- lib/ldap/server/preforkserver.rb
|
68
|
+
- lib/ldap/server/result.rb
|
69
|
+
- lib/ldap/server/schema.rb
|
70
|
+
- lib/ldap/server/server.rb
|
71
|
+
- lib/ldap/server/syntax.rb
|
72
|
+
- lib/ldap/server/tcpserver.rb
|
73
|
+
- lib/ldap/server/util.rb
|
74
|
+
- lib/ldap/server/version.rb
|
75
|
+
- ruby-ldapserver.gemspec
|
76
|
+
- test/core.schema
|
77
|
+
- test/encoding_test.rb
|
78
|
+
- test/filter_test.rb
|
79
|
+
- test/match_test.rb
|
80
|
+
- test/schema_test.rb
|
81
|
+
- test/syntax_test.rb
|
82
|
+
- test/test_helper.rb
|
83
|
+
- test/util_test.rb
|
84
|
+
homepage: https://github.com/Deveo/ruby-ldapserver
|
85
|
+
licenses: []
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options:
|
89
|
+
- "--main"
|
90
|
+
- README.txt
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: A pure-Ruby framework for building LDAP servers
|
109
|
+
test_files:
|
110
|
+
- test/core.schema
|
111
|
+
- test/encoding_test.rb
|
112
|
+
- test/filter_test.rb
|
113
|
+
- test/match_test.rb
|
114
|
+
- test/schema_test.rb
|
115
|
+
- test/syntax_test.rb
|
116
|
+
- test/test_helper.rb
|
117
|
+
- test/util_test.rb
|