summaryrefslogtreecommitdiff
path: root/users/test/functional
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-10-11 11:30:02 +0200
committerAzul <azul@leap.se>2012-10-11 11:30:02 +0200
commit9416bd9b8829f57fa54d50e8b3f53f614a1b29b5 (patch)
tree9f395d93a56fd2d319f9a9f8033b4dd599869d5a /users/test/functional
parent3b4703b6669bb712fd078080d6f3b83af089b19e (diff)
adjusted sessions controller test to new srp api
handshake.to_json now returns what we want.
Diffstat (limited to 'users/test/functional')
-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