diff options
Diffstat (limited to 'tests/test_auth_email.py')
-rw-r--r-- | tests/test_auth_email.py | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/tests/test_auth_email.py b/tests/test_auth_email.py index 319f2d4..b7fa65a 100644 --- a/tests/test_auth_email.py +++ b/tests/test_auth_email.py @@ -3,58 +3,60 @@ from fxa.errors import ClientError from api import * -def test_status_noauth(client, refresh_token): - with pytest.raises(ClientError) as e: - client.post_a("/recovery_email/status") - assert e.value.details == { - 'code': 401, - 'errno': 109, - 'error': 'Unauthorized', - 'message': 'invalid request signature' - } - with pytest.raises(ClientError) as e: - refresh_token.post_a("/recovery_email/status") - assert e.value.details == { - 'code': 401, - 'errno': 109, - 'error': 'Unauthorized', - 'message': 'invalid request signature' - } +class TestUnverified: + def test_status_unverified(self, unverified_account): + resp = unverified_account.get_a("/recovery_email/status") + assert resp == { + 'email': unverified_account.email, + 'emailVerified': False, + 'sessionVerified': False, + 'verified': False + } -def test_status_unverified(unverified_account): - resp = unverified_account.get_a("/recovery_email/status") - assert resp == { - 'email': unverified_account.email, - 'emailVerified': False, - 'sessionVerified': False, - 'verified': False - } + @pytest.mark.parametrize("args,code,errno,error,message", [ + ({ 'uid': '00', 'code': "" }, + 400, 107, 'Bad Request', 'invalid parameter in request body'), + ({ 'id': '00' * 16, 'code': 0 }, + 400, 107, 'Bad Request', 'invalid parameter in request body'), + ({ 'id': '00' * 16, 'code': "", 'extra': 0 }, + 400, 107, 'Bad Request', 'invalid parameter in request body'), + ]) + def test_verify_code_invalid(self, unverified_account, args, code, errno, error, message): + with pytest.raises(ClientError) as e: + unverified_account.post_a("/recovery_email/verify_code", args) + assert e.value.details == {'code': code, 'errno': errno, 'error': error, 'message': message} -def test_status_verified(account): - resp = account.get_a("/recovery_email/status") - assert resp == { - 'email': account.email, - 'emailVerified': True, - 'sessionVerified': True, - 'verified': True - } +class TestVerified: + def test_status_noauth(self, client, refresh_token): + with pytest.raises(ClientError) as e: + client.post_a("/recovery_email/status") + assert e.value.details == { + 'code': 401, + 'errno': 109, + 'error': 'Unauthorized', + 'message': 'invalid request signature' + } + with pytest.raises(ClientError) as e: + refresh_token.post_a("/recovery_email/status") + assert e.value.details == { + 'code': 401, + 'errno': 109, + 'error': 'Unauthorized', + 'message': 'invalid request signature' + } -@pytest.mark.parametrize("args,code,errno,error,message", [ - ({ 'uid': '00', 'code': "" }, - 400, 107, 'Bad Request', 'invalid parameter in request body'), - ({ 'id': '00' * 16, 'code': 0 }, - 400, 107, 'Bad Request', 'invalid parameter in request body'), - ({ 'id': '00' * 16, 'code': "", 'extra': 0 }, - 400, 107, 'Bad Request', 'invalid parameter in request body'), -]) -def test_verify_code_invalid(unverified_account, args, code, errno, error, message): - with pytest.raises(ClientError) as e: - unverified_account.post_a("/recovery_email/verify_code", args) - assert e.value.details == {'code': code, 'errno': errno, 'error': error, 'message': message} + def test_status_verified(self, account): + resp = account.get_a("/recovery_email/status") + assert resp == { + 'email': account.email, + 'emailVerified': True, + 'sessionVerified': True, + 'verified': True + } -def test_verify_code(account): - # fixture does all the work - pass + def test_verify_code(self, account): + # fixture does all the work + pass def test_verify_code_reuse(client, mail_server): s = client.create_account("test@test", "") |