activeldap 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGES +17 -0
  2. data/README +7 -1
  3. data/Rakefile +2 -1
  4. data/benchmark/bench-al.rb +3 -3
  5. data/examples/al-admin/app/helpers/users_helper.rb +1 -1
  6. data/examples/al-admin/config/environment.rb +4 -3
  7. data/examples/al-admin/config/initializers/gettext.rb +1 -0
  8. data/examples/al-admin/config/session_secret.txt +1 -1
  9. data/examples/al-admin/po/al-admin.pot +344 -0
  10. data/examples/al-admin/public/images/active-ldap.png +0 -0
  11. data/examples/al-admin/vendor/locale_rails/.gitignore +6 -0
  12. data/examples/al-admin/vendor/locale_rails/COPYING +56 -0
  13. data/examples/al-admin/vendor/locale_rails/ChangeLog +35 -0
  14. data/examples/al-admin/vendor/locale_rails/README.rdoc +62 -0
  15. data/examples/al-admin/vendor/locale_rails/Rakefile +73 -0
  16. data/examples/al-admin/vendor/locale_rails/lib/locale_rails.rb +18 -0
  17. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller.rb +15 -0
  18. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/base.rb +82 -0
  19. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/caching.rb +51 -0
  20. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/test_process.rb +44 -0
  21. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_view.rb +53 -0
  22. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/i18n.rb +67 -0
  23. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/version.rb +4 -0
  24. data/examples/al-admin/vendor/locale_rails/sample/README +22 -0
  25. data/examples/al-admin/vendor/locale_rails/sample/Rakefile +10 -0
  26. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/application.rb +42 -0
  27. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/samples_controller.rb +30 -0
  28. data/examples/al-admin/vendor/locale_rails/sample/app/helpers/application_helper.rb +3 -0
  29. data/examples/al-admin/vendor/locale_rails/sample/app/views/layouts/samples.html.erb +20 -0
  30. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part.html.erb +68 -0
  31. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part_nl.html.erb +2 -0
  32. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/cached_action.html.erb +6 -0
  33. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.html.erb +33 -0
  34. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.pt.html.erb +16 -0
  35. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index_uz_UZ.html.erb +16 -0
  36. data/examples/al-admin/vendor/locale_rails/sample/config/boot.rb +109 -0
  37. data/examples/al-admin/vendor/locale_rails/sample/config/environment.rb +25 -0
  38. data/examples/al-admin/vendor/locale_rails/sample/config/environments/development.rb +17 -0
  39. data/examples/al-admin/vendor/locale_rails/sample/config/environments/production.rb +24 -0
  40. data/examples/al-admin/vendor/locale_rails/sample/config/environments/test.rb +22 -0
  41. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/inflections.rb +10 -0
  42. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/mime_types.rb +5 -0
  43. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/new_rails_defaults.rb +17 -0
  44. data/examples/al-admin/vendor/locale_rails/sample/config/locales/en.yml +2 -0
  45. data/examples/al-admin/vendor/locale_rails/sample/config/locales/ja.yml +2 -0
  46. data/examples/al-admin/vendor/locale_rails/sample/config/routes.rb +13 -0
  47. data/examples/al-admin/vendor/locale_rails/sample/db/schema.rb +10 -0
  48. data/examples/al-admin/vendor/locale_rails/sample/public/404.html +30 -0
  49. data/examples/al-admin/vendor/locale_rails/sample/public/422.html +30 -0
  50. data/examples/al-admin/vendor/locale_rails/sample/public/500.html +33 -0
  51. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.cgi +10 -0
  52. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.fcgi +24 -0
  53. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.rb +10 -0
  54. data/examples/al-admin/vendor/locale_rails/sample/public/favicon.ico +0 -0
  55. data/examples/al-admin/vendor/locale_rails/sample/public/images/rails.png +0 -0
  56. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/application.js +2 -0
  57. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/controls.js +963 -0
  58. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/dragdrop.js +972 -0
  59. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/effects.js +1120 -0
  60. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/prototype.js +4221 -0
  61. data/examples/al-admin/vendor/locale_rails/sample/public/robots.txt +5 -0
  62. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/locale.css +81 -0
  63. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/scaffold.css +74 -0
  64. data/examples/al-admin/vendor/locale_rails/sample/script/about +4 -0
  65. data/examples/al-admin/vendor/locale_rails/sample/script/console +3 -0
  66. data/examples/al-admin/vendor/locale_rails/sample/script/dbconsole +3 -0
  67. data/examples/al-admin/vendor/locale_rails/sample/script/destroy +3 -0
  68. data/examples/al-admin/vendor/locale_rails/sample/script/generate +3 -0
  69. data/examples/al-admin/vendor/locale_rails/sample/script/performance/benchmarker +3 -0
  70. data/examples/al-admin/vendor/locale_rails/sample/script/performance/profiler +3 -0
  71. data/examples/al-admin/vendor/locale_rails/sample/script/performance/request +3 -0
  72. data/examples/al-admin/vendor/locale_rails/sample/script/plugin +3 -0
  73. data/examples/al-admin/vendor/locale_rails/sample/script/process/inspector +3 -0
  74. data/examples/al-admin/vendor/locale_rails/sample/script/process/reaper +3 -0
  75. data/examples/al-admin/vendor/locale_rails/sample/script/process/spawner +3 -0
  76. data/examples/al-admin/vendor/locale_rails/sample/script/runner +3 -0
  77. data/examples/al-admin/vendor/locale_rails/sample/script/server +3 -0
  78. data/examples/al-admin/vendor/locale_rails/sample/test/performance/browsing_test.rb +9 -0
  79. data/examples/al-admin/vendor/locale_rails/sample/test/test_helper.rb +38 -0
  80. data/examples/al-admin/vendor/locale_rails/test/README +243 -0
  81. data/examples/al-admin/vendor/locale_rails/test/Rakefile +10 -0
  82. data/examples/al-admin/vendor/locale_rails/test/app/controllers/application_controller.rb +10 -0
  83. data/examples/al-admin/vendor/locale_rails/test/app/controllers/articles_controller.rb +17 -0
  84. data/examples/al-admin/vendor/locale_rails/test/app/helpers/application_helper.rb +3 -0
  85. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index.html.erb +1 -0
  86. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_de.html.erb +1 -0
  87. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_fr_FR.html.erb +1 -0
  88. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_ja.html.erb +1 -0
  89. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/list.html.erb +1 -0
  90. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.html.erb +0 -0
  91. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.js.rjs +0 -0
  92. data/examples/al-admin/vendor/locale_rails/test/config/boot.rb +110 -0
  93. data/examples/al-admin/vendor/locale_rails/test/config/environment.rb +42 -0
  94. data/examples/al-admin/vendor/locale_rails/test/config/environments/development.rb +17 -0
  95. data/examples/al-admin/vendor/locale_rails/test/config/environments/production.rb +28 -0
  96. data/examples/al-admin/vendor/locale_rails/test/config/environments/test.rb +35 -0
  97. data/examples/al-admin/vendor/locale_rails/test/config/initializers/backtrace_silencers.rb +7 -0
  98. data/examples/al-admin/vendor/locale_rails/test/config/initializers/inflections.rb +10 -0
  99. data/examples/al-admin/vendor/locale_rails/test/config/initializers/mime_types.rb +5 -0
  100. data/examples/al-admin/vendor/locale_rails/test/config/initializers/new_rails_defaults.rb +19 -0
  101. data/examples/al-admin/vendor/locale_rails/test/config/initializers/session_store.rb +15 -0
  102. data/examples/al-admin/vendor/locale_rails/test/config/locales/en.yml +5 -0
  103. data/examples/al-admin/vendor/locale_rails/test/config/routes.rb +46 -0
  104. data/examples/al-admin/vendor/locale_rails/test/db/schema.rb +0 -0
  105. data/examples/al-admin/vendor/locale_rails/test/public/404.html +30 -0
  106. data/examples/al-admin/vendor/locale_rails/test/public/422.html +30 -0
  107. data/examples/al-admin/vendor/locale_rails/test/public/500.html +30 -0
  108. data/examples/al-admin/vendor/locale_rails/test/public/favicon.ico +0 -0
  109. data/examples/al-admin/vendor/locale_rails/test/public/images/rails.png +0 -0
  110. data/examples/al-admin/vendor/locale_rails/test/public/index.html +275 -0
  111. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/application.js +2 -0
  112. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/controls.js +963 -0
  113. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/dragdrop.js +973 -0
  114. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/effects.js +1128 -0
  115. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/prototype.js +4320 -0
  116. data/examples/al-admin/vendor/locale_rails/test/public/robots.txt +5 -0
  117. data/examples/al-admin/vendor/locale_rails/test/script/about +4 -0
  118. data/examples/al-admin/vendor/locale_rails/test/script/console +3 -0
  119. data/examples/al-admin/vendor/locale_rails/test/script/dbconsole +3 -0
  120. data/examples/al-admin/vendor/locale_rails/test/script/destroy +3 -0
  121. data/examples/al-admin/vendor/locale_rails/test/script/generate +3 -0
  122. data/examples/al-admin/vendor/locale_rails/test/script/performance/benchmarker +3 -0
  123. data/examples/al-admin/vendor/locale_rails/test/script/performance/profiler +3 -0
  124. data/examples/al-admin/vendor/locale_rails/test/script/plugin +3 -0
  125. data/examples/al-admin/vendor/locale_rails/test/script/runner +3 -0
  126. data/examples/al-admin/vendor/locale_rails/test/script/server +3 -0
  127. data/examples/al-admin/vendor/locale_rails/test/test/functional/articles_controller_test.rb +161 -0
  128. data/examples/al-admin/vendor/locale_rails/test/test/performance/browsing_test.rb +9 -0
  129. data/examples/al-admin/vendor/locale_rails/test/test/test_helper.rb +38 -0
  130. data/lib/active_ldap.rb +9 -4
  131. data/lib/active_ldap/adapter/base.rb +3 -3
  132. data/lib/active_ldap/adapter/jndi.rb +1 -1
  133. data/lib/active_ldap/adapter/jndi_connection.rb +1 -3
  134. data/lib/active_ldap/adapter/ldap.rb +11 -11
  135. data/lib/active_ldap/adapter/ldap_ext.rb +25 -3
  136. data/lib/active_ldap/adapter/net_ldap.rb +9 -2
  137. data/lib/active_ldap/association/collection.rb +14 -2
  138. data/lib/active_ldap/base.rb +13 -5
  139. data/lib/active_ldap/configuration.rb +1 -0
  140. data/lib/active_ldap/ldap_error.rb +3 -3
  141. data/lib/active_ldap/ldif.rb +1 -1
  142. data/lib/active_ldap/operations.rb +2 -0
  143. data/lib/active_ldap/schema/syntaxes.rb +2 -2
  144. data/lib/active_ldap/validations.rb +37 -26
  145. data/lib/active_ldap/xml.rb +2 -0
  146. data/po/active-ldap.pot +38 -58
  147. data/test-unit/COPYING +56 -0
  148. data/test-unit/GPL +340 -0
  149. data/test-unit/History.txt +65 -3
  150. data/test-unit/Manifest.txt +5 -0
  151. data/test-unit/PSFL +271 -0
  152. data/test-unit/README.txt +6 -1
  153. data/test-unit/lib/test/unit.rb +6 -1
  154. data/test-unit/lib/test/unit/assertions.rb +129 -13
  155. data/test-unit/lib/test/unit/autorunner.rb +21 -16
  156. data/test-unit/lib/test/unit/collector.rb +1 -8
  157. data/test-unit/lib/test/unit/collector/dir.rb +1 -1
  158. data/test-unit/lib/test/unit/collector/load.rb +15 -7
  159. data/test-unit/lib/test/unit/color-scheme.rb +6 -2
  160. data/test-unit/lib/test/unit/diff.rb +17 -1
  161. data/test-unit/lib/test/unit/error.rb +4 -0
  162. data/test-unit/lib/test/unit/failure.rb +4 -0
  163. data/test-unit/lib/test/unit/notification.rb +8 -4
  164. data/test-unit/lib/test/unit/omission.rb +4 -0
  165. data/test-unit/lib/test/unit/pending.rb +4 -0
  166. data/test-unit/lib/test/unit/priority.rb +2 -3
  167. data/test-unit/lib/test/unit/testcase.rb +18 -7
  168. data/test-unit/lib/test/unit/ui/console/testrunner.rb +5 -3
  169. data/test-unit/lib/test/unit/util/backtracefilter.rb +1 -0
  170. data/test-unit/lib/test/unit/util/output.rb +31 -0
  171. data/test-unit/lib/test/unit/version.rb +1 -1
  172. data/test-unit/test/collector/test-descendant.rb +2 -4
  173. data/test-unit/test/collector/test-load.rb +121 -8
  174. data/test-unit/test/collector/test_objectspace.rb +7 -5
  175. data/test-unit/test/test-color-scheme.rb +4 -2
  176. data/test-unit/test/test-testcase.rb +48 -38
  177. data/test-unit/test/test_assertions.rb +87 -5
  178. data/test-unit/test/util/test-output.rb +11 -0
  179. data/test/al-test-utils.rb +6 -1
  180. data/test/fixtures/lower_case_object_class_schema.rb +802 -0
  181. data/test/test_associations.rb +20 -1
  182. data/test/test_base.rb +50 -3
  183. data/test/test_ldif.rb +10 -1
  184. data/test/test_syntax.rb +12 -0
  185. data/test/test_validation.rb +0 -2
  186. metadata +225 -56
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
+ require 'commands/about'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/console'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/dbconsole'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/destroy'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/generate'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/benchmarker'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/profiler'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/plugin'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/runner'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/server'
@@ -0,0 +1,161 @@
1
+ require 'test_helper'
2
+ require 'fileutils'
3
+
4
+ class ArticlesControllerTest < ActionController::TestCase
5
+
6
+ def setup
7
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR;ja;q=0.7,de;q=0.3"
8
+ Locale.clear
9
+ end
10
+
11
+ test "localized template with accept_language" do
12
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "en-US"
13
+ get :index
14
+ assert_equal "index.html.erb", @response.body.chop
15
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "ja-jp"
16
+ get :index, :lang => "ja"
17
+ assert_equal "index_ja.html.erb", @response.body.chop
18
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR"
19
+ get :index
20
+ assert_equal "index_fr_FR.html.erb", @response.body.chop
21
+
22
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "fr"
23
+ get :index
24
+ assert_equal "index.html.erb", @response.body.chop
25
+ end
26
+
27
+ test "localized template with accept_languages" do
28
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
29
+ get :index
30
+ assert_equal "index.html.erb", @response.body.chop
31
+
32
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
33
+ get :index
34
+ assert_equal "index_fr_FR.html.erb", @response.body.chop
35
+
36
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
37
+ get :index
38
+ assert_equal "index_ja.html.erb", @response.body.chop
39
+ end
40
+
41
+ test "localized template with query string" do
42
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
43
+ get :index, :lang => "ja"
44
+ assert_equal "index_ja.html.erb", @response.body.chop
45
+
46
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
47
+ get :index, :lang => "ja"
48
+ assert_equal "index_ja.html.erb", @response.body.chop
49
+
50
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
51
+ get :index, :lang => "en"
52
+ assert_equal "index.html.erb", @response.body.chop
53
+ end
54
+
55
+ test "localized template with accept_languages and default is de" do
56
+ # index_de.html.erb is existed.
57
+ Locale.default = "de"
58
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
59
+ get :index
60
+ assert_equal "index_ja.html.erb", @response.body.chop
61
+
62
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
63
+ get :index
64
+ assert_equal "index_fr_FR.html.erb", @response.body.chop
65
+
66
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
67
+ get :index
68
+ assert_equal "index_ja.html.erb", @response.body.chop
69
+
70
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "de;q=0.7,en;q=0.3"
71
+ get :index
72
+ assert_equal "index_de.html.erb", @response.body.chop
73
+
74
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "zh"
75
+ get :index
76
+ assert_equal "index_de.html.erb", @response.body.chop
77
+ end
78
+
79
+ test "localized template with accept_languages and default is zh" do
80
+ # index_zh.html.erb is not existed.
81
+ Locale.default = "zh"
82
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
83
+ get :index
84
+ assert_equal "index_ja.html.erb", @response.body.chop
85
+
86
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
87
+ get :index
88
+ assert_equal "index_fr_FR.html.erb", @response.body.chop
89
+
90
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
91
+ get :index
92
+ assert_equal "index_ja.html.erb", @response.body.chop
93
+
94
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "en;q=0.7;nl;q=0.3"
95
+ get :index
96
+ assert_equal "index.html.erb", @response.body.chop
97
+
98
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "zh"
99
+ get :index
100
+ assert_equal "index.html.erb", @response.body.chop
101
+ end
102
+
103
+ test "list.html.erb should be cached" do
104
+ cache_path = RAILS_ROOT + "/tmp/cache/views"
105
+ FileUtils.rm_rf cache_path
106
+ @request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
107
+ get :list
108
+ assert_equal "list:en", @response.body.chop
109
+
110
+ path = Dir.glob(cache_path + "/**/list_en.cache")[0]
111
+ st = File.stat(path)
112
+ last_modified_en = [st.ctime.to_s, st.mtime.to_s]
113
+
114
+ get :list, :lang => "ja"
115
+ assert_equal "list:ja", @response.body.chop
116
+
117
+ path = Dir.glob(cache_path + "/**/list_ja.cache")[0]
118
+ st = File.stat(path)
119
+ last_modified_ja = [st.ctime.to_s, st.mtime.to_s]
120
+
121
+ get :list
122
+ st = File.stat(path)
123
+
124
+ assert_equal last_modified_en, [st.ctime.to_s, st.mtime.to_s]
125
+ assert_equal "list:en", @response.body.chop
126
+
127
+ get :list, :lang => "ja"
128
+ st = File.stat(path)
129
+ assert_equal last_modified_ja, [st.ctime.to_s, st.mtime.to_s]
130
+ assert_equal "list:ja", @response.body.chop
131
+
132
+ # expire test
133
+ assert_equal 2, Dir.glob(cache_path + "/**/*.cache").size
134
+ get :expire_cache, :lang => "ja"
135
+ assert_equal [], Dir.glob(cache_path + "/**/*.cache")
136
+ end
137
+
138
+ test "is robust against malformed parameters" do
139
+ # default to "de" when parsing does not work
140
+ Locale.default = "de"
141
+
142
+ assert_nothing_raised do
143
+ Locale.default = "de"
144
+ get :index, :lang => ["en"]
145
+ assert_equal "index_de.html.erb", @response.body.chop
146
+
147
+ get :index, :lang => []
148
+ assert_equal "index_de.html.erb", @response.body.chop
149
+ end
150
+ end
151
+
152
+ test "find template with specific format" do
153
+ xhr :get, :show
154
+ assert_template 'show.html'
155
+ end
156
+
157
+ teardown do
158
+ Locale.default = nil
159
+ end
160
+ end
161
+
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionController::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
+ require 'test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Transactional fixtures accelerate your tests by wrapping each test method
7
+ # in a transaction that's rolled back on completion. This ensures that the
8
+ # test database remains unchanged so your fixtures don't have to be reloaded
9
+ # between every test method. Fewer database queries means faster tests.
10
+ #
11
+ # Read Mike Clark's excellent walkthrough at
12
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
+ #
14
+ # Every Active Record database supports transactions except MyISAM tables
15
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
16
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
17
+ # is recommended.
18
+ #
19
+ # The only drawback to using transactional fixtures is when you actually
20
+ # need to test transactions. Since your test is bracketed by a transaction,
21
+ # any transactions started in your code will be automatically rolled back.
22
+ self.use_transactional_fixtures = true
23
+
24
+ # Instantiated fixtures are slow, but give you @david where otherwise you
25
+ # would need people(:david). If you don't want to migrate your existing
26
+ # test cases which use the @david style and don't mind the speed hit (each
27
+ # instantiated fixtures translates to a database query per test method),
28
+ # then set this back to true.
29
+ self.use_instantiated_fixtures = false
30
+
31
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
32
+ #
33
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
34
+ # -- they do not yet inherit this setting
35
+ fixtures :all
36
+
37
+ # Add more helper methods to be used by all tests here...
38
+ end
@@ -2,7 +2,7 @@
2
2
  # = ActiveLdap
