activeldap 1.0.2 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/CHANGES +32 -0
  2. data/README +8 -1
  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/app/controllers/{application.rb → application_controller.rb} +3 -1
  6. data/examples/al-admin/app/views/account/sign_up.html.erb +6 -5
  7. data/examples/al-admin/config/boot.rb +1 -0
  8. data/examples/al-admin/config/environment.rb +4 -2
  9. data/examples/al-admin/config.ru +7 -0
  10. data/examples/al-admin/lib/ldap_test_helper.rb +38 -0
  11. data/examples/al-admin/lib/tasks/gettext.rake +3 -2
  12. data/examples/al-admin/lib/tasks/testing.rake +10 -0
  13. data/examples/al-admin/po/en/al-admin.po +4 -4
  14. data/examples/al-admin/po/ja/al-admin.po +4 -4
  15. data/examples/al-admin/po/nl/al-admin.po +3 -3
  16. data/examples/al-admin/public/dispatch.cgi +2 -2
  17. data/examples/al-admin/public/dispatch.fcgi +1 -1
  18. data/examples/al-admin/public/dispatch.rb +2 -2
  19. data/examples/al-admin/test/functional/account_controller_test.rb +2 -14
  20. data/examples/al-admin/test/functional/attributes_controller_test.rb +2 -12
  21. data/examples/al-admin/test/functional/directory_controller_test.rb +2 -12
  22. data/examples/al-admin/test/functional/object_classes_controller_test.rb +2 -12
  23. data/examples/al-admin/test/functional/syntaxes_controller_test.rb +2 -12
  24. data/examples/al-admin/test/functional/users_controller_test.rb +2 -12
  25. data/examples/al-admin/test/functional/welcome_controller_test.rb +2 -12
  26. data/examples/al-admin/test/integration/sign_up_test.rb +44 -0
  27. data/examples/al-admin/test/run-test.sh +1 -1
  28. data/examples/al-admin/test/test_helper.rb +25 -1
  29. data/examples/al-admin/test/unit/user_test.rb +1 -2
  30. data/examples/groupadd +2 -2
  31. data/examples/groupdel +2 -2
  32. data/examples/groupls +2 -2
  33. data/examples/groupmod +2 -2
  34. data/examples/lpasswd +2 -2
  35. data/examples/objects/group.rb +2 -2
  36. data/examples/objects/user.rb +1 -1
  37. data/examples/ouadd +2 -2
  38. data/examples/useradd +2 -2
  39. data/examples/useradd-binary +6 -3
  40. data/examples/userdel +2 -2
  41. data/examples/userls +2 -2
  42. data/examples/usermod +2 -2
  43. data/examples/usermod-binary-add +6 -3
  44. data/examples/usermod-binary-add-time +6 -3
  45. data/examples/usermod-binary-del +2 -2
  46. data/examples/usermod-lang-add +2 -2
  47. data/lib/active_ldap/adapter/base.rb +47 -23
  48. data/lib/active_ldap/adapter/jndi.rb +30 -28
  49. data/lib/active_ldap/adapter/jndi_connection.rb +6 -0
  50. data/lib/active_ldap/adapter/ldap.rb +25 -26
  51. data/lib/active_ldap/adapter/net_ldap.rb +28 -33
  52. data/lib/active_ldap/adapter/net_ldap_ext.rb +0 -6
  53. data/lib/active_ldap/association/proxy.rb +2 -1
  54. data/lib/active_ldap/attributes.rb +31 -0
  55. data/lib/active_ldap/base.rb +75 -31
  56. data/lib/active_ldap/compatible.rb +44 -0
  57. data/lib/active_ldap/configuration.rb +3 -3
  58. data/lib/active_ldap/connection.rb +41 -12
  59. data/lib/active_ldap/distinguished_name.rb +1 -0
  60. data/lib/active_ldap/get_text.rb +0 -7
  61. data/lib/active_ldap/ldif.rb +59 -44
  62. data/lib/active_ldap/operations.rb +41 -10
  63. data/lib/active_ldap/schema.rb +41 -6
  64. data/lib/active_ldap/user_password.rb +7 -7
  65. data/lib/active_ldap/validations.rb +24 -12
  66. data/lib/active_ldap/xml.rb +2 -2
  67. data/lib/active_ldap.rb +120 -139
  68. data/po/en/active-ldap.po +5 -5
  69. data/po/ja/active-ldap.po +5 -5
  70. data/rails/README +2 -2
  71. data/rails/init.rb +2 -2
  72. data/test/al-test-utils.rb +11 -4
  73. data/test/run-test.rb +6 -2
  74. data/test/test_associations.rb +4 -4
  75. data/test/test_attributes.rb +3 -1
  76. data/test/test_base.rb +75 -15
  77. data/test/test_base_per_instance.rb +7 -1
  78. data/test/test_bind.rb +4 -4
  79. data/test/test_connection.rb +36 -14
  80. data/test/test_connection_per_class.rb +5 -5
  81. data/test/test_connection_per_dn.rb +11 -5
  82. data/test/test_groupadd.rb +2 -2
  83. data/test/test_groupdel.rb +2 -2
  84. data/test/test_groupls.rb +1 -1
  85. data/test/test_groupmod.rb +2 -2
  86. data/test/test_ldif.rb +11 -1
  87. data/test/test_schema.rb +38 -2
  88. data/test/test_syntax.rb +12 -2
  89. data/test/test_useradd-binary.rb +1 -0
  90. data/test/test_usermod-binary-add-time.rb +1 -0
  91. data/test/test_usermod-binary-add.rb +1 -0
  92. data/test/test_validation.rb +24 -13
  93. data/test-unit/lib/test/unit/assertions.rb +97 -14
  94. data/test-unit/lib/test/unit/autorunner.rb +20 -4
  95. data/test-unit/lib/test/unit/priority.rb +21 -1
  96. data/test-unit/lib/test/unit/ui/console/testrunner.rb +7 -4
  97. data/test-unit/test/test_assertions.rb +52 -5
  98. metadata +10 -14
  99. data/rails/plugin/active_ldap/README +0 -54
  100. data/rails/plugin/active_ldap/generators/README +0 -2
  101. data/rails/plugin/active_ldap/generators/model_active_ldap/USAGE +0 -17
  102. data/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb +0 -70
  103. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/fixtures.yml +0 -11
  104. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb +0 -3
  105. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/unit_test.rb +0 -10
  106. data/rails/plugin/active_ldap/generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb +0 -7
  107. data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +0 -20
  108. data/rails/plugin/active_ldap/init.rb +0 -36
  109. data/rails_generators/scaffold_al/scaffold_al_generator.rb +0 -20
