devise_ldap_authenticatable 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/MIT-LICENSE +20 -0
- data/README.md +4 -1
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/devise_ldap_authenticatable.gemspec +166 -0
- data/lib/devise_ldap_authenticatable.rb +3 -0
- data/lib/devise_ldap_authenticatable/ldap_adapter.rb +14 -4
- data/lib/devise_ldap_authenticatable/model.rb +26 -26
- data/lib/devise_ldap_authenticatable/version.rb +1 -1
- data/lib/generators/devise_ldap_authenticatable/install_generator.rb +2 -0
- data/rails/init.rb +2 -0
- data/test/devise_ldap_authenticatable_test.rb +8 -0
- data/test/ldap/base.ldif +54 -0
- data/test/ldap/clear.ldif +20 -0
- data/test/ldap/local.schema +6 -0
- data/test/ldap/run-server.sh +4 -0
- data/test/ldap/slapd-test.conf +106 -0
- data/test/rails_app/Gemfile +22 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/controllers/application_controller.rb +4 -0
- data/test/rails_app/app/controllers/posts_controller.rb +15 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/helpers/posts_helper.rb +2 -0
- data/test/rails_app/app/models/post.rb +2 -0
- data/test/rails_app/app/models/user.rb +10 -0
- data/test/rails_app/app/views/layouts/application.html.erb +26 -0
- data/test/rails_app/app/views/posts/index.html.erb +2 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +46 -0
- data/test/rails_app/config/boot.rb +13 -0
- data/test/rails_app/config/cucumber.yml +8 -0
- data/test/rails_app/config/database.yml +25 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +22 -0
- data/test/rails_app/config/environments/production.rb +46 -0
- data/test/rails_app/config/environments/test.rb +34 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/devise.rb +140 -0
- data/test/rails_app/config/initializers/inflections.rb +10 -0
- data/test/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/rails_app/config/initializers/session_store.rb +8 -0
- data/test/rails_app/config/ldap.yml +33 -0
- data/test/rails_app/config/ldap_with_uid.yml +30 -0
- data/test/rails_app/config/locales/devise.en.yml +39 -0
- data/test/rails_app/config/locales/en.yml +5 -0
- data/test/rails_app/config/routes.rb +64 -0
- data/test/rails_app/db/migrate/20100708120302_create_posts.rb +14 -0
- data/test/rails_app/db/migrate/20100708120448_devise_create_users.rb +26 -0
- data/test/rails_app/db/schema.rb +41 -0
- data/test/rails_app/db/seeds.rb +7 -0
- data/test/rails_app/features/manage_logins.feature +34 -0
- data/test/rails_app/features/step_definitions/login_steps.rb +16 -0
- data/test/rails_app/features/step_definitions/web_steps.rb +219 -0
- data/test/rails_app/features/support/env.rb +58 -0
- data/test/rails_app/features/support/paths.rb +38 -0
- data/test/rails_app/lib/tasks/.gitkeep +0 -0
- data/test/rails_app/lib/tasks/cucumber.rake +53 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/rails_app/public/images/rails.png +0 -0
- data/test/rails_app/public/javascripts/application.js +2 -0
- data/test/rails_app/public/javascripts/controls.js +965 -0
- data/test/rails_app/public/javascripts/dragdrop.js +974 -0
- data/test/rails_app/public/javascripts/effects.js +1123 -0
- data/test/rails_app/public/javascripts/prototype.js +4874 -0
- data/test/rails_app/public/javascripts/rails.js +118 -0
- data/test/rails_app/public/stylesheets/.gitkeep +0 -0
- data/test/rails_app/script/cucumber +10 -0
- data/test/rails_app/script/rails +6 -0
- data/test/rails_app/test/factories/users.rb +9 -0
- data/test/rails_app/test/functional/posts_controller_test.rb +58 -0
- data/test/rails_app/test/performance/browsing_test.rb +9 -0
- data/test/rails_app/test/test_helper.rb +22 -0
- data/test/rails_app/test/unit/helpers/posts_helper_test.rb +4 -0
- data/test/rails_app/test/unit/post_test.rb +8 -0
- data/test/rails_app/test/unit/user_test.rb +172 -0
- data/test/test_helper.rb +3 -0
- metadata +140 -30
| @@ -0,0 +1,118 @@ | |
| 1 | 
            +
            document.observe("dom:loaded", function() {
         | 
| 2 | 
            +
              function handleRemote(element) {
         | 
| 3 | 
            +
                var method, url, params;
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                if (element.tagName.toLowerCase() === 'form') {
         | 
| 6 | 
            +
                  method = element.readAttribute('method') || 'post';
         | 
| 7 | 
            +
                  url    = element.readAttribute('action');
         | 
| 8 | 
            +
                  params = element.serialize(true);
         | 
| 9 | 
            +
                } else {
         | 
| 10 | 
            +
                  method = element.readAttribute('data-method') || 'get';
         | 
| 11 | 
            +
                  url    = element.readAttribute('href');
         | 
| 12 | 
            +
                  params = {};
         | 
| 13 | 
            +
                }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                var event = element.fire("ajax:before");
         | 
| 16 | 
            +
                if (event.stopped) return false;
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                new Ajax.Request(url, {
         | 
| 19 | 
            +
                  method: method,
         | 
| 20 | 
            +
                  parameters: params,
         | 
| 21 | 
            +
                  asynchronous: true,
         | 
| 22 | 
            +
                  evalScripts: true,
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  onLoading:     function(request) { element.fire("ajax:loading", {request: request}); },
         | 
| 25 | 
            +
                  onLoaded:      function(request) { element.fire("ajax:loaded", {request: request}); },
         | 
| 26 | 
            +
                  onInteractive: function(request) { element.fire("ajax:interactive", {request: request}); },
         | 
| 27 | 
            +
                  onComplete:    function(request) { element.fire("ajax:complete", {request: request}); },
         | 
| 28 | 
            +
                  onSuccess:     function(request) { element.fire("ajax:success", {request: request}); },
         | 
| 29 | 
            +
                  onFailure:     function(request) { element.fire("ajax:failure", {request: request}); }
         | 
| 30 | 
            +
                });
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                element.fire("ajax:after");
         | 
| 33 | 
            +
              }
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              function handleMethod(element) {
         | 
| 36 | 
            +
                var method, url, token_name, token;
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                method     = element.readAttribute('data-method');
         | 
| 39 | 
            +
                url        = element.readAttribute('href');
         | 
| 40 | 
            +
                csrf_param = $$('meta[name=csrf-param]').first();
         | 
| 41 | 
            +
                csrf_token = $$('meta[name=csrf-token]').first();
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
         | 
| 44 | 
            +
                element.parentNode.appendChild(form);
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                if (method != 'post') {
         | 
| 47 | 
            +
                  var field = new Element('input', { type: 'hidden', name: '_method', value: method });
         | 
| 48 | 
            +
                  form.appendChild(field);
         | 
| 49 | 
            +
                }
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                if (csrf_param) {
         | 
| 52 | 
            +
                  var param = csrf_param.readAttribute('content');
         | 
| 53 | 
            +
                  var token = csrf_token.readAttribute('content');
         | 
| 54 | 
            +
                  var field = new Element('input', { type: 'hidden', name: param, value: token });
         | 
| 55 | 
            +
                  form.appendChild(field);
         | 
| 56 | 
            +
                }
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                form.submit();
         | 
| 59 | 
            +
              }
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              $(document.body).observe("click", function(event) {
         | 
| 62 | 
            +
                var message = event.findElement().readAttribute('data-confirm');
         | 
| 63 | 
            +
                if (message && !confirm(message)) {
         | 
| 64 | 
            +
                  event.stop();
         | 
| 65 | 
            +
                  return false;
         | 
| 66 | 
            +
                }
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                var element = event.findElement("a[data-remote]");
         | 
| 69 | 
            +
                if (element) {
         | 
| 70 | 
            +
                  handleRemote(element);
         | 
| 71 | 
            +
                  event.stop();
         | 
| 72 | 
            +
                  return true;
         | 
| 73 | 
            +
                }
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                var element = event.findElement("a[data-method]");
         | 
| 76 | 
            +
                if (element) {
         | 
| 77 | 
            +
                  handleMethod(element);
         | 
| 78 | 
            +
                  event.stop();
         | 
| 79 | 
            +
                  return true;
         | 
| 80 | 
            +
                }
         | 
| 81 | 
            +
              });
         | 
| 82 | 
            +
             | 
| 83 | 
            +
              // TODO: I don't think submit bubbles in IE
         | 
| 84 | 
            +
              $(document.body).observe("submit", function(event) {
         | 
| 85 | 
            +
                var element = event.findElement(),
         | 
| 86 | 
            +
                    message = element.readAttribute('data-confirm');
         | 
| 87 | 
            +
                if (message && !confirm(message)) {
         | 
| 88 | 
            +
                  event.stop();
         | 
| 89 | 
            +
                  return false;
         | 
| 90 | 
            +
                }
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                var inputs = element.select("input[type=submit][data-disable-with]");
         | 
| 93 | 
            +
                inputs.each(function(input) {
         | 
| 94 | 
            +
                  input.disabled = true;
         | 
| 95 | 
            +
                  input.writeAttribute('data-original-value', input.value);
         | 
| 96 | 
            +
                  input.value = input.readAttribute('data-disable-with');
         | 
| 97 | 
            +
                });
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                var element = event.findElement("form[data-remote]");
         | 
| 100 | 
            +
                if (element) {
         | 
| 101 | 
            +
                  handleRemote(element);
         | 
| 102 | 
            +
                  event.stop();
         | 
| 103 | 
            +
                }
         | 
| 104 | 
            +
              });
         | 
| 105 | 
            +
             | 
| 106 | 
            +
              $(document.body).observe("ajax:after", function(event) {
         | 
| 107 | 
            +
                var element = event.findElement();
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                if (element.tagName.toLowerCase() === 'form') {
         | 
| 110 | 
            +
                  var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
         | 
| 111 | 
            +
                  inputs.each(function(input) {
         | 
| 112 | 
            +
                    input.value = input.readAttribute('data-original-value');
         | 
| 113 | 
            +
                    input.writeAttribute('data-original-value', null);
         | 
| 114 | 
            +
                    input.disabled = false;
         | 
| 115 | 
            +
                  });
         | 
| 116 | 
            +
                }
         | 
| 117 | 
            +
              });
         | 
| 118 | 
            +
            });
         | 
