Skip to content

Commit

Permalink
fix pytest, move package
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanmcreynolds committed Oct 11, 2023
1 parent 8d3f690 commit 10f69c2
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ api_keys.yml
users.yml

splash_flows_globus/
splash_auth/

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
41 changes: 41 additions & 0 deletions splash_auth/_tests/test_config.py
Original file line number Diff line number Diff line change
@@ -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


4 changes: 2 additions & 2 deletions server/_version.py → splash_auth/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
14 changes: 7 additions & 7 deletions server/config.py → splash_auth/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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 = {
Expand All @@ -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")
Expand All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 10f69c2

Please sign in to comment.