activeldap 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/CHANGES +10 -0
  2. data/README +3 -2
  3. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  4. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  5. data/examples/al-admin/po/en/al-admin.po +1 -1
  6. data/examples/al-admin/po/ja/al-admin.po +1 -1
  7. data/examples/al-admin/po/nl/al-admin.po +1 -1
  8. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +7 -8
  9. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +2 -1
  10. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +1 -1
  11. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +2 -1
  12. data/lib/active_ldap.rb +9 -3
  13. data/lib/active_ldap/action_controller/ldap_benchmarking.rb +36 -0
  14. data/lib/active_ldap/adapter/jndi.rb +1 -1
  15. data/lib/active_ldap/adapter/jndi_connection.rb +2 -1
  16. data/lib/active_ldap/association/belongs_to_many.rb +10 -2
  17. data/lib/active_ldap/association/collection.rb +10 -0
  18. data/lib/active_ldap/association/has_many_utils.rb +13 -9
  19. data/lib/active_ldap/association/has_many_wrap.rb +10 -2
  20. data/lib/active_ldap/associations.rb +3 -3
  21. data/lib/active_ldap/base.rb +95 -32
  22. data/lib/active_ldap/connection.rb +1 -1
  23. data/lib/active_ldap/distinguished_name.rb +3 -0
  24. data/lib/active_ldap/entry_attribute.rb +2 -2
  25. data/lib/active_ldap/ldif.rb +2 -2
  26. data/lib/active_ldap/operations.rb +7 -3
  27. data/lib/active_ldap/user_password.rb +0 -1
  28. data/lib/active_ldap/validations.rb +2 -0
  29. data/po/en/active-ldap.po +1 -1
  30. data/po/ja/active-ldap.po +1 -1
  31. data/rails/plugin/active_ldap/init.rb +3 -34
  32. data/test-unit/History.txt +32 -0
  33. data/test-unit/Manifest.txt +70 -0
  34. data/test-unit/README.txt +32 -0
  35. data/test-unit/Rakefile +22 -0
  36. data/test-unit/bin/testrb +5 -0
  37. data/test-unit/lib/test/unit.rb +280 -0
  38. data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
  39. data/test-unit/lib/test/unit/assertions.rb +722 -0
  40. data/test-unit/lib/test/unit/attribute.rb +125 -0
  41. data/test-unit/lib/test/unit/autorunner.rb +250 -0
  42. data/test-unit/lib/test/unit/collector.rb +43 -0
  43. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  44. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  45. data/test-unit/lib/test/unit/collector/load.rb +135 -0
  46. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  47. data/test-unit/lib/test/unit/color.rb +61 -0
  48. data/test-unit/lib/test/unit/diff.rb +524 -0
  49. data/test-unit/lib/test/unit/error.rb +124 -0
  50. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  51. data/test-unit/lib/test/unit/failure.rb +110 -0
  52. data/test-unit/lib/test/unit/fixture.rb +185 -0
  53. data/test-unit/lib/test/unit/notification.rb +116 -0
  54. data/test-unit/lib/test/unit/omission.rb +129 -0
  55. data/test-unit/lib/test/unit/pending.rb +130 -0
  56. data/test-unit/lib/test/unit/priority.rb +146 -0
  57. data/test-unit/lib/test/unit/runner/console.rb +46 -0
  58. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  59. data/test-unit/lib/test/unit/testcase.rb +174 -0
  60. data/test-unit/lib/test/unit/testresult.rb +89 -0
  61. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  62. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  63. data/test-unit/lib/test/unit/ui/console/testrunner.rb +195 -0
  64. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  65. data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
  66. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  67. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  68. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  69. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  70. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  71. data/test-unit/lib/test/unit/version.rb +7 -0
  72. data/test-unit/sample/adder.rb +13 -0
  73. data/test-unit/sample/subtracter.rb +12 -0
  74. data/test-unit/sample/tc_adder.rb +18 -0
  75. data/test-unit/sample/tc_subtracter.rb +18 -0
  76. data/test-unit/sample/ts_examples.rb +7 -0
  77. data/test-unit/test/collector/test_descendant.rb +135 -0
  78. data/test-unit/test/collector/test_dir.rb +406 -0
  79. data/test-unit/test/collector/test_load.rb +333 -0
  80. data/test-unit/test/collector/test_objectspace.rb +98 -0
  81. data/test-unit/test/run-test.rb +13 -0
  82. data/test-unit/test/test_assertions.rb +693 -0
  83. data/test-unit/test/test_attribute.rb +86 -0
  84. data/{test-unit-ext → test-unit}/test/test_color.rb +3 -5
  85. data/{test-unit-ext → test-unit}/test/test_diff.rb +18 -16
  86. data/test-unit/test/test_emacs_runner.rb +60 -0
  87. data/test-unit/test/test_error.rb +26 -0
  88. data/test-unit/test/test_failure.rb +33 -0
  89. data/test-unit/test/test_fixture.rb +275 -0
  90. data/{test-unit-ext → test-unit}/test/test_notification.rb +7 -6
  91. data/test-unit/test/test_omission.rb +81 -0
  92. data/{test-unit-ext → test-unit}/test/test_pending.rb +15 -15
  93. data/{test-unit-ext → test-unit}/test/test_priority.rb +4 -3
  94. data/test-unit/test/test_testcase.rb +411 -0
  95. data/test-unit/test/test_testresult.rb +113 -0
  96. data/test-unit/test/test_testsuite.rb +129 -0
  97. data/test-unit/test/testunit_test_util.rb +12 -0
  98. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  99. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  100. data/test-unit/test/util/test_observable.rb +102 -0
  101. data/test-unit/test/util/test_procwrapper.rb +36 -0
  102. data/test/al-test-utils.rb +4 -4
  103. data/test/command.rb +1 -1
  104. data/test/run-test.rb +5 -4
  105. data/test/test_associations.rb +143 -9
  106. data/test/test_base.rb +25 -1
  107. data/test/test_dn.rb +2 -0
  108. data/test/test_find.rb +8 -1
  109. data/test/test_ldif.rb +51 -114
  110. data/test/test_reflection.rb +4 -8
  111. data/test/test_usermod-lang-add.rb +2 -1
  112. data/test/test_validation.rb +4 -3
  113. metadata +76 -31
  114. data/test-unit-ext/NEWS.en +0 -28
  115. data/test-unit-ext/NEWS.ja +0 -28
  116. data/test-unit-ext/README.en +0 -247
  117. data/test-unit-ext/README.ja +0 -246
  118. data/test-unit-ext/Rakefile +0 -111
  119. data/test-unit-ext/lib/test-unit-ext.rb +0 -16
  120. data/test-unit-ext/lib/test-unit-ext/always-show-result.rb +0 -28
  121. data/test-unit-ext/lib/test-unit-ext/assertions.rb +0 -40
  122. data/test-unit-ext/lib/test-unit-ext/attributes.rb +0 -129
  123. data/test-unit-ext/lib/test-unit-ext/backtrace-filter.rb +0 -17
  124. data/test-unit-ext/lib/test-unit-ext/color.rb +0 -59
  125. data/test-unit-ext/lib/test-unit-ext/colorized-runner.rb +0 -111
  126. data/test-unit-ext/lib/test-unit-ext/diff.rb +0 -516
  127. data/test-unit-ext/lib/test-unit-ext/long-display-for-emacs.rb +0 -25
  128. data/test-unit-ext/lib/test-unit-ext/notification.rb +0 -79
  129. data/test-unit-ext/lib/test-unit-ext/omission.rb +0 -96
  130. data/test-unit-ext/lib/test-unit-ext/pending.rb +0 -97
  131. data/test-unit-ext/lib/test-unit-ext/priority.rb +0 -158
  132. data/test-unit-ext/lib/test-unit-ext/version.rb +0 -3
  133. data/test-unit-ext/lib/test-unit-ext/xml-report.rb +0 -224
  134. data/test-unit-ext/test/run-test.rb +0 -14
  135. data/test-unit-ext/test/test_attributes.rb +0 -139
  136. data/test-unit-ext/test/test_omission.rb +0 -64
  137. data/test-unit-ext/test/test_xml_report.rb +0 -161
