Skip to content

Commit d3bf850

Browse files
test(auth): cases for verify_id_token
1 parent d896ab3 commit d3bf850

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/test_auth.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ def test_set_custom_user_claims(self, auth):
8383

8484
assert "'NoneType' object has no attribute 'valid'" in str(exc_info.value)
8585

86+
def test_verify_id_token(self, auth):
87+
with pytest.raises(KeyError) as exc_info:
88+
auth.verify_id_token(self.__class__.user.get('idToken'))['premium'] is True
89+
assert "'premium'" in str(exc_info.value)
90+
91+
with pytest.raises(KeyError) as exc_info:
92+
auth.verify_id_token(self.__class__.anonymous_user.get('idToken'))['premium'] is True
93+
assert "'premium'" in str(exc_info.value)
94+
8695
def test_delete_user_account(self, auth):
8796
assert auth.delete_user_account(self.__class__.user.get('idToken'))
8897
assert auth.delete_user_account(self.__class__.anonymous_user.get('idToken'))
@@ -145,9 +154,6 @@ def test_sign_in_with_custom_token(self, auth_admin):
145154
assert user1
146155
assert user2
147156

148-
def test_refresh(self, auth_admin):
149-
assert auth_admin.refresh(self.__class__.user.get('refreshToken'))
150-
151157
def test_get_account_info(self, auth_admin):
152158
assert auth_admin.get_account_info(self.__class__.user.get('idToken'))
153159

@@ -171,6 +177,20 @@ def test_set_custom_user_claims(self, auth_admin):
171177
auth_admin.set_custom_user_claims(self.__class__.user.get('localId'), {'premium': True})
172178
auth_admin.set_custom_user_claims(self.__class__.anonymous_user.get('localId'), {'premium': True})
173179

180+
def test_refresh(self, auth_admin):
181+
self.__class__.user = auth_admin.refresh(self.__class__.user.get('refreshToken'))
182+
self.__class__.custom_user = auth_admin.refresh(self.__class__.custom_user.get('refreshToken'))
183+
self.__class__.anonymous_user = auth_admin.refresh(self.__class__.anonymous_user.get('refreshToken'))
184+
185+
def test_verify_id_token(self, auth_admin):
186+
assert auth_admin.verify_id_token(self.__class__.user.get('idToken'))['premium'] is True
187+
assert auth_admin.verify_id_token(self.__class__.anonymous_user.get('idToken'))['premium'] is True
188+
assert auth_admin.verify_id_token(self.__class__.custom_user_with_claims.get('idToken'))['premium'] is True
189+
190+
with pytest.raises(KeyError) as exc_info:
191+
auth_admin.verify_id_token(self.__class__.custom_user.get('idToken'))['premium'] is True
192+
assert "'premium'" in str(exc_info.value)
193+
174194
def test_delete_user_account(self, auth_admin):
175195
assert auth_admin.delete_user_account(self.__class__.user.get('idToken'))
176196
assert auth_admin.delete_user_account(self.__class__.anonymous_user.get('idToken'))

0 commit comments

Comments
 (0)