blob: 97e0ff6ad3374ab0a2fb09d46483d27bd16a9491 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
require 'test_helper'
require_relative 'srp_test'
class LoginTest < SrpTest
setup do
register_user
end
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_nil server_auth["error"]
assert_equal ["M2", "id", "token"], server_auth.keys
assert last_response.successful?
assert server_auth["M2"]
end
test "wrong password login attempt" do
authenticate password: "wrong password"
assert_json_error "base" => I18n.t(:invalid_user_pass)
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" => I18n.t(:invalid_user_pass)
assert !last_response.successful?
assert_nil server_auth
end
test "logout" do
authenticate
logout
assert_equal 204, last_response.status
end
test "logout requires token" do
authenticate
logout(nil, {})
assert_login_required
end
end
|