3
3
  #
4
4
  # Copyright (C) 2004,2005 Will Drewry mailto:will@alum.bu.edu
5
- # Copyright (C) 2006-2009 Kouhei Sutou <kou@clear-code.com>
5
+ # Copyright (C) 2006-2010 Kouhei Sutou <kou@clear-code.com>
6
6
  #
7
7
  # == Introduction
8
8
  #
@@ -432,6 +432,7 @@
432
432
  # bind methods fail
433
433
  # * :try_sasl, when true, tells ActiveLdap to attempt a SASL-GSSAPI bind
434
434
  # * :sasl_quiet, when true, tells the SASL libraries to not spew messages to STDOUT
435
+ # * :sasl_options, if defined, should be a hash of options to pass through. This currently only works with the ruby-ldap adapter, which currently only supports :realm, :authcid, and :authzid.
435
436
  # * :retry_limit - indicates the number of attempts to reconnect that will be undertaken when a stale connection occurs. -1 means infinite.
436
437
  # * :retry_wait - seconds to wait before retrying a connection
437
438
  # * :scope - dictates how to find objects. (Default: :one)
@@ -887,6 +888,10 @@
887
888
  # package, and I'd like to see it prove helpful to more people than just myself.
888
889
  #
889
890
 
891
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", "net-ldap", "lib"))
892
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", "ldap", "lib"))
893
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", "ldap"))
894
+
890
895
  require_gem_if_need = Proc.new do |library_name, gem_name, *gem_args|
