def setup
User.current = nil
+ Setting.openid = '1'
+ end
+
+ def teardown
+ Setting.openid = '0'
end
if Object.const_defined?(:OpenID)
def test_login_with_openid_for_existing_user
Setting.self_registration = '3'
- Setting.openid = '1'
existing_user = User.new(:firstname => 'Cool',
:lastname => 'User',
:mail => 'user@somedomain.com',
def test_login_with_invalid_openid_provider
Setting.self_registration = '0'
- Setting.openid = '1'
post :login, :openid_url => 'http;//openid.example.com/good_user'
assert_redirected_to home_url
end
def test_login_with_openid_for_existing_non_active_user
Setting.self_registration = '2'
- Setting.openid = '1'
existing_user = User.new(:firstname => 'Cool',
:lastname => 'User',
:mail => 'user@somedomain.com',
def test_login_with_openid_with_new_user_created
Setting.self_registration = '3'
- Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to '/my/account'
user = User.find_by_login('cool_user')
def test_login_with_openid_with_new_user_and_self_registration_off
Setting.self_registration = '0'
- Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to home_url
user = User.find_by_login('cool_user')
def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token
Setting.self_registration = '1'
- Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to '/login'
user = User.find_by_login('cool_user')
def test_login_with_openid_with_new_user_created_with_manual_activation
Setting.self_registration = '2'
- Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to '/login'
user = User.find_by_login('cool_user')
def test_login_with_openid_with_new_user_with_conflict_should_register
Setting.self_registration = '3'
- Setting.openid = '1'
existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => 'user@somedomain.com')
existing_user.login = 'cool_user'
assert existing_user.save!
end
def test_setting_openid_should_return_true_when_set_to_true
- Setting.openid = '1'
assert_equal true, Setting.openid?
end