From d0f8d3d274fb86157d6bfac481eb66d0b8418f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Tue, 19 Nov 2024 14:26:31 +0100 Subject: [PATCH] debug test --- .github/workflows/ci.yml | 1 + src/tests/system/tests/test_authentication.py | 78 ++++++++++--------- 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa27cb00d94..11ce1bbbec5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -294,6 +294,7 @@ jobs: pytest \ --color=yes \ --show-capture=no \ + --mh-collect-logs=always --mh-collect-artifacts=always \ --mh-config=./mhc.yaml \ --mh-artifacts-dir=$GITHUB_WORKSPACE/artifacts \ --polarion-config=../polarion.yaml \ diff --git a/src/tests/system/tests/test_authentication.py b/src/tests/system/tests/test_authentication.py index 37bea3d4c59..16496bf3ecb 100644 --- a/src/tests/system/tests/test_authentication.py +++ b/src/tests/system/tests/test_authentication.py @@ -61,41 +61,49 @@ def test_authentication__with_overriding_home_directory(client: Client, provider 1. Login is successful and working directory matches the expected value :customerscenario: False """ - provider.user("user1").add(password="Secret123", home="/home/user1") - client.sssd.common.mkhomedir(clean=True) - client.sssd.start() - - user = client.tools.getent.passwd("user1") - assert user is not None - - home_map: dict[str, list[str]] = { - "user": ["/home/%u", f"/home/{user.name}"], - "uid": ["/home/%U", f"/home/{user.uid}"], - "fqn": ["/home/%f", f"/home/{user.name}@{client.sssd.default_domain}"], - "domain": ["/home/%d/%u", f"/home/{client.sssd.default_domain}/{user.name}"], - "first_char": ["/home/%l", f"/home/{str(user.name)[0]}"], - "upn": ["/home/%P", f"/home/{user.name}@{provider.domain.upper()}"], - "default": ["%o", f"{user.home}"], - "lowercase": ["%h", f"{str(user.home).lower()}"], - "substring": ["%H/%u", f"/home/homedir/{user.name}"], - "literal%": ["/home/%%/%u", f"/home/%/{user.name}"], - } - - if home_key == "upn" and isinstance(provider, LDAP): - pytest.skip("Skipping provider, userPrincipal attribute is not set!") - - if home_key == "domain": - client.fs.mkdir_p(f"/home/{client.sssd.default_domain}") - - home_fmt, home_exp = home_map[home_key] - client.sssd.domain["homedir_substring"] = "/home/homedir" - client.sssd.domain["override_homedir"] = home_fmt - client.sssd.start(clean=True) - - with client.ssh("user1", "Secret123") as ssh: - result = ssh.run("pwd").stdout - assert result is not None, "Getting path failed!" - assert result == home_exp, f"Current path {result} is not {home_exp}!" + client.logger.info("DEBUG BEFORE") + client.host.conn.run("ls -l /home") + + try: + provider.user("user1").add(password="Secret123", home="/home/user1") + # client.sssd.common.mkhomedir(clean=True) + client.sssd.common.mkhomedir() + client.sssd.start() + + user = client.tools.getent.passwd("user1") + assert user is not None + + home_map: dict[str, list[str]] = { + "user": ["/home/%u", f"/home/{user.name}"], + "uid": ["/home/%U", f"/home/{user.uid}"], + "fqn": ["/home/%f", f"/home/{user.name}@{client.sssd.default_domain}"], + "domain": ["/home/%d/%u", f"/home/{client.sssd.default_domain}/{user.name}"], + "first_char": ["/home/%l", f"/home/{str(user.name)[0]}"], + "upn": ["/home/%P", f"/home/{user.name}@{provider.domain.upper()}"], + "default": ["%o", f"{user.home}"], + "lowercase": ["%h", f"{str(user.home).lower()}"], + "substring": ["%H/%u", f"/home/homedir/{user.name}"], + "literal%": ["/home/%%/%u", f"/home/%/{user.name}"], + } + + if home_key == "upn" and isinstance(provider, LDAP): + pytest.skip("Skipping provider, userPrincipal attribute is not set!") + + if home_key == "domain": + client.fs.mkdir_p(f"/home/{client.sssd.default_domain}") + + home_fmt, home_exp = home_map[home_key] + client.sssd.domain["homedir_substring"] = "/home/homedir" + client.sssd.domain["override_homedir"] = home_fmt + client.sssd.restart() + + with client.ssh("user1", "Secret123") as ssh: + result = ssh.run("pwd").stdout + assert result is not None, "Getting path failed!" + assert result == home_exp, f"Current path {result} is not {home_exp}!" + finally: + client.logger.info("DEBUG AFTER") + client.host.conn.run("ls -l /home") @pytest.mark.topology(KnownTopologyGroup.AnyProvider)