891
896
  gem_name ||= library_name
892
897
  begin
@@ -901,7 +906,7 @@ require_gem_if_need = Proc.new do |library_name, gem_name, *gem_args|
901
906
  end
902
907
  end
903
908
 
904
- require_gem_if_need.call("active_support", "activesupport", "= 2.3.5")
909
+ require_gem_if_need.call("active_support", "activesupport", "= 2.3.8")
905
910
 
906
911
  if ActiveSupport.const_defined?(:Dependencies)
907
912
  dependencies = ActiveSupport::Dependencies
@@ -914,7 +919,7 @@ if dependencies.respond_to?(:load_paths)
914
919
  end
915
920
 
916
921
  module ActiveLdap
917
- VERSION = "1.2.1"
922
+ VERSION = "1.2.2"
918
923
  end
919
924
 
920
925
  if RUBY_PLATFORM.match('linux')
@@ -923,7 +928,7 @@ else
923
928
  require 'active_ldap/timeout_stub'
924
929
  end
925
930
 
926
- require_gem_if_need.call("active_record", "activerecord", "= 2.3.5")
931
+ require_gem_if_need.call("active_record", "activerecord", "= 2.3.8")
927
932
  begin
928
933
  require_gem_if_need.call("locale", nil, "= 2.0.5")