@@ -1,5 +1,4 @@
1
1
  require 'test/unit'
2
- require 'test-unit-ext'
3
2
 
4
3
  require 'erb'
5
4
  require 'yaml'
@@ -290,9 +289,10 @@ module AlTestUtils
290
289
  yield(uid)
291
290
  ensure
292
291
  if @user_class.exists?(uid)
293
- user = @user_class.find(uid)
294
- user.remove_connection
295
- @user_class.delete(user.dn)
292
+ @user_class.search(:value => uid) do |dn, attribute|
293
+ @user_class.remove_connection(dn)
294
+ @user_class.delete(dn)
295
+ end
296
296
  end
297
297
  end
298
298
 
@@ -32,7 +32,7 @@ module Command
32
32
  if args.any? {|x| x.nil?}
33
33
  raise ArgumentError, "args has nil: #{args.inspect}"
34
34
  end
35
- return java_run(cmd, *args, &block) unless Kernel.respond_to?(:fork)
35
+ return java_run(cmd, *args, &block) if Object.respond_to?(:java)
36
36
  in_r, in_w = IO.pipe
37
37
  out_r, out_w = IO.pipe
38
38
  pid = exit_status = nil
@@ -1,18 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $VERBOSE = true
4
+
3
5
  $KCODE = 'u'
