From e62c6ebc3fadf6a0058d29bf90067e90c1d4822b Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Thu, 5 Sep 2024 17:09:49 +0200 Subject: [PATCH 01/17] Add `auth_plugin` with tests --- conan/internal/cache/home_paths.py | 4 ++ conans/client/migrations.py | 3 + conans/client/rest/remote_credentials.py | 44 +++++++++++++- .../configuration/test_auth_plugin.py | 60 +++++++++++++++++++ 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 test/integration/configuration/test_auth_plugin.py diff --git a/conan/internal/cache/home_paths.py b/conan/internal/cache/home_paths.py index ba2402ded2a..562dfa994ff 100644 --- a/conan/internal/cache/home_paths.py +++ b/conan/internal/cache/home_paths.py @@ -55,6 +55,10 @@ def profiles_path(self): def profile_plugin_path(self): return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "profile.py") + @property + def auth_plugin_path(self): + return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "auth.py") + @property def sign_plugin_path(self): return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "sign", "sign.py") diff --git a/conans/client/migrations.py b/conans/client/migrations.py index ddde216ac69..26ec23cfea6 100644 --- a/conans/client/migrations.py +++ b/conans/client/migrations.py @@ -52,6 +52,9 @@ def _apply_migrations(self, old_version): # Update profile plugin from conan.internal.api.profile.profile_loader import migrate_profile_plugin migrate_profile_plugin(self.cache_folder) + # Update auth plugin + from conans.client.rest.remote_credentials import migrate_auth_plugin + migrate_auth_plugin(self.cache_folder) if old_version and old_version < "2.0.14-": _migrate_pkg_db_lru(self.cache_folder, old_version) diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index 33dbe638d08..cf6d6652a0d 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -4,16 +4,29 @@ from jinja2 import Template +from conan.internal.cache.home_paths import HomePaths + +from conans.client.loader import load_python_file from conan.api.output import ConanOutput from conans.client.userio import UserInput -from conans.errors import ConanException +from conans.errors import ConanException, scoped_traceback from conans.util.files import load +_default_auth_plugin = """ +# This file was generated by Conan. Remove this comment if you edit this file or Conan +# will destroy your changes. + +def auth_plugin(remote, user=None, password=None): + # TODO: Connect this function to your own keyring for user login credentials + return None, None +""" + class RemoteCredentials: def __init__(self, cache_folder, global_conf): self._global_conf = global_conf self._urls = {} + self.auth_plugin_path = HomePaths(cache_folder).auth_plugin_path creds_path = os.path.join(cache_folder, "credentials.json") if not os.path.exists(creds_path): return @@ -32,7 +45,19 @@ def auth(self, remote, user=None, password=None): if user is not None and password is not None: return user, password - # First prioritize the cache "credentials.json" file + # First get the auth_plugin + auth_plugin = self._load_auth_plugin() + if auth_plugin is not None: + try: + plugin_user, plugin_password = auth_plugin(remote, user=user, password=password) + except Exception as e: + msg = f"Error while processing 'auth.py' plugin" + msg = scoped_traceback(msg, e, scope="/extensions/plugins") + raise ConanException(msg) + if plugin_user and plugin_password: + return plugin_user, plugin_password + + # Then prioritize the cache "credentials.json" file creds = self._urls.get(remote) if creds is not None: try: @@ -66,3 +91,18 @@ def _get_env(remote, user): if passwd: ConanOutput().info("Got password '******' from environment") return user, passwd + + def _load_auth_plugin(self): + if not os.path.exists(self.auth_plugin_path): + raise ConanException("The 'auth.py' plugin file doesn't exist. If you want " + "to disable it, edit its contents instead of removing it") + + mod, _ = load_python_file(self.auth_plugin_path) + if hasattr(mod, "auth_plugin"): + return mod.auth_plugin + +def migrate_auth_plugin(cache_folder): + from conans.client.migrations import update_file + + auth_plugin_file = HomePaths(cache_folder).auth_plugin_path + update_file(auth_plugin_file, _default_auth_plugin) diff --git a/test/integration/configuration/test_auth_plugin.py b/test/integration/configuration/test_auth_plugin.py new file mode 100644 index 00000000000..8472a9a86a9 --- /dev/null +++ b/test/integration/configuration/test_auth_plugin.py @@ -0,0 +1,60 @@ +import os +import textwrap + +import pytest + +from conan.test.utils.tools import TestClient +from conans.util.files import save + + +class TestErrorsAuthPlugin: + """ when the plugin fails, we want a clear message and a helpful trace + """ + def test_error_profile_plugin(self): + c = TestClient(default_server_user=True) + auth_plugin = textwrap.dedent("""\ + def auth_plugin(remote, user=None, password=None): + raise Exception("Test Error") + """) + save(os.path.join(c.cache.plugins_path, "auth.py"), auth_plugin) + c.run("remote logout default") + c.run("remote login default", assert_error=True) + assert "Error while processing 'auth.py' plugin" in c.out + assert "Test Error" in c.out + + def test_remove_plugin_file(self): + c = TestClient() + c.run("version") # to trigger the creation + os.remove(os.path.join(c.cache.plugins_path, "auth.py")) + c.run("remote add default http://fake") + c.run("remote login default", assert_error=True) + assert "ERROR: The 'auth.py' plugin file doesn't exist" in c.out + + @pytest.mark.parametrize("password", ["password", "bad-password"]) + def test_profile_plugin_direct_credentials(self, password): + should_fail = password == "bad-password" + c = TestClient(default_server_user=True) + auth_plugin = textwrap.dedent(f"""\ + def auth_plugin(remote, user=None, password=None): + return "admin", "{password}" + """) + save(os.path.join(c.cache.plugins_path, "auth.py"), auth_plugin) + c.run("remote logout default") + c.run("remote login default", assert_error=should_fail) + if should_fail: + assert "ERROR: Wrong user or password. [Remote: default]" in c.out + else: + assert "Changed user of remote 'default' from 'None' (anonymous) to 'admin' (authenticated)" in c.out + + def test_profile_plugin_fallback(self): + c = TestClient(default_server_user=True) + auth_plugin = textwrap.dedent("""\ + def auth_plugin(remote, user=None, password=None): + return None, None + """) + save(os.path.join(c.cache.plugins_path, "auth.py"), auth_plugin) + c.run("remote logout default") + c.run("remote login default") + # As the auth plugin is not returning any password the code is falling back to the rest of + # the input methods in this case the stdin provided by TestClient. + assert "Changed user of remote 'default' from 'None' (anonymous) to 'admin' (authenticated)" in c.out From 0e1c5628dc2726420b680273e5a08884b87132f5 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Fri, 6 Sep 2024 13:19:19 +0200 Subject: [PATCH 02/17] remove migration --- conans/client/migrations.py | 3 --- conans/client/rest/remote_credentials.py | 27 ++++-------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/conans/client/migrations.py b/conans/client/migrations.py index 26ec23cfea6..ddde216ac69 100644 --- a/conans/client/migrations.py +++ b/conans/client/migrations.py @@ -52,9 +52,6 @@ def _apply_migrations(self, old_version): # Update profile plugin from conan.internal.api.profile.profile_loader import migrate_profile_plugin migrate_profile_plugin(self.cache_folder) - # Update auth plugin - from conans.client.rest.remote_credentials import migrate_auth_plugin - migrate_auth_plugin(self.cache_folder) if old_version and old_version < "2.0.14-": _migrate_pkg_db_lru(self.cache_folder, old_version) diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index cf6d6652a0d..4819e1faefe 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -12,16 +12,6 @@ from conans.errors import ConanException, scoped_traceback from conans.util.files import load -_default_auth_plugin = """ -# This file was generated by Conan. Remove this comment if you edit this file or Conan -# will destroy your changes. - -def auth_plugin(remote, user=None, password=None): - # TODO: Connect this function to your own keyring for user login credentials - return None, None -""" - - class RemoteCredentials: def __init__(self, cache_folder, global_conf): self._global_conf = global_conf @@ -93,16 +83,7 @@ def _get_env(remote, user): return user, passwd def _load_auth_plugin(self): - if not os.path.exists(self.auth_plugin_path): - raise ConanException("The 'auth.py' plugin file doesn't exist. If you want " - "to disable it, edit its contents instead of removing it") - - mod, _ = load_python_file(self.auth_plugin_path) - if hasattr(mod, "auth_plugin"): - return mod.auth_plugin - -def migrate_auth_plugin(cache_folder): - from conans.client.migrations import update_file - - auth_plugin_file = HomePaths(cache_folder).auth_plugin_path - update_file(auth_plugin_file, _default_auth_plugin) + if os.path.exists(self.auth_plugin_path): + mod, _ = load_python_file(self.auth_plugin_path) + if hasattr(mod, "auth_plugin"): + return mod.auth_plugin From 3da3845f92d51d2e101eb8381fe70696152b8fdc Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Tue, 10 Sep 2024 14:27:55 +0200 Subject: [PATCH 03/17] fix: remote_login accept patters --- conan/cli/commands/remote.py | 10 +++--- conans/client/rest/remote_credentials.py | 6 ++-- .../options/test_configure_options.py | 36 +++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/conan/cli/commands/remote.py b/conan/cli/commands/remote.py index 8cd43711003..35cffa9b8b3 100644 --- a/conan/cli/commands/remote.py +++ b/conan/cli/commands/remote.py @@ -196,14 +196,16 @@ def remote_login(conan_api, parser, subparser, *args): raise ConanException("There are no remotes matching the '{}' pattern".format(args.remote)) creds = RemoteCredentials(conan_api.cache_folder, conan_api.config.global_conf) - user, password = creds.auth(args.remote, args.username, args.password) - if args.username is not None and args.username != user: - raise ConanException(f"User '{args.username}' doesn't match user '{user}' in " - f"credentials.json or environment variables") ret = OrderedDict() for r in remotes: previous_info = conan_api.remotes.user_info(r) + + user, password = creds.auth(r, args.username, args.password) + if args.username is not None and args.username != user: + raise ConanException(f"User '{args.username}' doesn't match user '{user}' in " + f"credentials.json or environment variables") + conan_api.remotes.user_login(r, user, password) info = conan_api.remotes.user_info(r) ret[r.name] = {"previous_info": previous_info, "info": info} diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index 4819e1faefe..5d82cd8ea02 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -48,7 +48,7 @@ def auth(self, remote, user=None, password=None): return plugin_user, plugin_password # Then prioritize the cache "credentials.json" file - creds = self._urls.get(remote) + creds = self._urls.get(remote.name) if creds is not None: try: return creds["user"], creds["password"] @@ -56,7 +56,7 @@ def auth(self, remote, user=None, password=None): raise ConanException(f"Authentication error, wrong credentials.json: {e}") # Then, check environment definition - env_user, env_passwd = self._get_env(remote, user) + env_user, env_passwd = self._get_env(remote.name, user) if env_passwd is not None: if env_user is None: raise ConanException("Found password in env-var, but not defined user") @@ -64,7 +64,7 @@ def auth(self, remote, user=None, password=None): # If not found, then interactive prompt ui = UserInput(self._global_conf.get("core:non_interactive", check_type=bool)) - input_user, input_password = ui.request_login(remote, user) + input_user, input_password = ui.request_login(remote.name, user) return input_user, input_password @staticmethod diff --git a/test/integration/options/test_configure_options.py b/test/integration/options/test_configure_options.py index 1aff0e4d95b..6b557e6c890 100644 --- a/test/integration/options/test_configure_options.py +++ b/test/integration/options/test_configure_options.py @@ -1,9 +1,11 @@ import textwrap import unittest +import json from parameterized import parameterized from conan.test.utils.tools import TestClient +from conan.test.assets.genconanfile import GenConanfile class ConfigureOptionsTest(unittest.TestCase): @@ -123,3 +125,37 @@ class Pkg(ConanFile): client.save({"conanfile.py": conanfile}) client.run(f"create . --name=pkg --version=0.1") self.assertIn("Package 'da39a3ee5e6b4b0d3255bfef95601890afd80709' created", client.out) + +def test_none_option_default(): + tc = TestClient() + + tc.save({"conanfile.py": textwrap.dedent(""" + from conan import ConanFile + + class Conan(ConanFile): + name = "app" + version = "1.0" + + options = {"~myvalue": [None, "a", "b", "c"]} + + def generate(self): + self.output.info("Option value: %s" % getattr(self.options, "~myvalue")) + self.output.info("Option value: %s" % self.options["~myvalue"]) + """)}) + + tc.run("create .") + +def test_remote_login_pattern(): + tc = TestClient() + tc.save_home({"credentials.json": json.dumps({ + "credentials": [ + { + "remote": "remote1", + "user": "admin", + "password": "bad-password" + } + ]})}) + tc.run("remote add remote2 https://fake") + tc.run("remote login * admin", assert_error=True) + + assert 'Please enter a password for "admin"' in tc.out From bdfe162f2a3551d65e117d5d52f43928ce957f23 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Tue, 10 Sep 2024 14:33:09 +0200 Subject: [PATCH 04/17] _load_auth_plugin free function --- conans/client/rest/remote_credentials.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index 5d82cd8ea02..e37f8886e9f 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -36,7 +36,7 @@ def auth(self, remote, user=None, password=None): return user, password # First get the auth_plugin - auth_plugin = self._load_auth_plugin() + auth_plugin = _load_auth_plugin(self.auth_plugin_path) if auth_plugin is not None: try: plugin_user, plugin_password = auth_plugin(remote, user=user, password=password) @@ -82,8 +82,8 @@ def _get_env(remote, user): ConanOutput().info("Got password '******' from environment") return user, passwd - def _load_auth_plugin(self): - if os.path.exists(self.auth_plugin_path): - mod, _ = load_python_file(self.auth_plugin_path) - if hasattr(mod, "auth_plugin"): - return mod.auth_plugin +def _load_auth_plugin(auth_plugin_path): + if os.path.exists(auth_plugin_path): + mod, _ = load_python_file(auth_plugin_path) + if hasattr(mod, "auth_plugin"): + return mod.auth_plugin From 3adbdb146e9fa06ea86c326a107e1a8e43ee00f1 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Wed, 11 Sep 2024 11:28:14 +0200 Subject: [PATCH 05/17] Discard changes to test/integration/options/test_configure_options.py --- .../options/test_configure_options.py | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/test/integration/options/test_configure_options.py b/test/integration/options/test_configure_options.py index 6b557e6c890..1aff0e4d95b 100644 --- a/test/integration/options/test_configure_options.py +++ b/test/integration/options/test_configure_options.py @@ -1,11 +1,9 @@ import textwrap import unittest -import json from parameterized import parameterized from conan.test.utils.tools import TestClient -from conan.test.assets.genconanfile import GenConanfile class ConfigureOptionsTest(unittest.TestCase): @@ -125,37 +123,3 @@ class Pkg(ConanFile): client.save({"conanfile.py": conanfile}) client.run(f"create . --name=pkg --version=0.1") self.assertIn("Package 'da39a3ee5e6b4b0d3255bfef95601890afd80709' created", client.out) - -def test_none_option_default(): - tc = TestClient() - - tc.save({"conanfile.py": textwrap.dedent(""" - from conan import ConanFile - - class Conan(ConanFile): - name = "app" - version = "1.0" - - options = {"~myvalue": [None, "a", "b", "c"]} - - def generate(self): - self.output.info("Option value: %s" % getattr(self.options, "~myvalue")) - self.output.info("Option value: %s" % self.options["~myvalue"]) - """)}) - - tc.run("create .") - -def test_remote_login_pattern(): - tc = TestClient() - tc.save_home({"credentials.json": json.dumps({ - "credentials": [ - { - "remote": "remote1", - "user": "admin", - "password": "bad-password" - } - ]})}) - tc.run("remote add remote2 https://fake") - tc.run("remote login * admin", assert_error=True) - - assert 'Please enter a password for "admin"' in tc.out From 823dadc399011dce2b210117c6859111d0cc3818 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Fri, 13 Sep 2024 14:35:42 +0200 Subject: [PATCH 06/17] add auth_source plugin with test and small fixes --- conan/internal/cache/home_paths.py | 6 +- conans/client/rest/auth_manager.py | 2 +- conans/client/rest/conan_requester.py | 30 +++++++- conans/client/rest/remote_credentials.py | 2 +- .../conf/test_auth_source_plugin.py | 76 +++++++++++++++++++ .../configuration/test_auth_plugin.py | 18 ++--- 6 files changed, 117 insertions(+), 17 deletions(-) create mode 100644 test/integration/configuration/conf/test_auth_source_plugin.py diff --git a/conan/internal/cache/home_paths.py b/conan/internal/cache/home_paths.py index 562dfa994ff..f877cc0e3c0 100644 --- a/conan/internal/cache/home_paths.py +++ b/conan/internal/cache/home_paths.py @@ -57,7 +57,11 @@ def profile_plugin_path(self): @property def auth_plugin_path(self): - return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "auth.py") + return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "auth_remote.py") + + @property + def auth_source_plugin_path(self): + return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "auth_source.py") @property def sign_plugin_path(self): diff --git a/conans/client/rest/auth_manager.py b/conans/client/rest/auth_manager.py index cf1ab8dded9..35b5c9ddce0 100644 --- a/conans/client/rest/auth_manager.py +++ b/conans/client/rest/auth_manager.py @@ -71,7 +71,7 @@ def _retry_with_new_token(self, user, remote, method_name, *args, **kwargs): credentials are stored in localdb and rest method is called""" for _ in range(LOGIN_RETRIES): creds = RemoteCredentials(self._cache_folder, self._global_conf) - input_user, input_password = creds.auth(remote.name) + input_user, input_password = creds.auth(remote) try: self._authenticate(remote, input_user, input_password) except AuthenticationException: diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py index 4903ac181f8..be654bbca8a 100644 --- a/conans/client/rest/conan_requester.py +++ b/conans/client/rest/conan_requester.py @@ -6,11 +6,15 @@ import requests import urllib3 +from exceptiongroup import catch from jinja2 import Template from requests.adapters import HTTPAdapter +from conan.internal.cache.home_paths import HomePaths + from conans import __version__ as client_version -from conans.errors import ConanException +from conans.client.loader import load_python_file +from conans.errors import ConanException, scoped_traceback # Capture SSL warnings as pointed out here: # https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning @@ -30,6 +34,7 @@ class _SourceURLCredentials: """ def __init__(self, cache_folder): self._urls = {} + self.auth_source_plugin_path = HomePaths(cache_folder).auth_source_plugin_path if not cache_folder: return creds_path = os.path.join(cache_folder, "source_credentials.json") @@ -61,6 +66,23 @@ def _get_auth(credentials): raise ConanException(f"Error loading 'source_credentials.json' {creds_path}: {repr(e)}") def add_auth(self, url, kwargs): + # First, try to use "auth_source_plugin" + auth_source_plugin = _load_auth_source_plugin(self.auth_source_plugin_path) + if auth_source_plugin: + try: + c = auth_source_plugin(url) + except Exception as e: + msg = f"Error while processing 'auth_source_remote.py' plugin" + msg = scoped_traceback(msg, e, scope="/extensions/plugins") + raise ConanException(msg) + if c: + if c.get("token"): + kwargs["headers"]["Authorization"] = f"Bearer {c.get('token')}" + if c.get("user") and c.get("password"): + kwargs["auth"] = (c.get("user"), c.get("password")) + return + + # Then, try to find the credentials in "_urls" for u, creds in self._urls.items(): if url.startswith(u): token = creds.get("token") @@ -183,3 +205,9 @@ def _call_method(self, method, url, **kwargs): if popped: os.environ.clear() os.environ.update(old_env) + +def _load_auth_source_plugin(auth_source_plugin_path): + if os.path.exists(auth_source_plugin_path): + mod, _ = load_python_file(auth_source_plugin_path) + if hasattr(mod, "auth_source_plugin"): + return mod.auth_source_plugin diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index e37f8886e9f..cdee2c35bc2 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -41,7 +41,7 @@ def auth(self, remote, user=None, password=None): try: plugin_user, plugin_password = auth_plugin(remote, user=user, password=password) except Exception as e: - msg = f"Error while processing 'auth.py' plugin" + msg = f"Error while processing 'auth_remote.py' plugin" msg = scoped_traceback(msg, e, scope="/extensions/plugins") raise ConanException(msg) if plugin_user and plugin_password: diff --git a/test/integration/configuration/conf/test_auth_source_plugin.py b/test/integration/configuration/conf/test_auth_source_plugin.py new file mode 100644 index 00000000000..7d9d20e6fd7 --- /dev/null +++ b/test/integration/configuration/conf/test_auth_source_plugin.py @@ -0,0 +1,76 @@ +import json +import os +import textwrap + +import pytest + +from conan.test.utils.file_server import TestFileServer +from conan.test.utils.test_files import temp_folder +from conan.test.utils.tools import TestClient +from conans.util.files import save + + +class TestErrorsAuthSourcePlugin: + @pytest.fixture + def setup_test_client(self): + self.client = TestClient(default_server_user=True, light=True) + self.file_server = TestFileServer() + self.client.servers["file_server"] = self.file_server + self.download_cache_folder = temp_folder() + self.client.save_home({"global.conf": "tools.files.download:retry=0"}) + + save(os.path.join(self.file_server.store, "myfile.txt"), "Bye, world!") + + conanfile = textwrap.dedent(f""" + from conan import ConanFile + from conan.tools.files import download + class Pkg2(ConanFile): + name = "pkg" + version = "1.0" + def source(self): + download(self, "{self.file_server.fake_url}/basic-auth/myfile.txt", "myfile.txt") + """) + self.client.save({"conanfile.py": conanfile}) + + return self.client, self.file_server.fake_url + + """ when the plugin fails, we want a clear message and a helpful trace + """ + def test_error_source_plugin(self, setup_test_client): + c, url = setup_test_client + auth_plugin = textwrap.dedent("""\ + def auth_source_plugin(url): + raise Exception("Test Error") + """) + save(os.path.join(c.cache.plugins_path, "auth_source.py"), auth_plugin) + c.run("source conanfile.py", assert_error=True) + assert "Test Error" in c.out + + @pytest.mark.parametrize("password", ["password", "bad-password"]) + def test_profile_plugin_direct_credentials(self, password, setup_test_client): + should_fail = password == "bad-password" + c, url = setup_test_client + auth_plugin = textwrap.dedent(f"""\ + def auth_source_plugin(url): + return { json.dumps({'user': 'user', 'password': password}) } + """) + save(os.path.join(c.cache.plugins_path, "auth_source.py"), auth_plugin) + c.run("source conanfile.py", assert_error=should_fail) + if should_fail: + assert "AuthenticationException" in c.out + else: + assert os.path.exists(os.path.join(c.current_folder, "myfile.txt")) + + def test_profile_plugin_fallback(self, setup_test_client): + c, url = setup_test_client + auth_plugin = textwrap.dedent("""\ + def auth_plugin(remote, user=None, password=None): + return None + """) + save(os.path.join(c.cache.plugins_path, "auth_source.py"), auth_plugin) + source_credentials = json.dumps({"credentials": [{"url": url, "token": "password"}]}) + save(os.path.join(c.cache_folder, "source_credentials.json"), source_credentials) + c.run("source conanfile.py") + # As the auth plugin is not returning any password the code is falling back to the rest of + # the input methods in this case provided by source_credentials.json. + assert os.path.exists(os.path.join(c.current_folder, "myfile.txt")) diff --git a/test/integration/configuration/test_auth_plugin.py b/test/integration/configuration/test_auth_plugin.py index 8472a9a86a9..ef194fd1dc2 100644 --- a/test/integration/configuration/test_auth_plugin.py +++ b/test/integration/configuration/test_auth_plugin.py @@ -7,7 +7,7 @@ from conans.util.files import save -class TestErrorsAuthPlugin: +class TestErrorsAuthSourcePlugin: """ when the plugin fails, we want a clear message and a helpful trace """ def test_error_profile_plugin(self): @@ -16,20 +16,12 @@ def test_error_profile_plugin(self): def auth_plugin(remote, user=None, password=None): raise Exception("Test Error") """) - save(os.path.join(c.cache.plugins_path, "auth.py"), auth_plugin) + save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) c.run("remote logout default") c.run("remote login default", assert_error=True) - assert "Error while processing 'auth.py' plugin" in c.out + assert "Error while processing 'auth_remote.py' plugin" in c.out assert "Test Error" in c.out - def test_remove_plugin_file(self): - c = TestClient() - c.run("version") # to trigger the creation - os.remove(os.path.join(c.cache.plugins_path, "auth.py")) - c.run("remote add default http://fake") - c.run("remote login default", assert_error=True) - assert "ERROR: The 'auth.py' plugin file doesn't exist" in c.out - @pytest.mark.parametrize("password", ["password", "bad-password"]) def test_profile_plugin_direct_credentials(self, password): should_fail = password == "bad-password" @@ -38,7 +30,7 @@ def test_profile_plugin_direct_credentials(self, password): def auth_plugin(remote, user=None, password=None): return "admin", "{password}" """) - save(os.path.join(c.cache.plugins_path, "auth.py"), auth_plugin) + save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) c.run("remote logout default") c.run("remote login default", assert_error=should_fail) if should_fail: @@ -52,7 +44,7 @@ def test_profile_plugin_fallback(self): def auth_plugin(remote, user=None, password=None): return None, None """) - save(os.path.join(c.cache.plugins_path, "auth.py"), auth_plugin) + save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) c.run("remote logout default") c.run("remote login default") # As the auth plugin is not returning any password the code is falling back to the rest of From b6ac06e0b693f28e47f5f3f6a40c5cf37d09809d Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Fri, 13 Sep 2024 16:32:59 +0200 Subject: [PATCH 07/17] fix --- conans/client/rest/conan_requester.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py index be654bbca8a..812dd3c1d31 100644 --- a/conans/client/rest/conan_requester.py +++ b/conans/client/rest/conan_requester.py @@ -6,7 +6,6 @@ import requests import urllib3 -from exceptiongroup import catch from jinja2 import Template from requests.adapters import HTTPAdapter From 027197c591d0adfba23226592501a7a10f2a3f70 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Fri, 13 Sep 2024 16:37:23 +0200 Subject: [PATCH 08/17] fix load plugins at construction time --- conans/client/rest/conan_requester.py | 5 ++--- conans/client/rest/remote_credentials.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py index 812dd3c1d31..f6327ab7f29 100644 --- a/conans/client/rest/conan_requester.py +++ b/conans/client/rest/conan_requester.py @@ -33,7 +33,7 @@ class _SourceURLCredentials: """ def __init__(self, cache_folder): self._urls = {} - self.auth_source_plugin_path = HomePaths(cache_folder).auth_source_plugin_path + self.auth_source_plugin = _load_auth_source_plugin(HomePaths(cache_folder).auth_source_plugin_path) if not cache_folder: return creds_path = os.path.join(cache_folder, "source_credentials.json") @@ -66,8 +66,7 @@ def _get_auth(credentials): def add_auth(self, url, kwargs): # First, try to use "auth_source_plugin" - auth_source_plugin = _load_auth_source_plugin(self.auth_source_plugin_path) - if auth_source_plugin: + if self.auth_source_plugin: try: c = auth_source_plugin(url) except Exception as e: diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index cdee2c35bc2..5d14ac26bb7 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -16,7 +16,7 @@ class RemoteCredentials: def __init__(self, cache_folder, global_conf): self._global_conf = global_conf self._urls = {} - self.auth_plugin_path = HomePaths(cache_folder).auth_plugin_path + self.auth_plugin = _load_auth_plugin(HomePaths(cache_folder).auth_plugin_path) creds_path = os.path.join(cache_folder, "credentials.json") if not os.path.exists(creds_path): return @@ -36,8 +36,8 @@ def auth(self, remote, user=None, password=None): return user, password # First get the auth_plugin - auth_plugin = _load_auth_plugin(self.auth_plugin_path) - if auth_plugin is not None: + + if self.auth_plugin is not None: try: plugin_user, plugin_password = auth_plugin(remote, user=user, password=password) except Exception as e: From 69f6a2fdd88a32f4efd39b70fec0e460898b9ec8 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Mon, 16 Sep 2024 10:26:24 +0200 Subject: [PATCH 09/17] fix --- conans/client/rest/conan_requester.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py index f6327ab7f29..d3181b8b6ee 100644 --- a/conans/client/rest/conan_requester.py +++ b/conans/client/rest/conan_requester.py @@ -33,7 +33,8 @@ class _SourceURLCredentials: """ def __init__(self, cache_folder): self._urls = {} - self.auth_source_plugin = _load_auth_source_plugin(HomePaths(cache_folder).auth_source_plugin_path) + auth_source_plugin_path = HomePaths(cache_folder or "").auth_source_plugin_path + self.auth_source_plugin = _load_auth_source_plugin(auth_source_plugin_path) if not cache_folder: return creds_path = os.path.join(cache_folder, "source_credentials.json") @@ -68,7 +69,7 @@ def add_auth(self, url, kwargs): # First, try to use "auth_source_plugin" if self.auth_source_plugin: try: - c = auth_source_plugin(url) + c = self.auth_source_plugin(url) except Exception as e: msg = f"Error while processing 'auth_source_remote.py' plugin" msg = scoped_traceback(msg, e, scope="/extensions/plugins") From ba13b0c2eaa89ee3e51a299c2a21145c11c90df3 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Mon, 16 Sep 2024 10:56:38 +0200 Subject: [PATCH 10/17] fix --- conans/client/rest/remote_credentials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index 5d14ac26bb7..2ded104c954 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -39,7 +39,7 @@ def auth(self, remote, user=None, password=None): if self.auth_plugin is not None: try: - plugin_user, plugin_password = auth_plugin(remote, user=user, password=password) + plugin_user, plugin_password = self.auth_plugin(remote, user=user, password=password) except Exception as e: msg = f"Error while processing 'auth_remote.py' plugin" msg = scoped_traceback(msg, e, scope="/extensions/plugins") From d22753c4eab579ac8b518416e60d0e3838f25c55 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Tue, 17 Sep 2024 14:14:48 +0200 Subject: [PATCH 11/17] fixes --- conan/internal/cache/home_paths.py | 2 +- conans/client/rest/remote_credentials.py | 8 ++++---- .../configuration/conf/test_auth_source_plugin.py | 10 ++++++++-- ...st_auth_plugin.py => test_auth_remote_plugin.py} | 13 ++++++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) rename test/integration/configuration/{test_auth_plugin.py => test_auth_remote_plugin.py} (82%) diff --git a/conan/internal/cache/home_paths.py b/conan/internal/cache/home_paths.py index f877cc0e3c0..30e79002b34 100644 --- a/conan/internal/cache/home_paths.py +++ b/conan/internal/cache/home_paths.py @@ -56,7 +56,7 @@ def profile_plugin_path(self): return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "profile.py") @property - def auth_plugin_path(self): + def auth_remote_plugin_path(self): return os.path.join(self._home, _EXTENSIONS_FOLDER, _PLUGINS, "auth_remote.py") @property diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index 2ded104c954..850076d0b2b 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -16,7 +16,7 @@ class RemoteCredentials: def __init__(self, cache_folder, global_conf): self._global_conf = global_conf self._urls = {} - self.auth_plugin = _load_auth_plugin(HomePaths(cache_folder).auth_plugin_path) + self.auth_plugin = _load_auth_plugin(HomePaths(cache_folder).auth_remote_plugin_path) creds_path = os.path.join(cache_folder, "credentials.json") if not os.path.exists(creds_path): return @@ -82,8 +82,8 @@ def _get_env(remote, user): ConanOutput().info("Got password '******' from environment") return user, passwd -def _load_auth_plugin(auth_plugin_path): - if os.path.exists(auth_plugin_path): - mod, _ = load_python_file(auth_plugin_path) +def _load_auth_plugin(auth_remote_plugin_path): + if os.path.exists(auth_remote_plugin_path): + mod, _ = load_python_file(auth_remote_plugin_path) if hasattr(mod, "auth_plugin"): return mod.auth_plugin diff --git a/test/integration/configuration/conf/test_auth_source_plugin.py b/test/integration/configuration/conf/test_auth_source_plugin.py index 7d9d20e6fd7..fad428efed4 100644 --- a/test/integration/configuration/conf/test_auth_source_plugin.py +++ b/test/integration/configuration/conf/test_auth_source_plugin.py @@ -10,7 +10,7 @@ from conans.util.files import save -class TestErrorsAuthSourcePlugin: +class TestAuthSourcePlugin: @pytest.fixture def setup_test_client(self): self.client = TestClient(default_server_user=True, light=True) @@ -34,7 +34,7 @@ def source(self): return self.client, self.file_server.fake_url - """ when the plugin fails, we want a clear message and a helpful trace + """ Test when the plugin fails, we want a clear message and a helpful trace """ def test_error_source_plugin(self, setup_test_client): c, url = setup_test_client @@ -46,6 +46,9 @@ def auth_source_plugin(url): c.run("source conanfile.py", assert_error=True) assert "Test Error" in c.out + """ Test when the plugin give a correct and wrong password, we want a message about the success + or fail in login + """ @pytest.mark.parametrize("password", ["password", "bad-password"]) def test_profile_plugin_direct_credentials(self, password, setup_test_client): should_fail = password == "bad-password" @@ -61,6 +64,9 @@ def auth_source_plugin(url): else: assert os.path.exists(os.path.join(c.current_folder, "myfile.txt")) + """ Test when the plugin do not give any user or password, we want the code to continue with + the rest of the input methods + """ def test_profile_plugin_fallback(self, setup_test_client): c, url = setup_test_client auth_plugin = textwrap.dedent("""\ diff --git a/test/integration/configuration/test_auth_plugin.py b/test/integration/configuration/test_auth_remote_plugin.py similarity index 82% rename from test/integration/configuration/test_auth_plugin.py rename to test/integration/configuration/test_auth_remote_plugin.py index ef194fd1dc2..a6d3900c535 100644 --- a/test/integration/configuration/test_auth_plugin.py +++ b/test/integration/configuration/test_auth_remote_plugin.py @@ -7,8 +7,8 @@ from conans.util.files import save -class TestErrorsAuthSourcePlugin: - """ when the plugin fails, we want a clear message and a helpful trace +class TestAuthRemotePlugin: + """ Test when the plugin fails, we want a clear message and a helpful trace """ def test_error_profile_plugin(self): c = TestClient(default_server_user=True) @@ -20,8 +20,11 @@ def auth_plugin(remote, user=None, password=None): c.run("remote logout default") c.run("remote login default", assert_error=True) assert "Error while processing 'auth_remote.py' plugin" in c.out - assert "Test Error" in c.out + assert "ERROR: Error while processing 'auth_remote.py' plugin, line " in c.out + """ Test when the plugin give a correct and wrong password, we want a message about the success + or fail in login + """ @pytest.mark.parametrize("password", ["password", "bad-password"]) def test_profile_plugin_direct_credentials(self, password): should_fail = password == "bad-password" @@ -38,6 +41,10 @@ def auth_plugin(remote, user=None, password=None): else: assert "Changed user of remote 'default' from 'None' (anonymous) to 'admin' (authenticated)" in c.out + + """ Test when the plugin do not give any user or password, we want the code to continue with + the rest of the input methods + """ def test_profile_plugin_fallback(self): c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent("""\ From 14a1d69be42093ac764a2bceb6d2085bd4e593a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Tue, 17 Sep 2024 14:32:54 +0200 Subject: [PATCH 12/17] Improve empty cache_folder handling --- conans/client/rest/conan_requester.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py index d3181b8b6ee..f59fac373d0 100644 --- a/conans/client/rest/conan_requester.py +++ b/conans/client/rest/conan_requester.py @@ -33,10 +33,11 @@ class _SourceURLCredentials: """ def __init__(self, cache_folder): self._urls = {} - auth_source_plugin_path = HomePaths(cache_folder or "").auth_source_plugin_path - self.auth_source_plugin = _load_auth_source_plugin(auth_source_plugin_path) + self.auth_source_plugin = None if not cache_folder: return + auth_source_plugin_path = HomePaths(cache_folder).auth_source_plugin_path + self.auth_source_plugin = _load_auth_source_plugin(auth_source_plugin_path) creds_path = os.path.join(cache_folder, "source_credentials.json") if not os.path.exists(creds_path): return From 09dbad7eabdf69d266857fac3243ecdfa93df23a Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Tue, 17 Sep 2024 14:38:21 +0200 Subject: [PATCH 13/17] change name `auth_remote_plugin` --- conans/client/rest/remote_credentials.py | 14 +++++++------- .../configuration/test_auth_remote_plugin.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index 850076d0b2b..f6a01cb1d11 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -16,7 +16,7 @@ class RemoteCredentials: def __init__(self, cache_folder, global_conf): self._global_conf = global_conf self._urls = {} - self.auth_plugin = _load_auth_plugin(HomePaths(cache_folder).auth_remote_plugin_path) + self.auth_remote_plugin = _load_auth_remote_plugin(HomePaths(cache_folder).auth_remote_plugin_path) creds_path = os.path.join(cache_folder, "credentials.json") if not os.path.exists(creds_path): return @@ -35,11 +35,11 @@ def auth(self, remote, user=None, password=None): if user is not None and password is not None: return user, password - # First get the auth_plugin + # First get the auth_remote_plugin - if self.auth_plugin is not None: + if self.auth_remote_plugin is not None: try: - plugin_user, plugin_password = self.auth_plugin(remote, user=user, password=password) + plugin_user, plugin_password = self.auth_remote_plugin(remote, user=user, password=password) except Exception as e: msg = f"Error while processing 'auth_remote.py' plugin" msg = scoped_traceback(msg, e, scope="/extensions/plugins") @@ -82,8 +82,8 @@ def _get_env(remote, user): ConanOutput().info("Got password '******' from environment") return user, passwd -def _load_auth_plugin(auth_remote_plugin_path): +def _load_auth_remote_plugin(auth_remote_plugin_path): if os.path.exists(auth_remote_plugin_path): mod, _ = load_python_file(auth_remote_plugin_path) - if hasattr(mod, "auth_plugin"): - return mod.auth_plugin + if hasattr(mod, "auth_remote_plugin"): + return mod.auth_remote_plugin diff --git a/test/integration/configuration/test_auth_remote_plugin.py b/test/integration/configuration/test_auth_remote_plugin.py index a6d3900c535..a36c4d2a52c 100644 --- a/test/integration/configuration/test_auth_remote_plugin.py +++ b/test/integration/configuration/test_auth_remote_plugin.py @@ -13,7 +13,7 @@ class TestAuthRemotePlugin: def test_error_profile_plugin(self): c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent("""\ - def auth_plugin(remote, user=None, password=None): + def auth_remote_plugin(remote, user=None, password=None): raise Exception("Test Error") """) save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) @@ -30,7 +30,7 @@ def test_profile_plugin_direct_credentials(self, password): should_fail = password == "bad-password" c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent(f"""\ - def auth_plugin(remote, user=None, password=None): + def auth_remote_plugin(remote, user=None, password=None): return "admin", "{password}" """) save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) @@ -48,7 +48,7 @@ def auth_plugin(remote, user=None, password=None): def test_profile_plugin_fallback(self): c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent("""\ - def auth_plugin(remote, user=None, password=None): + def auth_remote_plugin(remote, user=None, password=None): return None, None """) save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) From 794b2d06788ef2b5d42446fab842a94d96296c06 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Wed, 18 Sep 2024 17:34:38 +0200 Subject: [PATCH 14/17] fix test names --- .../configuration/conf/test_auth_source_plugin.py | 4 ++-- test/integration/configuration/test_auth_remote_plugin.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/integration/configuration/conf/test_auth_source_plugin.py b/test/integration/configuration/conf/test_auth_source_plugin.py index fad428efed4..351bb5c5e3d 100644 --- a/test/integration/configuration/conf/test_auth_source_plugin.py +++ b/test/integration/configuration/conf/test_auth_source_plugin.py @@ -50,7 +50,7 @@ def auth_source_plugin(url): or fail in login """ @pytest.mark.parametrize("password", ["password", "bad-password"]) - def test_profile_plugin_direct_credentials(self, password, setup_test_client): + def test_auth_source_plugin_direct_credentials(self, password, setup_test_client): should_fail = password == "bad-password" c, url = setup_test_client auth_plugin = textwrap.dedent(f"""\ @@ -67,7 +67,7 @@ def auth_source_plugin(url): """ Test when the plugin do not give any user or password, we want the code to continue with the rest of the input methods """ - def test_profile_plugin_fallback(self, setup_test_client): + def test_auth_source_plugin_fallback(self, setup_test_client): c, url = setup_test_client auth_plugin = textwrap.dedent("""\ def auth_plugin(remote, user=None, password=None): diff --git a/test/integration/configuration/test_auth_remote_plugin.py b/test/integration/configuration/test_auth_remote_plugin.py index a36c4d2a52c..75c0f6ae83f 100644 --- a/test/integration/configuration/test_auth_remote_plugin.py +++ b/test/integration/configuration/test_auth_remote_plugin.py @@ -10,7 +10,7 @@ class TestAuthRemotePlugin: """ Test when the plugin fails, we want a clear message and a helpful trace """ - def test_error_profile_plugin(self): + def test_error_auth_remote_plugin(self): c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent("""\ def auth_remote_plugin(remote, user=None, password=None): @@ -26,7 +26,7 @@ def auth_remote_plugin(remote, user=None, password=None): or fail in login """ @pytest.mark.parametrize("password", ["password", "bad-password"]) - def test_profile_plugin_direct_credentials(self, password): + def test_auth_remote_plugin_direct_credentials(self, password): should_fail = password == "bad-password" c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent(f"""\ @@ -45,7 +45,7 @@ def auth_remote_plugin(remote, user=None, password=None): """ Test when the plugin do not give any user or password, we want the code to continue with the rest of the input methods """ - def test_profile_plugin_fallback(self): + def test_auth_remote_plugin_fallback(self): c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent("""\ def auth_remote_plugin(remote, user=None, password=None): From 608c3f158710a8994a737594896a2c04b74f3992 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Fri, 20 Sep 2024 16:01:33 +0200 Subject: [PATCH 15/17] remove password from auth_remote_plugin --- conans/client/rest/remote_credentials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/client/rest/remote_credentials.py b/conans/client/rest/remote_credentials.py index f6a01cb1d11..d9ad7ddafdd 100644 --- a/conans/client/rest/remote_credentials.py +++ b/conans/client/rest/remote_credentials.py @@ -39,7 +39,7 @@ def auth(self, remote, user=None, password=None): if self.auth_remote_plugin is not None: try: - plugin_user, plugin_password = self.auth_remote_plugin(remote, user=user, password=password) + plugin_user, plugin_password = self.auth_remote_plugin(remote, user=user) except Exception as e: msg = f"Error while processing 'auth_remote.py' plugin" msg = scoped_traceback(msg, e, scope="/extensions/plugins") From 126dbe9326f5e6e0d9d18c6a5fb2046c48662f21 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Sun, 22 Sep 2024 23:16:27 +0200 Subject: [PATCH 16/17] Update test/integration/configuration/test_auth_remote_plugin.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Abril Rincón Blanco --- test/integration/configuration/test_auth_remote_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/configuration/test_auth_remote_plugin.py b/test/integration/configuration/test_auth_remote_plugin.py index 75c0f6ae83f..9764c24d109 100644 --- a/test/integration/configuration/test_auth_remote_plugin.py +++ b/test/integration/configuration/test_auth_remote_plugin.py @@ -13,7 +13,7 @@ class TestAuthRemotePlugin: def test_error_auth_remote_plugin(self): c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent("""\ - def auth_remote_plugin(remote, user=None, password=None): + def auth_remote_plugin(remote, user=None): raise Exception("Test Error") """) save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) From d03623dc052761204539074aa457826dbefc43d5 Mon Sep 17 00:00:00 2001 From: Ernesto de Gracia Herranz Date: Mon, 23 Sep 2024 12:45:50 +0200 Subject: [PATCH 17/17] test fix --- .../integration/configuration/conf/test_auth_source_plugin.py | 2 +- test/integration/configuration/test_auth_remote_plugin.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/configuration/conf/test_auth_source_plugin.py b/test/integration/configuration/conf/test_auth_source_plugin.py index 351bb5c5e3d..c87116a63c3 100644 --- a/test/integration/configuration/conf/test_auth_source_plugin.py +++ b/test/integration/configuration/conf/test_auth_source_plugin.py @@ -70,7 +70,7 @@ def auth_source_plugin(url): def test_auth_source_plugin_fallback(self, setup_test_client): c, url = setup_test_client auth_plugin = textwrap.dedent("""\ - def auth_plugin(remote, user=None, password=None): + def auth_source_plugin(url): return None """) save(os.path.join(c.cache.plugins_path, "auth_source.py"), auth_plugin) diff --git a/test/integration/configuration/test_auth_remote_plugin.py b/test/integration/configuration/test_auth_remote_plugin.py index 9764c24d109..ab62507ccfc 100644 --- a/test/integration/configuration/test_auth_remote_plugin.py +++ b/test/integration/configuration/test_auth_remote_plugin.py @@ -30,7 +30,7 @@ def test_auth_remote_plugin_direct_credentials(self, password): should_fail = password == "bad-password" c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent(f"""\ - def auth_remote_plugin(remote, user=None, password=None): + def auth_remote_plugin(remote, user=None): return "admin", "{password}" """) save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin) @@ -48,7 +48,7 @@ def auth_remote_plugin(remote, user=None, password=None): def test_auth_remote_plugin_fallback(self): c = TestClient(default_server_user=True) auth_plugin = textwrap.dedent("""\ - def auth_remote_plugin(remote, user=None, password=None): + def auth_remote_plugin(remote, user=None): return None, None """) save(os.path.join(c.cache.plugins_path, "auth_remote.py"), auth_plugin)