929
934
  require_gem_if_need.call("gettext", nil, "= 2.1.0")
@@ -15,7 +15,7 @@ module ActiveLdap
15
15
  :password_block, :try_sasl,
16
16
  :sasl_mechanisms, :sasl_quiet,
17
17
  :allow_anonymous, :store_password,
18
- :scope]
18
+ :scope, :sasl_options]
19
19
 
20
20
  @@row_even = true
21
21
 
@@ -169,7 +169,7 @@ module ActiveLdap
169
169
  operation(options) do
170
170
  yield(base, scope, filter, attrs, limit, callback)
171
171
  end
172
- rescue LdapError
172
+ rescue LdapError::NoSuchObject, LdapError::InvalidDnSyntax
173
173
  # Do nothing on failure
174
174
  @logger.info do
175
175
  args = [$!.class, $!.message, filter, attrs.inspect]
@@ -274,7 +274,7 @@ module ActiveLdap
274
274
  with_timeout(try_reconnect, options) do
275
275
  yield
276
276
  end
277
- rescue Errno::EPIPE, ConnectionError
277
+ rescue ConnectionError
278
278
  if try_reconnect and !retried
279
279
  retried = true
280
280
  @disconnected = true
@@ -45,7 +45,7 @@ module ActiveLdap
45
45
  super(options) do |base, scope, filter, attrs, limit, callback|
