@@ -160,29 +160,6 @@ def test_session_cookies(api_key):
160
160
estimated_exp = int (time .time () + expires_in .total_seconds ())
161
161
assert abs (claims ['exp' ] - estimated_exp ) < 5
162
162
163
- def test_session_cookies_with_tolerance (api_key ):
164
- dev_claims = {'premium' : True , 'subscription' : 'silver' }
165
- custom_token = auth .create_custom_token ('user3' , dev_claims )
166
- id_token = _sign_in (custom_token , api_key )
167
- expires_in = datetime .timedelta (seconds = 3 )
168
- session_cookie = auth .create_session_cookie (id_token , expires_in = expires_in )
169
- time .sleep (4 )
170
- # expect this to fail because the cookie is expired
171
- with pytest .raises (auth .ExpiredSessionCookieError ):
172
- auth .verify_session_cookie (session_cookie )
173
-
174
- # expect this to succeed because we're within the tolerance
175
- claims = auth .verify_session_cookie (session_cookie , check_revoked = False , clock_skew_seconds = 2 )
176
- assert claims ['uid' ] == 'user3'
177
- assert claims ['premium' ] is True
178
- assert claims ['subscription' ] == 'silver'
179
- assert claims ['iss' ].startswith ('https://session.firebase.google.com' )
180
-
181
- with pytest .raises (ValueError ):
182
- auth .verify_session_cookie (session_cookie , clock_skew_seconds = - 1 )
183
- with pytest .raises (ValueError ):
184
- auth .verify_session_cookie (session_cookie , clock_skew_seconds = 61 )
185
-
186
163
def test_session_cookie_error ():
187
164
expires_in = datetime .timedelta (days = 1 )
188
165
with pytest .raises (auth .InvalidIdTokenError ):
@@ -640,43 +617,6 @@ def test_verify_session_cookie_revoked(new_user, api_key):
640
617
claims = auth .verify_session_cookie (session_cookie , check_revoked = True )
641
618
assert claims ['iat' ] * 1000 >= user .tokens_valid_after_timestamp
642
619
643
- def test_verify_session_cookie_tolerance (new_user , api_key ):
644
- expired_session_cookie = auth .create_session_cookie (
645
- _sign_in (auth .create_custom_token (new_user .uid ), api_key ),
646
- expires_in = datetime .timedelta (seconds = 3 )
647
- )
648
- time .sleep (3 )
649
- # Verify the session cookie with a tolerance of 0 seconds. This should
650
- # raise an exception because the cookie is expired.
651
- with pytest .raises (auth .ExpiredSessionCookieError ) as excinfo :
652
- auth .verify_session_cookie (expired_session_cookie , check_revoked = False ,
653
- clock_skew_seconds = 0 )
654
- assert str (excinfo .value ) == 'The Firebase session cookie is expired.'
655
-
656
- # Verify the session cookie with a tolerance of 2 seconds. This should
657
- # not raise an exception because the cookie is within the tolerance.
658
- auth .verify_session_cookie (expired_session_cookie , check_revoked = False , clock_skew_seconds = 2 )
659
-
660
- def test_verify_session_cookie_clock_skew_seconds_range (new_user , api_key ):
661
- expired_session_cookie = auth .create_session_cookie (
662
- _sign_in (auth .create_custom_token (new_user .uid ), api_key ),
663
- expires_in = datetime .timedelta (seconds = 3 )
664
- )
665
- # Verify the session cookie with a tolerance of 0 seconds. This should
666
- # raise an exception because the cookie is expired.
667
- with pytest .raises (ValueError ) as excinfo :
668
- auth .verify_session_cookie (
669
- expired_session_cookie , check_revoked = False , clock_skew_seconds = - 1 )
670
- assert str (excinfo .value ) == 'clock_skew_seconds must be between 0 and 60.'
671
- with pytest .raises (ValueError ) as excinfo :
672
- auth .verify_session_cookie (
673
- expired_session_cookie , check_revoked = False , clock_skew_seconds = 61 )
674
- assert str (excinfo .value ) == 'clock_skew_seconds must be between 0 and 60.'
675
-
676
- # Verify the session cookie with a tolerance of 2 seconds. This should
677
- # not raise an exception because the cookie is within the tolerance.
678
- auth .verify_session_cookie (expired_session_cookie , check_revoked = False , clock_skew_seconds = 2 )
679
-
680
620
681
621
def test_verify_session_cookie_disabled (new_user , api_key ):
682
622
custom_token = auth .create_custom_token (new_user .uid )
0 commit comments