4
6
 
5
7
  require 'yaml'
6
- require "test/unit"
7
8
 
8
9
  base_dir = File.expand_path(File.dirname(__FILE__))
9
10
  top_dir = File.expand_path(File.join(base_dir, ".."))
10
11
  $LOAD_PATH.unshift(File.join(top_dir, "lib"))
11
12
  $LOAD_PATH.unshift(File.join(top_dir, "test"))
12
13
 
13
- $LOAD_PATH.unshift(File.join(top_dir, "test-unit-ext", "lib"))
14
- require 'test-unit-ext'
15
- Test::Unit::TestSuite.priority_mode = true
14
+ $LOAD_PATH.unshift(File.join(top_dir, "test-unit", "lib"))
15
+ require "test/unit"
16
+ ARGV.unshift("--priority-mode")
16
17
 
17
18
  test_file = "test/test_*.rb"
18
19
  Dir.glob(test_file) do |file|
@@ -4,20 +4,117 @@ class TestAssociations < Test::Unit::TestCase
4
4
  include AlTestUtils
5
5
 
6
6
  priority :must
7
+ def test_has_many_wrap_with_dn_value
8
+ @user_class.has_many :references, :wrap => "seeAlso", :primary_key => "dn"
9
+ @user_class.set_associated_class(:references, @group_class)
10
+ @group_class.belongs_to :related_users, :many => "seeAlso",
11
+ :foreign_key => "dn"
12
+ @group_class.set_associated_class(:related_users, @user_class)
13
+ make_temporary_user do |user,|
14
+ make_temporary_group do |group1|
15
+ make_temporary_group do |group2|
16
+ make_temporary_group do |group3|
17
+ entries = [user, group1, group2, group3]
18
+
19
+ user.references << group1
20
+ user, group1, group2, group3 = reload_entries(*entries)
21
+ assert_references([[group1]], [user])
22
+ assert_related_users([user], group1)
23
+ assert_related_users([], group2)
24
+ assert_related_users([], group3)
25
+
26
+ user.references = [group2, group3]
27
+ user, group1, group2, group3 = reload_entries(*entries)
28
+ assert_references([[group2, group3]], [user])
29
+ assert_related_users([], group1)
30
+ assert_related_users([user], group2)
31
+ assert_related_users([user], group3)
32
+
33
+ user.references.delete(group2)
34
+ user, group1, group2, group3 = reload_entries(*entries)
35
+ assert_references([[group3]], [user])
36
+ assert_related_users([], group1)
37
+ assert_related_users([], group2)
38
+ assert_related_users([user], group3)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
7
44
 
