Sha256: 53b9fa5603e9308e76a703023b38f5dae73650a470d57be9551efbbc393f9463

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
  
  def reset_ldap_server!
    if ENV["LDAP_SSL"]
      `ldapmodify -x -H ldaps://localhost:3389 -D "cn=admin,dc=test,dc=com" -w secret -f ../ldap/clear.ldif`
      `ldapadd -x -H ldaps://localhost:3389 -D "cn=admin,dc=test,dc=com" -w secret -f ../ldap/base.ldif`
    else
      `ldapmodify -x -h localhost -p 3389 -D "cn=admin,dc=test,dc=com" -w secret -f ../ldap/clear.ldif`
      `ldapadd -x -h localhost -p 3389 -D "cn=admin,dc=test,dc=com" -w secret -f ../ldap/base.ldif`
    end
  end
  
  def default_devise_settings!
    ::Devise.ldap_logger = true
    ::Devise.ldap_create_user = false
    ::Devise.ldap_update_password = true
    ::Devise.ldap_config = "#{Rails.root}/config/#{"ssl_" if ENV["LDAP_SSL"]}ldap.yml"
    ::Devise.ldap_check_group_membership = false
    ::Devise.ldap_check_attributes = false
    ::Devise.ldap_auth_username_builder = Proc.new() {|attribute, login, ldap| "#{attribute}=#{login},#{ldap.base}" }
    ::Devise.authentication_keys = [:email]
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_ldap_authenticatable-0.4.5 test/rails_app/test/test_helper.rb
devise_ldap_authenticatable-0.4.4 test/rails_app/test/test_helper.rb