data/test/test_schema.rb CHANGED
@@ -2,6 +2,42 @@ require 'al-test-utils'
2
2
 
3
3
  class TestSchema < Test::Unit::TestCase
4
4
  priority :must
5
+ def test_dit_content_rule
6
+ object_class_schema = "( 2.5.6.6 NAME 'person' DESC " +
7
+ "'RFC2256: a person' SUP top STRUCTURAL MUST sn " +
8
+ "MAY ( userPassword $ telephoneNumber ) )"
9
+ dit_content_rule_schema = "( 2.5.6.6 NAME 'person' MUST cn " +
10
+ "MAY ( seeAlso $ description ) )"
11
+ attributes_schema =
12
+ [
13
+ "( 2.5.4.3 NAME 'cn' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )",
14
+ "( 2.5.4.4 NAME 'sn' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )",
15
+ "( 2.5.4.35 NAME 'userPassword' SYNTAX '1.3.6.1.4.1.1466.115.121.1.40' )",
16
+ "( 2.5.4.20 NAME 'telephoneNumber' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )",
17
+ "( 2.5.4.34 NAME 'seeAlso' SYNTAX '1.3.6.1.4.1.1466.115.121.1.12' )",
18
+ "( 2.5.4.13 NAME 'description' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' )",
19
+ ]
20
+
21
+ entry = {
22
+ "objectClasses" => [object_class_schema],
23
+ "dITContentRules" => [dit_content_rule_schema],
24
+ "attributeTypes" => attributes_schema,
25
+ }
26
+
27
+ schema = ActiveLdap::Schema.new(entry)
28
+ object_class = schema.object_class("person")
29
+ assert_equal({
30
+ :must => ["sn", "cn"],
31
+ :may => ["userPassword", "telephoneNumber",
32
+ "seeAlso", "description"],
33
+ },
34
+ {
35
+ :must => object_class.must.collect(&:name),
36
+ :may => object_class.may.collect(&:name),
37
+ })
38
+ end
39
+
40
+ priority :normal
5
41
  def test_oid_list_with_just_only_one_oid
