diff --git a/.gitignore b/.gitignore index ca98e97..74b8656 100644 --- a/.gitignore +++ b/.gitignore @@ -128,4 +128,4 @@ api_keys.yml users.yml splash_flows_globus/ -splash_auth/ + diff --git a/pyproject.toml b/pyproject.toml index 8c95dbd..32d2f78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,13 +26,16 @@ dependencies = [ "pyyaml" ] +dev-dependencies = [ + "pytest" +] dynamic = ["version"] [tool.hatch] version.source = "vcs" -build.hooks.vcs.version-file = "server/_version.py" +build.hooks.vcs.version-file = "splash_auth/_version.py" [tool.hatch.metadata] allow-direct-references = true \ No newline at end of file diff --git a/server/__init__.py b/splash_auth/__init__.py similarity index 100% rename from server/__init__.py rename to splash_auth/__init__.py diff --git a/splash_auth/_tests/test_config.py b/splash_auth/_tests/test_config.py new file mode 100644 index 0000000..24c2b6b --- /dev/null +++ b/splash_auth/_tests/test_config.py @@ -0,0 +1,41 @@ +import os + + + + +def test_config(monkeypatch): + + monkeypatch.setenv("JWT_SECRET", "secret") + monkeypatch.setenv("TOKEN_EXP_TIME", 2) + monkeypatch.setenv("OAUTH_AUTH_ENDPOINT", "http://magrathea.com") + monkeypatch.setenv("OAUTH_CLIENT_ID", "slartibartfast") + monkeypatch.setenv("OAUTH_CLIENT_SECRET", "mousey") + monkeypatch.setenv("OAUTH_TOKEN_URI", "http://earth.com/.well-known/openid-configuration") + monkeypatch.setenv("OAUTH_REDIRECT_URI", "http://earth.com") + monkeypatch.setenv("OUATH_FAIL_REDIRECT_URI", "http://whale.com") + monkeypatch.setenv("OUATH_SUCCESS_REDIRECT_URI", "http://dolphin.com") + monkeypatch.setenv("OUATH_JWKS_URI", "http://hearofgold.com") + monkeypatch.setenv("HTTP_CLIENT_MAX_CONNECTIONS", 101) + monkeypatch.setenv("HTTP_CLIENT_TIMEOUT_ALL", 1.0) + monkeypatch.setenv("HTTP_CLIENT_TIMEOUT_CONNECT", 4.0) + monkeypatch.setenv("HTTP_CLIENT_TIMEOUT_POOL", 10) + from splash_auth.config import Config + # Test default values + config = Config() + print(config) + assert config.jwt_secret == "secret" + assert config.token_exp_time == 2 + assert config.oauth_endpoint == "http://magrathea.com" + assert config.oauth_client_id == "slartibartfast" + assert config.oauth_client_secret == "mousey" + assert config.oauth_redirect_uri == "http://earth.com" + assert config.oauth_token_url == "http://earth.com/.well-known/openid-configuration" + assert config.oauth_success_redirect_uri == "http://dolphin.com" + assert config.oauth_fail_redirect_uri == "http://whale.com" + assert config.oauth_jwks_uri == "http://hearofgold.com" + assert config.http_client_max_connections == 101 + assert config.http_client_timeout_all == 1.0 + assert config.http_client_timeout_connect == 4.0 + assert config.http_client_timeout_pool == 10 + + diff --git a/server/_version.py b/splash_auth/_version.py similarity index 74% rename from server/_version.py rename to splash_auth/_version.py index 6bd539b..1a62d42 100644 --- a/server/_version.py +++ b/splash_auth/_version.py @@ -12,5 +12,5 @@ __version_tuple__: VERSION_TUPLE version_tuple: VERSION_TUPLE -__version__ = version = '0.1.11.dev1+gce6e10f.d20231011' -__version_tuple__ = version_tuple = (0, 1, 11, 'dev1', 'gce6e10f.d20231011') +__version__ = version = '0.1.11.dev2+g8d3f690.d20231011' +__version_tuple__ = version_tuple = (0, 1, 11, 'dev2', 'g8d3f690.d20231011') diff --git a/server/config.py b/splash_auth/config.py similarity index 83% rename from server/config.py rename to splash_auth/config.py index 2ee7f11..3968550 100644 --- a/server/config.py +++ b/splash_auth/config.py @@ -5,7 +5,7 @@ JWT_SECRET = os.environ["JWT_SECRET"] -TOKEN_TIME = int(os.environ["TOKEN_EXP_TIME"]) +TOKEN_EXP_TIME = int(os.environ["TOKEN_EXP_TIME"]) OAUTH_AUTH_ENDPOINT = os.environ["OAUTH_AUTH_ENDPOINT"] OAUTH_CLIENT_ID = os.environ["OAUTH_CLIENT_ID"] OAUTH_CLIENT_SECRET = os.environ["OAUTH_CLIENT_SECRET"] @@ -16,10 +16,10 @@ OUATH_SUCCESS_REDIRECT_URI = os.environ["OUATH_SUCCESS_REDIRECT_URI"] OUATH_FAIL_REDIRECT_URI = os.environ["OUATH_FAIL_REDIRECT_URI"] OUATH_JWKS_URI = os.environ["OUATH_JWKS_URI"] -HTTP_CLIENT_MAX_CONNECTIONS = os.getenv("HTTP_CLIENT_MAX_CONNECTIONS", 100) -HTTP_CLIENT_TIMEOUT_ALL = os.getenv("HTTP_CLIENT_TIMEOUT_ALL", 5.0) -HTTP_CLIENT_TIMEOUT_CONNECT = os.getenv("HTTP_CLIENT_TIMEOUT_CONNECT", 3.0) -HTTP_CLIENT_TIMEOUT_POOL = os.getenv("HTTP_CLIENT_TIMEOUT_POOL", 10) +HTTP_CLIENT_MAX_CONNECTIONS = int(os.getenv("HTTP_CLIENT_MAX_CONNECTIONS", 100)) +HTTP_CLIENT_TIMEOUT_ALL = float(os.getenv("HTTP_CLIENT_TIMEOUT_ALL", 5.0)) +HTTP_CLIENT_TIMEOUT_CONNECT = float(os.getenv("HTTP_CLIENT_TIMEOUT_CONNECT", 3.0)) +HTTP_CLIENT_TIMEOUT_POOL = int(os.getenv("HTTP_CLIENT_TIMEOUT_POOL", 10)) google_claims = { @@ -29,7 +29,7 @@ } logger.info(f"JWT_SECRET {JWT_SECRET}") -logger.info(f"TOKEN_TIME {TOKEN_TIME}") +logger.info(f"TOKEN_EXP_TIME {TOKEN_EXP_TIME}") logger.info(f"OAUTH_AUTH_ENDPOINT {OAUTH_AUTH_ENDPOINT}") logger.info(f"OAUTH_CLIENT_ID {OAUTH_CLIENT_ID}") logger.info("OAUTH_CLIENT_SECRET is a secret") @@ -46,7 +46,7 @@ class Config: jwt_secret = JWT_SECRET - token_time = TOKEN_TIME + token_exp_time = TOKEN_EXP_TIME oauth_endpoint = OAUTH_AUTH_ENDPOINT oauth_client_id = OAUTH_CLIENT_ID oauth_client_secret = OAUTH_CLIENT_SECRET diff --git a/server/main.py b/splash_auth/main.py similarity index 100% rename from server/main.py rename to splash_auth/main.py diff --git a/server/oidc.py b/splash_auth/oidc.py similarity index 100% rename from server/oidc.py rename to splash_auth/oidc.py diff --git a/server/user_db.py b/splash_auth/user_db.py similarity index 100% rename from server/user_db.py rename to splash_auth/user_db.py