activeldap 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CHANGES +15 -0
  2. data/README +4 -1
  3. data/Rakefile +1 -1
  4. data/TODO +1 -2
  5. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  6. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  7. data/examples/al-admin/app/models/user.rb +1 -1
  8. data/examples/al-admin/config/boot.rb +1 -1
  9. data/examples/al-admin/config/environment.rb +1 -15
  10. data/examples/al-admin/config/initializers/session_store.rb +23 -0
  11. data/examples/al-admin/config/session_secret.txt +1 -0
  12. data/examples/al-admin/db/schema.rb +23 -0
  13. data/examples/al-admin/locale/en/LC_MESSAGES/al-admin.mo +0 -0
  14. data/examples/al-admin/locale/ja/LC_MESSAGES/al-admin.mo +0 -0
  15. data/examples/al-admin/locale/nl/LC_MESSAGES/al-admin.mo +0 -0
  16. data/lib/active_ldap.rb +3 -3
  17. data/lib/active_ldap/acts/tree.rb +1 -1
  18. data/lib/active_ldap/adapter/base.rb +9 -1
  19. data/lib/active_ldap/adapter/ldap.rb +7 -1
  20. data/lib/active_ldap/association/belongs_to_many.rb +6 -2
  21. data/lib/active_ldap/association/children.rb +1 -1
  22. data/lib/active_ldap/association/has_many_utils.rb +2 -2
  23. data/lib/active_ldap/association/has_many_wrap.rb +6 -2
  24. data/lib/active_ldap/attributes.rb +5 -1
  25. data/lib/active_ldap/base.rb +133 -59
  26. data/lib/active_ldap/connection.rb +10 -3
  27. data/lib/active_ldap/distinguished_name.rb +33 -1
  28. data/lib/active_ldap/ldif.rb +1 -0
  29. data/lib/active_ldap/operations.rb +33 -14
  30. data/lib/active_ldap/populate.rb +21 -12
  31. data/lib/active_ldap/schema.rb +21 -0
  32. data/lib/active_ldap/validations.rb +49 -4
  33. data/po/active-ldap.pot +4030 -0
  34. data/po/en/active-ldap.po +57 -37
  35. data/po/ja/active-ldap.po +58 -38
  36. data/test-unit/History.txt +1 -1
  37. data/test-unit/Manifest.txt +2 -0
  38. data/test-unit/README.txt +1 -1
  39. data/test-unit/lib/test/unit/assertions.rb +1 -1
  40. data/test-unit/lib/test/unit/autorunner.rb +19 -4
  41. data/test-unit/lib/test/unit/collector/load.rb +3 -1
  42. data/test-unit/lib/test/unit/color-scheme.rb +5 -1
  43. data/test-unit/lib/test/unit/error.rb +7 -5
  44. data/test-unit/lib/test/unit/runner/tap.rb +8 -0
  45. data/test-unit/lib/test/unit/ui/console/testrunner.rb +63 -8
  46. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
  47. data/test-unit/test/collector/test-load.rb +1 -5
  48. data/test-unit/test/test-color-scheme.rb +4 -0
  49. data/test/al-test-utils.rb +30 -2
  50. data/test/test_acts_as_tree.rb +6 -3
  51. data/test/test_associations.rb +3 -2
  52. data/test/test_base.rb +104 -5
  53. data/test/test_dn.rb +10 -0
  54. data/test/test_groupls.rb +1 -1
  55. data/test/test_lpasswd.rb +1 -1
  56. data/test/test_reflection.rb +23 -16
  57. data/test/test_schema.rb +33 -1
  58. data/test/test_useradd-binary.rb +1 -1
  59. data/test/test_useradd.rb +1 -1
  60. data/test/test_userdel.rb +1 -1
  61. data/test/test_userls.rb +1 -1
  62. data/test/test_usermod-binary-add-time.rb +1 -1
  63. data/test/test_usermod-binary-add.rb +1 -1
  64. data/test/test_usermod-binary-del.rb +1 -1
  65. data/test/test_usermod-lang-add.rb +1 -1
  66. data/test/test_usermod.rb +1 -1
  67. data/test/test_validation.rb +48 -10
  68. metadata +44 -35
