powerhome-activeldap 3.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +6 -0
  3. data/COPYING +340 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE +59 -0
  6. data/README.textile +140 -0
  7. data/TODO +32 -0
  8. data/benchmark/README.md +64 -0
  9. data/benchmark/bench-backend.rb +247 -0
  10. data/benchmark/bench-instantiate.rb +98 -0
  11. data/benchmark/config.yaml.sample +5 -0
  12. data/doc/text/development.textile +54 -0
  13. data/doc/text/news.textile +811 -0
  14. data/doc/text/rails.textile +144 -0
  15. data/doc/text/tutorial.textile +1010 -0
  16. data/examples/config.yaml.example +5 -0
  17. data/examples/example.der +0 -0
  18. data/examples/example.jpg +0 -0
  19. data/examples/groupadd +41 -0
  20. data/examples/groupdel +35 -0
  21. data/examples/groupls +49 -0
  22. data/examples/groupmod +42 -0
  23. data/examples/lpasswd +55 -0
  24. data/examples/objects/group.rb +13 -0
  25. data/examples/objects/ou.rb +4 -0
  26. data/examples/objects/user.rb +20 -0
  27. data/examples/ouadd +38 -0
  28. data/examples/useradd +45 -0
  29. data/examples/useradd-binary +53 -0
  30. data/examples/userdel +34 -0
  31. data/examples/userls +50 -0
  32. data/examples/usermod +42 -0
  33. data/examples/usermod-binary-add +50 -0
  34. data/examples/usermod-binary-add-time +54 -0
  35. data/examples/usermod-binary-del +48 -0
  36. data/examples/usermod-lang-add +43 -0
  37. data/lib/active_ldap.rb +85 -0
  38. data/lib/active_ldap/action_controller/ldap_benchmarking.rb +55 -0
  39. data/lib/active_ldap/acts/tree.rb +78 -0
  40. data/lib/active_ldap/adapter/base.rb +707 -0
  41. data/lib/active_ldap/adapter/jndi.rb +184 -0
  42. data/lib/active_ldap/adapter/jndi_connection.rb +185 -0
  43. data/lib/active_ldap/adapter/ldap.rb +290 -0
  44. data/lib/active_ldap/adapter/ldap_ext.rb +105 -0
  45. data/lib/active_ldap/adapter/net_ldap.rb +309 -0
  46. data/lib/active_ldap/adapter/net_ldap_ext.rb +23 -0
  47. data/lib/active_ldap/association/belongs_to.rb +47 -0
  48. data/lib/active_ldap/association/belongs_to_many.rb +58 -0
  49. data/lib/active_ldap/association/children.rb +21 -0
  50. data/lib/active_ldap/association/collection.rb +105 -0
  51. data/lib/active_ldap/association/has_many.rb +31 -0
  52. data/lib/active_ldap/association/has_many_utils.rb +44 -0
  53. data/lib/active_ldap/association/has_many_wrap.rb +75 -0
  54. data/lib/active_ldap/association/proxy.rb +107 -0
  55. data/lib/active_ldap/associations.rb +205 -0
  56. data/lib/active_ldap/attribute_methods.rb +23 -0
  57. data/lib/active_ldap/attribute_methods/before_type_cast.rb +24 -0
  58. data/lib/active_ldap/attribute_methods/dirty.rb +43 -0
  59. data/lib/active_ldap/attribute_methods/query.rb +31 -0
  60. data/lib/active_ldap/attribute_methods/read.rb +44 -0
  61. data/lib/active_ldap/attribute_methods/write.rb +38 -0
  62. data/lib/active_ldap/attributes.rb +176 -0
  63. data/lib/active_ldap/base.rb +1410 -0
  64. data/lib/active_ldap/callbacks.rb +71 -0
  65. data/lib/active_ldap/command.rb +49 -0
  66. data/lib/active_ldap/compatible.rb +44 -0
  67. data/lib/active_ldap/configuration.rb +147 -0
  68. data/lib/active_ldap/connection.rb +299 -0
  69. data/lib/active_ldap/distinguished_name.rb +291 -0
  70. data/lib/active_ldap/entry_attribute.rb +78 -0
  71. data/lib/active_ldap/escape.rb +12 -0
  72. data/lib/active_ldap/get_text.rb +20 -0
  73. data/lib/active_ldap/get_text/parser.rb +161 -0
  74. data/lib/active_ldap/helper.rb +92 -0
  75. data/lib/active_ldap/human_readable.rb +133 -0
  76. data/lib/active_ldap/ldap_error.rb +74 -0
  77. data/lib/active_ldap/ldif.rb +930 -0
  78. data/lib/active_ldap/log_subscriber.rb +50 -0
  79. data/lib/active_ldap/object_class.rb +95 -0
  80. data/lib/active_ldap/operations.rb +624 -0
  81. data/lib/active_ldap/persistence.rb +100 -0
  82. data/lib/active_ldap/populate.rb +53 -0
  83. data/lib/active_ldap/railtie.rb +43 -0
  84. data/lib/active_ldap/railties/controller_runtime.rb +48 -0
  85. data/lib/active_ldap/schema.rb +701 -0
  86. data/lib/active_ldap/schema/syntaxes.rb +422 -0
  87. data/lib/active_ldap/timeout.rb +75 -0
  88. data/lib/active_ldap/timeout_stub.rb +17 -0
  89. data/lib/active_ldap/user_password.rb +99 -0
  90. data/lib/active_ldap/validations.rb +200 -0
  91. data/lib/active_ldap/version.rb +3 -0
  92. data/lib/active_ldap/xml.rb +139 -0
  93. data/lib/rails/generators/active_ldap/model/USAGE +18 -0
  94. data/lib/rails/generators/active_ldap/model/model_generator.rb +47 -0
  95. data/lib/rails/generators/active_ldap/model/templates/model_active_ldap.rb +3 -0
  96. data/lib/rails/generators/active_ldap/scaffold/scaffold_generator.rb +14 -0
  97. data/lib/rails/generators/active_ldap/scaffold/templates/ldap.yml +19 -0
  98. data/po/en/active-ldap.po +4029 -0
  99. data/po/ja/active-ldap.po +4060 -0
  100. data/test/add-phonetic-attribute-options-to-slapd.ldif +10 -0
  101. data/test/al-test-utils.rb +428 -0
  102. data/test/command.rb +111 -0
  103. data/test/config.yaml.sample +6 -0
  104. data/test/fixtures/lower_case_object_class_schema.rb +802 -0
  105. data/test/run-test.rb +34 -0
  106. data/test/test_acts_as_tree.rb +60 -0
  107. data/test/test_adapter.rb +121 -0
  108. data/test/test_associations.rb +701 -0
  109. data/test/test_attributes.rb +117 -0
  110. data/test/test_base.rb +1214 -0
  111. data/test/test_base_per_instance.rb +61 -0
  112. data/test/test_bind.rb +62 -0
  113. data/test/test_callback.rb +31 -0
  114. data/test/test_configuration.rb +40 -0
  115. data/test/test_connection.rb +82 -0
  116. data/test/test_connection_per_class.rb +112 -0
  117. data/test/test_connection_per_dn.rb +112 -0
  118. data/test/test_dirty.rb +98 -0
  119. data/test/test_dn.rb +172 -0
  120. data/test/test_find.rb +176 -0
  121. data/test/test_groupadd.rb +50 -0
  122. data/test/test_groupdel.rb +46 -0
  123. data/test/test_groupls.rb +107 -0
  124. data/test/test_groupmod.rb +51 -0
  125. data/test/test_ldif.rb +1890 -0
  126. data/test/test_load.rb +133 -0
  127. data/test/test_lpasswd.rb +75 -0
  128. data/test/test_object_class.rb +74 -0
  129. data/test/test_persistence.rb +131 -0
  130. data/test/test_reflection.rb +175 -0
  131. data/test/test_schema.rb +559 -0
  132. data/test/test_syntax.rb +444 -0
  133. data/test/test_user.rb +217 -0
  134. data/test/test_user_password.rb +108 -0
  135. data/test/test_useradd-binary.rb +62 -0
  136. data/test/test_useradd.rb +57 -0
  137. data/test/test_userdel.rb +48 -0
  138. data/test/test_userls.rb +91 -0
  139. data/test/test_usermod-binary-add-time.rb +65 -0
  140. data/test/test_usermod-binary-add.rb +64 -0
  141. data/test/test_usermod-binary-del.rb +66 -0
  142. data/test/test_usermod-lang-add.rb +59 -0
  143. data/test/test_usermod.rb +58 -0
  144. data/test/test_validation.rb +274 -0
  145. metadata +379 -0
