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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import pytest
from fxa.errors import ClientError
from api import *
def test_session_loggedout(client):
with pytest.raises(ClientError) as e:
client.post("/session/destroy")
assert e.value.details == {
'code': 401,
'errno': 109,
'error': 'Unauthorized',
'message': 'invalid request signature'
}
class TestSession:
def test_status(self, account):
resp = account.get_a("/session/status")
assert resp == { 'state': '', 'uid': account.props['uid'] }
def test_resend(self, account, mail_server):
c = account.login(account.email, "")
(to, body) = mail_server.wait()
assert to == [account.email]
c.post_a("/session/resend_code", {})
(to2, body2) = mail_server.wait()
assert to == to2
assert body == body2
@pytest.mark.parametrize("args", [
{ 'custom_session_id': '00' },
{ 'extra': '00' },
])
def test_session_invalid(self, account, args):
with pytest.raises(ClientError) as e:
account.post_a("/session/destroy", args)
assert e.value.details == {
'code': 400,
'errno': 107,
'error': 'Bad Request',
'message': 'invalid parameter in request body'
}
def test_session_noid(self, account):
with pytest.raises(ClientError) as e:
account.post_a("/session/destroy", { 'custom_session_id': '0' * 64 })
assert e.value.details == {
'code': 400,
'errno': 123,
'error': 'Bad Request',
'message': 'unknown device'
}
def test_session_destroy_other(self, account, account2):
with pytest.raises(ClientError) as e:
account.post_a("/session/destroy", { 'custom_session_id': account2.auth.id })
assert e.value.details == {
'code': 400,
'errno': 123,
'error': 'Bad Request',
'message': 'unknown device'
}
def test_session_destroy_unverified(unverified_account):
unverified_account.destroy_session()
unverified_account.destroy_session = lambda *args: None
def test_session_destroy(account):
s = account.login(account.email, "")
s.destroy_session()
|