| 
            File without changes
         | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
         | 
| 4 | 
            +
            if vendored_cucumber_bin
         | 
| 5 | 
            +
              load File.expand_path(vendored_cucumber_bin)
         | 
| 6 | 
            +
            else
         | 
| 7 | 
            +
              require 'rubygems' unless ENV['NO_RUBYGEMS']
         | 
| 8 | 
            +
              require 'cucumber'
         | 
| 9 | 
            +
              load Cucumber::BINARY
         | 
| 10 | 
            +
            end
         | 
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            APP_PATH = File.expand_path('../../config/application',  __FILE__)
         | 
| 5 | 
            +
            require File.expand_path('../../config/boot',  __FILE__)
         | 
| 6 | 
            +
            require 'rails/commands'
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class PostsControllerTest < ActionController::TestCase
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              include Devise::TestHelpers
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              context "not logged in" do
         | 
| 8 | 
            +
                should "should get INDEX" do
         | 
| 9 | 
            +
                  get :index
         | 
| 10 | 
            +
                  assert_response :success
         | 
| 11 | 
            +
                  assert_equal(response.body, "posts#index")
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
                
         | 
| 14 | 
            +
                context "go to NEW page" do
         | 
| 15 | 
            +
                  setup do
         | 
| 16 | 
            +
                    get :new
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  should "not get NEW" do
         | 