@@ -17,7 +17,8 @@ class TestActsAsTree < Test::Unit::TestCase
17
17
  users = ou_class.find("Users")
18
18
  assert_equal(["SubUsers"], users.children.collect(&:ou))
19
19
 
20
- assert_equal("ou=SubUsers,#{users.dn}", sub_users.dn)
20
+ assert_equal(dn("ou=SubUsers,#{users.dn}"),
21
+ sub_users.dn)
21
22
 
22
23
  assert(ou_class.exists?("SubUsers"))
23
24
  users.children.replace([])
@@ -31,7 +32,8 @@ class TestActsAsTree < Test::Unit::TestCase
31
32
 
32
33
  sub_users = users.class.new("SubUsers")
33
34
  sub_users.parent = users
34
- assert_equal("ou=SubUsers,#{users.dn}", sub_users.dn)
35
+ assert_equal(dn("ou=SubUsers,#{users.dn}"),
36
+ sub_users.dn)
35
37
  assert_equal(["SubUsers"], users.children.collect(&:ou))
36
38
 
37
39
  sub_users = ou_class.find("SubUsers")
@@ -46,7 +48,8 @@ class TestActsAsTree < Test::Unit::TestCase
46
48
  assert_equal([], other_users.children.collect(&:ou))
47
49
 
48
50
  sub_users.parent = other_users.dn
49
- assert_equal("ou=SubUsers,#{other_users.dn}", sub_users.dn)
51
+ assert_equal(dn("ou=SubUsers,#{other_users.dn}"),
52
+ sub_users.dn)
50
53
 
51
54
  other_users.clear_association_cache
52
55
  assert_equal(["SubUsers"], other_users.children.collect(&:ou))
@@ -96,13 +96,14 @@ EOX
96
96
  make_temporary_group do |group1|
97
97
  make_temporary_group do |group2|
98
98
  user.references = [group1, group2]
99
- group3_dn = group2.dn.sub(/cn=(.*?),/, "cn=\\1-nonexistent,")
99
+ group3_dn = group2.dn.to_s.sub(/cn=(.*?),/, "cn=\\1-nonexistent,")
100
100
  user.see_also += [group3_dn]
101
101
  user.save!
102
102
 
103
+ group3_dn = dn(group3_dn)
103
104
  user = @user_class.find(user.dn)
104
105
  assert_equal([group1.dn, group2.dn, group3_dn],
105
- user.see_also.collect(&:to_s))
106
+ user.see_also)
106
107
  assert_equal([group1.dn, group2.dn, group3_dn],
107
108
  user.references.collect(&:dn))
