Buckets:
AnonymousSpottedToad/human_verified_bucket / codebase /python /ddeutils_ddeutil-observe /tests /test_auth_securities.py
| import time | |
| from datetime import timedelta | |
| import pytest | |
| from jwt.exceptions import ExpiredSignatureError, InvalidSignatureError | |
| from src.ddeutil.observe.auth.securities import ( | |
| create_access_token, | |
| create_refresh_token, | |
| decode_access_token, | |
| decode_refresh_token, | |
| ) | |
| def test_access_token(): | |
| token = create_access_token( | |
| {"sub": "demo"}, expires_delta=timedelta(seconds=10) | |
| ) | |
| payload = decode_access_token(token) | |
| assert payload["sub"] == "demo" | |
| def test_access_token_raise(): | |
| token = create_access_token( | |
| {"sub": "demo"}, expires_delta=timedelta(seconds=0.1) | |
| ) | |
| time.sleep(0.2) | |
| with pytest.raises(ExpiredSignatureError): | |
| decode_access_token(token) | |
| with pytest.raises(InvalidSignatureError): | |
| decode_access_token(token[:-6] + "extend") | |
| def test_refresh_token(): | |
| token = create_refresh_token( | |
| {"sub": "demo"}, expires_delta=timedelta(seconds=10) | |
| ) | |
| payload = decode_refresh_token(token) | |
| assert payload["sub"] == "demo" | |
| def test_refresh_token_raise(): | |
| token = create_refresh_token( | |
| {"sub": "demo"}, expires_delta=timedelta(seconds=0.1) | |
| ) | |
| time.sleep(0.2) | |
| with pytest.raises(ExpiredSignatureError): | |
| decode_refresh_token(token) | |
| with pytest.raises(InvalidSignatureError): | |
| decode_access_token(token[:-6] + "extend") | |
Xet Storage Details
- Size:
- 1.37 kB
- Xet hash:
- 045ce33ed2208ff1f1e695ab5b83e1bea50eded4790a7701f83c6ca01b702790
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.