Project

General

Profile

« Previous | Next » 

Revision 4a2b46e5

Added by Marek Hulán about 9 years ago

Fixes #9957 - rename and fix auth source tests

View differences:

test/unit/auth_source_external.rb
require 'test_helper'
class AuthSourceExternalTest < ActiveSupport::TestCase
test_to_label do
source = AuthSourceExternal.new
assert_equal source.auth_method_name, source.to_label
end
end
test/unit/auth_source_external_test.rb
require 'test_helper'
class AuthSourceExternalTest < ActiveSupport::TestCase
test 'aliases auth_method_name to to_label' do
source = AuthSourceExternal.new
assert_equal source.auth_method_name, source.to_label
end
end
test/unit/auth_source_hidden.rb
require 'test_helper'
class AuthSourceHiddenTest < ActiveSupport::TestCase
test "#authenticate returns nil" do
refute AuthSourceHidden.new.authenticate('unknown user', 'secret')
end
test "#authenticate returns nil for known user" do
u = FactoryGirl.create(:user)
refute AuthSourceHidden.new.authenticate(u.login, 'password')
end
test "cannot change password" do
refute AuthSourceHidden.new.can_set_password?
end
test "#to_label returns HIDDEN" do
assert_equal 'HIDDEN', AuthSourceHidden.new.to_label
end
end
test/unit/auth_source_hidden_test.rb
require 'test_helper'
class AuthSourceHiddenTest < ActiveSupport::TestCase
test "#authenticate returns nil" do
refute AuthSourceHidden.new.authenticate('unknown user', 'secret')
end
test "#authenticate returns nil for known user" do
u = FactoryGirl.create(:user)
refute AuthSourceHidden.new.authenticate(u.login, 'password')
end
test "cannot change password" do
refute AuthSourceHidden.new.can_set_password?
end
test "#to_label returns HIDDEN" do
assert_equal 'HIDDEN', AuthSourceHidden.new.to_label
end
end
test/unit/auth_source_internal.rb
require 'test_helper'
class AuthSourceInternalTest < ActiveSupport::TestCase
test "#authenticate returns nil when username is blank" do
refute AuthSourceInternal.new.authenticate('', 'secret')
end
test "#authenticate returns nil when password is blank" do
refute AuthSourceInternal.new.authenticate('foobar', '')
end
test "#authenticate returns nil for unknown user" do
refute AuthSourceInternal.new.authenticate('unknown user account', 'secret')
end
test "#authenticate returns nil when User#matching_password? fails" do
u = FactoryGirl.create(:user)
User.any_instance.expects(:matching_password?).with('password').returns(false)
refute AuthSourceInternal.new.authenticate(u.login, 'password')
end
test "#authenticate returns true when User#matching_password? succeeds" do
u = FactoryGirl.create(:user)
User.any_instance.expects(:matching_password?).with('password').returns(true)
assert AuthSourceInternal.new.authenticate(u.login, 'password')
end
test "can change password" do
assert AuthSourceInternal.new.can_set_password?
end
test "#to_label returns INTERNAL" do
assert_equal 'INTERNAL', AuthSourceInternal.new.to_label
end
end
test/unit/auth_source_internal_test.rb
require 'test_helper'
class AuthSourceInternalTest < ActiveSupport::TestCase
test "#authenticate returns nil when username is blank" do
refute AuthSourceInternal.new.authenticate('', 'secret')
end
test "#authenticate returns nil when password is blank" do
refute AuthSourceInternal.new.authenticate('foobar', '')
end
test "#authenticate returns nil for unknown user" do
refute AuthSourceInternal.new.authenticate('unknown user account', 'secret')
end
test "#authenticate returns nil when User#matching_password? fails" do
u = FactoryGirl.create(:user)
User.any_instance.expects(:matching_password?).with('password').returns(false)
refute AuthSourceInternal.new.authenticate(u.login, 'password')
end
test "#authenticate returns true when User#matching_password? succeeds" do
u = FactoryGirl.create(:user)
User.any_instance.expects(:matching_password?).with('password').returns(true)
assert AuthSourceInternal.new.authenticate(u.login, 'password')
end
test "can change password" do
assert AuthSourceInternal.new.can_set_password?
end
test "#to_label returns INTERNAL" do
assert_equal 'INTERNAL', AuthSourceInternal.new.to_label
end
end

Also available in: Unified diff