| 20 | 
            +
                    assert_response :redirect
         | 
| 21 | 
            +
                  end      
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
              
         | 
| 25 | 
            +
              context "logged in" do
         | 
| 26 | 
            +
                setup do
         | 
| 27 | 
            +
                  @user = Factory(:user)
         | 
| 28 | 
            +
                  sign_in(@user)
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                context "get NEW action" do
         | 
| 32 | 
            +
                  setup do
         | 
| 33 | 
            +
                    get :new
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  should "get the NEW action" do
         | 
| 37 | 
            +
                    assert_response :success
         | 
| 38 | 
            +
                    assert_equal(response.body, "posts#new")
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
                
         | 
| 42 | 
            +
                context "log out user" do
         | 
| 43 | 
            +
                  setup do
         | 
| 44 | 
            +
                    sign_out(@user)
         | 
| 45 | 
            +
                    get :new
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  should "get redirected to the login page" do
         | 
| 49 | 
            +
                    assert_response :redirect
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
                
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
              
         | 
| 56 | 
            +
             | 
| 57 | 
            +
             | 
| 58 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            ENV["RAILS_ENV"] = "test"
         | 
| 2 | 
            +
            require File.expand_path('../../config/environment', __FILE__)
         | 
| 3 | 
            +
            require 'rails/test_help'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class ActiveSupport::TestCase
         | 
| 6 | 
            +
              
         | 
| 7 | 
            +
              def reset_ldap_server!
         | 
| 8 | 
            +
                `ldapmodify -x -h localhost -p 3389 -D "cn=admin,dc=test,dc=com" -w secret -f ../ldap/clear.ldif`
         | 
| 9 | 
            +
                `ldapadd -x -h localhost -p 3389 -D "cn=admin,dc=test,dc=com" -w secret -f ../ldap/base.ldif`
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              def default_devise_settings!
         | 
| 13 | 
            +
                ::Devise.ldap_logger = true
         | 
| 14 | 
            +
                ::Devise.ldap_create_user = false
         | 
| 15 | 
            +
                ::Devise.ldap_update_password = true
         | 
| 16 | 
            +
                ::Devise.ldap_config = "#{Rails.root}/config/ldap.yml"
         | 
| 17 | 
            +
                ::Devise.ldap_check_group_membership = false
         | 
| 18 | 
            +
                ::Devise.ldap_check_attributes = false
         | 
| 19 | 
            +
                ::Devise.authentication_keys = [:email]
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,172 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class UserTest < ActiveSupport::TestCase
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              def should_be_validated(user, password, message = "Password is invalid")
         | 
| 6 | 
            +
                assert(user.valid_ldap_authentication?(password), message)
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              def should_not_be_validated(user, password, message = "Password is not properly set")
         | 
| 10 | 
            +
                 assert(!user.valid_ldap_authentication?(password), message)
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              context "With default settings" do
         | 
| 14 | 
            +
                setup do
         | 