@@ -0,0 +1,66 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestUsermodBinaryDel < Test::Unit::TestCase
4
+ include AlTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@examples_dir, "usermod-binary-del")
9
+ make_ou("People")
10
+ @user_class.prefix = "ou=People"
11
+ end
12
+
13
+ priority :must
14
+
15
+ priority :normal
16
+ def test_non_exist_user
17
+ ensure_delete_user("test-user") do |uid,|
18
+ assert(!@user_class.exists?(uid))
19
+ assert_equal([false, "User #{uid} doesn't exist.\n"],
20
+ run_command(uid, "New CN", 11111))
21
+ assert(!@user_class.exists?(uid))
22
+ end
23
+ end
24
+
25
+ def test_modify_user
26
+ make_temporary_user(:simple => true) do |user, password|
27
+ user.add_class("strongAuthenticationUser")
28
+ user.user_certificate = certificate
29
+ assert_true(user.save)
30
+ assert_usermod_binary_del_successfully(user.uid, "New #{user.cn}",
31
+ user.uid_number.to_i + 100)
32
+ end
33
+ end
34
+
35
+ private
36
+ def assert_usermod_binary_del_successfully(name, cn, uid, *args, &block)
37
+ _wrap_assertion do
38
+ assert(@user_class.exists?(name))
39
+ previous_classes = @user_class.find(name).classes
40
+ assert_operator(previous_classes, :include?, "strongAuthenticationUser")
41
+ args.concat([name, cn, uid])
42
+ assert_equal([true, ""], run_command(*args, &block))
43
+ assert(@user_class.exists?(name))
44
+
45
+ user = @user_class.find(name)
46
+ assert_equal(name, user.uid)
47
+ assert_equal(cn, user.cn)
48
+ assert_equal(uid.to_i, user.uid_number)
49
+ assert_equal(uid.to_i, user.gid_number)
50
+ assert_equal(uid.to_s, user.uid_number_before_type_cast)
51
+ assert_equal(uid.to_s, user.gid_number_before_type_cast)
52
+ assert_equal((previous_classes - ['strongAuthenticationUser']).sort,
53
+ user.classes.sort)
54
+ assert(!user.respond_to?(:user_certificate))
55
+ end
56
+ end
57
+
58
+ def assert_usermod_binary_del_failed(name, cn, uid, message, *args, &block)
59
+ _wrap_assertion do
60
+ assert(@user_class.exists?(name))
61
+ args.concat([name, cn, uid])
62
+ assert_equal([false, message], run_command(*args, &block))
63
+ assert(@user_class.exists?(name))
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,59 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestUsermodLangAdd < Test::Unit::TestCase
4
+ include AlTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@examples_dir, "usermod-lang-add")
9
+ make_ou("People")
10
+ @user_class.prefix = "ou=People"
11
+ end
12
+
13
+ priority :must
14
+
15
+ priority :normal
16
+ def test_non_exist_user
17
+ ensure_delete_user("test-user") do |uid,|
18
+ assert(!@user_class.exists?(uid))
19
+ assert_equal([false, "User #{uid} doesn't exist.\n"],
20
+ run_command(uid, "New CN", 11111))
21
+ assert(!@user_class.exists?(uid))
22
+ end
23
+ end
24
+
25
+ def test_modify_user
26
+ make_temporary_user do |user, password|
27
+ assert_usermod_lang_add_successfully(user.uid, "New #{user.cn}",
28
+ user.uid_number.to_i + 100)
29
+ end
30
+ end
31
+
32
+ private
33
+ def assert_usermod_lang_add_successfully(name, cn, uid, *args, &block)
34
+ _wrap_assertion do
35
+ assert(@user_class.exists?(name))
36
+ args.concat([name, cn, uid])
37
+ assert_equal([true, ""], run_command(*args, &block))
38
+ assert(@user_class.exists?(name))
39
+
40
+ user = @user_class.find(name)
41
+ assert_equal(name, user.uid)
42
+ assert_equal([cn, {'lang-en-us' => cn}].sort_by(&:inspect),
43
+ user.cn.sort_by(&:inspect))
44
+ assert_equal(uid.to_i, user.uid_number)
45
+ assert_equal(uid.to_i, user.gid_number)
46
+ assert_equal(uid.to_s, user.uid_number_before_type_cast)
47
+ assert_equal(uid.to_s, user.gid_number_before_type_cast)
48
+ end
49
+ end
50
+
51
+ def assert_usermod_lang_add_failed(name, cn, uid, message, *args, &block)
52
+ _wrap_assertion do
53
+ assert(@user_class.exists?(name))
54
+ args.concat([name, cn, uid])
55
+ assert_equal([false, message], run_command(*args, &block))
56
+ assert(@user_class.exists?(name))
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,58 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestUsermod < Test::Unit::TestCase
4
+ include AlTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@examples_dir, "usermod")
9
+ make_ou("People")
10
+ @user_class.prefix = "ou=People"
11
+ end
12
+
13
+ priority :must
14
+
15
+ priority :normal
16
+ def test_non_exist_user
17
+ ensure_delete_user("test-user") do |uid,|
18
+ assert(!@user_class.exists?(uid))
19
+ assert_equal([false, "User #{uid} doesn't exist.\n"],
20
+ run_command(uid, "New CN", 11111))
21
+ assert(!@user_class.exists?(uid))
22
+ end
23
+ end
24
+
25
+ def test_modify_user
26
+ make_temporary_user do |user, password|
27
+ assert_usermod_successfully(user.uid, "New #{user.cn}",
28
+ user.uid_number.to_i + 100)
29
+ end
30
+ end
31
+
32
+ private
33
+ def assert_usermod_successfully(name, cn, uid, *args, &block)
34
+ _wrap_assertion do
35
+ assert(@user_class.exists?(name))
36
+ args.concat([name, cn, uid])
37
+ assert_equal([true, ""], run_command(*args, &block))
38
+ assert(@user_class.exists?(name))
39
+
40
+ user = @user_class.find(name)
41
+ assert_equal(name, user.uid)
42
+ assert_equal(cn, user.cn)
43
+ assert_equal(uid.to_i, user.uid_number)
44
+ assert_equal(uid.to_i, user.gid_number)
45
+ assert_equal(uid.to_s, user.uid_number_before_type_cast)
46
+ assert_equal(uid.to_s, user.gid_number_before_type_cast)
47
+ end
48
+ end
49
+
50
+ def assert_usermod_failed(name, cn, uid, message, *args, &block)
51
+ _wrap_assertion do
52
+ assert(@user_class.exists?(name))
53
+ args.concat([name, cn, uid])
54
+ assert_equal([false, message], run_command(*args, &block))
55
+ assert(@user_class.exists?(name))
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,274 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'al-test-utils'
3
+
4
+ class TestValidation < Test::Unit::TestCase
5
+ include AlTestUtils
6
+ include ActiveLdap::Helper
7
+
8
+ priority :must
9
+ def test_rename_duplicated
10
+ make_temporary_user(:simple => true) do |user1,|
11
+ make_temporary_user(:simple => true) do |user2,|
12
+ user1.id = user2.id
13
+ assert_false(user1.save)
14
+
15
+ format = la_('distinguishedName').humanize
16
+ format << ' ' << _("is duplicated: %s")
17
+ assert_equal([format % [user2.dn.to_s]],
18
+ user1.errors.full_messages)
19
+ end
20
+ end
21
+ end
22
+
23
+ priority :normal
24
+ def test_not_show_binary_value
25
+ make_temporary_user do |user,|
26
+ user.user_certificate = nil
27
+ user.jpeg_photo = "XXX"
28
+ assert_not_predicate(user, :save)
29
+
30
+ format = la_('jpegPhoto').humanize
31
+ format << ' ' << _("has invalid format: %s: required syntax: %s: %s")
32
+ arguments = [_("<binary-value>"),
33
+ lsd_("1.3.6.1.4.1.1466.115.121.1.28"),
34
+ _("invalid JPEG format")]
35
+ message = format % arguments
36
+ assert_equal([message],
37
+ user.errors.full_messages)
38
+ end
39
+ end
40
+
41
+ def test_validation_skip_attributes
42
+ make_temporary_group do |group|
43
+ group.gid_number = nil
44
+ assert_raise(ActiveLdap::EntryInvalid) do
45
+ group.save!
46
+ end
47
+ group.validation_skip_attributes << "gidNumber"
48
+ assert_raise(ActiveLdap::RequiredAttributeMissed) do
49
+ group.save!
50
+ end
51
+ end
52
+ end
53
+
54
+ def test_set_attributes_with_invalid_dn_attribute_value
55
+ user = nil
56
+ assert_nothing_raised do
57
+ user = @user_class.new(:uid => "=", :cn => "#")
58
+ end
59
+ assert(!user.valid?)
60
+ end
61
+
62
+ def test_set_attribute_to_invalid_dn_attribute_value_object
63
+ user = @user_class.new("=")
64
+ assert_nothing_raised do
65
+ user.uid_number = 11111
66
+ end
67
+ assert_equal(11111, user.uid_number)
68
+ end
69
+
70
+ def test_dn_validate_on_new
71
+ user = @user_class.new("=")
72
+ assert(!user.valid?)
73
+ reason = _("attribute value is missing")
74
+ invalid_format = _("%s is invalid distinguished name (DN): %s")
75
+ invalid_message = invalid_format % ["uid==,#{user.class.base}", reason]
76
+ format = la_('distinguishedName').humanize
77
+ format << ' ' << _("is invalid: %s")
78
+ message = format % invalid_message
79
+ assert_equal([message],
80
+ user.errors.full_messages.find_all {|m| /DN/ =~ m})
81
+ end
82
+
83
+ def test_dn_validate
84
+ make_temporary_user do |user,|
85
+ user.uid = "="
86
+ assert(!user.valid?)
87
+ reason = _("attribute value is missing")
88
+ invalid_format = _("%s is invalid distinguished name (DN): %s")
89
+ invalid_message = invalid_format % ["uid==,#{user.class.base}", reason]
90
+ format = la_('distinguishedName').humanize
91
+ format << ' ' << _("is invalid: %s")
92
+ message = format % invalid_message
93
+ assert_equal([message], user.errors.full_messages)
94
+ end
95
+ end
96
+
97
+ def test_not_validate_empty_string
98
+ make_temporary_user do |user,|
99
+ assert(user.valid?)
100
+ user.uid_number = ""
101
+ assert(!user.valid?)
102
+ format = la_('uidNumber').humanize
103
+ format << ' ' << _("is required attribute by objectClass '%s'")
104
+ blank_message = format % loc_("posixAccount")
105
+ assert_equal([blank_message], user.errors.full_messages)
106
+ end
107
+ end
108
+
109
+ def test_validate_excluded_classes
110
+ make_temporary_user do |user,|
111
+ assert(user.save)
112
+ user.class.excluded_classes = ['person']
113
+ assert(!user.save)
114
+ format = la_("objectClass").humanize
115
+ format << ' ' << n_("has excluded value: %s",
116
+ "has excluded values: %s",
117
+ 1)
118
+ message = format % loc_("person")
119
+ assert_equal([message], user.errors.full_messages)
120
+ end
121
+ end
122
+
123
+ def test_valid_subtype_and_single_value
124
+ make_temporary_user do |user, password|
125
+ user.display_name = [{"lang-ja" => ["ユーザ"]},
126
+ {"lang-en" => "User"}]
127
+ assert(user.save)
128
+
129
+ user = user.class.find(user.dn)
130
+ assert_equal([{"lang-ja" => "ユーザ"},
131
+ {"lang-en" => "User"}].sort_by {|hash| hash.keys.first},
132
+ user.display_name.sort_by {|hash| hash.keys.first})
133
+ end
134
+ end
135
+
136
+ def test_invalid_subtype_and_single_value
137
+ assert_invalid_display_name_value(["User1", "User2"],
138
+ ["User1", "User2"])
139
+ assert_invalid_display_name_value(["User3", "User4"],
140
+ [{"lang-en" => ["User3", "User4"]}],
141
+ {"lang-en" => ["User3", "User4"]}.inspect)
142
+ assert_invalid_display_name_value(["U2", "U3"],
143
+ [{"lang-ja" => ["User1"]},
144
+ {"lang-en" => ["U2", "U3"]}],
145
+ [{"lang-ja" => "User1"},
146
+ {"lang-en" => ["U2", "U3"]}].inspect)
147
+ end
148
+
149
+ def test_validate_required_ldap_values
150
+ make_temporary_user(:simple => true) do |user, password|
151
+ assert(user.save)
152
+
153
+ user.add_class("strongAuthenticationUser")
154
+ user.user_certificate = nil
155
+ assert(!user.save)
156
+ assert(user.errors[:userCertificate].any?)
157
+ assert_equal(1, user.errors.size)
158
+ end
159
+ end
160
+
161
+ def test_syntax_validation
162
+ make_temporary_user do |user, password|
163
+ assert(user.save)
164
+
165
+ user.see_also = "cn=test,dc=example,dc=com"
166
+ assert(user.save)
167
+ end
168
+
169
+ assert_invalid_see_also_value("test", "test")
170
+ assert_invalid_see_also_value("test-en",
171
+ ["cn=test,dc=example,dc=com",
172
+ {"lang-en-us" => "test-en"}],
173
+ "lang-en-us")
174
+ assert_invalid_see_also_value("test-ja-jp",
175
+ ["cn=test,dc=example,dc=com",
176
+ {"lang-ja-jp" =>
177
+ ["cn=test-ja,dc=example,dc=com",
178
+ "test-ja-jp"]}],
179
+ "lang-ja-jp")
180
+ end
181
+
182
+ def test_duplicated_dn_creation
183
+ assert(ou_class.new("YYY").save)
184
+ ou = ou_class.new("YYY")
185
+ assert(!ou.save)
186
+ format = la_("distinguishedName").humanize
187
+ format << ' ' << _("is duplicated: %s")
188
+ message = format % ou.dn
189
+ assert_equal([message], ou.errors.full_messages)
190
+ end
191
+
192
+ def test_save!
193
+ make_temporary_group do |group|
194
+ group.description = ""
195
+
196
+ assert_nothing_raised do
197
+ group.save!
198
+ end
199
+
200
+ @group_class.validates_presence_of(:description)
201
+ assert_raises(ActiveLdap::EntryInvalid) do
202
+ group.save!
203
+ end
204
+ end
205
+ end
206
+
207
+ def test_validates_presence_of
208
+ make_temporary_group do |group|
209
+ assert_nothing_raised do
210
+ group.description = ""
211
+ end
212
+ assert(group.valid?)
213
+ assert_equal([], group.errors.to_a)
214
+
215
+ @group_class.validates_presence_of(:description)
216
+ assert(!group.valid?)
217
+ assert(group.errors[:description].any?)
218
+ assert_equal(1, group.errors.size)
219
+ end
220
+ end
221
+
222
+ private
223
+ def assert_invalid_value(name, formatted_value, syntax, reason, model, option)
224
+ syntax_description = lsd_(syntax)
225
+ assert_not_nil(syntax_description)
226
+ params = [formatted_value, syntax_description, reason]
227
+ params.unshift(option) if option
228
+ localized_name = la_(name).humanize
229
+ format = localized_name << ' '
230
+ if option
231
+ format << _("(%s) has invalid format: %s: required syntax: %s: %s")
232
+ else
233
+ format << _("has invalid format: %s: required syntax: %s: %s")
234
+ end
235
+ message = format % params
236
+ assert_equal([message], model.errors.full_messages)
237
+ end
238
+
239
+ def assert_invalid_see_also_value(invalid_value, value, option=nil)
240
+ make_temporary_user do |user, password|
241
+ assert(user.save)
242
+
243
+ user.see_also = "cn=test,dc=example,dc=com"
244
+ assert(user.save)
245
+
246
+ user.see_also = value
247
+ assert(!user.save)
248
+ assert(user.errors[:seeAlso].any?)
249
+ assert_equal(1, user.errors.size)
250
+
251
+ reason_params = [invalid_value, _("attribute value is missing")]
252
+ reason = _('%s is invalid distinguished name (DN): %s') % reason_params
253
+ assert_invalid_value("seeAlso", value.inspect,
254
+ "1.3.6.1.4.1.1466.115.121.1.12",
255
+ reason, user, option)
256
+ end
257
+ end
258
+
259
+ def assert_invalid_display_name_value(invalid_value, value,
260
+ formatted_value=nil)
261
+ make_temporary_user do |user, password|
262
+ assert(user.save)
263
+
264
+ user.display_name = value
265
+ assert(!user.save)
266
+
267
+ reason_params = [la_("displayName"), invalid_value.inspect]
268
+ reason = _('Attribute %s can only have a single value: %s') % reason_params
269
+ assert_invalid_value("displayName", formatted_value || value.inspect,
270
+ "1.3.6.1.4.1.1466.115.121.1.15",
271
+ reason, user, nil)
272
+ end
273
+ end
274
+ end