mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
35 lines
871 B
Python
35 lines
871 B
Python
from datetime import timedelta
|
|
|
|
import pytest
|
|
|
|
from endpoints.auth import ACCESS_TOKEN_EXPIRE_MINUTES, REFRESH_TOKEN_EXPIRE_DAYS
|
|
from handler.auth import oauth_handler
|
|
|
|
|
|
@pytest.fixture()
|
|
def access_token(admin_user): # noqa
|
|
data = {
|
|
"sub": admin_user.username,
|
|
"iss": "romm:oauth",
|
|
"scopes": " ".join(admin_user.oauth_scopes),
|
|
"type": "access",
|
|
}
|
|
|
|
return oauth_handler.create_oauth_token(
|
|
data=data, expires_delta=timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
|
|
)
|
|
|
|
|
|
@pytest.fixture()
|
|
def refresh_token(admin_user): # noqa
|
|
data = {
|
|
"sub": admin_user.username,
|
|
"iss": "romm:oauth",
|
|
"scopes": " ".join(admin_user.oauth_scopes),
|
|
"type": "refresh",
|
|
}
|
|
|
|
return oauth_handler.create_oauth_token(
|
|
data=data, expires_delta=timedelta(days=REFRESH_TOKEN_EXPIRE_DAYS)
|
|
)
|