| 15 | 
            +
                  reset_ldap_server!
         | 
| 16 | 
            +
                  default_devise_settings!
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              
         | 
| 19 | 
            +
                context "create a basic user" do
         | 
| 20 | 
            +
                  setup do
         | 
| 21 | 
            +
                    @user = Factory(:user)
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  should "check for password validation" do
         | 
| 25 | 
            +
                    assert_equal(@user.email, "example.user@test.com")
         | 
| 26 | 
            +
                    should_be_validated @user, "secret"
         | 
| 27 | 
            +
                    should_not_be_validated @user, "wrong_secret"
         | 
| 28 | 
            +
                    should_not_be_validated @user, "Secret"
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              
         | 
| 32 | 
            +
                context "change a LDAP password" do
         | 
| 33 | 
            +
                  setup do
         | 
| 34 | 
            +
                    @user = Factory(:user)
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  should "change password" do
         | 
| 38 | 
            +
                    should_be_validated @user, "secret"
         | 
| 39 | 
            +
                    @user.reset_password!("changed","changed")
         | 
| 40 | 
            +
                    should_be_validated @user, "changed", "password was not changed properly on the LDAP sevrer"
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                
         | 
| 43 | 
            +
                  should "not allow to change password if setting is false" do
         | 
| 44 | 
            +
                    should_be_validated @user, "secret"
         | 
| 45 | 
            +
                    ::Devise.ldap_update_password = false
         | 
| 46 | 
            +
                    @user.reset_password!("wrong_secret", "wrong_secret")
         | 
| 47 | 
            +
                    should_not_be_validated @user, "wrong_secret"
         | 
| 48 | 
            +
                    should_be_validated @user, "secret"
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
              
         | 
| 52 | 
            +
                context "create new local user if user is in LDAP" do
         | 
| 53 | 
            +
                
         | 
| 54 | 
            +
                  setup do
         | 
| 55 | 
            +
                    assert(User.all.blank?, "There shouldn't be any users in the database")
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
                
         | 
| 58 | 
            +
                  should "don't create user in the database" do
         | 
| 59 | 
            +
                    @user = User.authenticate_with_ldap(:email => "example.user@test.com", :password => "secret")
         | 
| 60 | 
            +
                    assert(User.all.blank?)
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                
         | 
| 63 | 
            +
                  context "creating users is enabled" do
         | 
| 64 | 
            +
                    setup do
         | 
| 65 | 
            +
                      ::Devise.ldap_create_user = true
         | 
| 66 | 
            +
                    end
         | 
| 67 | 
            +
                  
         | 
| 68 | 
            +
                    should "create a user in the database" do
         | 
| 69 | 
            +
                      @user = User.authenticate_with_ldap(:email => "example.user@test.com", :password => "secret")
         | 
| 70 | 
            +
                      assert_equal(User.all.size, 1)
         | 
| 71 | 
            +
                      assert_contains(User.all.collect(&:email), "example.user@test.com", "user not in database")
         | 
| 72 | 
            +
                    end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                    should "not create a user in the database if the password is wrong_secret" do
         | 
| 75 | 
            +
                      @user = User.authenticate_with_ldap(:email => "example.user", :password => "wrong_secret")
         | 
| 76 | 
            +
                      assert(User.all.blank?, "There's users in the database")
         | 
| 77 | 
            +
                    end
         | 
| 78 | 
            +
                  
         | 
| 79 | 
            +
                    should "create a user if the user is not in LDAP" do
         | 
| 80 | 
            +
                      @user = User.authenticate_with_ldap(:email => "wrong_secret.user@test.com", :password => "wrong_secret")
         | 
| 81 | 
            +
                      assert(User.all.blank?, "There's users in the database")
         | 
| 82 | 
            +
                    end
         | 
| 83 | 
            +
                  end
         | 
| 84 | 
            +
                
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
              
         | 
| 87 | 
            +
                context "use groups for authorization" do
         | 
| 88 | 
            +
                  setup do
         | 
| 89 | 
            +
                    @admin = Factory(:admin)
         | 
| 90 | 
            +
                    @user = Factory(:user)
         | 
| 91 | 
            +
                    ::Devise.authentication_keys = [:email]
         | 
| 92 | 
            +
                    ::Devise.ldap_check_group_membership = true
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  should "admin should be allowed in" do
         | 
| 96 | 
            +
                    should_be_validated @admin, "admin_secret"
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
                
         | 
| 99 | 
            +
                  should "admin should have the proper groups set" do
         | 
| 100 | 
            +
                    assert_contains(@admin.ldap_groups, /cn=admins/, "groups attribute not being set properly")
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
                
         | 
| 103 | 
            +
                  should "user should not be allowed in" do
         | 
| 104 | 
            +
                    should_not_be_validated @user, "secret"
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
              
         | 
| 108 | 
            +
                context "use role attribute for authorization" do
         | 
| 109 | 
            +
                  setup do
         | 