46
46
  info = {
47
47
  :base => base, :scope => scope_name(scope), :filter => filter,
48
- :attributes => attrs,
48
+ :attributes => attrs, :limit => limit,
49
49
  }
50
50
  execute(:search, info,
51
51
  base, scope, filter, attrs, limit, callback, &block)
@@ -109,13 +109,12 @@ module ActiveLdap
109
109
  controls = SearchControls.new
110
110
  controls.search_scope = scope
111
111
 
112
+ controls.count_limit = limit if limit
112
113
  unless attrs.blank?
113
114
  controls.returning_attributes = attrs.to_java(:string)
114
115
  end
115
116
 
116
- i = 0
117
117
  @context.search(base, filter, controls).each do |result|
118
- i += 1
119
118
  attributes = {}
120
119
  result.attributes.get_all.each do |attribute|
121
120
  attributes[attribute.get_id] = attribute.get_all.collect do |value|
@@ -123,7 +122,6 @@ module ActiveLdap
123
122
  end
124
123
  end
125
124
  callback.call([result.name_in_namespace, attributes], block)
126
- break if limit and limit <= i
127
125
  end
128
126
  end
129
127
 
@@ -82,26 +82,19 @@ module ActiveLdap
82
82
  def search(options={}, &block)
83
83
  super(options) do |base, scope, filter, attrs, limit, callback|
