From 9416bd9b8829f57fa54d50e8b3f53f614a1b29b5 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 11 Oct 2012 11:30:02 +0200 Subject: adjusted sessions controller test to new srp api handshake.to_json now returns what we want. --- users/test/functional/sessions_controller_test.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'users/test/functional/sessions_controller_test.rb') diff --git a/users/test/functional/sessions_controller_test.rb b/users/test/functional/sessions_controller_test.rb index 7876d84..b6e56a7 100644 --- a/users/test/functional/sessions_controller_test.rb +++ b/users/test/functional/sessions_controller_test.rb @@ -8,7 +8,9 @@ class SessionsControllerTest < ActionController::TestCase @server_hex = 'b123' @server_rnd = @server_hex.hex @server_rnd_exp = 'e123'.hex + @salt = 'stub user salt' @server_handshake = stub :aa => @client_rnd, :bb => @server_rnd, :b => @server_rnd_exp + @server_auth = 'adfe' end test "should get login screen" do @@ -21,11 +23,13 @@ class SessionsControllerTest < ActionController::TestCase user.expects(:initialize_auth). with(@client_rnd). returns(@server_handshake) + @server_handshake.expects(:to_json). + returns({'B' => @server_hex, 'salt' => @salt}.to_json) User.expects(:find_by_param).with(user.login).returns(user) post :create, :login => user.login, 'A' => @client_hex assert_equal @server_handshake, session[:handshake] assert_response :success - assert_json_response :B => @server_hex + assert_json_response :B => @server_hex, :salt => @salt end test "should report user not found" do @@ -39,9 +43,11 @@ class SessionsControllerTest < ActionController::TestCase test "should authorize" do session[:handshake] = @server_handshake user = stub :login => "me", :id => 123 - user.expects(:authenticate!). - with(@client_rnd, @server_handshake). + @server_handshake.expects(:authenticate!). + with(@client_rnd). returns(@server_auth) + @server_handshake.expects(:to_json). + returns({:M2 => @server_auth}.to_json) User.expects(:find_by_param).with(user.login).returns(user) post :update, :id => user.login, :client_auth => @client_hex assert_nil session[:handshake] @@ -52,8 +58,8 @@ class SessionsControllerTest < ActionController::TestCase test "should report wrong password" do session[:handshake] = @server_handshake user = stub :login => "me", :id => 123 - user.expects(:authenticate!). - with(@client_rnd, @server_handshake). + @server_handshake.expects(:authenticate!). + with(@client_rnd). raises(WRONG_PASSWORD) User.expects(:find_by_param).with(user.login).returns(user) post :update, :id => user.login, :client_auth => @client_hex -- cgit v1.2.3