##// END OF EJS Templates
Added tests for the other OpenID authentication cases. #699...
Eric Davis -
r2384:876fb69271ed
parent child
Show More
@@ -201,9 +201,9 private
201 201 user = User.find_or_initialize_by_identity_url(identity_url)
202 202 if user.new_record?
203 203 # Create on the fly
204 user.login = registration['nickname']
205 user.mail = registration['email']
206 user.firstname, user.lastname = registration['fullname'].split(' ')
204 user.login = registration['nickname'] unless registration['nickname'].nil?
205 user.mail = registration['email'] unless registration['email'].nil?
206 user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
207 207 user.random_password
208 208 if user.save
209 209 successful_authentication(user)
@@ -70,12 +70,24 class AccountControllerTest < Test::Unit::TestCase
70 70 end
71 71
72 72 def test_login_with_openid_with_new_user_created
73
73 post :login, :openid_url => 'http://openid.example.com/good_user'
74 assert_redirected_to 'my/page'
75 user = User.find_by_login('cool_user')
76 assert user
77 assert_equal 'Cool', user.firstname
78 assert_equal 'User', user.lastname
74 79 end
75 80
76
77 def test_login_with_openid_with_new_user_with_conflict
81 def test_login_with_openid_with_new_user_with_conflict_should_register
82 existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => 'user@somedomain.com')
83 existing_user.login = 'cool_user'
84 assert existing_user.save!
78 85
86 post :login, :openid_url => 'http://openid.example.com/good_user'
87 assert_response :success
88 assert_template 'register'
89 assert assigns(:user)
90 assert_equal 'http://openid.example.com/good_user', assigns(:user)[:identity_url]
79 91 end
80 92
81 93 def test_autologin
@@ -19,7 +19,7 ENV["RAILS_ENV"] ||= "test"
19 19 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
20 20 require 'test_help'
21 21 require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
22 load File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
22 require File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
23 23
24 24 class Test::Unit::TestCase
25 25 # Transactional fixtures accelerate your tests by wrapping each test method
General Comments 0
You need to be logged in to leave comments. Login now