108
109
  assert_equal([group1.gid_number, group2.gid_number, nil],
@@ -6,6 +6,106 @@ class TestBase < Test::Unit::TestCase
6
6
  include AlTestUtils
7
7
 
8
8
  priority :must
9
+ def test_rename_with_superior
10
+ make_ou("sub,ou=users")
11
+ make_temporary_user(:simple => true) do |user,|
12
+ user.id = "user2,ou=sub,#{@user_class.base}"
13
+ assert_raise(ActiveLdap::NotImplemented) do
14
+ assert_true(user.save)
15
+
16
+ # the following codes aren't reached for now. :<
17
+ found_user = nil
18
+ assert_nothing_raised do
19
+ found_user = @user_class.find("user2")
20
+ end
21
+ base = @user_class.base
22
+ assert_equal("#{@user_class.dn_attribute}=user2,ou=sub,#{base}",
23
+ found_user.dn.to_s)
24
+ end
25
+ end
26
+ end
27
+
28
+ def test_rename
29
+ make_temporary_user(:simple => true) do |user,|
30
+ assert_not_equal("user2", user.id)
31
+ assert_raise(ActiveLdap::EntryNotFound) do
32
+ @user_class.find("user2")
33
+ end
34
+ user.id = "user2"
35
+ assert_true(user.save)
36
+ assert_equal("user2", user.id)
37
+
38
+ found_user = nil
39
+ assert_nothing_raised do
40
+ found_user = @user_class.find("user2")
41
+ end
42
+ assert_equal("user2", found_user.id)
43
+ end
44
+ end
45
+
46
+ priority :normal
47
+ def test_operational_attributes
48
+ make_temporary_group do |group|
49
+ dn, attributes = @group_class.search(:attributes => ["*"])[0]
50
+ normal_attributes = attributes.keys
51
+ dn, attributes = @group_class.search(:attributes => ["*", "+"])[0]
52
+ operational_attributes = attributes.keys - normal_attributes
53
+ operational_attribute = operational_attributes[0]
54
+
55
+ group = @group_class.find(:first, :attributes => ["*", "+"])
56
+ operational_attribute_value = group[operational_attribute]
57
+ assert_not_nil(operational_attribute_value)
58
+ group.save!
59
+ assert_equal(operational_attribute_value, group[operational_attribute])
60
+ end
61
+ end
62
+
63
+ def test_destroy_mixed_tree_by_instance
64
+ make_ou("base")
65
+ _entry_class = entry_class("ou=base")
66
+ _ou_class = ou_class("ou=base")
67
+ _dc_class = dc_class("ou=base")
68
+
69
+ root1 = _ou_class.create("root1")
70
+ child1 = _ou_class.create(:ou => "child1", :parent => root1)
71
+ child2 = _ou_class.create(:ou => "child2", :parent => root1)
72
+ domain = _dc_class.create(:dc => "domain", :o => "domain", :parent => root1)
73
+ child3 = _ou_class.create(:ou => "child3", :parent => root1)
74
+ root2 = _ou_class.create("root2")
75
+ assert_equal(["base",
76
+ "root1", "child1", "child2", "domain", "child3",
77
+ "root2"],
78
+ _entry_class.find(:all).collect(&:id))
79
+ assert_raise(ActiveLdap::DeleteError) do
80
+ root1.destroy_all
81
+ end
82
+ assert_equal(["base", "root1", "domain", "root2"],
83
+ _entry_class.find(:all).collect(&:id))
84
+ end
85
+
86
+ def test_delete_mixed_tree_by_instance
87
+ make_ou("base")
88
+ _entry_class = entry_class("ou=base")
89
+ _ou_class = ou_class("ou=base")
90
+ _dc_class = dc_class("ou=base")
91
+
92
+ root1 = _ou_class.create("root1")
93
+ child1 = _ou_class.create(:ou => "child1", :parent => root1)
94
+ child2 = _ou_class.create(:ou => "child2", :parent => root1)
95
+ domain = _dc_class.create(:dc => "domain", :o => "domain", :parent => root1)
96
+ child3 = _ou_class.create(:ou => "child3", :parent => root1)
97
+ root2 = _ou_class.create("root2")
98
+ assert_equal(["base",
99
+ "root1", "child1", "child2", "domain", "child3",
100
+ "root2"],
101
+ _entry_class.find(:all).collect(&:id))
102
+ assert_raise(ActiveLdap::DeleteError) do
103
+ root1.delete_all
104
+ end
105
+ assert_equal(["base", "root1", "domain", "root2"],
106
+ _entry_class.find(:all).collect(&:id))
107
+ end
108
+
9
109
  def test_delete_tree
10
110
  make_ou("base")
11
111
  _ou_class = ou_class("ou=base")
@@ -48,7 +148,6 @@ class TestBase < Test::Unit::TestCase
48
148
  entry_class.find(:all).collect(&:id))
49
149
  end
50
150
 
51
- priority :normal
52
151
  def test_first
53
152
  make_temporary_user(:simple => true) do |user1,|
54
153
  make_temporary_user(:simple => true) do |user2,|
@@ -290,7 +389,7 @@ class TestBase < Test::Unit::TestCase
290
389
  make_temporary_user(:uid => "test-user,ou=SUB") do |user, password|
291
390
  sub_user_class = Class.new(@user_class)