| 110 | 
            +
                    @admin = Factory(:admin)
         | 
| 111 | 
            +
                    @user = Factory(:user)
         | 
| 112 | 
            +
                    ::Devise.ldap_check_attributes = true
         | 
| 113 | 
            +
                  end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                  should "admin should be allowed in" do
         | 
| 116 | 
            +
                    should_be_validated @admin, "admin_secret"
         | 
| 117 | 
            +
                  end
         | 
| 118 | 
            +
                
         | 
| 119 | 
            +
                  should "user should not be allowed in" do
         | 
| 120 | 
            +
                    should_not_be_validated @user, "secret"
         | 
| 121 | 
            +
                  end
         | 
| 122 | 
            +
                end
         | 
| 123 | 
            +
                
         | 
| 124 | 
            +
                context "use admin setting to bind" do
         | 
| 125 | 
            +
                  setup do
         | 
| 126 | 
            +
                    @admin = Factory(:admin)
         | 
| 127 | 
            +
                    @user = Factory(:user)
         | 
| 128 | 
            +
                    ::Devise.ldap_use_admin_to_bind = true
         | 
| 129 | 
            +
                  end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                  should "description" do
         | 
| 132 | 
            +
                    should_be_validated @admin, "admin_secret"
         | 
| 133 | 
            +
                  end
         | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
              
         | 
| 136 | 
            +
              end
         | 
| 137 | 
            +
              
         | 
| 138 | 
            +
              context "use uid for login" do
         | 
| 139 | 
            +
                setup do
         | 
| 140 | 
            +
                  reset_ldap_server!
         | 
| 141 | 
            +
                  default_devise_settings!
         | 
| 142 | 
            +
                  ::Devise.ldap_config = "#{Rails.root}/config/ldap_with_uid.yml"
         | 
| 143 | 
            +
                  ::Devise.authentication_keys = [:uid]
         | 
| 144 | 
            +
                end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                context "description" do
         | 
| 147 | 
            +
                  setup do
         | 
| 148 | 
            +
                    @admin = Factory(:admin)
         | 
| 149 | 
            +
                    @user = Factory(:user, :uid => "example_user")
         | 
| 150 | 
            +
                  end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                  should "be able to authenticate using uid" do
         | 
| 153 | 
            +
                    should_be_validated @user, "secret"
         | 
| 154 | 
            +
                    should_not_be_validated @admin, "admin_secret"
         | 
| 155 | 
            +
                  end
         | 
| 156 | 
            +
                end
         | 
| 157 | 
            +
                
         | 
| 158 | 
            +
                context "create user" do
         | 
| 159 | 
            +
                  setup do
         | 
| 160 | 
            +
                    ::Devise.ldap_create_user = true
         | 
| 161 | 
            +
                  end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                  should "create a user in the database" do
         | 
| 164 | 
            +
                    @user = User.authenticate_with_ldap(:uid => "example_user", :password => "secret")
         | 
| 165 | 
            +
                    assert_equal(User.all.size, 1)
         | 
| 166 | 
            +
                    assert_contains(User.all.collect(&:uid), "example_user", "user not in database")
         | 
| 167 | 
            +
                  end
         | 
| 168 | 
            +
                end    
         | 
| 169 | 
            +
              end
         | 
| 170 | 
            +
              
         | 
| 171 | 
            +
              
         | 
| 172 | 
            +
            end
         | 
    
        data/test/test_helper.rb
    ADDED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,21 +1,21 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: devise_ldap_authenticatable
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              hash: 13
         | 
| 4 5 | 
             
              prerelease: false
         | 
| 5 6 | 
             
              segments: 
         | 
| 6 7 | 
             
              - 0
         | 
| 7 8 | 
             
              - 4
         | 
| 8 | 
            -
              -  | 
| 9 | 
            -
              version: 0.4. | 
| 9 | 
            +
              - 1
         | 
| 10 | 
            +
              version: 0.4.1
         | 
| 10 11 | 
             
            platform: ruby
         | 
| 11 12 | 
             
            authors: 
         | 
| 12 | 
            -
            - Daniel McNevin
         | 
| 13 13 | 
             
            - Curtis Schiewek
         | 
| 14 14 | 
             
            autorequire: 
         | 
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2010- | 
| 18 | 
            +
            date: 2010-08-01 00:00:00 -04:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -24,13 +24,14 @@ dependencies: | |
| 24 24 | 
             
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 25 25 | 
             
                none: false
         | 
| 26 26 | 
             
                requirements: 
         | 
| 27 | 
            -
                - -  | 
| 27 | 
            +
                - - ">"
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            +
                    hash: 31
         | 
| 29 30 | 
             
                    segments: 
         | 
| 30 31 | 
             
                    - 1
         | 
| 31 | 
            -
                    -  | 
| 32 | 
            -
                    -  | 
| 33 | 
            -
                    version: 1. | 
| 32 | 
            +
                    - 0
         | 
| 33 | 
            +
                    - 4
         | 