6
42
  ou_schema = "( 2.5.6.5 NAME 'organizationalUnit' SUP top STRUCTURAL MUST " +
7
43
  "(ou ) MAY (c $ l $ st $ street $ searchGuide $ businessCategory $ " +
@@ -32,7 +68,6 @@ class TestSchema < Test::Unit::TestCase
32
68
  assert_schema(expect, "organizationalUnit", ou_schema)
33
69
  end
34
70
 
35
- priority :normal
36
71
  def test_normalize_attribute_value
37
72
  entry = {
38
73
  "attributeTypes" =>
@@ -455,7 +490,7 @@ class TestSchema < Test::Unit::TestCase
455
490
 
456
491
  private
457
492
  def assert_schema(expect, name, schema)
458
- sub = "objectClass"
493
+ sub = "objectClasses"
459
494
  entry = {sub => [schema]}
460
495
  schema = ActiveLdap::Schema.new(entry)
461
496
  actual = {}
@@ -466,6 +501,7 @@ class TestSchema < Test::Unit::TestCase
466
501
  actual[normalized_key] = schema[sub, name, normalized_key]
467
502
  end
468
503
  assert_equal(normalized_expect, actual)
504
+ schema
469
505
  end
470
506
 
471
507
  def assert_make_schema_with_empty_entries(entries)
data/test/test_syntax.rb CHANGED
@@ -182,7 +182,12 @@ class TestSyntax < Test::Unit::TestCase
182
182
  assert_valid("これはDirectoryString文字列です。",
183
183
  "Directory String")
184
184
 
185
- value = NKF.nkf("-We", "これはDirectoryString文字列です。")
185
+ value = "これはDirectoryString文字列です。"
186
+ if value.respond_to?(:encode)
187
+ value = value.encode("euc-jp")
188
+ else
189
+ value = NKF.nkf("-We", value)
190
+ end
186
191
  assert_invalid(_("%s has invalid UTF-8 character") % value.inspect,
187
192
  value, "Directory String")
188
193
  end
@@ -281,7 +286,12 @@ class TestSyntax < Test::Unit::TestCase
281
286
 
282
287
  assert_invalid(_("empty string"), "", "Postal Address")
283
288
 
284
- value = NKF.nkf("-We", "東京")
289
+ value = "東京"
290
+ if value.respond_to?(:encode)
291
+ value = value.encode("euc-jp")
292
+ else
293
+ value = NKF.nkf("-We", value)
294
+ end
285
295
  assert_invalid(_("%s has invalid UTF-8 character") % value.inspect,
286
296
  value, "Postal Address")
287
297
  end
@@ -46,6 +46,7 @@ class TestUseraddBinary < Test::Unit::TestCase
46
46
  assert_equal(['person', 'posixAccount', 'shadowAccount',
47
47
  'strongAuthenticationUser'].sort, user.classes.sort)
48
48
  cert = File.read(File.join(@examples_dir, 'example.der'))
49
+ cert.force_encoding('ascii-8bit') if cert.respond_to?(:force_encoding)
49
50
  assert_equal(cert, user.user_certificate)
50
51
  end
51
52
  end
@@ -48,6 +48,7 @@ class TestUsermodBinaryAddTime < Test::Unit::TestCase
48
48
  assert_equal((previous_classes + ['strongAuthenticationUser']).sort,
49
49
  user.classes.sort)
50
50
  cert = File.read(File.join(@examples_dir, 'example.der'))
51
+ cert.force_encoding("ascii-8bit") if cert.respond_to?(:force_encoding)
51
52
  assert_equal(cert, user.user_certificate)
52
53
  end
53
54
  end
@@ -48,6 +48,7 @@ class TestUsermodBinaryAdd < Test::Unit::TestCase
48
48
  assert_equal((previous_classes + ['strongAuthenticationUser']).sort,
49
49
  user.classes.sort)
50
50
  cert = File.read(File.join(@examples_dir, 'example.der'))
51
+ cert.force_encoding("ascii-8bit") if cert.respond_to?(:force_encoding)
51
52
  assert_equal(cert, user.user_certificate)
52
53
  end
53
54
  end
@@ -29,8 +29,9 @@ class TestValidation < Test::Unit::TestCase
29
29
  reason = _("attribute value is missing")
30
30
  invalid_format = _("%s is invalid distinguished name (DN): %s")
31
31
  invalid_message = invalid_format % ["uid==,#{user.class.base}", reason]
32
- message = _("is invalid: %s") % invalid_message
33
- message = "Dn" + " " + message
32
+ format = _("%{fn} is invalid: %s")
33
+ format = format.sub(/^%\{fn\}/, la_('DN'))
34
+ message = format % invalid_message
34
35
  assert_equal([message],
35
36
  user.errors.full_messages.find_all {|m| /DN/ =~ m})
36
37
  end
@@ -42,8 +43,9 @@ class TestValidation < Test::Unit::TestCase
42
43
  reason = _("attribute value is missing")
43
44
  invalid_format = _("%s is invalid distinguished name (DN): %s")
44
45
  invalid_message = invalid_format % ["uid==,#{user.class.base}", reason]
45
- message = _("is invalid: %s") % invalid_message
46
- message = "Dn" + " " + message
46
+ format = _("%{fn} is invalid: %s")
47
+ format = format.sub(/^%\{fn\}/, la_('DN'))
48
+ message = format % invalid_message
47
49
  assert_equal([message], user.errors.full_messages)
48
50
  end
49
51
  end
@@ -53,8 +55,9 @@ class TestValidation < Test::Unit::TestCase
53
55
  assert(user.valid?)
54
56
  user.uid_number = ""
55
57
  assert(!user.valid?)
56
- format = _("is required attribute by objectClass '%s'")
57
- blank_message = la_("uidNumber") + ' ' + (format % loc_("posixAccount"))
58
+ format = _("%{fn} is required attribute by objectClass '%s'")
59
+ format = format.sub(/^%\{fn\}/, la_('uidNumber'))
60
+ blank_message = format % loc_("posixAccount")
58
61
  assert_equal([blank_message], user.errors.full_messages)
59
62
  end
60
63
  end
@@ -66,10 +69,11 @@ class TestValidation < Test::Unit::TestCase
66
69
  assert(user.save)
67
70
  user.class.excluded_classes = ['person']
68
71
  assert(!user.save)
69
- format = n_("has excluded value: %s",
70
- "has excluded values: %s",
72
+ format = n_("%{fn} has excluded value: %s",
73
+ "%{fn} has excluded values: %s",
71
74
  1)
72
- message = la_("objectClass") + ' ' + (format % loc_("person"))
75
+ format = format.sub(/^%\{fn\}/, la_("objectClass"))
76
+ message = format % loc_("person")
73
77
  assert_equal([message], user.errors.full_messages)
74
78
  end
75
79
  end
@@ -137,7 +141,9 @@ class TestValidation < Test::Unit::TestCase
137
141
  assert(ou_class.new("YYY").save)
138
142
  ou = ou_class.new("YYY")
139
143
  assert(!ou.save)
140
- message = la_("DN") + ' ' + (_("is duplicated: %s") % ou.dn)
144
+ format = _("%{fn} is duplicated: %s")
145
+ format = format.sub(/^%\{fn\}/, la_("DN"))
146
+ message = format % ou.dn
141
147
  assert_equal([message], ou.errors.full_messages)
142
148
  end
143
149
 
@@ -184,11 +190,16 @@ class TestValidation < Test::Unit::TestCase
184
190
  params = [formatted_value, syntax_description, reason]
185
191
  params.unshift(option) if option
186
192
  if option
187
- format = _("(%s) has invalid format: %s: required syntax: %s: %s")
193
+ format = _("%{fn}(%s) has invalid format: %s: required syntax: %s: %s")
188
194
  else
189
- format = _("has invalid format: %s: required syntax: %s: %s")
195
+ format = _("%{fn} has invalid format: %s: required syntax: %s: %s")
190
196
  end
191
- message = la_(name) + ' ' + (format % params)
197
+ localized_name = la_(name)
198
+ if option and !ActiveLdap.get_text_supported?
199
+ localized_name += ' '
200
+ end
201
+ format = format.sub(/^%\{fn\}/, localized_name)
202
+ message = format % params
192
203
  assert_equal([message], model.errors.full_messages)
193
204
  end
194
205
 
@@ -154,21 +154,43 @@ EOT
154
154
 
155
155
 
156
156
  ##
157
- # Passes if +object+ .instance_of? +klass+
157
+ # Passes if +object+.instance_of?(+klass+). When +klass+ is
158
+ # an array of classes, it passes if any class
159
+ # satisfies +object.instance_of?(class).
158
160
  #
159
161
  # Example:
160
- # assert_instance_of String, 'foo'
162
+ # assert_instance_of(String, 'foo') # -> pass
163
+ # assert_instance_of([Fixnum, NilClass], 100) # -> pass
164
+ # assert_instance_of([Numeric, NilClass], 100) # -> fail
161
165
 
162
166
  public
163
167
  def assert_instance_of(klass, object, message="")
164
168
  _wrap_assertion do
165
- assert_equal(Class, klass.class, "assert_instance_of takes a Class as its first argument")
166
- full_message = build_message(message, <<EOT, object, klass, object.class)
169
+ klasses = nil
170
+ klasses = klass if klass.is_a?(Array)
171
+ assert_block("The first parameter to assert_instance_of should be " +
172
+ "a Class or an Array of Class.") do
173
+ if klasses
174
+ klasses.all? {|k| k.is_a?(Class)}
175
+ else
176
+ klass.is_a?(Class)
177
+ end
178
+ end
179
+ klass_message = AssertionMessage.maybe_container(klass) do |value|
180
+ "<#{value}>"
181
+ end
182
+ full_message = build_message(message, <<EOT, object, klass_message, object.class)
167
183
  <?> expected to be an instance of
168
- <?> but was
184
+ ? but was
169
185
  <?>.
170
186
  EOT
171
- assert_block(full_message){object.instance_of?(klass)}
187
+ assert_block(full_message) do
188
+ if klasses
189
+ klasses.any? {|k| object.instance_of?(k)}
190
+ else
191
+ object.instance_of?(klass)
192
+ end
193
+ end
172
194
  end
173
195
  end
174
196
 
@@ -187,17 +209,45 @@ EOT
187
209
  end
188
210
 
189
211
  ##
190
- # Passes if +object+ .kind_of? +klass+
212
+ # Passes if +object+.kind_of?(+klass+). When +klass+ is
213
+ # an array of classes or modules, it passes if any
214
+ # class or module satisfies +object.kind_of?(class_or_module).
191
215
  #
192
216
  # Example:
193
- # assert_kind_of Object, 'foo'
217
+ # assert_kind_of(Object, 'foo') # -> pass
218
+ # assert_kind_of([Fixnum, NilClass], 100) # -> pass
219
+ # assert_kind_of([Fixnum, NilClass], "string") # -> fail
194
220
 
195
221
  public
196
222
  def assert_kind_of(klass, object, message="")
197
223
  _wrap_assertion do
198
- assert(klass.kind_of?(Module), "The first parameter to assert_kind_of should be a kind_of Module.")
199
- full_message = build_message(message, "<?>\nexpected to be kind_of\\?\n<?> but was\n<?>.", object, klass, object.class)
200
- assert_block(full_message){object.kind_of?(klass)}
224
+ klasses = nil
225
+ klasses = klass if klass.is_a?(Array)
226
+ assert_block("The first parameter to assert_kind_of should be " +
227
+ "a kind_of Module or an Array of a kind_of Module.") do
228
+ if klasses
229
+ klasses.all? {|k| k.kind_of?(Module)}
230
+ else
231
+ klass.kind_of?(Module)
232
+ end
233
+ end
234
+ klass_message = AssertionMessage.maybe_container(klass) do |value|
235
+ "<#{value}>"
236
+ end
237
+ full_message = build_message(message,
238
+ "<?> expected to be kind_of\\?\n" +
239
+ "? but was\n" +
240
+ "<?>.",
241
+ object,
242
+ klass_message,
243
+ object.class)
244
+ assert_block(full_message) do
245
+ if klasses
246
+ klasses.any? {|k| object.kind_of?(k)}
247
+ else
248
+ object.kind_of?(klass)
249
+ end
250
+ end
201
251
  end
202
252
  end
203
253
 
@@ -826,6 +876,19 @@ EOT
826
876
  DelayedLiteral.new(block)
827
877
  end
828
878
 
879
+ def maybe_container(value, &formatter)
880
+ MaybeContainer.new(value, &formatter)
881
+ end
882
+
883
+ MAX_DIFF_TARGET_STRING_SIZE = 300
884
+ def diff_target_string?(string)
885
+ if string.respond_to?(:bytesize)
886
+ string.bytesize < MAX_DIFF_TARGET_STRING_SIZE
887
+ else
888
+ string.size < MAX_DIFF_TARGET_STRING_SIZE
889
+ end
890
+ end
891
+
829
892
  def delayed_diff(from, to)
830
893
  delayed_literal do
831
894
  if !from.is_a?(String) or !to.is_a?(String)
@@ -833,7 +896,9 @@ EOT
833
896
  to = convert(to)
834
897
  end
835
898
 
836
- diff = Diff.readable(from, to)
899
+ diff = nil
900
+ diff = "" if !diff_target_string?(from) or !diff_target_string?(to)
901
+ diff ||= Diff.readable(from, to)
837
902
  if /^[-+]/ !~ diff
838
903
  diff = ""
839
904
  elsif /^[ ?]/ =~ diff or /(?:.*\n){2,}/ =~ diff
@@ -879,7 +944,7 @@ EOM
879
944
  def initialize(value)
880
945
  @value = value
881
946
  end
882
-
947
+
883
948
  def inspect
884
949
  @value.to_s
885
950
  end
@@ -889,12 +954,30 @@ EOM
889
954
  def initialize(value)
890
955
  @value = value
891
956
  end
892
-
957
+
893
958
  def inspect
894
959
  @value.call.to_s
895
960
  end
896
961
  end
897
962
 
963
+ class MaybeContainer
964
+ def initialize(value, &formatter)
965
+ @value = value
966
+ @formatter = formatter
967
+ end
968
+
969
+ def inspect
970
+ if @value.is_a?(Array)
971
+ values = @value.collect do |value|
972
+ @formatter.call(AssertionMessage.convert(value))
973
+ end
974
+ "[#{values.join(', ')}]"
975
+ else
976
+ @formatter.call(AssertionMessage.convert(@value))
977
+ end
978
+ end
979
+ end
980
+
898
981
  class Template
899
982
  def self.create(string)
900
983
  parts = (string ? string.scan(/(?=[^\\])\?|(?:\\\?|[^\?])+/m) : [])
@@ -1,4 +1,3 @@
1
- require 'test/unit'
2
1
  require 'test/unit/color-scheme'
3
2
  require 'optparse'
4
3
 
@@ -204,6 +203,13 @@ module Test
204
203
  end
205
204
  end
206
205
 
206
+ o.on("--default-priority=PRIORITY",
207
+ Priority.available_values,
208
+ "Uses PRIORITY as default priority",
209
+ "(#{keyword_display(Priority.available_values)})") do |priority|
210
+ Priority.default = priority
211
+ end
212
+
207
213
  o.on('-I', "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
208
214
  "Appends directory list to $LOAD_PATH.") do |dirs|
209
215
  $LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR))
