summaryrefslogtreecommitdiff
path: root/users/test/functional
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2012-10-17 10:12:11 -0700
committerjessib <jessib@riseup.net>2012-10-17 10:12:11 -0700
commitc072a2fe1d50715bad1cd8c14213cba6aa1cc8ff (patch)
tree14a599dadbe440952c0de73c487113bc09aa9142 /users/test/functional
parent171d07a64d3f76e68c22f0fb4cc3795daad806d1 (diff)
parentd9a510fa2126c29f0af58c6bbeff35802777eee6 (diff)
Merge branch 'develop' into help_develop
Diffstat (limited to 'users/test/functional')
-rw-r--r--users/test/functional/sessions_controller_test.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/users/test/functional/sessions_controller_test.rb b/users/test/functional/sessions_controller_test.rb
index b6e56a7..47d7052 100644
--- a/users/test/functional/sessions_controller_test.rb
+++ b/users/test/functional/sessions_controller_test.rb
@@ -3,6 +3,7 @@ require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
def setup
+ @user = stub :login => "me", :id => 123
@client_hex = 'a123'
@client_rnd = @client_hex.hex
@server_hex = 'b123'
@@ -19,14 +20,13 @@ class SessionsControllerTest < ActionController::TestCase
end
test "should perform handshake" do
- user = stub :login => "me", :id => 123
- user.expects(:initialize_auth).
+ @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
+ 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, :salt => @salt
@@ -42,27 +42,23 @@ class SessionsControllerTest < ActionController::TestCase
test "should authorize" do
session[:handshake] = @server_handshake
- user = stub :login => "me", :id => 123
@server_handshake.expects(:authenticate!).
with(@client_rnd).
- returns(@server_auth)
+ returns(@user)
@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
+ post :update, :id => @user.login, :client_auth => @client_hex
assert_nil session[:handshake]
assert_json_response :M2 => @server_auth
- assert_equal user.id, session[:user_id]
+ assert_equal @user.id, session[:user_id]
end
test "should report wrong password" do
session[:handshake] = @server_handshake
- user = stub :login => "me", :id => 123
@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
+ post :update, :id => @user.login, :client_auth => @client_hex
assert_nil session[:handshake]
assert_nil session[:user_id]
assert_json_response :errors => {"password" => ["wrong password"]}