Skip to content

Commit

Permalink
debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrezina committed Nov 20, 2024
1 parent aa8bd40 commit d0f8d3d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
78 changes: 43 additions & 35 deletions src/tests/system/tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d0f8d3d

Please sign in to comment.