Skip to content

Commit 1cbe6b7

Browse files
taimoorzaeemsteve-chavez
authored andcommitted
test(io): remove stale jwt cache test
Removes a test related to jwt cache which is stale since #4084. Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com> (cherry picked from commit 379eaec)
1 parent f972009 commit 1cbe6b7

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

test/io/test_io.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,53 +1805,6 @@ def test_schema_cache_startup_load_with_in_db_config(defaultenv, metapostgrest):
18051805
assert response.status_code == 204
18061806

18071807

1808-
def test_jwt_cache_purges_expired_entries(defaultenv):
1809-
"test expired cache entries are purged on cache miss"
1810-
1811-
# The verification of actual cache size reduction is done manually, see https://github.com/PostgREST/postgrest/pull/3801#issuecomment-2620776041
1812-
# This test is written for code coverage of purgeExpired function
1813-
1814-
def relativeSeconds(sec):
1815-
return int((datetime.now(timezone.utc) + timedelta(seconds=sec)).timestamp())
1816-
1817-
def headers(sec):
1818-
return jwtauthheader(
1819-
{"role": "postgrest_test_author", "exp": relativeSeconds(sec)}, SECRET
1820-
)
1821-
1822-
env = {
1823-
**defaultenv,
1824-
"PGRST_JWT_CACHE_MAX_ENTRIES": "86400",
1825-
"PGRST_JWT_SECRET": SECRET,
1826-
"PGRST_DB_CONFIG": "false",
1827-
}
1828-
1829-
with run(env=env) as postgrest:
1830-
1831-
# Generate two unique JWT tokens
1832-
# The 1 second sleep is needed for it generate a unique token
1833-
hdrs1 = headers(5)
1834-
postgrest.session.get("/authors_only", headers=hdrs1)
1835-
1836-
time.sleep(1)
1837-
1838-
hdrs2 = headers(5)
1839-
postgrest.session.get("/authors_only", headers=hdrs2)
1840-
1841-
# Wait 5 seconds for the tokens to expire
1842-
time.sleep(5)
1843-
1844-
hdrs3 = headers(5)
1845-
1846-
# Make another request which should cause a cache miss and so
1847-
# the purgeExpired function will be triggered.
1848-
#
1849-
# This should remove the 2 expired tokens but adds another to cache
1850-
response = postgrest.session.get("/authors_only", headers=hdrs3)
1851-
1852-
assert response.status_code == 200
1853-
1854-
18551808
def test_pgrst_log_503_client_error_to_stderr(defaultenv):
18561809
"PostgREST should log 503 errors to stderr"
18571810

0 commit comments

Comments
 (0)