| 34 | 
            +
                    version: 1.0.4
         | 
| 34 35 | 
             
              type: :runtime
         | 
| 35 36 | 
             
              version_requirements: *id001
         | 
| 36 37 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -39,25 +40,32 @@ dependencies: | |
| 39 40 | 
             
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 40 41 | 
             
                none: false
         | 
| 41 42 | 
             
                requirements: 
         | 
| 42 | 
            -
                - -  | 
| 43 | 
            +
                - - ">="
         | 
| 43 44 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 45 | 
            +
                    hash: 31
         | 
| 44 46 | 
             
                    segments: 
         | 
| 45 47 | 
             
                    - 0
         | 
| 46 | 
            -
                    -  | 
| 47 | 
            -
                    -  | 
| 48 | 
            -
                    version: 0. | 
| 48 | 
            +
                    - 0
         | 
| 49 | 
            +
                    - 0
         | 
| 50 | 
            +
                    version: 0.0.0
         | 
| 49 51 | 
             
              type: :runtime
         | 
| 50 52 | 
             
              version_requirements: *id002
         | 
| 51 | 
            -
            description: LDAP  | 
| 52 | 
            -
            email: 
         | 
| 53 | 
            -
            - dpmcnevin@gmail.com
         | 
| 53 | 
            +
            description: LDAP authentication module for Devise
         | 
| 54 | 
            +
            email: curtis.schiewek@gmail.com
         | 
| 54 55 | 
             
            executables: []
         | 
| 55 56 |  | 
| 56 57 | 
             
            extensions: []
         | 
| 57 58 |  | 
| 58 | 
            -
            extra_rdoc_files:  | 
| 59 | 
            -
             | 
| 59 | 
            +
            extra_rdoc_files: 
         | 
| 60 | 
            +
            - README.md
         | 
| 60 61 | 
             
            files: 
         | 
| 62 | 
            +
            - .gitignore
         | 
| 63 | 
            +
            - MIT-LICENSE
         | 
| 64 | 
            +
            - README.md
         | 
| 65 | 
            +
            - Rakefile
         | 
| 66 | 
            +
            - VERSION
         | 
| 67 | 
            +
            - devise_ldap_authenticatable.gemspec
         | 
| 68 | 
            +
            - lib/devise_ldap_authenticatable.rb
         | 
| 61 69 | 
             
            - lib/devise_ldap_authenticatable/exception.rb
         | 
| 62 70 | 
             
            - lib/devise_ldap_authenticatable/ldap_adapter.rb
         | 
| 63 71 | 
             
            - lib/devise_ldap_authenticatable/logger.rb
         | 
| @@ -66,17 +74,84 @@ files: | |
| 66 74 | 
             
            - lib/devise_ldap_authenticatable/schema.rb
         | 
| 67 75 | 
             
            - lib/devise_ldap_authenticatable/strategy.rb
         | 
| 68 76 | 
             
            - lib/devise_ldap_authenticatable/version.rb
         | 
| 69 | 
            -
            - lib/devise_ldap_authenticatable.rb
         | 
| 70 77 | 
             
            - lib/generators/devise_ldap_authenticatable/install_generator.rb
         | 
| 71 78 | 
             
            - lib/generators/devise_ldap_authenticatable/templates/ldap.yml
         | 
| 72 | 
            -
            -  | 
| 79 | 
            +
            - rails/init.rb
         | 
| 80 | 
            +
            - test/devise_ldap_authenticatable_test.rb
         | 
| 81 | 
            +
            - test/ldap/base.ldif
         | 
| 82 | 
            +
            - test/ldap/clear.ldif
         | 
| 83 | 
            +
            - test/ldap/local.schema
         | 
| 84 | 
            +
            - test/ldap/run-server.sh
         | 
| 85 | 
            +
            - test/ldap/slapd-test.conf
         | 
| 86 | 
            +
            - test/rails_app/Gemfile
         | 
| 87 | 
            +
            - test/rails_app/Rakefile
         | 
| 88 | 
            +
            - test/rails_app/app/controllers/application_controller.rb
         | 
| 89 | 
            +
            - test/rails_app/app/controllers/posts_controller.rb
         | 
| 90 | 
            +
            - test/rails_app/app/helpers/application_helper.rb
         | 
| 91 | 
            +
            - test/rails_app/app/helpers/posts_helper.rb
         | 
| 92 | 
            +
            - test/rails_app/app/models/post.rb
         | 
| 93 | 
            +
            - test/rails_app/app/models/user.rb
         | 
| 94 | 
            +
            - test/rails_app/app/views/layouts/application.html.erb
         | 
| 95 | 
            +
            - test/rails_app/app/views/posts/index.html.erb
         | 
| 96 | 
            +
            - test/rails_app/config.ru
         | 
| 97 | 
            +
            - test/rails_app/config/application.rb
         | 
| 98 | 
            +
            - test/rails_app/config/boot.rb
         | 
