mirror of
https://github.com/redmine/redmine.git
synced 2025-11-01 19:05:51 +01:00
Removing shoulda context.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11315 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -58,61 +58,48 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
if ldap_configured?
|
||||
context '#authenticate' do
|
||||
setup do
|
||||
@auth = AuthSourceLdap.find(1)
|
||||
@auth.update_attribute :onthefly_register, true
|
||||
end
|
||||
test '#authenticate with a valid LDAP user should return the user attributes' do
|
||||
auth = AuthSourceLdap.find(1)
|
||||
auth.update_attribute :onthefly_register, true
|
||||
|
||||
context 'with a valid LDAP user' do
|
||||
should 'return the user attributes' do
|
||||
attributes = @auth.authenticate('example1','123456')
|
||||
assert attributes.is_a?(Hash), "An hash was not returned"
|
||||
assert_equal 'Example', attributes[:firstname]
|
||||
assert_equal 'One', attributes[:lastname]
|
||||
assert_equal 'example1@redmine.org', attributes[:mail]
|
||||
assert_equal @auth.id, attributes[:auth_source_id]
|
||||
attributes.keys.each do |attribute|
|
||||
assert User.new.respond_to?("#{attribute}="), "Unexpected :#{attribute} attribute returned"
|
||||
end
|
||||
end
|
||||
attributes = auth.authenticate('example1','123456')
|
||||
assert attributes.is_a?(Hash), "An hash was not returned"
|
||||
assert_equal 'Example', attributes[:firstname]
|
||||
assert_equal 'One', attributes[:lastname]
|
||||
assert_equal 'example1@redmine.org', attributes[:mail]
|
||||
assert_equal auth.id, attributes[:auth_source_id]
|
||||
attributes.keys.each do |attribute|
|
||||
assert User.new.respond_to?("#{attribute}="), "Unexpected :#{attribute} attribute returned"
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an invalid LDAP user' do
|
||||
should 'return nil' do
|
||||
assert_equal nil, @auth.authenticate('nouser','123456')
|
||||
end
|
||||
end
|
||||
test '#authenticate with an invalid LDAP user should return nil' do
|
||||
auth = AuthSourceLdap.find(1)
|
||||
assert_equal nil, auth.authenticate('nouser','123456')
|
||||
end
|
||||
|
||||
context 'without a login' do
|
||||
should 'return nil' do
|
||||
assert_equal nil, @auth.authenticate('','123456')
|
||||
end
|
||||
end
|
||||
test '#authenticate without a login should return nil' do
|
||||
auth = AuthSourceLdap.find(1)
|
||||
assert_equal nil, auth.authenticate('','123456')
|
||||
end
|
||||
|
||||
context 'without a password' do
|
||||
should 'return nil' do
|
||||
assert_equal nil, @auth.authenticate('edavis','')
|
||||
end
|
||||
end
|
||||
test '#authenticate without a password should return nil' do
|
||||
auth = AuthSourceLdap.find(1)
|
||||
assert_equal nil, auth.authenticate('edavis','')
|
||||
end
|
||||
|
||||
context 'without filter' do
|
||||
should 'return any user' do
|
||||
assert @auth.authenticate('example1','123456')
|
||||
assert @auth.authenticate('edavis', '123456')
|
||||
end
|
||||
end
|
||||
test '#authenticate without filter should return any user' do
|
||||
auth = AuthSourceLdap.find(1)
|
||||
assert auth.authenticate('example1','123456')
|
||||
assert auth.authenticate('edavis', '123456')
|
||||
end
|
||||
|
||||
context 'with filter' do
|
||||
setup do
|
||||
@auth.filter = "(mail=*@redmine.org)"
|
||||
end
|
||||
test '#authenticate with filter should return user who matches the filter only' do
|
||||
auth = AuthSourceLdap.find(1)
|
||||
auth.filter = "(mail=*@redmine.org)"
|
||||
|
||||
should 'return user who matches the filter only' do
|
||||
assert @auth.authenticate('example1','123456')
|
||||
assert_nil @auth.authenticate('edavis', '123456')
|
||||
end
|
||||
end
|
||||
assert auth.authenticate('example1','123456')
|
||||
assert_nil auth.authenticate('edavis', '123456')
|
||||
end
|
||||
|
||||
def test_authenticate_should_timeout
|
||||
|
||||
Reference in New Issue
Block a user