292
391
  sub_user_class.ldap_mapping :prefix => "ou=sub"
293
- assert_equal("uid=test-user,ou=sub,#{@user_class.base}",
392
+ assert_equal(dn("uid=test-user,ou=sub,#{@user_class.base}"),
294
393
  sub_user_class.find(user.uid).dn)
295
394
  end
296
395
  end
@@ -398,9 +497,9 @@ class TestBase < Test::Unit::TestCase
398
497
 
399
498
  def test_loose_dn
400
499
  make_temporary_user do |user,|
401
- assert(user.class.exists?(user.dn))
402
- assert(user.class.exists?(user.dn.gsub(/,/, " , ")))
403
- assert(user.class.exists?(user.dn.gsub(/=/, " = ")))
500
+ assert(user.class.exists?(user.dn.to_s))
501
+ assert(user.class.exists?(user.dn.to_s.gsub(/,/, " , ")))
502
+ assert(user.class.exists?(user.dn.to_s.gsub(/=/, " = ")))
404
503
  end
405
504
  end
406
505
 
@@ -12,6 +12,12 @@ class TestDN < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  priority :must
15
+ def test_parent
16
+ dn = parse("o=xxx,dc=local,dc=net")
17
+ assert_equal(parse("dc=local,dc=net"), dn.parent)
18
+ assert_equal(parse("dc=net"), dn.parent.parent)
19
+ assert_nil(dn.parent.parent.parent)
20
+ end
15
21
 
16
22
  priority :normal
17
23
  def test_case_insensitive_dn_minus
@@ -159,4 +165,8 @@ class TestDN < Test::Unit::TestCase
159
165
  def assert_dn_to_s(expected, dn)
160
166
  assert_equal(expected, ActiveLdap::DN.parse(dn).to_s)
161
167
  end
168
+
169
+ def parse(dn)
170
+ ActiveLdap::DN.parse(dn)
171
+ end
162
172
  end
@@ -7,7 +7,7 @@ class TestGroupls < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "groupls")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestLPasswd < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "lpasswd")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -15,38 +15,28 @@ 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).collect(&:name)
18
+ attributes = (user.must + user.may).collect(&:name) - ["objectClass"]
19
19
  _wrap_assertion do
20
20
  attributes.each do |name|
21
- assert(user.respond_to?(name), name)
22
- assert(user.respond_to?("#{name}="), "#{name}=")
23
- assert(user.respond_to?("#{name}?"), "#{name}?")
24
- assert(user.respond_to?("#{name}_before_type_cast"),
25
- "#{name}_before_type_cast")
21
+ assert_respond_to(user, name)
26
22
  end
23
+ assert_not_respond_to(user, "objectClass")
27
24
  end
28
25
 
29
26
  user.replace_class(user.class.required_classes)
30
27
  new_attributes = collect_attributes(user.class.required_classes)
28
+ new_attributes -= ["objectClass"]
31
29
 
32
30
  _wrap_assertion do
33
31
  assert_not_equal([], new_attributes)
34
32
  new_attributes.each do |name|
35
- assert(user.respond_to?(name), name)
36
- assert(user.respond_to?("#{name}="), "#{name}=")
37
- assert(user.respond_to?("#{name}?"), "#{name}?")
38
- assert(user.respond_to?("#{name}_before_type_cast"),
39
- "#{name}_before_type_cast")
33
+ assert_respond_to(user, name)
40
34
  end
41
35
 
42
36
  remained_attributes = (attributes - new_attributes)
43
37
  assert_not_equal([], remained_attributes)
44
38
  remained_attributes.each do |name|
45
- assert(!user.respond_to?(name), name)
46
- assert(!user.respond_to?("#{name}="), "#{name}=")
47
- assert(!user.respond_to?("#{name}?"), "#{name}?")
48
- assert(!user.respond_to?("#{name}_before_type_cast"),
49
- "#{name}_before_type_cast")
39
+ assert_not_respond_to(user, name)
50
40
  end
51
41
  end
52
42
  end
