Created
December 28, 2008 05:14
-
-
Save emk/40381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
class << self | |
def authenticate_for_with_ldap(site, login, password) | |
user = authenticate_for_without_ldap(site, login, password) | |
if user.nil? | |
# Look in LDAP for login, create a local user, and return it. | |
end | |
user | |
end | |
alias_method_chain :authenticate_for, :ldap | |
end | |
end | |
class UserLdapTest << ActiveSupport::TestCase | |
test "should use LDAP data to create missing local users" do | |
assert_nil User.find_by_login('sam') | |
# Mock LDAP interface to return user 'sam' with password 'foo'. | |
assert_difference 'User.count', 1 do | |
User.authenticate_for sites(:first), 'sam', 'foo' | |
end | |
@sam = User.find_by_login('sam') | |
# Make sure sam has the expected properties. | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment