diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..4eb71c7 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +pythonpath = src/ +filterwarnings = + ignore::jwt.InsecureKeyLengthWarning diff --git a/src/rain_api_core/auth.py b/src/rain_api_core/auth.py index 0fdaba8..eeb06fd 100644 --- a/src/rain_api_core/auth.py +++ b/src/rain_api_core/auth.py @@ -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 diff --git a/src/rain_api_core/view_util.py b/src/rain_api_core/view_util.py index e19526c..369ca7e 100644 --- a/src/rain_api_core/view_util.py +++ b/src/rain_api_core/view_util.py @@ -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") diff --git a/tests/test_view_util.py b/tests/test_view_util.py index 3def765..91c446f 100644 --- a/tests/test_view_util.py +++ b/tests/test_view_util.py @@ -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(