8
45
  priority :normal
46
+ def test_belongs_to_many_with_dn_value
47
+ @user_class.has_many :references, :wrap => "seeAlso", :primary_key => "dn"
48
+ @user_class.set_associated_class(:references, @group_class)
49
+ @group_class.belongs_to :related_users, :many => "seeAlso",
50
+ :foreign_key => "dn"
51
+ @group_class.set_associated_class(:related_users, @user_class)
52
+ make_temporary_group do |group|
53
+ make_temporary_user do |user1,|
54
+ make_temporary_user do |user2,|
55
+ make_temporary_user do |user3,|
56
+ entries = [group, user1, user2, user3]
57
+
58
+ group.related_users = [user1, user2]
59
+ group, user1, user2, user3 = reload_entries(*entries)
60
+ assert_references([[group], [group], []],
61
+ [user1, user2, user3])
62
+ assert_related_users([user1, user2], group)
63
+
64
+ group.related_users << user3
65
+ group, user1, user2, user3 = reload_entries(*entries)
66
+ assert_references([[group], [group], [group]],
67
+ [user1, user2, user3])
68
+ assert_related_users([user1, user2, user3], group)
69
+
70
+ group.related_users.delete(user1)
71
+ group, user1, user2, user3 = reload_entries(*entries)
72
+ assert_references([[], [group], [group]],
73
+ [user1, user2, user3])
74
+ assert_related_users([user2, user3], group)
75
+
76
+ group.related_users = []
77
+ group, user1, user2, user3 = reload_entries(*entries)
78
+ assert_references([[], [], []],
79
+ [user1, user2, user3])
80
+ assert_related_users([], group)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+
9
87
  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)
88
+ @user_class.belongs_to :dn_groups, :many => "memberUid", :foreign_key => "dn"
89
+ @user_class.set_associated_class(:dn_groups, @group_class)
90
+ @group_class.has_many :dn_members, :wrap => "memberUid", :primary_key => "dn"
91
+ @group_class.set_associated_class(:dn_members, @user_class)
14
92
  make_temporary_group do |group|
15
93
  make_temporary_user do |user1,|
16
94
  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))
95
+ make_temporary_user do |user3,|
96
+ entries = [group, user1, user2, user3]
97
+
98
+ user1.dn_groups << group
99
+ group, user1, user2, user3 = reload_entries(*entries)
100
+ assert_dn_groups([[group], [], []], [user1, user2, user3])
101
+ assert_dn_members([user1], group)
102
+
103
+ user2.dn_groups = [group]
104
+ group, user1, user2, user3 = reload_entries(*entries)
105
+ assert_dn_groups([[group], [group], []], [user1, user2, user3])
106
+ assert_dn_members([user1, user2], group)
107
+
108
+ user1.dn_groups = []
109
+ group, user1, user2, user3 = reload_entries(*entries)
110
+ assert_dn_groups([[], [group], []], [user1, user2, user3])
111
+ assert_dn_members([user2], group)
112
+
113
+ user2.dn_groups.delete(group)
114
+ group, user1, user2, user3 = reload_entries(*entries)
115
+ assert_dn_groups([[], [], []], [user1, user2, user3])
116
+ assert_dn_members([], group)
117
+ end
21
118
  end
22
119
  end
23
120
  end