| 99 | 
            +
            - test/rails_app/config/cucumber.yml
         | 
| 100 | 
            +
            - test/rails_app/config/database.yml
         | 
| 101 | 
            +
            - test/rails_app/config/environment.rb
         | 
| 102 | 
            +
            - test/rails_app/config/environments/development.rb
         | 
| 103 | 
            +
            - test/rails_app/config/environments/production.rb
         | 
| 104 | 
            +
            - test/rails_app/config/environments/test.rb
         | 
| 105 | 
            +
            - test/rails_app/config/initializers/backtrace_silencers.rb
         | 
| 106 | 
            +
            - test/rails_app/config/initializers/devise.rb
         | 
| 107 | 
            +
            - test/rails_app/config/initializers/inflections.rb
         | 
| 108 | 
            +
            - test/rails_app/config/initializers/mime_types.rb
         | 
| 109 | 
            +
            - test/rails_app/config/initializers/secret_token.rb
         | 
| 110 | 
            +
            - test/rails_app/config/initializers/session_store.rb
         | 
| 111 | 
            +
            - test/rails_app/config/ldap.yml
         | 
| 112 | 
            +
            - test/rails_app/config/ldap_with_uid.yml
         | 
| 113 | 
            +
            - test/rails_app/config/locales/devise.en.yml
         | 
| 114 | 
            +
            - test/rails_app/config/locales/en.yml
         | 
| 115 | 
            +
            - test/rails_app/config/routes.rb
         | 
| 116 | 
            +
            - test/rails_app/db/migrate/20100708120302_create_posts.rb
         | 
| 117 | 
            +
            - test/rails_app/db/migrate/20100708120448_devise_create_users.rb
         | 
| 118 | 
            +
            - test/rails_app/db/schema.rb
         | 
| 119 | 
            +
            - test/rails_app/db/seeds.rb
         | 
| 120 | 
            +
            - test/rails_app/features/manage_logins.feature
         | 
| 121 | 
            +
            - test/rails_app/features/step_definitions/login_steps.rb
         | 
| 122 | 
            +
            - test/rails_app/features/step_definitions/web_steps.rb
         | 
| 123 | 
            +
            - test/rails_app/features/support/env.rb
         | 
| 124 | 
            +
            - test/rails_app/features/support/paths.rb
         | 
| 125 | 
            +
            - test/rails_app/lib/tasks/.gitkeep
         | 
| 126 | 
            +
            - test/rails_app/lib/tasks/cucumber.rake
         | 
| 127 | 
            +
            - test/rails_app/public/404.html
         | 
| 128 | 
            +
            - test/rails_app/public/422.html
         | 
| 129 | 
            +
            - test/rails_app/public/500.html
         | 
| 130 | 
            +
            - test/rails_app/public/images/rails.png
         | 
| 131 | 
            +
            - test/rails_app/public/javascripts/application.js
         | 
| 132 | 
            +
            - test/rails_app/public/javascripts/controls.js
         | 
| 133 | 
            +
            - test/rails_app/public/javascripts/dragdrop.js
         | 
| 134 | 
            +
            - test/rails_app/public/javascripts/effects.js
         | 
| 135 | 
            +
            - test/rails_app/public/javascripts/prototype.js
         | 
| 136 | 
            +
            - test/rails_app/public/javascripts/rails.js
         | 
| 137 | 
            +
            - test/rails_app/public/stylesheets/.gitkeep
         | 
| 138 | 
            +
            - test/rails_app/script/cucumber
         | 
| 139 | 
            +
            - test/rails_app/script/rails
         | 
| 140 | 
            +
            - test/rails_app/test/factories/users.rb
         | 
| 141 | 
            +
            - test/rails_app/test/functional/posts_controller_test.rb
         | 
| 142 | 
            +
            - test/rails_app/test/performance/browsing_test.rb
         | 
| 143 | 
            +
            - test/rails_app/test/test_helper.rb
         | 
| 144 | 
            +
            - test/rails_app/test/unit/helpers/posts_helper_test.rb
         | 
| 145 | 
            +
            - test/rails_app/test/unit/post_test.rb
         | 
| 146 | 
            +
            - test/rails_app/test/unit/user_test.rb
         | 
| 147 | 
            +
            - test/test_helper.rb
         | 
| 73 148 | 
             
            has_rdoc: true
         | 
| 74 | 
            -
            homepage: http://github.com/cschiewek/devise_ldap_authenticatable | 
| 149 | 
            +
            homepage: http://github.com/cschiewek/devise_ldap_authenticatable
         | 
| 75 150 | 
             
            licenses: []
         | 
| 76 151 |  | 
| 77 152 | 
             
            post_install_message: 
         | 
| 78 | 
            -
            rdoc_options:  | 
| 79 | 
            -
             | 
| 153 | 
            +
            rdoc_options: 
         | 
| 154 | 
            +
            - --charset=UTF-8
         | 
| 80 155 | 
             
            require_paths: 
         | 
| 81 156 | 
             
            - lib
         | 
