MCPcopy Create free account
hub / github.com/Pometry/Raphtory / test_expired_token

Function test_expired_token

python/tests/test_auth.py:89–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88
89def test_expired_token():
90 work_dir = tempfile.mkdtemp()
91 with GraphServer(
92 work_dir, config={"auth": {"public_key": PUB_KEY}}
93 ).start() as server:
94 port = server.port()
95 exp = time() - 100
96 token = jwt.encode({"access": "ro", "exp": exp}, PRIVATE_KEY, algorithm="EdDSA")
97 headers = {
98 "Authorization": f"Bearer {token}",
99 }
100 response = requests.post(
101 raphtory_url(port), headers=headers, data=json.dumps({"query": QUERY_ROOT})
102 )
103 assert response.status_code == 401
104
105 token = jwt.encode({"access": "rw", "exp": exp}, PRIVATE_KEY, algorithm="EdDSA")
106 headers = {
107 "Authorization": f"Bearer {token}",
108 }
109 response = requests.post(
110 raphtory_url(port), headers=headers, data=json.dumps({"query": QUERY_ROOT})
111 )
112 assert response.status_code == 401
113
114
115@pytest.mark.parametrize("query", TEST_QUERIES)

Callers

nothing calls this directly

Calls 5

GraphServerClass · 0.90
raphtory_urlFunction · 0.85
encodeMethod · 0.80
startMethod · 0.45
portMethod · 0.45

Tested by

no test coverage detected