84
84
  begin
85
- i = 0
86
85
  info = {
87
86
  :base => base, :scope => scope_name(scope),
88
- :filter => filter, :attributes => attrs,
87
+ :filter => filter, :attributes => attrs, :limit => limit,
89
88
  }
90
- execute(:search, info, base, scope, filter, attrs) do |entry|
91
- i += 1
89
+ execute(:search_with_limit,
90
+ info, base, scope, filter, attrs, limit) do |entry|
92
91
  attributes = {}
93
92
  entry.attrs.each do |attr|
94
93
  attributes[attr] = entry.vals(attr)
95
94
  end
96
95
  callback.call([entry.dn, attributes], block)
97
- break if limit and limit <= i
98
96
  end
99
97
  rescue RuntimeError
100
- begin
101
- @connection.assert_error_code
102
- rescue LDAP::ServerDown
103
- raise ConnectionError, $!.message
104
- end
105
98
  if $!.message == "no result returned by search"
106
99
  @logger.debug do
107
100
  args = [filter, attrs.inspect]
@@ -234,8 +227,15 @@ module ActiveLdap
234
227
  sasl_quiet = @connection.sasl_quiet
235
228
  @connection.sasl_quiet = quiet unless quiet.nil?
236
229
  args = [_bind_dn, mechanism]
