Skip to content

Commit

Permalink
chore: no auth
Browse files Browse the repository at this point in the history
  • Loading branch information
tzing committed Mar 16, 2024
1 parent 7c2b815 commit be15a41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions secrets_env/providers/vault/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def create_auth_by_name(url: Url, config: dict) -> Auth:
from secrets_env.providers.vault.auth.userpass import LDAPAuth
return LDAPAuth.create(url, config)
elif method == "null":
from secrets_env.providers.vault.auth.base import NullAuth
return NullAuth.create(url, config)
from secrets_env.providers.vault.auth.base import NoAuth
return NoAuth.create(url, config)
elif method == "oidc":
from secrets_env.providers.vault.auth.oidc import OpenIDConnectAuth
return OpenIDConnectAuth.create(url, config)
Expand Down
4 changes: 2 additions & 2 deletions secrets_env/providers/vault/auth/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def login(self, client: httpx.Client) -> str | None:
"""Login and get token."""


class NullAuth(Auth):
class NoAuth(Auth):
"""No authentication.
This class is used when no authentication is required.
Expand All @@ -46,7 +46,7 @@ class NullAuth(Auth):
token: str = ""

@classmethod
def create(cls, url: Any, config: dict[str, Any]) -> NullAuth:
def create(cls, url: Any, config: dict[str, Any]) -> NoAuth:
return cls()

def login(self, client: Any) -> str:
Expand Down
12 changes: 6 additions & 6 deletions tests/providers/vault/auth/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from pydantic_core import Url

from secrets_env.providers.vault.auth import create_auth_by_name
from secrets_env.providers.vault.auth.base import Auth, NullAuth
from secrets_env.providers.vault.auth.base import Auth, NoAuth


@pytest.mark.parametrize(
("method", "path"),
[
("basic", "secrets_env.providers.vault.auth.userpass.BasicAuth.create"),
("ldap", "secrets_env.providers.vault.auth.userpass.LDAPAuth.create"),
("null", "secrets_env.providers.vault.auth.base.NullAuth.create"),
("null", "secrets_env.providers.vault.auth.base.NoAuth.create"),
("oidc", "secrets_env.providers.vault.auth.oidc.OpenIDConnectAuth.create"),
("okta", "secrets_env.providers.vault.auth.userpass.OktaAuth.create"),
("radius", "secrets_env.providers.vault.auth.userpass.RADIUSAuth.create"),
Expand All @@ -30,13 +30,13 @@ def test_create_auth_by_name_fail():
create_auth_by_name(Url("https://example.com/"), {"method": "invalid"})


class TestNullAuth:
class TestNoAuth:
def test_login(self):
auth = NullAuth()
auth = NoAuth()
assert auth.login(Mock()) == ""

auth = NullAuth(token="test")
auth = NoAuth(token="test")
assert auth.login(Mock()) == "test"

def test_create(self):
assert isinstance(NullAuth.create(Url("https://example.com/"), {}), NullAuth)
assert isinstance(NoAuth.create(Url("https://example.com/"), {}), NoAuth)

0 comments on commit be15a41

Please sign in to comment.