test/test_user.rb in authlogic-connect-0.0.5.1 vs test/test_user.rb in authlogic-connect-0.0.6

- old
+ new

@@ -4,11 +4,11 @@ class UserTest < Test::Unit::TestCase context "User creation" do setup do @user = User.new(:login => "viatropos") end - + should "make sure we are loading the models" do assert_equal "viatropos", @user.login end context "responds to added oauth methods (our oauth api on the user)" do @@ -42,162 +42,44 @@ should "have an empty 'auth_session'" do assert @user.auth_session.empty? assert_equal false, @user.auth_session? end + + end + + context "save the user without any parameters" do - context "save the user without any parameters" do - - setup do - @save_success = @user.save - end - - should "be a valid save" do - assert @save_success - end - - should "not be using oauth" do - assert_equal false, @user.using_oauth? - end - - should "not be using openid" do - assert_equal false, @user.using_openid? - end - + setup do + @save_success = @user.save end - context "with oauth parameters" do - - setup do - @user.auth_controller.params.merge!(:oauth_provider => "twitter") - # mock token - @token = OAuth::RequestToken.new("twitter", "key", "secret") - @token.params = { - :oauth_callback_confirmed => "true", - :oauth_token_secret=>"secret", - :oauth_token=>"key" - } - @token.consumer = OAuth::Consumer.new("key", "secret", - :site=>"http://twitter.com", - :proxy=>nil, - :oauth_version=>"1.0", - :request_token_path=>"/oauth/request_token", - :authorize_path=>"/oauth/authorize", - :scheme=>:header, - :signature_method=>"HMAC-SHA1", - :authorize_url=>"http://twitter.com/oauth/authenticate", - :access_token_path=>"/oauth/access_token" - ) - @session_vars = [ - :authentication_type, - :auth_request_class, - :oauth_provider, - :auth_callback_method - ] - end - - should "have an 'oauth_provider'" do - assert @user.oauth_provider? - end - - should "be an 'oauth_request'" do - assert @user.oauth_request? - end - - should "not be an 'oauth_response'" do - assert_equal false, @user.oauth_response? - end - - should "be using oauth" do - assert @user.using_oauth? - end - - should "not be using openid" do - assert_equal false, @user.using_openid? - end - - should "have the correct class (authentication_type == user)" do - assert @user.correct_request_class? - end - - should "realize we are authenticating_with_oauth?" do - assert @user.authenticating_with_oauth? - end - + should "be a valid save" do + assert @save_success end - context "with openid parameters" do - setup do - @user.auth_controller.params.merge!(:openid_identifier => "viatropos.myopenid.com") - @session_vars = [ - :authentication_type, - :auth_request_class, - :openid_identifier, - :auth_callback_method - ] - end - - should "have an 'openid_identifier'" do - assert_equal true, @user.openid_identifier? - end - - should "be an 'openid_request'" do - assert @user.openid_request? - end - - should "not be an 'openid_response'" do - assert_equal false, @user.openid_response? - end - - should "be using openid" do - assert @user.using_openid? - end - - should "not be using oauth" do - assert_equal false, @user.using_oauth? - end - - should "have the correct class (authentication_type == user)" do - assert @user.correct_request_class? - end - - should "realize we are authenticating_with_openid?" do - assert @user.authenticating_with_openid? - end - - context "and 'save_with_openid', manually checking each step" do - - setup do - # mock save - # this, and the whole redirect process happens - # but we'll just assume we saved the session data and got the redirect back - @user.save_openid_session - @user.save(:skip_redirect => true, :keep_session => true) do - "I'm the block you want" - end - # copy to test controller - @user.auth_session.each do |key, value| - @user.auth_controller.session[key] = value - end - end - - teardown do - @user.destroy - end - - end + should "not be using oauth" do + assert_equal false, @user.using_oauth? + # using_oauth? == (oauth_request? || oauth_response? || stored_oauth_token_and_secret?) + assert_equal false, @user.oauth_request? + # oauth_request? == (auth_params? && oauth_provider?) + assert_equal false, @user.auth_params? + assert_equal false, @user.oauth_provider? + assert_equal false, @user.oauth_response? + # oauth_response? == (!oauth_response.nil? && auth_session? && auth_session[:auth_request_class] == self.class.name && auth_session[:auth_method] == "oauth") + assert_equal false, !@user.oauth_response.nil? + assert_equal false, @user.auth_session? + assert_equal false, @user.stored_oauth_token_and_secret? end - + + should "not be using openid" do + assert_equal false, @user.using_openid? + end + end - end - - context "tokens" do - setup do - @token = TwitterToken.new - end - should "be version 1 since it's twitter" do - assert_equal 1.0, @token.oauth_version + context "user with required password field" do + end end end end