diff options
author | Azul <azul@leap.se> | 2014-02-08 12:29:08 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-02-10 14:26:30 +0100 |
commit | 758b9a3c30a73fd985943fb7a887f0373be3a833 (patch) | |
tree | 935bf639bb17ea034d7864205d087f6cd3497175 /users/test/integration/api/login_test.rb | |
parent | 67f17e65b9e9e8ad2991b9c4002dba5203baa77f (diff) |
split up and expand account integration test
Diffstat (limited to 'users/test/integration/api/login_test.rb')
-rw-r--r-- | users/test/integration/api/login_test.rb | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/users/test/integration/api/login_test.rb b/users/test/integration/api/login_test.rb index a760d38..82219d0 100644 --- a/users/test/integration/api/login_test.rb +++ b/users/test/integration/api/login_test.rb @@ -1,15 +1,43 @@ require 'test_helper' +require_relative 'srp_test' -class LoginTest < RackTest +class LoginTest < SrpTest setup do - @login = "integration_test_user" + register_user end - test "require json requests" do - put "http://api.lvh.me:3000/1/sessions/" + @login, - :client_auth => "This is not a valid login anyway" + test "requires handshake before validation" do + validate("bla") assert_json_error login: I18n.t(:all_strategies_failed) end + test "login with srp" do + authenticate + assert last_response.successful? + assert_nil server_auth["errors"] + assert server_auth["M2"] + end + + test "wrong password login attempt" do + authenticate password: "wrong password" + assert_json_error "base" => "Not a valid username/password combination" + assert !last_response.successful? + assert_nil server_auth["M2"] + end + + test "wrong username login attempt" do + assert_raises RECORD_NOT_FOUND do + authenticate login: "wrong login" + end + assert_json_error "base" => "Not a valid username/password combination" + assert !last_response.successful? + assert_nil server_auth + end + + test "logout" do + authenticate + logout + assert_equal 204, last_response.status + end end |