@@ -135,6 +125,7 @@ class TestReflection < Test::Unit::TestCase
135
125
  end
136
126
  end
137
127
 
128
+ private
138
129
  def assert_methods_with_only_required_classes(object, attributes)
139
130
  old_classes = (object.classes - object.class.required_classes).uniq
140
131
  old_attributes = collect_attributes(old_classes, false).uniq.sort
@@ -157,6 +148,22 @@ class TestReflection < Test::Unit::TestCase
157
148
  required_attributes)
158
149
  end
159
150
 
151
+ def assert_respond_to(object, name)
152
+ assert_true(object.respond_to?(name), name)
153
+ assert_true(object.respond_to?("#{name}="), "#{name}=")
154
+ assert_true(object.respond_to?("#{name}?"), "#{name}?")
155
+ assert_true(object.respond_to?("#{name}_before_type_cast"),
156
+ "#{name}_before_type_cast")
157
+ end
158
+
159
+ def assert_not_respond_to(object, name)
160
+ assert_false(object.respond_to?(name), name)
161
+ assert_false(object.respond_to?("#{name}="), "#{name}=")
162
+ assert_false(object.respond_to?("#{name}?"), "#{name}?")
163
+ assert_false(object.respond_to?("#{name}_before_type_cast"),
164
+ "#{name}_before_type_cast")
165
+ end
166
+
160
167
  def collect_attributes(object_classes, with_aliases=true)
161
168
  attributes = []
162
169
  object_classes.each do |object_class|
@@ -2,6 +2,29 @@ require 'al-test-utils'
2
2
 
3
3
  class TestSchema < Test::Unit::TestCase
4
4
  priority :must
5
+ def test_directory_operation
6
+ attributes_schema =
7
+ "( 2.5.18.1 NAME 'createTimestamp' " +
8
+ "DESC 'RFC4512: time which ob ject was created' " +
9
+ "EQUALITY generalizedTimeMatch " +
10
+ "ORDERING generalizedTimeOrderingMatch " +
11
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 " +
12
+ "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )"
13
+
14
+ assert_attribute_type({
15
+ :read_only => true,
16
+ :single_value => true,
17
+ :binary => false,
18
+ :binary_required => false,
19
+ :directory_operation => true,
20
+ :syntax => "1.3.6.1.4.1.1466.115.121.1.24",
21
+ :syntax_description => nil,
22
+ },
23
+ "createTimestamp",
24
+ [attributes_schema])
25
+ end
26
+
27
+ priority :normal
5
28
  def test_dit_content_rule
6
29
  object_class_schema = "( 2.5.6.6 NAME 'person' DESC " +
7
30
  "'RFC2256: a person' SUP top STRUCTURAL MUST sn " +
@@ -37,7 +60,6 @@ class TestSchema < Test::Unit::TestCase
37
60
  })
38
61
  end
39
62
 
40
- priority :normal
41
63
  def test_oid_list_with_just_only_one_oid
42
64
  ou_schema = "( 2.5.6.5 NAME 'organizationalUnit' SUP top STRUCTURAL MUST " +
43
65
  "(ou ) MAY (c $ l $ st $ street $ searchGuide $ businessCategory $ " +
@@ -524,4 +546,14 @@ class TestSchema < Test::Unit::TestCase
524
546
  end
525
547
  assert_equal(expected, result)
526
548
  end
549
+
550
+ def assert_attribute_type(expected, name, schemata)
551
+ group = 'attributeTypes'
552
+ entry = {group => schemata}
553
+ schema = ActiveLdap::Schema.new(entry)
554
+ attribute_hash = schema.attribute(name).to_hash
555
+ syntax = attribute_hash[:syntax]
556
+ attribute_hash[:syntax] = syntax.id if syntax
557
+ assert_equal(expected, attribute_hash)
558
+ end
527
559
  end
