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/CHANGES CHANGED
@@ -1,3 +1,35 @@
1
+ 1.0.9:
2
+ * Added documents in Japanese. [Kazuaki Takase]
3
+ * Supported Ruby 1.9.1.
4
+ * [#20] [Ruby 1.9 Support] :: Running Tests [Alexey.Chebotar]
5
+ * Supported Rails 2.3.2.
6
+ * [#18] [Rails 2.3 Support] :: Running WEBrick Hangs [Alexey.Chebotar]
7
+ * Bug fixes:
8
+ * Fixed blank values detection. [David Morton]
9
+ * [#22] Ruby 1.8.6 p287 :: Undefined methods [Alexey.Chebotar]
10
+ * Fixed gem loading. [Tiago Fernandes]
11
+ * Fixed DN change via #base=. [David Morton]
12
+ * Fixed infinite retry on timeout.
13
+ * Fixed needless reconnection.
14
+ * API improvements:
15
+ * Removed needless instance methods: #prefix=,
16
+ #dn_attribute=, #sort_by=, #order=, #required_classes=,
17
+ #recommended_classes= and #excluded_classes. [David Morton]
18
+ * Removed obsolete scafoold_al generator.
19
+ * Reduced default :retry_limit.
20
+ * Supported association as parameter. [Joe Francis]
21
+ * Normalized schema attribute name. [Tim Hermans]
22
+ * Suppressed AuthenticationError -> ConnectionError
23
+ conversion on reconnection. [Kazuaki Takase]
24
+ * Added ActiveLdap::Schema#dump.
25
+ * ActiveLdap::Base.establish_connection ->
26
+ ActiveLdap::Base.setup_connection.
27
+ * Supported ActiveLdap::Base.find(:last).
28
+ * Added convenient methods:
29
+ * ActiveLdap::Base.first
30
+ * ActiveLdap::Base.last
31
+ * ActiveLdap::Base.all
32
+
1
33
  1.0.2:
2
34
  * Removed Base64 module use.
3
35
  * Improved LDIF parser.
data/README CHANGED
@@ -104,7 +104,9 @@ list, please point out.
104
104
  * A suggestion for behavior on simple bind with empty password.
105
105
  * Bug reports.
106
106
  * Naoto Morishima: Bug reports.
107
- * David Morton: An API improvement idea.
107
+ * David Morton:
108
+ * An API improvement idea.
109
+ * Bug reports.
108
110
  * Lennon Day-Reynolds: Bug reports.
109
111
  * Tilo: A bug report.
110
112
  * Matt Mencel: A bug report.
@@ -122,3 +124,8 @@ list, please point out.
122
124
  * Alexey.Chebotar: Bug reports.
123
125
  * ery.lee: A bug report.
124
126
  * id:dicdak: A bug report.
127
+ * Raiko Mitsu: A bug report.
128
+ * Kazuaki Takase: Documents in Japanese.
129
+ * Tim Hermans: A bug report.
130
+ * Joe Francis: A suggestion.
131
+ * Tiago Fernandes: Bug reports.
@@ -8,13 +8,15 @@ class ApplicationController < ActionController::Base
8
8
  # Uncomment the :secret if you're not using the cookie session store
9
9
  protect_from_forgery # :secret => '5965eefc93d824a9c145fe8edb6d1a36'
10
10
 
11
- init_gettext "al-admin"
11
+ # init_gettext "al-admin"
12
12
 
13
13
  include ExceptionNotifiable
14
14
 
15
15
  include AuthenticatedSystem
16
16
  before_filter :login_from_cookie
17
17
 
18
+ filter_parameter_logging :password, :password_confirmation
19
+
18
20
  private
19
21
  def default_url_options(options)
20
22
  default_options = {}
@@ -1,21 +1,22 @@
1
1
  <%= error_messages_for(:user) %>
2
2
  <%= error_messages_for(:system_user) %>
3
3
  <% form_for(:user) do |f| %>
4
- <p><label for="<%= @user.dn_attribute %>"><%= _("Login") %></label><br/>
4
+ <p><%= f.label @user.dn_attribute, _("Login") %><br/>
5
5
  <%= f.text_field(@user.dn_attribute) %></p>
6
6
 
7
- <p><label for="password"><%= _("Password") %></label><br/>
7
+ <p><%= f.label(:password, _("Password")) %><br/>
8
8
  <%= f.password_field(:password) %></p>
9
9
 
10
- <p><label for="password_confirmation"><%= _("Confirm Password") %></label><br/>
10
+ <p><%= f.label(:password_confirmation, _("Confirm Password")) %><br/>
11
11
  <%= f.password_field(:password_confirmation) %></p>
12
12
 
13
13
  <p><%= submit_tag(_('Sign up')) %></p>
14
14
 
15
- <% names = @user.attribute_names(true) - ["objectClass", "userPassword"] %>
15
+ <% names = @user.attribute_names(true) -
16
+ ["objectClass", @user.dn_attribute, "userPassword"] %>
16
17
  <% names.sort.each do |name| %>
17
18
  <p>
18
- <label for="<%= h name %>"><%=h la_(name) %>
19
+ <%= f.label(name, la_(name)) %>
19
20
  <% if @required_attributes.include?(name) %>
20
21
  <span class="required-attribute-mark">*</span>
21
22
  <% end %>
@@ -44,6 +44,7 @@ module Rails
44
44
  def load_initializer
45
45
  require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
46
  Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
47
48
  end
48
49
  end
49
50
 
@@ -5,7 +5,7 @@
5
5
  # ENV['RAILS_ENV'] ||= 'production'
6
6
 
7
7
  # Specifies gem version of Rails to use when vendor/rails is not present
8
- RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
8
+ RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
9
9
 
10
10
  # Bootstrap the Rails environment, frameworks, and default configuration
11
11
  require File.join(File.dirname(__FILE__), 'boot')
@@ -27,7 +27,9 @@ Rails::Initializer.run do |config|
27
27
  # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
28
28
  # config.gem "sqlite3-ruby", :lib => "sqlite3"
29
29
  # config.gem "aws-s3", :lib => "aws/s3"
30
- config.gem "locale_rails"
30
+ # config.gem "locale_rails"
31
+ # config.gem "gettext_activerecord"
32
+ # config.gem "gettext_rails"
31
33
 
32
34
  # Only load the plugins named here, in the order given. By default, all plugins
33
35
  # in vendor/plugins are loaded in alphabetical order.
@@ -0,0 +1,7 @@
1
+ # Rack Dispatcher
2
+
3
+ # Require your environment file to bootstrap Rails
4
+ require ::File.dirname(__FILE__) + '/config/environment'
5
+
6
+ # Dispatch the request
7
+ run ActionController::Dispatcher.new
@@ -0,0 +1,38 @@
1
+ module LdapTestHelper
2
+ def setup_ldap_data
3
+ @ldap_dumped_data = nil
4
+ begin
5
+ @ldap_dumped_data = ActiveLdap::Base.dump(:scope => :sub)
6
+ rescue ActiveLdap::ConnectionError
7
+ end
8
+ ActiveLdap::Base.delete_all(nil, :scope => :sub)
9
+ populate_ldap_data
10
+ end
11
+
12
+ def teardown_ldap_data
13
+ if @ldap_dumped_data
14
+ ActiveLdap::Base.setup_connection
15
+ ActiveLdap::Base.delete_all(nil, :scope => :sub)
16
+ ActiveLdap::Base.load(@ldap_dumped_data)
17
+ end
18
+ end
19
+
20
+ def populate_ldap_data
21
+ populate_ldap_base
22
+ populate_ldap_ou
23
+ end
24
+
25
+ def populate_ldap_base
26
+ ActiveLdap::Populate.ensure_base
27
+ end
28
+
29
+ def populate_ldap_ou
30
+ %w(Users Groups).each do |name|
31
+ make_ou(name)
32
+ end
33
+ end
34
+
35
+ def make_ou(name)
36
+ ActiveLdap::Populate.ensure_ou(name)
37
+ end
38
+ end
@@ -7,7 +7,8 @@ namespace :gettext do
7
7
  namespace :environment do
8
8
  desc "Setup environment for GetText"
9
9
  task :setup => :environment do
10
- require "gettext/utils"
10
+ require 'gettext_rails/tools'
11
+ Locale.module_eval("@@locale_driver_module = nil")
11
12
  end
12
13
  end
13
14
 
@@ -29,7 +30,7 @@ namespace :gettext do
29
30
  namespace :mo do
30
31
  desc "Create *.mo from *.po (GetText)"
31
32
  task :create => "gettext:environment:setup" do
32
- GetText.create_mofiles(false, 'po', 'locale')
33
+ GetText.create_mofiles
33
34
  end
34
35
  end
35
36
  end
@@ -0,0 +1,10 @@
1
+ # -*- ruby -*-
2
+
3
+ namespace :test do
4
+ Rake::TestTask.new(:all => "db:test:prepare") do |task|
5
+ task.libs << "test"
6
+ task.verbose = false
7
+ task.test_files = Dir.glob("test/{unit,functional,integration}/**/*_test.rb").uniq
8
+ end
9
+ Rake::Task["test:all"].comment = "Run all tests in a test run"
10
+ end
@@ -1,13 +1,13 @@
1
1
  # English translations for AL Admin package.
2
- # Copyright (C) 2007,2008 Kouhei Sutou
2
+ # Copyright (C) 2007-2009 Kouhei Sutou
3
3
  # This file is distributed under the same license as the AL Admin package.
4
- # Kouhei Sutou <kou@cozmixng.org>, 2007,2008.
4
+ # Kouhei Sutou <kou@cozmixng.org>, 2007.
5
5
  #
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: AL Admin 1.0.2\n"
8
+ "Project-Id-Version: AL Admin 1.1.0\n"
9
9
  "POT-Creation-Date: 2008-02-09 14:25+0900\n"
10
- "PO-Revision-Date: 2007-08-19 09:44+0900\n"
10
+ "PO-Revision-Date: 2009-02-25 08:41+0900\n"
11
11
  "Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
12
12
  "Language-Team: English\n"
13
13
  "MIME-Version: 1.0\n"
@@ -1,13 +1,13 @@
1
1
  # AL Admin's translated messages for Japanese.
2
- # Copyright (C) 2007,2008 Kouhei Sutou
2
+ # Copyright (C) 2007-2009 Kouhei Sutou
3
3
  # This file is distributed under the same license as the AL Admin package.
4
- # Kouhei Sutou <kou@cozmixng.org>, 2007,2008.
4
+ # Kouhei Sutou <kou@cozmixng.org>, 2007.
5
5
  #
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: AL Admin 1.0.2\n"
8
+ "Project-Id-Version: AL Admin 1.1.0\n"
9
9
  "POT-Creation-Date: 2008-02-09 14:25+0900\n"
10
- "PO-Revision-Date: 2007-11-04 16:02+0900\n"
10
+ "PO-Revision-Date: 2009-02-25 08:41+0900\n"
11
11
  "Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
12
12
  "Language-Team: Japanese\n"
13
13
  "MIME-Version: 1.0\n"
@@ -3,12 +3,12 @@
3
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,2008.
6
+ # Ace Suares <ace@suares.an>, 2007.
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: AL Admin 1.0.2\n"
9
+ "Project-Id-Version: AL Admin 1.1.0\n"
10
10
  "POT-Creation-Date: 2008-02-09 14:25+0900\n"
11
- "PO-Revision-Date: 2007-08-24 22:03+0900\n"
11
+ "PO-Revision-Date: 2009-02-25 08:42+0900\n"
12
12
  "Last-Translator: Ace Suares <ace@suares.an>\n"
13
13
  "Language-Team: Nederlands <nl@li.org>\n"
14
14
  "MIME-Version: 1.0\n"
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby1.8
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
4
 
@@ -7,4 +7,4 @@ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_
7
7
  require "dispatcher"
8
8
 
9
9
  ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
- Dispatcher.dispatch
10
+ Dispatcher.dispatch
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby1.8
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # You may specify the path to the FastCGI crash log (a log of unhandled
4
4
  # exceptions which forced the FastCGI instance to exit, great for debugging)
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby1.8
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
4
 
@@ -7,4 +7,4 @@ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_
7
7
  require "dispatcher"
8
8
 
9
9
  ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
- Dispatcher.dispatch
10
+ Dispatcher.dispatch
@@ -1,22 +1,10 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'account_controller'
1
+ require 'test_helper'
3
2
 
4
- # Re-raise errors caught by the controller.
5
- class AccountController; def rescue_action(e) raise e end; end
6
-
7
- class AccountControllerTest < Test::Unit::TestCase
3
+ class AccountControllerTest < ActionController::TestCase
8
4
  # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
9
5
  # Then, you can remove it from this and the units test.
10
6
  include AuthenticatedTestHelper
11
7
 
12
- fixtures :users
13
-
14
- def setup
15
- @controller = AccountController.new
16
- @request = ActionController::TestRequest.new
17
- @response = ActionController::TestResponse.new
18
- end
19
-
20
8
  # Replace this with your real tests.
21
9
  def test_truth
22
10
  assert true
@@ -1,16 +1,6 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'attributes_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class AttributesController; def rescue_action(e) raise e end; end
6
-
7
- class AttributesControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = AttributesController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
1
+ require 'test_helper'
13
2
 
3
+ class AttributesControllerTest < ActionController::TestCase
14
4
  # Replace this with your real tests.
15
5
  def test_truth
16
6
  assert true
@@ -1,16 +1,6 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'directory_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class DirectoryController; def rescue_action(e) raise e end; end
6
-
7
- class DirectoryControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = DirectoryController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
1
+ require 'test_helper'
13
2
 
3
+ class DirectoryControllerTest < ActionController::TestCase
14
4
  # Replace this with your real tests.
15
5
  def test_truth
16
6
  assert true
@@ -1,16 +1,6 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'object_classes_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class ObjectClassesController; def rescue_action(e) raise e end; end
6
-
7
- class ObjectClassesControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = ObjectClassesController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
1
+ require 'test_helper'
13
2
 
3
+ class ObjectClassesControllerTest < ActionController::TestCase
14
4
  # Replace this with your real tests.
15
5
  def test_truth
16
6
  assert true
@@ -1,16 +1,6 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'syntaxes_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class SyntaxesController; def rescue_action(e) raise e end; end
6
-
7
- class SyntaxesControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = SyntaxesController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
1
+ require 'test_helper'
13
2
 
3
+ class SyntaxesControllerTest < ActionController::TestCase
14
4
  # Replace this with your real tests.
15
5
  def test_truth
16
6
  assert true
@@ -1,16 +1,6 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'users_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class UsersController; def rescue_action(e) raise e end; end
6
-
7
- class UsersControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = UsersController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
1
+ require 'test_helper'
13
2
 
3
+ class UsersControllerTest < ActionController::TestCase
14
4
  # Replace this with your real tests.
15
5
  def test_truth
16
6
  assert true
@@ -1,16 +1,6 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'welcome_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class WelcomeController; def rescue_action(e) raise e end; end
6
-
7
- class WelcomeControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = WelcomeController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
1
+ require 'test_helper'
13
2
 
3
+ class WelcomeControllerTest < ActionController::TestCase
14
4
  # Replace this with your real tests.
15
5
  def test_truth
16
6
  assert true
@@ -0,0 +1,44 @@
1
+ require 'test_helper'
2
+
3
+ class SignUpTest < ActionController::IntegrationTest
4
+ include LdapTestHelper
5
+ fixtures :all
6
+
7
+ def setup
8
+ setup_ldap_data
9
+ end
10
+
11
+ def teardown
12
+ teardown_ldap_data
13
+ end
14
+
15
+ def test_sign_up
16
+ visit("/")
17
+ click_link("Sign up")
18
+
19
+ fill_in("Login", :with => "test-user")
20
+ fill_in("Password", :with => "test password")
21
+ fill_in("Confirm Password", :with => "test password")
22
+ fill_in("user[sn]", :with => "ser")
23
+ assert_difference("User.count", 1) do
24
+ assert_difference("LdapUser.count", 1) do
25
+ click_button("Sign up")
26
+ end
27
+ end
28
+ end
29
+
30
+ def test_sign_up_failure
31
+ visit("/")
32
+ click_link("Sign up")
33
+
34
+ fill_in("Login", :with => "test-user")
35
+ fill_in("Password", :with => "test password")
36
+ fill_in("Confirm Password", :with => "test password")
37
+ assert_no_difference("User.count") do
38
+ assert_no_difference("LdapUser.count") do
39
+ click_button("Sign up")
40
+ end
41
+ end
42
+ assert_have_selector("div.fieldWithErrors input#user_sn")
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- rake test
3
+ rake -s test:all TESTOPTS="$@"
@@ -1,8 +1,22 @@
1
+ test_unit_dir = File.dirname(__FILE__) + "/../../../test-unit/lib"
2
+ if File.directory?(test_unit_dir)
3
+ $LOAD_PATH.unshift(test_unit_dir)
4
+ else
5
+ require 'rubygems'
6
+ gem 'test-unit'
7
+ end
8
+ require 'test/unit'
9
+
1
10
  ENV["RAILS_ENV"] = "test"
2
11
  require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
12
  require 'test_help'
4
13
 
5
- class Test::Unit::TestCase
14
+ require 'webrat'
15
+ Webrat.configure do |config|
16
+ config.mode = :rails
17
+ end
18
+
19
+ class ActiveSupport::TestCase
6
20
  # Transactional fixtures accelerate your tests by wrapping each test method
7
21
  # in a transaction that's rolled back on completion. This ensures that the
8
22
  # test database remains unchanged so your fixtures don't have to be reloaded
@@ -15,6 +29,10 @@ class Test::Unit::TestCase
15
29
  # in MySQL. Turn off transactional fixtures in this case; however, if you
16
30
  # don't care one way or the other, switching from MyISAM to InnoDB tables
17
31
  # is recommended.
32
+ #
33
+ # The only drawback to using transactional fixtures is when you actually
34
+ # need to test transactions. Since your test is bracketed by a transaction,
35
+ # any transactions started in your code will be automatically rolled back.
18
36
  self.use_transactional_fixtures = true
19
37
 
20
38
  # Instantiated fixtures are slow, but give you @david where otherwise you
@@ -24,5 +42,11 @@ class Test::Unit::TestCase
24
42
  # then set this back to true.
25
43
  self.use_instantiated_fixtures = false
26
44
 
45
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
46
+ #
47
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
48
+ # -- they do not yet inherit this setting
49
+ fixtures :all
50
+
27
51
  # Add more helper methods to be used by all tests here...
28
52
  end
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class UserTest < Test::Unit::TestCase
3
+ class UserTest < ActiveSupport::TestCase
4
4
  # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead.
5
5
  # Then, you can remove it from this and the functional test.
6
6
  include AuthenticatedTestHelper
7
- fixtures :users
8
7
 
9
8
  # Replace this with your real tests.
10
9
  def test_truth
data/examples/groupadd CHANGED
@@ -23,8 +23,8 @@ pwb = Proc.new do |user|
23
23
  ActiveLdap::Command.read_password("[#{user}] Password: ")
24
24
  end
25
25
 
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
26
+ ActiveLdap::Base.setup_connection(:password_block => pwb,
27
+ :allow_anonymous => false)
28
28
 
29
29
  if Group.exists?(name)
30
30
  $stderr.puts("Group #{name} already exists.")
data/examples/groupdel CHANGED
@@ -23,8 +23,8 @@ pwb = Proc.new do |user|
23
23
  ActiveLdap::Command.read_password("[#{user}] Password: ")
24
24
  end
25
25
 
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
26
+ ActiveLdap::Base.setup_connection(:password_block => pwb,
27
+ :allow_anonymous => false)
28
28
 
29
29
 
30
30
  unless Group.exists?(name)
data/examples/groupls CHANGED
@@ -23,8 +23,8 @@ pwb = Proc.new do |user|
23
23
  ActiveLdap::Command.read_password("[#{user}] Password: ")
24
24
  end
25
25
 
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
26
+ ActiveLdap::Base.setup_connection(:password_block => pwb,
27
+ :allow_anonymous => false)
28
28
 
29
29
  unless Group.exists?(name)
30
30
  $stderr.puts("Group #{name} doesn't exist.")
data/examples/groupmod CHANGED
@@ -23,8 +23,8 @@ pwb = Proc.new do |user|
23
23
  ActiveLdap::Command.read_password("[#{user}] Password: ")
24
24
  end
25
25
 
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
26
+ ActiveLdap::Base.setup_connection(:password_block => pwb,
27
+ :allow_anonymous => false)
28
28
 
29
29
 
30
30
  unless Group.exists?(name)
data/examples/lpasswd CHANGED
@@ -23,8 +23,8 @@ pwb = Proc.new do |user|
23
23
  user ||= ENV["USER"]
24
24
  ActiveLdap::Command.read_password("[#{user}] Password: ")
25
25
  end
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
26
+ ActiveLdap::Base.setup_connection(:password_block => pwb,
27
+ :allow_anonymous => false)
28
28
 
29
29
  unless User.exists?(name)
30
30
  $stderr.puts("User #{name} doesn't exist.")
@@ -6,8 +6,8 @@ class Group < ActiveLdap::Base
6
6
  # some class |:class_name| where the attributes name is
7
7
  # |:local_key|. This means that it will call
8
8
  # :class_name.new(value_of(:local_key)) to create the objects.
9
- has_many :members, :class => "User", :wrap => "memberUid"
10
- has_many :primary_members, :class => 'User',
9
+ has_many :members, :class_name => "User", :wrap => "memberUid"
10
+ has_many :primary_members, :class_name => 'User',
11
11
  :foreign_key => 'gidNumber',
12
12
  :primary_key => 'gidNumber'
13
13
  end # Group
@@ -3,7 +3,7 @@ require 'objects/group'
3
3
  class User < ActiveLdap::Base
4
4
  ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=People',
5
5
  :classes => ['person', 'posixAccount']
6
- belongs_to :primary_group, :class => "Group",
6
+ belongs_to :primary_group, :class_name => "Group",
7
7
  :foreign_key => "gidNumber", :primary_key => "gidNumber"
8
8
  belongs_to :groups, :many => 'memberUid'
9
9
 
data/examples/ouadd CHANGED
@@ -22,8 +22,8 @@ pwb = Proc.new do |user|
22
22
  ActiveLdap::Command.read_password("[#{user}] Password: ")
23
23
  end
24
24
 
25
- ActiveLdap::Base.establish_connection(:password_block => pwb,
26
- :allow_anonymous => false)
25
+ ActiveLdap::Base.setup_connection(:password_block => pwb,
26
+ :allow_anonymous => false)
27
27
 
28
28
  if Ou.exists?(name)
29
29
  $stderr.puts("Ou #{name} already exists.")