ruby-activeldap 0.8.2 → 0.8.3
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.
- data/test/test_adapter.rb +17 -0
- data/test/test_associations.rb +19 -0
- data/test/test_attributes.rb +2 -1
- data/test/test_base.rb +28 -1
- data/test/test_base_per_instance.rb +2 -1
- data/test/test_callback.rb +2 -2
- data/test/test_connection.rb +2 -1
- data/test/test_connection_per_dn.rb +81 -0
- data/test/test_dn.rb +3 -2
- data/test/test_find.rb +35 -1
- data/test/test_object_class.rb +12 -1
- data/test/test_reflection.rb +16 -10
- data/test/test_schema.rb +141 -2
- data/test/test_user.rb +14 -4
- metadata +7 -104
- data/CHANGES +0 -397
- data/COPYING +0 -340
- data/LICENSE +0 -58
- data/Manifest.txt +0 -99
- data/README +0 -85
- data/Rakefile +0 -70
- data/TODO +0 -23
- data/benchmark/bench-al.rb +0 -152
- data/examples/config.yaml.example +0 -5
- data/examples/example.der +0 -0
- data/examples/example.jpg +0 -0
- data/examples/groupadd +0 -41
- data/examples/groupdel +0 -35
- data/examples/groupls +0 -49
- data/examples/groupmod +0 -42
- data/examples/lpasswd +0 -55
- data/examples/objects/group.rb +0 -13
- data/examples/objects/ou.rb +0 -4
- data/examples/objects/user.rb +0 -20
- data/examples/ouadd +0 -38
- data/examples/useradd +0 -45
- data/examples/useradd-binary +0 -50
- data/examples/userdel +0 -34
- data/examples/userls +0 -50
- data/examples/usermod +0 -42
- data/examples/usermod-binary-add +0 -47
- data/examples/usermod-binary-add-time +0 -51
- data/examples/usermod-binary-del +0 -48
- data/examples/usermod-lang-add +0 -43
- data/lib/active_ldap.rb +0 -964
- data/lib/active_ldap/adapter/base.rb +0 -461
- data/lib/active_ldap/adapter/ldap.rb +0 -232
- data/lib/active_ldap/adapter/ldap_ext.rb +0 -69
- data/lib/active_ldap/adapter/net_ldap.rb +0 -288
- data/lib/active_ldap/adapter/net_ldap_ext.rb +0 -29
- data/lib/active_ldap/association/belongs_to.rb +0 -40
- data/lib/active_ldap/association/belongs_to_many.rb +0 -39
- data/lib/active_ldap/association/collection.rb +0 -80
- data/lib/active_ldap/association/has_many.rb +0 -40
- data/lib/active_ldap/association/has_many_wrap.rb +0 -55
- data/lib/active_ldap/association/proxy.rb +0 -89
- data/lib/active_ldap/associations.rb +0 -162
- data/lib/active_ldap/attributes.rb +0 -203
- data/lib/active_ldap/base.rb +0 -1510
- data/lib/active_ldap/callbacks.rb +0 -19
- data/lib/active_ldap/command.rb +0 -46
- data/lib/active_ldap/configuration.rb +0 -106
- data/lib/active_ldap/connection.rb +0 -142
- data/lib/active_ldap/distinguished_name.rb +0 -246
- data/lib/active_ldap/ldap_error.rb +0 -74
- data/lib/active_ldap/object_class.rb +0 -74
- data/lib/active_ldap/schema.rb +0 -299
- data/lib/active_ldap/timeout.rb +0 -75
- data/lib/active_ldap/timeout_stub.rb +0 -17
- data/lib/active_ldap/user_password.rb +0 -92
- data/lib/active_ldap/validations.rb +0 -76
- data/rails/plugin/active_ldap/README +0 -54
- data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +0 -7
- data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +0 -21
- data/rails/plugin/active_ldap/init.rb +0 -12
- data/test/TODO +0 -2
- data/test/al-test-utils.rb +0 -381
- data/test/command.rb +0 -62
- data/test/config.yaml.sample +0 -6
- data/test/run-test.rb +0 -29
- data/test/test-unit-ext.rb +0 -2
- data/test/test-unit-ext/always-show-result.rb +0 -28
- data/test/test-unit-ext/priority.rb +0 -163
data/test/test_adapter.rb
CHANGED
@@ -12,6 +12,17 @@ class TestAdapter < Test::Unit::TestCase
|
|
12
12
|
priority :must
|
13
13
|
|
14
14
|
priority :normal
|
15
|
+
def test_filter_with_escaped_character
|
16
|
+
assert_parse_filter("(uid=Alice\\28Bob)", {:uid => "Alice(Bob"})
|
17
|
+
assert_parse_filter("(uid=Alice\\29Bob)", {:uid => "Alice)Bob"})
|
18
|
+
assert_parse_filter("(uid=Alice\\29Bob\\28)", {:uid => "Alice)Bob("})
|
19
|
+
assert_parse_filter("(uid=Alice\\28\\29Bob)", {:uid => "Alice()Bob"})
|
20
|
+
assert_parse_filter("(uid=Alice*Bob)", {:uid => "Alice*Bob"})
|
21
|
+
assert_parse_filter("(uid=Alice\\2ABob)", {:uid => "Alice**Bob"})
|
22
|
+
assert_parse_filter("(uid=Alice\\2A*\\5CBob)", {:uid => "Alice***\\Bob"})
|
23
|
+
assert_parse_filter("(uid=Alice\\5C\\2A*Bob)", {:uid => "Alice\\***Bob"})
|
24
|
+
end
|
25
|
+
|
15
26
|
def test_empty_filter
|
16
27
|
assert_parse_filter(nil, nil)
|
17
28
|
assert_parse_filter(nil, "")
|
@@ -64,6 +75,12 @@ class TestAdapter < Test::Unit::TestCase
|
|
64
75
|
[:and,
|
65
76
|
[:and, {"gidNumber"=>["100001"]}],
|
66
77
|
[:or, {"uid"=>["temp-user1", "temp-user2"]}]])
|
78
|
+
assert_parse_filter("(&(gidNumber=100001)" +
|
79
|
+
"(objectClass=person)(objectClass=posixAccount))",
|
80
|
+
[:and,
|
81
|
+
[:or, ["gidNumber", "100001"]],
|
82
|
+
["objectClass", "person"],
|
83
|
+
["objectClass", "posixAccount"]])
|
67
84
|
end
|
68
85
|
|
69
86
|
def test_invalid_operator
|
data/test/test_associations.rb
CHANGED
@@ -4,6 +4,25 @@ class TestAssociations < Test::Unit::TestCase
|
|
4
4
|
include AlTestUtils
|
5
5
|
|
6
6
|
priority :must
|
7
|
+
|
8
|
+
priority :normal
|
9
|
+
def test_belongs_to_many_with_dn_key
|
10
|
+
@user_class.belongs_to :groups, :many => "memberUid", :foreign_key => "dn"
|
11
|
+
@user_class.set_associated_class(:groups, @group_class)
|
12
|
+
@group_class.has_many :members, :wrap => "memberUid", :primary_key => "dn"
|
13
|
+
@group_class.set_associated_class(:members, @user_class)
|
14
|
+
make_temporary_group do |group|
|
15
|
+
make_temporary_user do |user1,|
|
16
|
+
make_temporary_user do |user2,|
|
17
|
+
group.members = [user1, user2]
|
18
|
+
assert(group.save)
|
19
|
+
assert_equal([group.cn], user1.groups.collect(&:cn))
|
20
|
+
assert_equal([group.cn], user2.groups.collect(&:cn))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
7
26
|
def test_belongs_to_many_delete
|
8
27
|
make_temporary_group do |group1|
|
9
28
|
make_temporary_group do |group2|
|
data/test/test_attributes.rb
CHANGED
@@ -4,6 +4,8 @@ class TestAttributes < Test::Unit::TestCase
|
|
4
4
|
include AlTestUtils
|
5
5
|
|
6
6
|
priority :must
|
7
|
+
|
8
|
+
priority :normal
|
7
9
|
def test_to_real_attribute_name
|
8
10
|
user = @user_class.new("user")
|
9
11
|
assert_nil(user.__send__(:to_real_attribute_name, "objectclass"))
|
@@ -11,7 +13,6 @@ class TestAttributes < Test::Unit::TestCase
|
|
11
13
|
user.__send__(:to_real_attribute_name, "objectclass", true))
|
12
14
|
end
|
13
15
|
|
14
|
-
priority :normal
|
15
16
|
def test_protect_object_class_from_mass_assignment
|
16
17
|
classes = @user_class.required_classes + ["inetOrgPerson"]
|
17
18
|
user = @user_class.new(:uid => "XXX", :object_class => classes)
|
data/test/test_base.rb
CHANGED
@@ -4,6 +4,34 @@ class TestBase < Test::Unit::TestCase
|
|
4
4
|
include AlTestUtils
|
5
5
|
|
6
6
|
priority :must
|
7
|
+
|
8
|
+
priority :normal
|
9
|
+
def test_dn_attribute_per_instance
|
10
|
+
user = @user_class.new
|
11
|
+
assert_equal("uid", user.dn_attribute)
|
12
|
+
assert_nil(user.uid)
|
13
|
+
|
14
|
+
user.dn = "cn=xxx"
|
15
|
+
assert_equal("cn", user.dn_attribute)
|
16
|
+
assert_nil(user.uid)
|
17
|
+
assert_equal("xxx", user.cn)
|
18
|
+
assert_equal("cn=xxx,#{@user_class.base}", user.dn)
|
19
|
+
|
20
|
+
assert_equal("uid", @user_class.new.dn_attribute)
|
21
|
+
|
22
|
+
user.dn = "ZZZ"
|
23
|
+
assert_equal("cn", user.dn_attribute)
|
24
|
+
assert_nil(user.uid)
|
25
|
+
assert_equal("ZZZ", user.cn)
|
26
|
+
assert_equal("cn=ZZZ,#{@user_class.base}", user.dn)
|
27
|
+
|
28
|
+
user.dn = "uid=aaa"
|
29
|
+
assert_equal("uid", user.dn_attribute)
|
30
|
+
assert_equal("aaa", user.uid)
|
31
|
+
assert_equal("ZZZ", user.cn)
|
32
|
+
assert_equal("uid=aaa,#{@user_class.base}", user.dn)
|
33
|
+
end
|
34
|
+
|
7
35
|
def test_case_insensitive_nested_ou
|
8
36
|
ou_class("ou=Users").new("Sub").save!
|
9
37
|
make_temporary_user(:uid => "test-user,ou=SUB") do |user, password|
|
@@ -14,7 +42,6 @@ class TestBase < Test::Unit::TestCase
|
|
14
42
|
end
|
15
43
|
end
|
16
44
|
|
17
|
-
priority :normal
|
18
45
|
def test_nested_ou
|
19
46
|
make_ou("units")
|
20
47
|
units = ou_class("ou=units")
|
@@ -9,6 +9,8 @@ class TestBasePerInstance < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
priority :must
|
12
|
+
|
13
|
+
priority :normal
|
12
14
|
def test_loose_dn
|
13
15
|
user = @user_class.new("test-user , ou = Sub")
|
14
16
|
assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
|
@@ -17,7 +19,6 @@ class TestBasePerInstance < Test::Unit::TestCase
|
|
17
19
|
assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
|
18
20
|
end
|
19
21
|
|
20
|
-
priority :normal
|
21
22
|
def test_exists?
|
22
23
|
make_temporary_user(:uid => "test-user,ou=Sub") do |user, password|
|
23
24
|
assert(@user_class.exists?(user.uid))
|
data/test/test_callback.rb
CHANGED
@@ -4,6 +4,8 @@ class TestCallback < Test::Unit::TestCase
|
|
4
4
|
include AlTestUtils
|
5
5
|
|
6
6
|
priority :must
|
7
|
+
|
8
|
+
priority :normal
|
7
9
|
def test_callback_after_find_and_after_initialize
|
8
10
|
make_temporary_group do |group|
|
9
11
|
found_entries = []
|
@@ -30,6 +32,4 @@ class TestCallback < Test::Unit::TestCase
|
|
30
32
|
initialized_entries.collect {|g| g.cn}.sort)
|
31
33
|
end
|
32
34
|
end
|
33
|
-
|
34
|
-
priority :normal
|
35
35
|
end
|
data/test/test_connection.rb
CHANGED
@@ -14,6 +14,8 @@ class TestConnection < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
priority :must
|
17
|
+
|
18
|
+
priority :normal
|
17
19
|
def test_bind_format_check
|
18
20
|
connector = Class.new(ActiveLdap::Base)
|
19
21
|
assert(!connector.connected?)
|
@@ -30,7 +32,6 @@ class TestConnection < Test::Unit::TestCase
|
|
30
32
|
assert_equal("Unknown key(s): bind_format", exception.message)
|
31
33
|
end
|
32
34
|
|
33
|
-
priority :normal
|
34
35
|
def test_can_reconnect?
|
35
36
|
assert(!ActiveLdap::Base.connected?)
|
36
37
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'al-test-utils'
|
2
|
+
|
3
|
+
class TestConnectionPerDN < Test::Unit::TestCase
|
4
|
+
include AlTestUtils
|
5
|
+
|
6
|
+
priority :must
|
7
|
+
|
8
|
+
priority :normal
|
9
|
+
def test_establish_connection
|
10
|
+
make_temporary_user do |user, password|
|
11
|
+
assert_equal(user.class.connection, user.connection)
|
12
|
+
assert_raises(ActiveLdap::AuthenticationError) do
|
13
|
+
user.establish_connection(:bind_dn => nil,
|
14
|
+
:allow_anonymous => false,
|
15
|
+
:retry_limit => 0)
|
16
|
+
end
|
17
|
+
assert_equal(user.class.connection, user.connection)
|
18
|
+
|
19
|
+
assert_nothing_raised do
|
20
|
+
user.establish_connection(:bind_dn => nil,
|
21
|
+
:allow_anonymous => true)
|
22
|
+
end
|
23
|
+
assert_not_equal(user.class.connection, user.connection)
|
24
|
+
|
25
|
+
assert_equal(user.connection, user.class.find(user.dn).connection)
|
26
|
+
assert_equal(user.connection, user.find(user.dn).connection)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_find
|
31
|
+
make_temporary_user do |user, password|
|
32
|
+
make_temporary_user do |user2, password2|
|
33
|
+
user.establish_connection(:bind_dn => user.dn,
|
34
|
+
:password => password)
|
35
|
+
assert_not_equal(user.class.connection, user.connection)
|
36
|
+
|
37
|
+
found_user2 = user.find(user2.dn)
|
38
|
+
assert_not_equal(user2.connection, found_user2.connection)
|
39
|
+
assert_equal(user.connection, found_user2.connection)
|
40
|
+
|
41
|
+
assert_equal(found_user2.class.connection,
|
42
|
+
found_user2.class.find(found_user2.dn).connection)
|
43
|
+
|
44
|
+
found_user2.establish_connection(:bind_dn => user2.dn,
|
45
|
+
:password => password2)
|
46
|
+
assert_not_equal(user.connection, found_user2.connection)
|
47
|
+
assert_equal(user2.connection, found_user2.connection)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_associations
|
53
|
+
make_temporary_user do |user, password|
|
54
|
+
make_temporary_group do |group1|
|
55
|
+
make_temporary_group do |group2|
|
56
|
+
user.groups = [group1]
|
57
|
+
assert_equal(group1.connection, user.connection)
|
58
|
+
|
59
|
+
user.establish_connection(:bind_dn => user.dn,
|
60
|
+
:password => password)
|
61
|
+
assert_not_equal(user.class.connection, user.connection)
|
62
|
+
assert_not_equal(group1.connection, user.connection)
|
63
|
+
assert_equal(user.groups[0].connection, user.connection)
|
64
|
+
|
65
|
+
assert_raise(ActiveLdap::LdapError::InsufficientAccess) do
|
66
|
+
user.groups << group2
|
67
|
+
end
|
68
|
+
assert_equal([group1.cn], user.groups.collect(&:cn))
|
69
|
+
|
70
|
+
assert_not_equal(group1.connection, user.connection)
|
71
|
+
assert_equal(user.groups[0].connection, user.connection)
|
72
|
+
|
73
|
+
found_user = user.class.find(user.dn)
|
74
|
+
assert_equal(user.connection, found_user.connection)
|
75
|
+
assert_equal(found_user.connection,
|
76
|
+
found_user.groups[0].connection)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/test/test_dn.rb
CHANGED
@@ -10,11 +10,12 @@ class TestDN < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
priority :must
|
13
|
+
|
14
|
+
priority :normal
|
13
15
|
def test_case_insensitive_dn_minus
|
14
16
|
assert_dn_minus("dc=xxx", "dc=xxx,dc=LoCaL,dc=net", "dc=LOCAL,dc=net")
|
15
17
|
end
|
16
18
|
|
17
|
-
priority :normal
|
18
19
|
def test_dn_hash
|
19
20
|
dn1 = ActiveLdap::DN.parse("o=xxx,dc=local,dc=net")
|
20
21
|
dn2 = ActiveLdap::DN.parse("O = xxx , DC = local , DC = net")
|
@@ -135,7 +136,7 @@ class TestDN < Test::Unit::TestCase
|
|
135
136
|
end
|
136
137
|
assert_not_nil(exception)
|
137
138
|
assert_equal(dn, exception.dn)
|
138
|
-
assert_equal(reason, exception.reason)
|
139
|
+
assert_equal(_(reason), exception.reason)
|
139
140
|
end
|
140
141
|
|
141
142
|
def assert_dn_parser_collect_pairs(expected, source)
|
data/test/test_find.rb
CHANGED
@@ -4,6 +4,41 @@ class TestFind < Test::Unit::TestCase
|
|
4
4
|
include AlTestUtils
|
5
5
|
|
6
6
|
priority :must
|
7
|
+
|
8
|
+
priority :normal
|
9
|
+
def test_find_with_limit
|
10
|
+
make_temporary_user(:uid => "user1") do |user1,|
|
11
|
+
make_temporary_user(:uid => "user2") do |user2,|
|
12
|
+
make_temporary_user(:uid => "user3") do |user3,|
|
13
|
+
users = @user_class.find(:all)
|
14
|
+
assert_equal(["user1", "user2", "user3"].sort,
|
15
|
+
users.collect {|u| u.uid}.sort)
|
16
|
+
|
17
|
+
users = @user_class.find(:all, :limit => 2)
|
18
|
+
assert_operator([["user1", "user2"].sort,
|
19
|
+
["user2", "user3"].sort,
|
20
|
+
["user3", "user1"].sort],
|
21
|
+
:include?,
|
22
|
+
users.collect {|u| u.uid}.sort)
|
23
|
+
|
24
|
+
users = @user_class.find(:all, :limit => 1)
|
25
|
+
assert_operator([["user1"], ["user2"], ["user3"]],
|
26
|
+
:include?,
|
27
|
+
users.collect {|u| u.uid})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_find_all_with_dn_attribute_value
|
34
|
+
make_temporary_user(:uid => "user1") do |user1,|
|
35
|
+
make_temporary_user(:uid => "user2") do |user2,|
|
36
|
+
assert_equal(["user1"],
|
37
|
+
@user_class.find(:all, "*1").collect {|u| u.uid})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
7
42
|
def test_find_with_sort
|
8
43
|
make_temporary_user(:uid => "user1") do |user1,|
|
9
44
|
make_temporary_user(:uid => "user2") do |user2,|
|
@@ -25,7 +60,6 @@ class TestFind < Test::Unit::TestCase
|
|
25
60
|
end
|
26
61
|
end
|
27
62
|
|
28
|
-
priority :normal
|
29
63
|
def test_split_search_value
|
30
64
|
assert_split_search_value([nil, "test-user", nil], "test-user")
|
31
65
|
assert_split_search_value([nil, "test-user", "ou=Sub"], "test-user,ou=Sub")
|
data/test/test_object_class.rb
CHANGED
@@ -4,6 +4,18 @@ class TestObjectClass < Test::Unit::TestCase
|
|
4
4
|
include AlTestUtils
|
5
5
|
|
6
6
|
priority :must
|
7
|
+
|
8
|
+
priority :normal
|
9
|
+
def test_case_insensitive_match
|
10
|
+
assert_nothing_raised do
|
11
|
+
@group_class.instantiate(["cn=test-group,#{@group_class.base}",
|
12
|
+
{
|
13
|
+
:cn => "test-group",
|
14
|
+
:objectClass => ["TOP", "posixgroup"],
|
15
|
+
}])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
7
19
|
def test_ensure_recommended_classes
|
8
20
|
make_temporary_group do |group|
|
9
21
|
added_class = "labeledURIObject"
|
@@ -20,7 +32,6 @@ class TestObjectClass < Test::Unit::TestCase
|
|
20
32
|
end
|
21
33
|
end
|
22
34
|
|
23
|
-
priority :normal
|
24
35
|
def test_unknown_object_class
|
25
36
|
make_temporary_group do |group|
|
26
37
|
assert_raises(ActiveLdap::ObjectClassError) do
|
data/test/test_reflection.rb
CHANGED
@@ -15,7 +15,7 @@ class TestReflection < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
def test_respond_to?
|
17
17
|
make_temporary_user do |user, password|
|
18
|
-
attributes = user.must + user.may
|
18
|
+
attributes = (user.must + user.may).collect(&:name)
|
19
19
|
_wrap_assertion do
|
20
20
|
attributes.each do |name|
|
21
21
|
assert(user.respond_to?(name), name)
|
@@ -59,7 +59,8 @@ class TestReflection < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
make_temporary_user do |user, password|
|
62
|
-
attributes = user.must + user.may
|
62
|
+
attributes = user.must.collect(&:name) + user.may.collect(&:name)
|
63
|
+
attributes -= ["objectClass"]
|
63
64
|
assert_equal([], attributes - user.methods)
|
64
65
|
assert_equal([], attributes - user.methods(false))
|
65
66
|
|
@@ -68,7 +69,8 @@ class TestReflection < Test::Unit::TestCase
|
|
68
69
|
|
69
70
|
make_temporary_user do |user, password|
|
70
71
|
user.remove_class("inetOrgPerson")
|
71
|
-
attributes = user.must + user.may
|
72
|
+
attributes = user.must.collect(&:name) + user.may.collect(&:name)
|
73
|
+
attributes -= ["objectClass"]
|
72
74
|
assert_equal([], attributes - user.methods)
|
73
75
|
assert_equal([], attributes - user.methods(false))
|
74
76
|
|
@@ -76,7 +78,8 @@ class TestReflection < Test::Unit::TestCase
|
|
76
78
|
end
|
77
79
|
|
78
80
|
make_temporary_user do |user, password|
|
79
|
-
attributes = user.must + user.may
|
81
|
+
attributes = user.must.collect(&:name) + user.may.collect(&:name)
|
82
|
+
attributes -= ["objectClass"]
|
80
83
|
attributes = attributes.collect {|x| x.downcase}
|
81
84
|
assert_not_equal([], attributes - user.methods)
|
82
85
|
assert_not_equal([], attributes - user.methods(false))
|
@@ -91,7 +94,8 @@ class TestReflection < Test::Unit::TestCase
|
|
91
94
|
end
|
92
95
|
|
93
96
|
make_temporary_user do |user, password|
|
94
|
-
attributes = user.must + user.may
|
97
|
+
attributes = user.must.collect(&:name) + user.may.collect(&:name)
|
98
|
+
attributes -= ["objectClass"]
|
95
99
|
attributes = attributes.collect do |x|
|
96
100
|
Inflector.underscore(x)
|
97
101
|
end
|
@@ -109,7 +113,8 @@ class TestReflection < Test::Unit::TestCase
|
|
109
113
|
|
110
114
|
make_temporary_user do |user, password|
|
111
115
|
user.remove_class("inetOrgPerson")
|
112
|
-
attributes = user.must + user.may
|
116
|
+
attributes = user.must.collect(&:name) + user.may.collect(&:name)
|
117
|
+
attributes -= ["objectClass"]
|
113
118
|
attributes = attributes.collect do |x|
|
114
119
|
Inflector.underscore(x)
|
115
120
|
end
|
@@ -159,13 +164,14 @@ class TestReflection < Test::Unit::TestCase
|
|
159
164
|
def collect_attributes(object_classes, with_aliases=true)
|
160
165
|
attributes = []
|
161
166
|
object_classes.each do |object_class|
|
162
|
-
|
167
|
+
object_klass = ActiveLdap::Base.schema.object_class(object_class)
|
163
168
|
if with_aliases
|
164
|
-
(
|
165
|
-
attributes.
|
169
|
+
(object_klass.must + object_klass.may).each do |attribute|
|
170
|
+
attributes << attribute.name
|
171
|
+
attributes.concat(attribute.aliases)
|
166
172
|
end
|
167
173
|
else
|
168
|
-
attributes.concat(
|
174
|
+
attributes.concat((object_klass.must + object_klass.may).collect(&:name))
|
169
175
|
end
|
170
176
|
end
|
171
177
|
attributes
|
data/test/test_schema.rb
CHANGED
@@ -2,6 +2,134 @@ require 'al-test-utils'
|
|
2
2
|
|
3
3
|
class TestSchema < Test::Unit::TestCase
|
4
4
|
priority :must
|
5
|
+
|
6
|
+
def test_super_class?
|
7
|
+
group = 'objectClasses'
|
8
|
+
entry = {
|
9
|
+
group => [
|
10
|
+
"( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP " +
|
11
|
+
"top STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ " +
|
12
|
+
"telephoneNumber $ seeAlso $ description ) )",
|
13
|
+
|
14
|
+
"( 2.5.6.7 NAME 'organizationalPerson' DESC 'RFC2256: " +
|
15
|
+
"an organizational person' SUP person STRUCTURAL MAY ( " +
|
16
|
+
"title $ x121Address $ registeredAddress $ " +
|
17
|
+
"destinationIndicator $ preferredDeliveryMethod $ " +
|
18
|
+
"telexNumber $ teletexTerminalIdentifier $ telephoneNumber " +
|
19
|
+
"$ internationaliSDNNumber $ facsimileTelephoneNumber $ " +
|
20
|
+
"street $ postOfficeBox $ postalCode $ postalAddress $ " +
|
21
|
+
"physicalDeliveryOfficeName $ ou $ st $ l ) )",
|
22
|
+
|
23
|
+
"( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson' DESC " +
|
24
|
+
"'RFC2798: Internet Organizational Person' SUP " +
|
25
|
+
"organizationalPerson STRUCTURAL MAY ( audio $ " +
|
26
|
+
"businessCategory $ carLicense $ departmentNumber $ " +
|
27
|
+
"displayName $ employeeNumber $ employeeType $ givenName " +
|
28
|
+
"$ homePhone $ homePostalAddress $ initials $ jpegPhoto " +
|
29
|
+
"$ labeledURI $ mail $ manager $ mobile $ o $ pager $ " +
|
30
|
+
"photo $ roomNumber $ secretary $ uid $ userCertificate $ " +
|
31
|
+
"x500UniqueIdentifier $ preferredLanguage $ " +
|
32
|
+
"userSMIMECertificate $ userPKCS12 ) )",
|
33
|
+
]
|
34
|
+
}
|
35
|
+
schema = ActiveLdap::Schema.new(entry)
|
36
|
+
|
37
|
+
person = schema.object_class('person')
|
38
|
+
organizational_person = schema.object_class("organizationalPerson")
|
39
|
+
inet_org_person = schema.object_class("inetOrgPerson")
|
40
|
+
|
41
|
+
assert_equal([false, false, false],
|
42
|
+
[person.super_class?(person),
|
43
|
+
person.super_class?(organizational_person),
|
44
|
+
person.super_class?(inet_org_person)])
|
45
|
+
|
46
|
+
assert_equal([true, false, false],
|
47
|
+
[organizational_person.super_class?(person),
|
48
|
+
organizational_person.super_class?(organizational_person),
|
49
|
+
organizational_person.super_class?(inet_org_person)])
|
50
|
+
|
51
|
+
assert_equal([true, true, false],
|
52
|
+
[inet_org_person.super_class?(person),
|
53
|
+
inet_org_person.super_class?(organizational_person),
|
54
|
+
inet_org_person.super_class?(inet_org_person)])
|
55
|
+
end
|
56
|
+
|
57
|
+
priority :normal
|
58
|
+
def test_duplicate_schema
|
59
|
+
sasNMASProductOptions_schema =
|
60
|
+
"( 2.16.840.1.113719.1.39.42.1.0.38 NAME 'sasNMASProductOptions' " +
|
61
|
+
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64512} SINGLE-VALUE " +
|
62
|
+
"X-NDS_PUBLIC_READ '1' )"
|
63
|
+
rADIUSActiveConnections_schema =
|
64
|
+
"( 2.16.840.1.113719.1.39.42.1.0.38 NAME 'rADIUSActiveConnections' " +
|
65
|
+
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64512} X-NDS_NAME " +
|
66
|
+
"'RADIUS:ActiveConnections' X-NDS_NOT_SCHED_SYNC_IMMEDIATE '1' )"
|
67
|
+
|
68
|
+
sasNMASProductOptions = 'sasNMASProductOptions'
|
69
|
+
rADIUSActiveConnections = 'rADIUSActiveConnections'
|
70
|
+
sasNMASProductOptions_aliases =
|
71
|
+
[sasNMASProductOptions, []]
|
72
|
+
rADIUSActiveConnections_aliases =
|
73
|
+
[rADIUSActiveConnections, []]
|
74
|
+
sas_radius_aliases = [sasNMASProductOptions, [rADIUSActiveConnections]]
|
75
|
+
radius_sas_aliases = [rADIUSActiveConnections, [sasNMASProductOptions]]
|
76
|
+
|
77
|
+
assert_attribute_aliases([sasNMASProductOptions_aliases],
|
78
|
+
[sasNMASProductOptions],
|
79
|
+
[sasNMASProductOptions_schema],
|
80
|
+
false)
|
81
|
+
assert_attribute_aliases([rADIUSActiveConnections_aliases],
|
82
|
+
[rADIUSActiveConnections],
|
83
|
+
[rADIUSActiveConnections_schema],
|
84
|
+
false)
|
85
|
+
|
86
|
+
assert_attribute_aliases([sasNMASProductOptions_aliases,
|
87
|
+
sas_radius_aliases],
|
88
|
+
[sasNMASProductOptions,
|
89
|
+
rADIUSActiveConnections],
|
90
|
+
[sasNMASProductOptions_schema,
|
91
|
+
rADIUSActiveConnections_schema],
|
92
|
+
false)
|
93
|
+
assert_attribute_aliases([rADIUSActiveConnections_aliases,
|
94
|
+
radius_sas_aliases],
|
95
|
+
[rADIUSActiveConnections,
|
96
|
+
sasNMASProductOptions],
|
97
|
+
[rADIUSActiveConnections_schema,
|
98
|
+
sasNMASProductOptions_schema],
|
99
|
+
false)
|
100
|
+
|
101
|
+
assert_attribute_aliases([sas_radius_aliases,
|
102
|
+
sas_radius_aliases],
|
103
|
+
[rADIUSActiveConnections,
|
104
|
+
sasNMASProductOptions],
|
105
|
+
[sasNMASProductOptions_schema,
|
106
|
+
rADIUSActiveConnections_schema],
|
107
|
+
false)
|
108
|
+
assert_attribute_aliases([radius_sas_aliases,
|
109
|
+
radius_sas_aliases],
|
110
|
+
[sasNMASProductOptions,
|
111
|
+
rADIUSActiveConnections],
|
112
|
+
[rADIUSActiveConnections_schema,
|
113
|
+
sasNMASProductOptions_schema],
|
114
|
+
false)
|
115
|
+
|
116
|
+
assert_attribute_aliases([sas_radius_aliases,
|
117
|
+
sas_radius_aliases],
|
118
|
+
[sasNMASProductOptions,
|
119
|
+
rADIUSActiveConnections],
|
120
|
+
[sasNMASProductOptions_schema,
|
121
|
+
rADIUSActiveConnections_schema],
|
122
|
+
true)
|
123
|
+
assert_attribute_aliases([radius_sas_aliases,
|
124
|
+
radius_sas_aliases],
|
125
|
+
[rADIUSActiveConnections,
|
126
|
+
sasNMASProductOptions],
|
127
|
+
[rADIUSActiveConnections_schema,
|
128
|
+
sasNMASProductOptions_schema],
|
129
|
+
true)
|
130
|
+
end
|
131
|
+
|
132
|
+
priority :normal
|
5
133
|
def test_empty_schema
|
6
134
|
assert_make_schema_with_empty_entries(nil)
|
7
135
|
assert_make_schema_with_empty_entries({})
|
@@ -13,7 +141,6 @@ class TestSchema < Test::Unit::TestCase
|
|
13
141
|
assert_equal([], schema["attributeTypes", "cn", "DESC"])
|
14
142
|
end
|
15
143
|
|
16
|
-
priority :normal
|
17
144
|
def test_attribute_name_with_under_score
|
18
145
|
top_schema =
|
19
146
|
"( 2.5.6.0 NAME 'Top' STRUCTURAL MUST objectClass MAY ( " +
|
@@ -244,7 +371,7 @@ class TestSchema < Test::Unit::TestCase
|
|
244
371
|
|
245
372
|
schema = ActiveLdap::Schema.new({"attributeTypes" => [jpeg_photo_schema],
|
246
373
|
"ldapSyntaxes" => [jpeg_schema]})
|
247
|
-
assert(schema.
|
374
|
+
assert(schema.attribute("jpegPhoto").binary?)
|
248
375
|
end
|
249
376
|
|
250
377
|
private
|
@@ -270,4 +397,16 @@ class TestSchema < Test::Unit::TestCase
|
|
270
397
|
"DESC"])
|
271
398
|
assert_equal([], schema["objectClasses", "posixAccount", "MUST"])
|
272
399
|
end
|
400
|
+
|
401
|
+
def assert_attribute_aliases(expected, keys, schemata, ensure_parse)
|
402
|
+
group = 'attributeTypes'
|
403
|
+
entry = {group => schemata}
|
404
|
+
schema = ActiveLdap::Schema.new(entry)
|
405
|
+
schema.send(:ensure_parse, group) if ensure_parse
|
406
|
+
result = keys.collect do |key|
|
407
|
+
attribute = schema.attribute(key)
|
408
|
+
[attribute.name, attribute.aliases]
|
409
|
+
end
|
410
|
+
assert_equal(expected, result)
|
411
|
+
end
|
273
412
|
end
|