Skip to content

Commit

Permalink
fix: remove more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stillmatic committed Oct 12, 2023
1 parent 96f030d commit 46c3ed0
Showing 1 changed file with 0 additions and 60 deletions.
60 changes: 0 additions & 60 deletions integration/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,6 @@ def test_session_cookies(api_key):
estimated_exp = int(time.time() + expires_in.total_seconds())
assert abs(claims['exp'] - estimated_exp) < 5

def test_session_cookies_with_tolerance(api_key):
dev_claims = {'premium' : True, 'subscription' : 'silver'}
custom_token = auth.create_custom_token('user3', dev_claims)
id_token = _sign_in(custom_token, api_key)
expires_in = datetime.timedelta(seconds=3)
session_cookie = auth.create_session_cookie(id_token, expires_in=expires_in)
time.sleep(4)
# expect this to fail because the cookie is expired
with pytest.raises(auth.ExpiredSessionCookieError):
auth.verify_session_cookie(session_cookie)

# expect this to succeed because we're within the tolerance
claims = auth.verify_session_cookie(session_cookie, check_revoked=False, clock_skew_seconds=2)
assert claims['uid'] == 'user3'
assert claims['premium'] is True
assert claims['subscription'] == 'silver'
assert claims['iss'].startswith('https://session.firebase.google.com')

with pytest.raises(ValueError):
auth.verify_session_cookie(session_cookie, clock_skew_seconds=-1)
with pytest.raises(ValueError):
auth.verify_session_cookie(session_cookie, clock_skew_seconds=61)

def test_session_cookie_error():
expires_in = datetime.timedelta(days=1)
with pytest.raises(auth.InvalidIdTokenError):
Expand Down Expand Up @@ -640,43 +617,6 @@ def test_verify_session_cookie_revoked(new_user, api_key):
claims = auth.verify_session_cookie(session_cookie, check_revoked=True)
assert claims['iat'] * 1000 >= user.tokens_valid_after_timestamp

def test_verify_session_cookie_tolerance(new_user, api_key):
expired_session_cookie = auth.create_session_cookie(
_sign_in(auth.create_custom_token(new_user.uid), api_key),
expires_in=datetime.timedelta(seconds=3)
)
time.sleep(3)
# Verify the session cookie with a tolerance of 0 seconds. This should
# raise an exception because the cookie is expired.
with pytest.raises(auth.ExpiredSessionCookieError) as excinfo:
auth.verify_session_cookie(expired_session_cookie, check_revoked=False,
clock_skew_seconds=0)
assert str(excinfo.value) == 'The Firebase session cookie is expired.'

# Verify the session cookie with a tolerance of 2 seconds. This should
# not raise an exception because the cookie is within the tolerance.
auth.verify_session_cookie(expired_session_cookie, check_revoked=False, clock_skew_seconds=2)

def test_verify_session_cookie_clock_skew_seconds_range(new_user, api_key):
expired_session_cookie = auth.create_session_cookie(
_sign_in(auth.create_custom_token(new_user.uid), api_key),
expires_in=datetime.timedelta(seconds=3)
)
# Verify the session cookie with a tolerance of 0 seconds. This should
# raise an exception because the cookie is expired.
with pytest.raises(ValueError) as excinfo:
auth.verify_session_cookie(
expired_session_cookie, check_revoked=False, clock_skew_seconds=-1)
assert str(excinfo.value) == 'clock_skew_seconds must be between 0 and 60.'
with pytest.raises(ValueError) as excinfo:
auth.verify_session_cookie(
expired_session_cookie, check_revoked=False, clock_skew_seconds=61)
assert str(excinfo.value) == 'clock_skew_seconds must be between 0 and 60.'

# Verify the session cookie with a tolerance of 2 seconds. This should
# not raise an exception because the cookie is within the tolerance.
auth.verify_session_cookie(expired_session_cookie, check_revoked=False, clock_skew_seconds=2)


def test_verify_session_cookie_disabled(new_user, api_key):
custom_token = auth.create_custom_token(new_user.uid)
Expand Down

0 comments on commit 46c3ed0

Please sign in to comment.