Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
pythonpath = src/
filterwarnings =
ignore::jwt.InsecureKeyLengthWarning
2 changes: 1 addition & 1 deletion src/rain_api_core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
private_key: str,
cookie_name: str,
blacklist={},
session_ttl_in_hours: float = 7 * 24,
session_ttl_in_hours: float = 24,
):
self.algorithm = algorithm
self.public_key = public_key
Expand Down
3 changes: 1 addition & 2 deletions src/rain_api_core/view_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
HTML_TEMPLATE_LOCAL_CACHEDIR = "/tmp/templates/" # nosec We want to leverage instance persistance
HTML_TEMPLATE_PROJECT_DIR = Path().resolve() / "templates"

_HOURS_PER_WEEK = 7 * 24
SESSTTL = int(os.getenv("SESSION_TTL", _HOURS_PER_WEEK)) * 60 * 60
SESSTTL = int(os.getenv("SESSION_TTL", 24)) * 60 * 60

JWT_ALGO = os.getenv("JWT_ALGO", "RS256")
JWT_COOKIE_NAME = os.getenv("JWT_COOKIENAME", "asf-urs")
Expand Down
10 changes: 5 additions & 5 deletions tests/test_view_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,22 @@ def test_get_cookie_vars_error(mock_decode_jwt_payload, mock_get_cookies):
def test_get_exp_time(mock_time):
mock_time.return_value = 100

assert get_exp_time() == 100 + (168 * 60 * 60)
assert get_exp_time() == 100 + (24 * 60 * 60)


@mock.patch(f"{MODULE}.time", autospec=True)
def test_get_cookie_expiration_date_str(mock_time):
mock_time.return_value = 0
assert get_cookie_expiration_date_str() == "Thu, 08 Jan 1970 00:00:00 GMT"
assert get_cookie_expiration_date_str() == "Fri, 02 Jan 1970 00:00:00 GMT"

mock_time.return_value = 1
assert get_cookie_expiration_date_str() == "Thu, 08 Jan 1970 00:00:01 GMT"
assert get_cookie_expiration_date_str() == "Fri, 02 Jan 1970 00:00:01 GMT"

mock_time.return_value = 1_000_000
assert get_cookie_expiration_date_str() == "Mon, 19 Jan 1970 13:46:40 GMT"
assert get_cookie_expiration_date_str() == "Tue, 13 Jan 1970 13:46:40 GMT"

mock_time.return_value = 1_000_000_000
assert get_cookie_expiration_date_str() == "Sun, 16 Sep 2001 01:46:40 GMT"
assert get_cookie_expiration_date_str() == "Mon, 10 Sep 2001 01:46:40 GMT"


@given(
Expand Down
Loading