@@ -252,10 +258,20 @@ module Test
252
258
  end
253
259
 
254
260
  def keyword_display(keywords)
255
- keywords.collect do |keyword, _|
261
+ keywords = keywords.collect do |keyword, _|
256
262
  keyword.to_s
257
- end.uniq.sort.collect do |keyword|
258
- keyword.sub(/^(.)([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')
263
+ end.uniq.sort
264
+
265
+ i = 0
266
+ keywords.collect do |keyword|
267
+ if (i > 0 and keyword[0] == keywords[i - 1][0]) or
268
+ ((i < keywords.size - 1) and (keyword[0] == keywords[i + 1][0]))
269
+ n = 2
270
+ else
271
+ n = 1
272
+ end
273
+ i += 1
274
+ keyword.sub(/^(.{#{n}})([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')
259
275
  end.join(", ")
260
276
  end
261
277
 
@@ -26,6 +26,19 @@ module Test
26
26
  def disable
27
27
  @@enabled = false
28
28
  end
29
+
30
+ @@default = :normal
31
+ def default
32
+ @@default || :normal
33
+ end
34
+
35
+ def default=(default)
36
+ @@default = default
37
+ end
38
+
39
+ def available_values
40
+ Checker.available_priorities
41
+ end
29
42
  end
30
43
 
31
44
  class Checker
@@ -36,7 +49,7 @@ module Test
36
49
  end
37
50
 
38
51
  def need_to_run?(test)
39
- priority = test[:priority] || :normal
52
+ priority = test[:priority] || Priority.default
40
53
  if have_priority?(priority)
41
54
  send(priority_check_method_name(priority), test)
42
55
  else
@@ -44,6 +57,13 @@ module Test
44
57
  end
45
58
  end
46
59
 
60
+ def available_priorities
61
+ methods(false).collect do |name|
62
+ /\Arun_priority_(.+)\?\z/ =~ name.to_s
63
+ $1
64
+ end.compact
65
+ end
66
+
47
67
  def run_priority_must?(test)
48
68
  true
49
69
  end
@@ -185,10 +185,13 @@ module Test
185
185
 
186
186
  def guess_color_availability
187
187
  return false unless @output.tty?
188
- term = ENV["TERM"]
189
- return true if term and (/term\z/ =~ term or term == "screen")
190
- return true if ENV["EMACS"] == "t"
191
- false
188
+ case ENV["TERM"]
189
+ when /term(?:-color)?\z/, "screen"
190
+ true
191
+ else
192
+ return true if ENV["EMACS"] == "t"
193
+ false
194
+ end
192
195
  end
193
196
 
194
197
  def guess_progress_row_max
@@ -246,6 +246,37 @@ EOM
246
246
  end
247
247
  end
248
248
 
249
+ def test_assert_equal_with_large_string
250
+ message = <<-EOM.chomp
251
+ <#{("a\n" + "x" * 297).inspect}> expected but was
252
+ <#{"x".inspect}>.
253
+
254
+ diff:
255
+ + x
256
+ - a
257
+ - #{"x" * 297}
258
+
259
+ folded diff:
260
+ + x
261
+ - a
262
+ - #{"x" * 78}
263
+ - #{"x" * 78}
264
+ - #{"x" * 78}
265
+ - #{"x" * 63}
266
+ EOM
267
+ check_fails(message) do
268
+ assert_equal("a\n" + "x" * 297, "x")
269
+ end
270
+
271
+ message = <<-EOM.chomp
272
+ <#{("a\n" + "x" * 298).inspect}> expected but was
273
+ <#{"x".inspect}>.
274
+ EOM
275
+ check_fails(message) do
276
+ assert_equal("a\n" + "x" * 298, "x")
277
+ end
278
+ end
279
+
249
280
  def test_assert_raise_success
250
281
  return_value = nil
251
282
  check_nothing_fails(true) do
@@ -447,8 +478,18 @@ EOM
447
478
  check_fails(%Q{failed assert_instance_of.\n<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
448
479
  assert_instance_of(Hash, "string", "failed assert_instance_of")
449
480
  }
481
+
482
+ check_nothing_fails do
483
+ assert_instance_of([Fixnum, NilClass], 100)
484
+ end
485
+ check_fails(%Q{<"string"> expected to be an instance of\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
486
+ assert_instance_of([Fixnum, NilClass], "string")
487
+ end
488
+ check_fails(%Q{<100> expected to be an instance of\n[<Numeric>, <NilClass>] but was\n<Fixnum>.}) do
489
+ assert_instance_of([Numeric, NilClass], 100)
490
+ end
450
491
  end
451
-
492
+
452
493
  def test_assert_nil
453
494
  check_nothing_fails {
454
495
  assert_nil(nil)
@@ -487,14 +528,21 @@ EOM
487
528
  check_nothing_fails {
488
529
  assert_kind_of(Comparable, 1)
489
530
  }
490
- check_fails(%Q{<"string">\nexpected to be kind_of?\n<Class> but was\n<String>.}) {
531
+ check_fails(%Q{<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
491
532
  assert_kind_of(Class, "string")
492
533
  }
493
- check_fails(%Q{failed assert_kind_of.\n<"string">\nexpected to be kind_of?\n<Class> but was\n<String>.}) {
534
+ check_fails(%Q{failed assert_kind_of.\n<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
494
535
  assert_kind_of(Class, "string", "failed assert_kind_of")
495
536
  }
537
+
538
+ check_nothing_fails do
539
+ assert_kind_of([Fixnum, NilClass], 100)
540
+ end
541
+ check_fails(%Q{<"string"> expected to be kind_of?\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
542
+ assert_kind_of([Fixnum, NilClass], "string")
543
+ end
496
544
  end
497
-
545
+
498
546
  def test_assert_match
499
547
  check_nothing_fails {
500
548
  assert_match(/strin./, "string")
@@ -1032,4 +1080,3 @@ EOM
1032
1080
  end
1033
1081
  end
1034
1082
  end
1035
- p
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Drewry
@@ -10,7 +10,7 @@ autorequire: active_ldap
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-02-22 00:00:00 -06:00
13
+ date: 2009-06-03 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -55,10 +55,12 @@ files:
55
55
  - TODO
56
56
  - benchmark/bench-al.rb
57
57
  - benchmark/config.yaml.sample
58
+ - data/locale/en/LC_MESSAGES/active-ldap.mo
59
+ - data/locale/ja/LC_MESSAGES/active-ldap.mo
58
60
  - examples/al-admin/README
59
61
  - examples/al-admin/Rakefile
60
62
  - examples/al-admin/app/controllers/account_controller.rb
61
- - examples/al-admin/app/controllers/application.rb
63
+ - examples/al-admin/app/controllers/application_controller.rb
62
64
  - examples/al-admin/app/controllers/attributes_controller.rb
63
65
  - examples/al-admin/app/controllers/directory_controller.rb
64
66
  - examples/al-admin/app/controllers/object_classes_controller.rb
@@ -112,6 +114,7 @@ files:
112
114
  - examples/al-admin/app/views/users/index.html.erb
113
115
  - examples/al-admin/app/views/users/show.html.erb
114
116
  - examples/al-admin/app/views/welcome/index.html.erb
117
+ - examples/al-admin/config.ru
115
118
  - examples/al-admin/config/boot.rb
116
119
  - examples/al-admin/config/database.yml.example
117
120
  - examples/al-admin/config/environment.rb
@@ -127,7 +130,9 @@ files:
127
130
  - examples/al-admin/db/migrate/001_create_users.rb
128
131
  - examples/al-admin/lib/authenticated_system.rb
129
132
  - examples/al-admin/lib/authenticated_test_helper.rb
133
+ - examples/al-admin/lib/ldap_test_helper.rb
130
134
  - examples/al-admin/lib/tasks/gettext.rake
135
+ - examples/al-admin/lib/tasks/testing.rake
131
136
  - examples/al-admin/po/en/al-admin.po
132
137
  - examples/al-admin/po/ja/al-admin.po
133
138
  - examples/al-admin/po/nl/al-admin.po
@@ -346,6 +351,7 @@ files:
346
351
  - examples/al-admin/test/functional/syntaxes_controller_test.rb
347
352
  - examples/al-admin/test/functional/users_controller_test.rb
348
353
  - examples/al-admin/test/functional/welcome_controller_test.rb
354
+ - examples/al-admin/test/integration/sign_up_test.rb
349
355
  - examples/al-admin/test/run-test.sh
350
356
  - examples/al-admin/test/test_helper.rb
351
357
  - examples/al-admin/test/unit/user_test.rb
@@ -407,6 +413,7 @@ files:
407
413
  - lib/active_ldap/base.rb
408
414
  - lib/active_ldap/callbacks.rb
409
415
  - lib/active_ldap/command.rb
416
+ - lib/active_ldap/compatible.rb
410
417
  - lib/active_ldap/configuration.rb
411
418
  - lib/active_ldap/connection.rb
412
419
  - lib/active_ldap/distinguished_name.rb
@@ -434,23 +441,12 @@ files:
434
441
  - po/ja/active-ldap.po
435
442
  - rails/README
436
443
  - rails/init.rb
437
- - rails/plugin/active_ldap/README
438
- - rails/plugin/active_ldap/generators/README
439
- - rails/plugin/active_ldap/generators/model_active_ldap/USAGE
440
- - rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb
441
- - rails/plugin/active_ldap/generators/model_active_ldap/templates/fixtures.yml
442
- - rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb
443
- - rails/plugin/active_ldap/generators/model_active_ldap/templates/unit_test.rb
444
- - rails/plugin/active_ldap/generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb
445
- - rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb
446
- - rails/plugin/active_ldap/init.rb
447
444
  - rails_generators/model_active_ldap/USAGE
448
445
  - rails_generators/model_active_ldap/model_active_ldap_generator.rb
449
446
  - rails_generators/model_active_ldap/templates/model_active_ldap.rb
450
447
  - rails_generators/model_active_ldap/templates/unit_test.rb
451
448
  - rails_generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb
452
449
  - rails_generators/scaffold_active_ldap/templates/ldap.yml
453
- - rails_generators/scaffold_al/scaffold_al_generator.rb
454
450
  - test-unit/History.txt
455
451
  - test-unit/Manifest.txt
456
452
  - test-unit/README.txt