From e09c68642b20f76e8e46ad3f31fa4aacc432ab17 Mon Sep 17 00:00:00 2001 From: Ihor Kalnytskyi Date: Wed, 8 May 2024 18:58:40 +0300 Subject: [PATCH] Use plugin via '-A store', deprecate '-A creds' The `-A` (`--auth-type`) parameter stands for authentication type, and is essentially the ID of the authentication plugin to invoke. This patch deprecates both `-A credential-store` and `-A creds` usages in favor of newly added `-A store`. I believe that `store` is both convenient and transparent, so we better deprecate other aliases and remove them in the future in order to prevent polluting plugins namespace. --- README.rst | 10 +++++----- pyproject.toml | 1 + src/httpie_credential_store/__init__.py | 4 ++-- src/httpie_credential_store/_plugin.py | 16 +++++++++++----- tests/test_plugin.py | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index e753d0d..858c2f8 100644 --- a/README.rst +++ b/README.rst @@ -20,7 +20,7 @@ Usage ----- .. note:: Please, do not forget to activate the plugin by invoking - ``http`` with ``-A creds`` option. + ``http`` with ``-A store`` option. Once installed, the plugin will look for credentials in the credential file. The credential file is stored in HTTPie configuration directory. @@ -95,19 +95,19 @@ the following credential record: ] Once the credential store is filled, you're ready to use the plugin at -your will. In order to activate the plugin, you must pass ``-A creds`` -or ``-A credential-store`` to ``http`` executable. +your will. In order to activate the plugin, you must pass ``-A store`` +to ``http`` executable. .. code:: bash - $ http -A creds https://api.github.com + $ http -A store https://api.github.com Optionally, you can provide an ID of the credential record to use by passing ``-a`` argument. .. code:: bash - $ http -A creds -a bots https://api.github.com + $ http -A store -a bots https://api.github.com Authentication providers diff --git a/pyproject.toml b/pyproject.toml index 0b2e86f..395d819 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ pytest-github-actions-annotate-failures = "*" httpie-hmac = "*" [tool.poetry.plugins."httpie.plugins.auth.v1"] +store = "httpie_credential_store:StoreAuthPlugin" credential-store = "httpie_credential_store:CredentialStoreAuthPlugin" creds = "httpie_credential_store:CredsAuthPlugin" diff --git a/src/httpie_credential_store/__init__.py b/src/httpie_credential_store/__init__.py index eb934b8..d606bff 100644 --- a/src/httpie_credential_store/__init__.py +++ b/src/httpie_credential_store/__init__.py @@ -1,6 +1,6 @@ """HTTPie Credential Store.""" -from ._plugin import CredentialStoreAuthPlugin, CredsAuthPlugin +from ._plugin import CredentialStoreAuthPlugin, CredsAuthPlugin, StoreAuthPlugin -__all__ = ["CredentialStoreAuthPlugin", "CredsAuthPlugin"] +__all__ = ["StoreAuthPlugin", "CredentialStoreAuthPlugin", "CredsAuthPlugin"] diff --git a/src/httpie_credential_store/_plugin.py b/src/httpie_credential_store/_plugin.py index 8bcbbab..0fd824b 100644 --- a/src/httpie_credential_store/_plugin.py +++ b/src/httpie_credential_store/_plugin.py @@ -6,7 +6,7 @@ from ._store import get_credential_store -class CredentialStoreAuthPlugin(httpie.plugins.AuthPlugin): +class StoreAuthPlugin(httpie.plugins.AuthPlugin): """Attach authentication to ongoing HTTP request. Usage:: @@ -15,10 +15,10 @@ class CredentialStoreAuthPlugin(httpie.plugins.AuthPlugin): $ http -A credential-store -a ihor http://example.com/v1/resource """ - name = "credential-store" + name = "HTTPie Credential Store" description = "Retrieve & attach authentication to ongoing HTTP request." - auth_type = "credential-store" # use plugin by passing '-A credential-store' + auth_type = "store" # use plugin by passing '-A store' auth_require = False # do not require passing '-a' argument auth_parse = False # do not parse '-a' content @@ -36,7 +36,13 @@ def __call__(self, request): return CredentialStoreAuth() +class CredentialStoreAuthPlugin(StoreAuthPlugin): + """DEPRECATED: invoke 'store' authentication via '-A credential-store'.""" + + auth_type = "credential-store" + + class CredsAuthPlugin(CredentialStoreAuthPlugin): - """Nothing more but a convenient alias.""" + """DEPRECATED: invoke 'store' authentication via '-A creds'.""" - auth_type = "creds" # use plugin by passing '-A creds' + auth_type = "creds" diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 68b42dd..db2ff68 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -98,7 +98,7 @@ def main(args): return main -@pytest.fixture(params=["credential-store", "creds"]) +@pytest.fixture(params=["store", "credential-store", "creds"]) def creds_auth_type(request): """All possible aliases."""