230
+ credential = nil
237
231
  if need_credential_sasl_mechanism?(mechanism)
238
- args << password(_bind_dn, options)
232
+ credential = password(_bind_dn, options)
233
+ end
234
+ if @sasl_options
235
+ credential ||= ""
236
+ args.concat([credential, nil, nil, @sasl_options])
237
+ else
238
+ args << credential if credential
239
239
  end
240
240
  info = {
241
241
  :name => "bind: SASL", :dn => _bind_dn, :mechanism => mechanism
@@ -50,6 +50,27 @@ module LDAP
50
50
  end
51
51
 
52
52
  class Conn
53
+ begin
54
+ instance_method(:search_ext)
55
+ @@have_search_ext = true
56
+ rescue NameError
57
+ @@have_search_ext = false
58
+ end
59
+
60
+ def search_with_limit(base, scope, filter, attributes, limit, &block)
61
+ if @@have_search_ext
62
+ search_ext(base, scope, filter, attributes,
63
+ false, nil, nil, 0, 0, limit || 0, &block)
64
+ else
65
+ i = 0
66
+ search(base, scope, filter, attributes) do |entry|
67
+ i += 1
68
+ block.call(entry)
69
+ break if limit and limit <= i
70
+ end
71
+ end
72
+ end
73
+
53
74
  def failed?
54
75
  not error_code.zero?
55
76
  end
@@ -71,13 +92,14 @@ module LDAP
71
92
  def assert_error_code
72
93
  return unless failed?
73
94
  code = error_code
95
+ message = error_message
74
96
  klass = ActiveLdap::LdapError::ERRORS[code]
75
97
  klass ||= IMPLEMENT_SPECIFIC_ERRORS[code]
76
- if klass.nil? and error_message == "Can't contact LDAP server"
77
- klass = LDAP::ServerDown
98
+ if klass.nil? and message == "Can't contact LDAP server"
99
+ klass = ActiveLdap::ConnectionError
78
100
  end
79
101
  klass ||= ActiveLdap::LdapError
80
- raise klass, LDAP.err2string(code)
102
+ raise klass, message
81
103
  end
82
104
  end
83
105
  end