summaryrefslogtreecommitdiff
path: root/users/test/functional
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2012-10-11 09:47:12 -0700
committerjessib <jessib@riseup.net>2012-10-11 09:47:12 -0700
commit336d5f786bbd1aaf1847007db64e55f96e585b9d (patch)
tree0a18244ba8d21ed821c52edb2d44544b5358aa26 /users/test/functional
parentcf9ed38ab1840092352efdbb71bfeb5bc3b9f9d5 (diff)
parent09003d3d2df7c250d3a0b55e83094e5e27094859 (diff)
Merge branch 'develop' into help_develop
Conflicts: .gitignore
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