activeldap 0.10.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/CHANGES +6 -30
  2. data/README +4 -2
  3. data/Rakefile +7 -0
  4. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  5. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  6. data/examples/al-admin/po/en/al-admin.po +3 -3
  7. data/examples/al-admin/po/ja/al-admin.po +3 -3
  8. data/examples/al-admin/po/nl/al-admin.po +3 -3
  9. data/lib/active_ldap/adapter/base.rb +0 -2
  10. data/lib/active_ldap/base.rb +4 -2
  11. data/lib/active_ldap/get_text_support.rb +3 -11
  12. data/lib/active_ldap/operations.rb +1 -0
  13. data/lib/active_ldap/schema/syntaxes.rb +5 -3
  14. data/lib/active_ldap/validations.rb +25 -15
  15. data/lib/active_ldap.rb +1 -1
  16. data/po/en/active-ldap.po +1 -1
  17. data/po/ja/active-ldap.po +1 -1
  18. data/rails/plugin/active_ldap/init.rb +1 -1
  19. data/test/run-test.rb +2 -0
  20. data/test/test_base.rb +63 -1
  21. data/test/test_syntax.rb +3 -2
  22. data/test-unit-ext/NEWS.en +28 -0
  23. data/test-unit-ext/NEWS.ja +28 -0
  24. data/test-unit-ext/README.en +247 -0
  25. data/test-unit-ext/README.ja +246 -0
  26. data/test-unit-ext/Rakefile +111 -0
  27. data/{test → test-unit-ext/lib}/test-unit-ext/always-show-result.rb +0 -0
  28. data/test-unit-ext/lib/test-unit-ext/assertions.rb +40 -0
  29. data/test-unit-ext/lib/test-unit-ext/attributes.rb +129 -0
  30. data/{test → test-unit-ext/lib}/test-unit-ext/backtrace-filter.rb +0 -0
  31. data/test-unit-ext/lib/test-unit-ext/color.rb +59 -0
  32. data/test-unit-ext/lib/test-unit-ext/colorized-runner.rb +111 -0
  33. data/test-unit-ext/lib/test-unit-ext/diff.rb +516 -0
  34. data/{test → test-unit-ext/lib}/test-unit-ext/long-display-for-emacs.rb +0 -0
  35. data/test-unit-ext/lib/test-unit-ext/notification.rb +79 -0
  36. data/test-unit-ext/lib/test-unit-ext/omission.rb +96 -0
  37. data/test-unit-ext/lib/test-unit-ext/pending.rb +97 -0
  38. data/{test → test-unit-ext/lib}/test-unit-ext/priority.rb +25 -53
  39. data/test-unit-ext/lib/test-unit-ext/version.rb +3 -0
  40. data/test-unit-ext/lib/test-unit-ext/xml-report.rb +224 -0
  41. data/test-unit-ext/lib/test-unit-ext.rb +16 -0
  42. data/test-unit-ext/misc/rd2html.rb +42 -0
  43. data/test-unit-ext/test/run-test.rb +14 -0
  44. data/test-unit-ext/test/test_attributes.rb +139 -0
  45. data/test-unit-ext/test/test_color.rb +39 -0
  46. data/test-unit-ext/test/test_diff.rb +475 -0
  47. data/test-unit-ext/test/test_notification.rb +32 -0
  48. data/test-unit-ext/test/test_omission.rb +64 -0
  49. data/test-unit-ext/test/test_pending.rb +64 -0
  50. data/test-unit-ext/test/test_priority.rb +88 -0
  51. data/test-unit-ext/test/test_xml_report.rb +161 -0
  52. metadata +34 -7
  53. data/test/test-unit-ext.rb +0 -4
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ 1.0.0:
2
+ * Fixed GSSAPI auth failure. [#18764] (Reported by Lennon Day-Reynolds)
3
+ * Supported Symbol as :dn_attribute_value. [#18921] (Requested by Nobody)
4
+ * Improved DN attribute detection. (Reported by Iain Pople)
5
+ * Avoided unnecesally modify operation. (Reported by Tilo)
6
+
1
7
  0.10.0:
2
8
  * Implemented LDIF parser.
3
9
  * Improved validation:
@@ -15,36 +21,6 @@
15
21
  user.user_certificate # => "..."
16
22
  * Added :excluded_classed ldap_mapping option.
17
23
  * Logged operation time used for LDAP operation.
18
- * Improved API:
19
- * Accepted non String value for find(:value => XXX).
20
- (Suggested by Marc Dequèn)
21
- * Accepted DN as ActiveLdap::Base.new(XXX).
22
- (Reported by Jeremy Pruitt)
23
- * Treated empty password for smiple bind as anonymous bind.
24
- (Suggested by Bodaniel Jeans)
25
- * Ensured adding "objectClass" for find's :attribute value. [#16946]
26
- (Suggested by Nobody)
27
- * Fixed a GeneralizedTime type casting bug.
28
- (Reported by Bodaniel Jeanes)
29
-
30
- 0.9.1:
31
- * Implemented LDIF parser.
32
- * Improved validation:
33
- * Added some validations.
34
- * Fixed SINGLE-VALUE validation. [#17763]
35
- (Reported by Naoto Morishima)
36
- * Supported JNDI as backend.
37
- * Improved auto reconnection.
38
- * Supported Rails 2.0.2.
39
- * Improved performance. (4x)
40
- * [API CHANGE]: removed "'binary' =>" from getter result.
41
- e.g.
42
- before:
43
- user.user_certificate # => {"binary" => "..."}
44
- now:
45
- user.user_certificate # => "..."
46
- * Added :excluded_classed ldap_mapping option.
47
- * Logged operation time used for LDAP operation.
48
24
  * Improved API:
49
25
  * Accepted non String value for find(:value => XXX).
50
26
  (Suggested by Marc Dequèn)
data/README CHANGED
@@ -104,5 +104,7 @@ list, please point out.
104
104
  * Bodaniel Jeanes:
105
105
  * A suggestion for behavior on simple bind with empty password.
106
106
  * Bug reports.
107
- * Naoto Morishima:
108
- * Bug reports.
107
+ * Naoto Morishima: Bug reports.
108
+ * David Morton: An API improvement idea.
109
+ * Lennon Day-Reynolds: Bug reports.
110
+ * Tilo: A bug report.
data/Rakefile CHANGED
@@ -44,6 +44,13 @@ at_exit do
44
44
  FileUtils.rm_f(manifest)
45
45
  end
46
46
 
47
+ # For Hoe's no user friendly default behavior. :<
48
+ File.open("README.txt", "w") {|file| file << "= Dummy README\n== XXX\n"}
49
+ FileUtils.cp("CHANGES", "History.txt")
50
+ at_exit do
51
+ FileUtils.rm_f("README.txt")
52
+ FileUtils.rm_f("History.txt")
53
+ end
47
54
 
48
55
  project = Hoe.new('activeldap', ActiveLdap::VERSION) do |project|
49
56
  project.rubyforge_name = 'ruby-activeldap'
@@ -1,11 +1,11 @@
1
1
  # English translations for AL Admin package.
2
- # Copyright (C) 2007 Kouhei Sutou
2
+ # Copyright (C) 2007,2008 Kouhei Sutou
3
3
  # This file is distributed under the same license as the AL Admin package.
4
- # Kouhei Sutou <kou@cozmixng.org>, 2007.
4
+ # Kouhei Sutou <kou@cozmixng.org>, 2007,2008.
5
5
  #
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: AL Admin 0.10.0\n"
8
+ "Project-Id-Version: AL Admin 1.0.0\n"
9
9
  "POT-Creation-Date: 2008-02-09 14:25+0900\n"
10
10
  "PO-Revision-Date: 2007-08-19 09:44+0900\n"
11
11
  "Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
@@ -1,11 +1,11 @@
1
1
  # AL Admin's translated messages for Japanese.
2
- # Copyright (C) 2007 Kouhei Sutou
2
+ # Copyright (C) 2007,2008 Kouhei Sutou
3
3
  # This file is distributed under the same license as the AL Admin package.
4
- # Kouhei Sutou <kou@cozmixng.org>, 2007.
4
+ # Kouhei Sutou <kou@cozmixng.org>, 2007,2008.
5
5
  #
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: AL Admin 0.10.0\n"
8
+ "Project-Id-Version: AL Admin 1.0.0\n"
9
9
  "POT-Creation-Date: 2008-02-09 14:25+0900\n"
10
10
  "PO-Revision-Date: 2007-11-04 16:02+0900\n"
11
11
  "Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
@@ -1,12 +1,12 @@
1
1
  # translation of al-admin.po to Nederlands
2
2
  # Nederlands translations for AL Admin package.
3
- # Copyright (C) 2007 Ace Suares
3
+ # Copyright (C) 2007,2008 Ace Suares
4
4
  # This file is distributed under the same license as the AL Admin package.
5
5
  #
6
- # Ace Suares <ace@suares.an>, 2007.
6
+ # Ace Suares <ace@suares.an>, 2007,2008.
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: AL Admin 0.10.0\n"
9
+ "Project-Id-Version: AL Admin 1.0.0\n"
10
10
  "POT-Creation-Date: 2008-02-09 14:25+0900\n"
11
11
  "PO-Revision-Date: 2007-08-24 22:03+0900\n"
12
12
  "Last-Translator: Ace Suares <ace@suares.an>\n"
@@ -287,8 +287,6 @@ module ActiveLdap
287
287
  end
288
288
 
289
289
  def sasl_bind(bind_dn, options={})
290
- return false unless bind_dn
291
-
292
290
  # Get all SASL mechanisms
293
291
  mechanisms = operation(options) do
294
292
  root_dse_values("supportedSASLMechanisms")
@@ -353,6 +353,7 @@ module ActiveLdap
353
353
  validate_ldap_mapping_options(options)
354
354
 
355
355
  self.dn_attribute = options[:dn_attribute] || default_dn_attribute
356
+ self.dn_attribute = dn_attribute.to_s if dn_attribute.is_a?(Symbol)
356
357
  self.prefix = options[:prefix] || default_prefix
357
358
  self.scope = options[:scope]
358
359
  self.required_classes = options[:classes]
@@ -602,7 +603,8 @@ module ActiveLdap
602
603
 
603
604
  alias_method(:dn_attribute_of_class, :dn_attribute)
604
605
  def dn_attribute
605
- @dn_attribute || dn_attribute_of_class
606
+ _dn_attribute = @dn_attribute || dn_attribute_of_class
607
+ to_real_attribute_name(_dn_attribute) || _dn_attribute
606
608
  end
607
609
 
608
610
  def default_search_attribute
@@ -1210,7 +1212,7 @@ module ActiveLdap
1210
1212
  end
1211
1213
 
1212
1214
  def collect_all_attributes(data)
1213
- dn_attr = to_real_attribute_name(dn_attribute)
1215
+ dn_attr = dn_attribute
1214
1216
  dn_value = data[dn_attr]
1215
1217
 
1216
1218
  attributes = []
@@ -1,15 +1,7 @@
1
1
  module ActiveLdap
2
- if const_defined?(:GetTextFallback)
3
- class << self
4
- def get_text_supported?
5
- false
6
- end
7
- end
8
- else
9
- class << self
10
- def get_text_supported?
11
- true
12
- end
2
+ class << self
3
+ def get_text_supported?
4
+ not const_defined?(:GetTextFallback)
13
5
  end
14
6
  end
15
7
 
@@ -479,6 +479,7 @@ module ActiveLdap
479
479
  end
480
480
 
481
481
  def modify_entry(dn, attributes, options={})
482
+ return if attributes.empty?
482
483
  unnormalized_attributes = attributes.collect do |type, key, value|
483
484
  [type, key, unnormalize_attribute(key, value)]
484
485
  end
@@ -391,11 +391,13 @@ module ActiveLdap
391
391
  end
392
392
  end
393
393
 
394
- class TelephoneNumber < Base
394
+ class TelephoneNumber < PrintableString
395
395
  SYNTAXES["1.3.6.1.4.1.1466.115.121.1.50"] = self
396
396
 
397
- def validate(value)
398
- PrintableString.new.validate(value)
397
+ private
398
+ def validate_normalized_value(value, original_value)
399
+ return nil if value.blank?
400
+ super
399
401
  end
400
402
  end
401
403
  end
@@ -37,12 +37,14 @@ module ActiveLdap
37
37
  validate :validate_ldap_values
38
38
 
39
39
  class << self
40
- def evaluate_condition_with_active_ldap_support(condition, entry)
41
- evaluate_condition_without_active_ldap_support(condition, entry)
42
- rescue ActiveRecord::ActiveRecordError
43
- raise Error, $!.message
40
+ if method_defined?(:evaluate_condition)
41
+ def evaluate_condition_with_active_ldap_support(condition, entry)
42
+ evaluate_condition_without_active_ldap_support(condition, entry)
43
+ rescue ActiveRecord::ActiveRecordError
44
+ raise Error, $!.message
45
+ end
46
+ alias_method_chain :evaluate_condition, :active_ldap_support
44
47
  end
45
- alias_method_chain :evaluate_condition, :active_ldap_support
46
48
  end
47
49
 
48
50
  def save_with_active_ldap_support!
@@ -58,7 +60,15 @@ module ActiveLdap
58
60
  rescue ActiveRecord::ActiveRecordError
59
61
  raise Error, $!.message
60
62
  end
61
- alias_method_chain :run_validations, :active_ldap_support
63
+ if private_method_defined?(:run_validations)
64
+ alias_method_chain :run_validations, :active_ldap_support
65
+ else
66
+ alias_method(:run_callbacks_with_active_ldap_support,
67
+ :run_validations_with_active_ldap_support)
68
+ alias_method_chain :run_callbacks, :active_ldap_support
69
+ alias_method(:run_validations_without_active_ldap_support,
70
+ :run_callbacks_without_active_ldap_support)
71
+ end
62
72
  end
63
73
  end
64
74
 
@@ -94,11 +104,13 @@ module ActiveLdap
94
104
  "%{fn} has excluded values: %s",
95
105
  names.size)
96
106
  else
97
- format = n_("has excluded value: %s",
98
- "has excluded values: %s",
99
- names.size)
107
+ if names.size == 1
108
+ format = "has excluded value: %s"
109
+ else
110
+ format = "has excluded values: %s"
111
+ end
100
112
  end
101
- errors.add("objectClass", format % names.join(', '))
113
+ errors.add("objectClass", format % names.join(", "))
102
114
  end
103
115
 
104
116
  # validate_required_ldap_values
@@ -132,11 +144,9 @@ module ActiveLdap
132
144
  args << aliases.join(', ')
133
145
  end
134
146
  else
135
- if aliases.empty?
136
- format = "is required attribute by objectClass '%s'"
137
- else
138
- format = "is required attribute by objectClass '%s'" \
139
- ": aliases: %s"
147
+ format = "is required attribute by objectClass '%s'"
148
+ unless aliases.empty?
149
+ format << ": aliases: %s"
140
150
  args << aliases.join(', ')
141
151
  end
142
152
  end
data/lib/active_ldap.rb CHANGED
@@ -922,7 +922,7 @@ if Dependencies.respond_to?(:load_paths)
922
922
  end
923
923
 
924
924
  module ActiveLdap
925
- VERSION = "0.10.0"
925
+ VERSION = "1.0.0"
926
926
  end
927
927
 
928
928
  if RUBY_PLATFORM.match('linux')
data/po/en/active-ldap.po CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: Ruby/ActiveLdap 0.10.0\n"
8
+ "Project-Id-Version: Ruby/ActiveLdap 1.0.0\n"
9
9
  "POT-Creation-Date: 2008-02-10 22:36+0900\n"
10
10
  "PO-Revision-Date: 2007-08-19 09:49+0900\n"
11
11
  "Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
data/po/ja/active-ldap.po CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: Ruby/ActiveLdap 0.10.0\n"
8
+ "Project-Id-Version: Ruby/ActiveLdap 1.0.0\n"
9
9
  "POT-Creation-Date: 2008-02-10 22:36+0900\n"
10
10
  "PO-Revision-Date: 2008-02-10 22:37+0900\n"
11
11
  "Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
@@ -1,7 +1,7 @@
1
1
  require_library_or_gem 'active_ldap'
2
2
  ActiveLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
3
3
 
4
- required_version = ["0", "9", "1"]
4
+ required_version = ["0", "10", "0"]
5
5
  if (ActiveLdap::VERSION.split(".") <=> required_version) < 0
6
6
  ActiveLdap::Base.class_eval do
7
7
  format = _("You need ActiveLdap %s or later")
data/test/run-test.rb CHANGED
@@ -10,7 +10,9 @@ top_dir = File.expand_path(File.join(base_dir, ".."))
10
10
  $LOAD_PATH.unshift(File.join(top_dir, "lib"))
11
11
  $LOAD_PATH.unshift(File.join(top_dir, "test"))
12
12
 
13
+ $LOAD_PATH.unshift(File.join(top_dir, "test-unit-ext", "lib"))
13
14
  require 'test-unit-ext'
15
+ Test::Unit::TestSuite.priority_mode = true
14
16
 
15
17
  test_file = "test/test_*.rb"
16
18
  Dir.glob(test_file) do |file|
data/test/test_base.rb CHANGED
@@ -1,10 +1,42 @@
1
1
  # -*- coding: utf-8 -*-
2
+
2
3
  require 'al-test-utils'
3
4
 
4
5
  class TestBase < Test::Unit::TestCase
5
6
  include AlTestUtils
6
7
 
7
8
  priority :must
9
+ def test_save_with_changes
10
+ make_temporary_user do |user, password|
11
+ user.cn += "!!!"
12
+ assert_true(detect_modify(user) {user.save})
13
+ end
14
+ end
15
+
16
+ def test_save_without_changes
17
+ make_temporary_user do |user, password|
18
+ assert_false(detect_modify(user) {user.save})
19
+ end
20
+ end
21
+
22
+ priority :normal
23
+ def test_normalize_dn_attribute
24
+ make_ou("Ous")
25
+ ou_class = Class.new(ActiveLdap::Base)
26
+ ou_class.ldap_mapping(:dn_attribute => "OU",
27
+ :prefix => "ou=OUS",
28
+ :classes => ["top", "organizationalUnit"])
29
+ ou_class.new("ou1").save!
30
+ ou_class.new("ou2").save!
31
+
32
+ ou1 = ou_class.find("ou1")
33
+ assert_equal("ou1", ou1.ou)
34
+ assert_equal("ou=ou1,#{ou_class.base}", ou1.dn)
35
+ ou2 = ou_class.find("ou2")
36
+ assert_equal("ou2", ou2.ou)
37
+ assert_equal("ou=ou2,#{ou_class.base}", ou2.dn)
38
+ end
39
+
8
40
  def test_excluded_classes
9
41
  mapping = {:classes => ["person"]}
10
42
  person_class = Class.new(@user_class)
@@ -36,7 +68,6 @@ class TestBase < Test::Unit::TestCase
36
68
  end
37
69
  end
38
70
 
39
- priority :normal
40
71
  def test_new_with_dn
41
72
  cn = "XXX"
42
73
  dn = "cn=#{cn},#{@user_class.base}"
@@ -459,6 +490,16 @@ class TestBase < Test::Unit::TestCase
459
490
  end
460
491
  end
461
492
 
493
+ def test_ldap_mapping_symbol_dn_attribute
494
+ ou_class = Class.new(ActiveLdap::Base)
495
+ ou_class.ldap_mapping(:dn_attribute => :ou,
496
+ :prefix => "",
497
+ :classes => ["top", "organizationalUnit"])
498
+ assert_equal(["ou=Groups,#{current_configuration['base']}",
499
+ "ou=Users,#{current_configuration['base']}"],
500
+ ou_class.find(:all).collect(&:dn).sort)
501
+ end
502
+
462
503
  def test_ldap_mapping_validation
463
504
  ou_class = Class.new(ActiveLdap::Base)
464
505
  assert_raises(ArgumentError) do
@@ -594,4 +635,25 @@ EOX
594
635
  end
595
636
  end
596
637
  end
638
+
639
+ private
640
+ def detect_modify(object)
641
+ modify_called = false
642
+ singleton_class = class << object; self; end
643
+ singleton_class.send(:define_method, :modify_entry) do |*args|
644
+ dn, attributes, options = args
645
+ options ||= {}
646
+ modify_detector = Object.new
647
+ modify_detector.instance_variable_set("@called", false)
648
+ def modify_detector.modify(dn, entries, options)
649
+ @called = true
650
+ end
651
+ options[:connection] = modify_detector
652
+ result = super(dn, attributes, options)
653
+ modify_called = modify_detector.instance_variable_get("@called")
654
+ result
655
+ end
656
+ yield
657
+ modify_called
658
+ end
597
659
  end
data/test/test_syntax.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  require 'al-test-utils'
2
4
 
3
5
  class TestSyntax < Test::Unit::TestCase
@@ -283,8 +285,7 @@ class TestSyntax < Test::Unit::TestCase
283
285
 
284
286
  def test_telephone_number_validate
285
287
  assert_valid("+1 512 305 0280", "Telephone Number")
286
-
287
- assert_invalid(_("empty string"), "", "Telephone Number")
288
+ assert_valid("", "Telephone Number")
288
289
 
289
290
  value = "+1 5!2 305 0280"
290
291
  params = [value.inspect, "!"]
@@ -0,0 +1,28 @@
1
+ # -*- rd -*-
2
+
3
+ = NEWS
4
+
5
+ == 0.5.0: 2008-04-07
6
+
7
+ * Update document.
8
+ * Support pend.
9
+ * Support notify.
10
+
11
+ == 0.4.0: 2008-03-17
12
+
13
+ * Changed XML report format.
14
+
15
+ == 0.3.0: 2008-03-10
16
+
17
+ * Changed XML report format.
18
+ * Improved search method to find test result directory.
19
+
20
+ == 0.2.0: 2008-03-03
21
+
22
+ * Supported XML report.
23
+ * Added --xml-report option.
24
+ * Supported diff output for assert_equal.
25
+
26
+ == 0.1.0: 2008-02-21
27
+
28
+ * Initial release.
@@ -0,0 +1,28 @@
1
+ # -*- rd -*-
2
+
3
+ = NEWS.ja
4
+
5
+ == 0.5.0: 2008-04-07
6
+
7
+ * ドキュメントの更新
8
+ * pend(保留)のサポート
9
+ * notify(通知)のサポート
10
+
11
+ == 0.4.0: 2008-03-17
12
+
13
+ * XML出力形式の変更
14
+
15
+ == 0.3.0: 2008-03-10
16
+
17
+ * XML出力形式の変更
18
+ * テスト結果を保存するディレクトリの検索処理を改良
19
+
20
+ == 0.2.0: 2008-03-03
21
+
22
+ * XML出力のサポート。
23
+ * --xml-reportオプションの追加。
24
+ * assert_equal時のdiff出力のサポート。
25
+
26
+ == 0.1.0: 2008-02-21
27
+
28
+ * 最初のリリース。