Skip to content
Snippets Groups Projects
Commit f1d16bc0 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang
Browse files

Test that AuthSourceLdap#authenticate returns valid User attributes only.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3491 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 899f0661
Branches
Tags
No related merge requests found
...@@ -42,25 +42,18 @@ class AuthSourceLdapTest < ActiveSupport::TestCase ...@@ -42,25 +42,18 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
end end
context 'with a valid LDAP user' do context 'with a valid LDAP user' do
should 'return the firstname user attributes' do should 'return the user attributes' do
response = @auth.authenticate('example1','123456') response = @auth.authenticate('example1','123456')
assert response.is_a?(Array), "An array was not returned" assert response.is_a?(Array), "An array was not returned"
assert response.first.present?, "No user data returned" assert response.first.present?, "No user data returned"
assert_equal 'Example', response.first[:firstname] attributes = response.first
end assert_equal 'Example', attributes[:firstname]
assert_equal 'One', attributes[:lastname]
should 'return the lastname user attributes' do assert_equal 'example1@redmine.org', attributes[:mail]
response = @auth.authenticate('example1','123456') assert_equal @auth.id, attributes[:auth_source_id]
assert response.is_a?(Array), "An array was not returned" attributes.keys.each do |attribute|
assert response.first.present?, "No user data returned" assert User.new.respond_to?("#{attribute}="), "Unexpected :#{attribute} attribute returned"
assert_equal 'One', response.first[:lastname] end
end
should 'return mail user attributes' do
response = @auth.authenticate('example1','123456')
assert response.is_a?(Array), "An array was not returned"
assert response.first.present?, "No user data returned"
assert_equal 'example1@redmine.org', response.first[:mail]
end end
end end
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment