summaryrefslogtreecommitdiff
path: root/users/test/functional/sessions_controller_test.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-10-11 12:44:07 +0200
committerAzul <azul@leap.se>2012-10-11 12:44:07 +0200
commita86de8ca44d30d48db1cf05520f54a8cf48b645d (patch)
treef8ca191b7df29468f6750fd73ede973120c229a0 /users/test/functional/sessions_controller_test.rb
parentbd17dee3ae5650e8ff1c7700fa0e83adf386b91b (diff)
parent689c2831680ece3ec8e1cceb45933f9b501b5734 (diff)
Merge branch 'fixing_tests' into release-0.1.0
Diffstat (limited to 'users/test/functional/sessions_controller_test.rb')
-rw-r--r--users/test/functional/sessions_controller_test.rb16
1 files changed, 11 insertions, 5 deletions
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