@@ -7,7 +7,7 @@ class TestUseraddBinary < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "useradd-binary")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUseradd < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "useradd")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUserdel < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "userdel")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUserls < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "userls")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUsermodBinaryAddTime < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "usermod-binary-add-time")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUsermodBinaryAdd < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "usermod-binary-add")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUsermodBinaryDel < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "usermod-binary-del")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUsermodLangAdd < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "usermod-lang-add")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -7,7 +7,7 @@ class TestUsermod < Test::Unit::TestCase
7
7
  super
8
8
  @command = File.join(@examples_dir, "usermod")
9
9
  make_ou("People")
10
- @user_class.instance_variable_set("@prefix", "ou=People")
10
+ @user_class.prefix = "ou=People"
11
11
  end
12
12
 
13
13
  priority :must
@@ -6,6 +6,51 @@ class TestValidation < Test::Unit::TestCase
6
6
  include ActiveLdap::Helper
7
7
 
8
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 = _("%{fn} is duplicated: %s")
16
+ format = format.sub(/^%\{fn\}/, la_('distinguishedName'))
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 = _("%{fn} has invalid format: %s: required syntax: %s: %s")
31
+ format = format.sub(/^%\{fn\}/, la_('jpegPhoto'))
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
+
9
54
  def test_set_attributes_with_invalid_dn_attribute_value
10
55
  user = nil
11
56
  assert_nothing_raised do
@@ -14,7 +59,6 @@ class TestValidation < Test::Unit::TestCase
14
59
  assert(!user.valid?)
15
60
  end
16
61
 
17
- priority :normal
18
62
  def test_set_attribute_to_invalid_dn_attribute_value_object
19
63
  user = @user_class.new("=")
20
64
  assert_nothing_raised do
@@ -30,7 +74,7 @@ class TestValidation < Test::Unit::TestCase
30
74
  invalid_format = _("%s is invalid distinguished name (DN): %s")
31
75
  invalid_message = invalid_format % ["uid==,#{user.class.base}", reason]
32
76
  format = _("%{fn} is invalid: %s")
33
- format = format.sub(/^%\{fn\}/, la_('DN'))
77
+ format = format.sub(/^%\{fn\}/, la_('distinguishedName'))
34
78
  message = format % invalid_message
35
79
  assert_equal([message],
36
80
  user.errors.full_messages.find_all {|m| /DN/ =~ m})
@@ -44,7 +88,7 @@ class TestValidation < Test::Unit::TestCase
44
88
  invalid_format = _("%s is invalid distinguished name (DN): %s")
45
89
  invalid_message = invalid_format % ["uid==,#{user.class.base}", reason]
46
90
  format = _("%{fn} is invalid: %s")
47
- format = format.sub(/^%\{fn\}/, la_('DN'))
91
+ format = format.sub(/^%\{fn\}/, la_('distinguishedName'))
48
92
  message = format % invalid_message
49
93
  assert_equal([message], user.errors.full_messages)
50
94
  end
@@ -142,7 +186,7 @@ class TestValidation < Test::Unit::TestCase
142
186
  ou = ou_class.new("YYY")
143
187
  assert(!ou.save)
144
188
  format = _("%{fn} is duplicated: %s")
145
- format = format.sub(/^%\{fn\}/, la_("DN"))
189
+ format = format.sub(/^%\{fn\}/, la_("distinguishedName"))
146
190
  message = format % ou.dn
147
191
  assert_equal([message], ou.errors.full_messages)
148
192
  end
@@ -156,9 +200,6 @@ class TestValidation < Test::Unit::TestCase
156
200
  end
157
201
 
158
202
  @group_class.validates_presence_of(:description)
159
- def @group_class.name
160
- "Group"
161
- end
162
203
  assert_raises(ActiveLdap::EntryInvalid) do
163
204
  group.save!
164
205
  end
@@ -174,9 +215,6 @@ class TestValidation < Test::Unit::TestCase
174
215
  assert_equal([], group.errors.to_a)
175
216
 
176
217
  @group_class.validates_presence_of(:description)
177
- def @group_class.name
178
- "Group"
179
- end
180
218
  assert(!group.valid?)
181
219
  assert(group.errors.invalid?(:description))
182
220
  assert_equal(1, group.errors.size)