@@ -44,7 +141,6 @@ class TestAssociations < Test::Unit::TestCase
44
141
  end
45
142
  end
46
143
 
47
- priority :normal
48
144
  def test_belongs_to_before_save
49
145
  make_temporary_group do |group1|
50
146
  make_temporary_group do |group2|
@@ -350,4 +446,42 @@ class TestAssociations < Test::Unit::TestCase
350
446
  end
351
447
  end
352
448
  end
449
+
450
+ private
451
+ def reload_entries(*entries)
452
+ entries.collect do |entry|
453
+ entry.class.find(entry[entry.dn_attribute])
454
+ end
455
+ end
456
+
457
+ def assert_groups_relation(expected_groups_values, entries, relation_name)
458
+ expected_groups_values = expected_groups_values.collect do |groups|
459
+ groups.collect(&:cn).sort
460
+ end
461
+ actual_groups_values = entries.collect do |entry|
462
+ entry.send(relation_name).collect(&:cn).sort
463
+ end
464
+ assert_equal(expected_groups_values, actual_groups_values)
465
+ end
466
+
467
+ def assert_users_relation(expected_users, group, relation_name)
468
+ assert_equal(expected_users.collect(&:cn).sort,
469
+ group.send(relation_name).collect(&:cn).sort)
470
+ end
471
+
472
+ def assert_references(expected_groups_values, users)
473
+ assert_groups_relation(expected_groups_values, users, :references)
474
+ end
475
+
476
+ def assert_related_users(expected_users, group)
477
+ assert_users_relation(expected_users, group, :related_users)
478
+ end
479
+
480
+ def assert_dn_groups(expected_groups_values, users)
481
+ assert_groups_relation(expected_groups_values, users, :dn_groups)
482
+ end
483
+
484
+ def assert_dn_members(expected_users, group)
485
+ assert_users_relation(expected_users, group, :dn_members)
486
+ end
353
487
  end
@@ -6,6 +6,17 @@ class TestBase < Test::Unit::TestCase
6
6
  include AlTestUtils
7
7
 
8
8
  priority :must
9
+ def test_to_ldif
10
+ make_temporary_group do |group,|
11
+ assert_to_ldif(group)
12
+
13
+ group.gidNumber += 1
14
+ group.description = ["Description", {"en" => "Description(en)"}]
15
+ assert_to_ldif(group)
16
+ end
17
+ end
18
+
19
+ priority :normal
9
20
  def test_save_with_changes
10
21
  make_temporary_user do |user, password|
11
22
  user.cn += "!!!"
@@ -19,7 +30,6 @@ class TestBase < Test::Unit::TestCase
19
30
  end
20
31
  end
21
32
 
22
- priority :normal
23
33
  def test_normalize_dn_attribute
24
34
  make_ou("Ous")
25
35
  ou_class = Class.new(ActiveLdap::Base)
@@ -595,6 +605,12 @@ EOX
595
605
  end
596
606
  end
597
607
 
608
+ def test_attribute_present_with_unknown_attribute
609
+ make_temporary_user do |user, password|
610
+ assert(!user.attribute_present?(:unknown_attribute))
611
+ end
612
+ end
613
+
598
614
  def test_update_all
599
615
  make_temporary_user do |user, password|
600
616
  make_temporary_user do |user2, password|
@@ -656,4 +672,12 @@ EOX
656
672
  yield
657
673
  modify_called
658
674
  end
675
+
676
+ def assert_to_ldif(entry)
677
+ records = ActiveLdap::LDIF.parse(entry.to_ldif).records
678
+ parsed_entries = records.collect do |record|
679
+ entry.class.send(:instantiate, [record.dn, record.attributes])
680
+ end
681
+ assert_equal([entry], parsed_entries)
682
+ end
659
683
  end
@@ -1,3 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  require 'al-test-utils'
2
4
 
3
5
  class TestDN < Test::Unit::TestCase
