mirror of
https://github.com/rommapp/romm.git
synced 2026-07-01 08:16:21 +00:00
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
from datetime import timedelta
|
|
|
|
import pytest
|
|
from handler.auth import oauth_handler
|
|
from handler.tests.conftest import ( # noqa
|
|
admin_user,
|
|
clear_database,
|
|
editor_user,
|
|
platform,
|
|
rom,
|
|
save,
|
|
setup_database,
|
|
state,
|
|
viewer_user,
|
|
)
|
|
|
|
from ..auth import ACCESS_TOKEN_EXPIRE_MINUTES, REFRESH_TOKEN_EXPIRE_DAYS
|
|
|
|
|
|
@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)
|
|
)
|