| 82 157 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| @@ -84,6 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 84 159 | 
             
              requirements: 
         | 
| 85 160 | 
             
              - - ">="
         | 
| 86 161 | 
             
                - !ruby/object:Gem::Version 
         | 
| 162 | 
            +
                  hash: 3
         | 
| 87 163 | 
             
                  segments: 
         | 
| 88 164 | 
             
                  - 0
         | 
| 89 165 | 
             
                  version: "0"
         | 
| @@ -92,17 +168,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 92 168 | 
             
              requirements: 
         | 
| 93 169 | 
             
              - - ">="
         | 
| 94 170 | 
             
                - !ruby/object:Gem::Version 
         | 
| 171 | 
            +
                  hash: 3
         | 
| 95 172 | 
             
                  segments: 
         | 
| 96 | 
            -
                  -  | 
| 97 | 
            -
                   | 
| 98 | 
            -
                  - 6
         | 
| 99 | 
            -
                  version: 1.3.6
         | 
| 173 | 
            +
                  - 0
         | 
| 174 | 
            +
                  version: "0"
         | 
| 100 175 | 
             
            requirements: []
         | 
| 101 176 |  | 
| 102 | 
            -
            rubyforge_project:  | 
| 177 | 
            +
            rubyforge_project: 
         | 
| 103 178 | 
             
            rubygems_version: 1.3.7
         | 
| 104 179 | 
             
            signing_key: 
         | 
| 105 180 | 
             
            specification_version: 3
         | 
| 106 | 
            -
            summary: LDAP  | 
| 107 | 
            -
            test_files:  | 
| 108 | 
            -
             | 
| 181 | 
            +
            summary: LDAP authentication module for Devise
         | 
| 182 | 
            +
            test_files: 
         | 
| 183 | 
            +
            - test/devise_ldap_authenticatable_test.rb
         | 
| 184 | 
            +
            - test/rails_app/app/controllers/application_controller.rb
         | 
| 185 | 
            +
            - test/rails_app/app/controllers/posts_controller.rb
         | 
| 186 | 
            +
            - test/rails_app/app/helpers/application_helper.rb
         | 
| 187 | 
            +
            - test/rails_app/app/helpers/posts_helper.rb
         | 
| 188 | 
            +
            - test/rails_app/app/models/post.rb
         | 
| 189 | 
            +
            - test/rails_app/app/models/user.rb
         | 
| 190 | 
            +
            - test/rails_app/config/application.rb
         | 
| 191 | 
            +
            - test/rails_app/config/boot.rb
         | 
| 192 | 
            +
            - test/rails_app/config/environment.rb
         | 
| 193 | 
            +
            - test/rails_app/config/environments/development.rb
         | 
| 194 | 
            +
            - test/rails_app/config/environments/production.rb
         | 
| 195 | 
            +
            - test/rails_app/config/environments/test.rb
         | 
| 196 | 
            +
            - test/rails_app/config/initializers/backtrace_silencers.rb
         | 
| 197 | 
            +
            - test/rails_app/config/initializers/devise.rb
         | 
| 198 | 
            +
            - test/rails_app/config/initializers/inflections.rb
         | 
| 199 | 
            +
            - test/rails_app/config/initializers/mime_types.rb
         | 
| 200 | 
            +
            - test/rails_app/config/initializers/secret_token.rb
         | 
| 201 | 
            +
            - test/rails_app/config/initializers/session_store.rb
         | 
| 202 | 
            +
            - test/rails_app/config/routes.rb
         | 
| 203 | 
            +
            - test/rails_app/db/migrate/20100708120302_create_posts.rb
         | 
| 204 | 
            +
            - test/rails_app/db/migrate/20100708120448_devise_create_users.rb
         | 
| 205 | 
            +
            - test/rails_app/db/schema.rb
         | 
| 206 | 
            +
            - test/rails_app/db/seeds.rb
         | 
| 207 | 
            +
            - test/rails_app/features/step_definitions/login_steps.rb
         | 
| 208 | 
            +
            - test/rails_app/features/step_definitions/web_steps.rb
         | 
| 209 | 
            +
            - test/rails_app/features/support/env.rb
         | 
| 210 | 
            +
            - test/rails_app/features/support/paths.rb
         | 
| 211 | 
            +
            - test/rails_app/test/factories/users.rb
         | 
| 212 | 
            +
            - test/rails_app/test/functional/posts_controller_test.rb
         | 
| 213 | 
            +
            - test/rails_app/test/performance/browsing_test.rb
         | 
| 214 | 
            +
            - test/rails_app/test/test_helper.rb
         | 
| 215 | 
            +
            - test/rails_app/test/unit/helpers/posts_helper_test.rb
         | 
| 216 | 
            +
            - test/rails_app/test/unit/post_test.rb
         | 
| 217 | 
            +
            - test/rails_app/test/unit/user_test.rb
         | 
| 218 | 
            +
            - test/test_helper.rb
         |