@@ -4,6 +4,14 @@ class TestFind < Test::Unit::TestCase
4
4
  include AlTestUtils
5
5
 
6
6
  priority :must
7
+ def test_find_with_dn
8
+ make_temporary_user do |user,|
9
+ assert_equal(user.dn, @user_class.find(user.dn).dn)
10
+ assert_equal(user.dn, @user_class.find(ActiveLdap::DN.parse(user.dn)).dn)
11
+ end
12
+ end
13
+
14
+ priority :normal
7
15
  def test_find_with_special_value_prefix
8
16
  # \2C == ','
9
17
  make_ou("a\\2Cb,ou=Users")
@@ -31,7 +39,6 @@ class TestFind < Test::Unit::TestCase
31
39
  end
32
40
  end
33
41
 
34
- priority :normal
35
42
  def test_find_with_sort_by_in_ldap_mapping
36
43
  @user_class.ldap_mapping(:dn_attribute => @user_class.dn_attribute,
37
44
  :prefix => @user_class.prefix,
@@ -1,3 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  require 'al-test-utils'
2
4
 
3
5
  class TestLDIF < Test::Unit::TestCase
@@ -560,6 +562,55 @@ replace: postaladdress
560
562
  -
561
563
  delete: description
562
564
  -
565
+ EOL
566
+
567
+ assert_ldif_to_s(<<-EOL, ldif_source)
568
+ version: 1
569
+ dn: cn=Fiona Jensen,ou=Marketing,dc=airius,dc=com
570
+ changetype: add
571
+ cn: Fiona Jensen
572
+ objectclass: organizationalPerson
573
+ objectclass: person
574
+ objectclass: top
575
+ sn: Jensen
576
+ telephonenumber: +1 408 555 1212
577
+ uid: fiona
578
+
579
+ dn: cn=Robert Jensen,ou=Marketing,dc=airius,dc=com
580
+ changetype: delete
581
+
582
+ dn: cn=Paul Jensen,ou=Product Development,dc=airius,dc=com
583
+ changetype: modrdn
584
+ newrdn: cn=Paula Jensen
585
+ deleteoldrdn: 1
586
+
587
+ dn: ou=PD Accountants,ou=Product Development,dc=airius,dc=com
588
+ changetype: modrdn
589
+ newrdn: ou=Product Development Accountants
590
+ deleteoldrdn: 0
591
+ newsuperior: ou=Accounting,dc=airius,dc=com
592
+
593
+ dn: cn=Paula Jensen,ou=Product Development,dc=airius,dc=com
594
+ changetype: modify
595
+ add: postaladdress
596
+ postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086
597
+ -
598
+ delete: description
599
+ -
600
+ replace: telephonenumber
601
+ telephonenumber: +1 408 555 1234
602
+ telephonenumber: +1 408 555 5678
603
+ -
604
+ delete: facsimiletelephonenumber
605
+ facsimiletelephonenumber: +1 408 555 9876
606
+ -
607
+
608
+ dn: cn=Ingrid Jensen,ou=Product Support,dc=airius,dc=com
609
+ changetype: modify
610
+ replace: postaladdress
611
+ -
612
+ delete: description
613
+ -
563
614
  EOL
564
615
 
565
616
  change_attributes_add = {
@@ -665,120 +716,6 @@ EOL
665
716
  actual)
666
717
  end
667
718
 
668
- def test_multi_change_type_records
669
- ldif_source = <<-EOL
670
- version: 1
671
- # Add a new entry
672
- dn: cn=Fiona Jensen, ou=Marketing, dc=airius, dc=com
673
- changetype: add
674
- objectclass: top
675
- objectclass: person
676
- objectclass: organizationalPerson
677
- cn: Fiona Jensen
678
- sn: Jensen
679
- uid: fiona
680
- telephonenumber: +1 408 555 1212
681
-
682
- # Delete an existing entry
683
- dn: cn=Robert Jensen, ou=Marketing, dc=airius, dc=com
684
- changetype: delete
685
-
686
- # Modify an entry's relative distinguished name
687
- dn: cn=Paul Jensen, ou=Product Development, dc=airius, dc=com
688
- changetype: modrdn
689
- newrdn: cn=Paula Jensen
690
- deleteoldrdn: 1
691
-
692
- # Rename an entry and move all of its children to a new location in
693
- # the directory tree (only implemented by LDAPv3 servers).
694
- dn: ou=PD Accountants, ou=Product Development, dc=airius, dc=com
695
- changetype: modrdn
696
- newrdn: ou=Product Development Accountants
697
- deleteoldrdn: 0
698
- newsuperior: ou=Accounting, dc=airius, dc=com
699
-
700
- # Modify an entry: add an additional value to the postaladdress
701
- # attribute, completely delete the description attribute, replace
702
- # the telephonenumber attribute with two values, and delete a specific
703
- # value from the facsimiletelephonenumber attribute
704
- dn: cn=Paula Jensen, ou=Product Development, dc=airius, dc=com
705
- changetype: modify
706
- add: postaladdress
707
- postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086
708
- -
709
- delete: description
710
- -
711
- replace: telephonenumber
712
- telephonenumber: +1 408 555 1234
713
- telephonenumber: +1 408 555 5678
714
- -
715
- delete: facsimiletelephonenumber
716
- facsimiletelephonenumber: +1 408 555 9876
717
- -
718
-
719
- # Modify an entry: replace the postaladdress attribute with an empty
720
- # set of values (which will cause the attribute to be removed), and
721
- # delete the entire description attribute. Note that the first will
722
- # always succeed, while the second will only succeed if at least
723
- # one value for the description attribute is present.
724
- dn: cn=Ingrid Jensen, ou=Product Support, dc=airius, dc=com
725
- changetype: modify
726
- replace: postaladdress
727
- -
728
- delete: description
729
- -
730
- EOL
731
-
732
- assert_ldif_to_s(<<-EOL, ldif_source)
733
- version: 1
734
- dn: cn=Fiona Jensen,ou=Marketing,dc=airius,dc=com
735
- changetype: add
736
- cn: Fiona Jensen
737
- objectclass: organizationalPerson
738
- objectclass: person
739
- objectclass: top
740
- sn: Jensen
741
- telephonenumber: +1 408 555 1212
742
- uid: fiona
743
-
744
- dn: cn=Robert Jensen,ou=Marketing,dc=airius,dc=com
745
- changetype: delete
746
-
747
- dn: cn=Paul Jensen,ou=Product Development,dc=airius,dc=com
748
- changetype: modrdn
749
- newrdn: cn=Paula Jensen
750
- deleteoldrdn: 1
751
-
752
- dn: ou=PD Accountants,ou=Product Development,dc=airius,dc=com
753
- changetype: modrdn
754
- newrdn: ou=Product Development Accountants
755
- deleteoldrdn: 0
756
- newsuperior: ou=Accounting,dc=airius,dc=com
757
-
758
- dn: cn=Paula Jensen,ou=Product Development,dc=airius,dc=com
759
- changetype: modify
760
- add: postaladdress
761
- postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086
762
- -
763
- delete: description
764
- -
765
- replace: telephonenumber
766
- telephonenumber: +1 408 555 1234
767
- telephonenumber: +1 408 555 5678
768
- -
769
- delete: facsimiletelephonenumber
770
- facsimiletelephonenumber: +1 408 555 9876
771
- -
772
-
773
- dn: cn=Ingrid Jensen,ou=Product Support,dc=airius,dc=com
774
- changetype: modify
775
- replace: postaladdress
776
- -
777
- delete: description
778
- -
779
- EOL
780
- end
781
-
782
719
  def test_modify_record
783
720
  ldif_source = <<-EOL
784
721
  version: 1