Skip to content

tests: add LDAP+KRB5 DNS discovery and SASL tests#8647

Open
madhuriupadhye wants to merge 1 commit intoSSSD:masterfrom
madhuriupadhye:tests/ldap-krb5-dns-sasl
Open

tests: add LDAP+KRB5 DNS discovery and SASL tests#8647
madhuriupadhye wants to merge 1 commit intoSSSD:masterfrom
madhuriupadhye:tests/ldap-krb5-dns-sasl

Conversation

@madhuriupadhye
Copy link
Copy Markdown
Contributor

Add three pytest system tests to test_ldap_krb5.py:

  • DNS SRV discovery for LDAP (Trac 754): dns_discovery_domain without ldap_uri
  • BZ 700805: ldap_backup_uri when discovery domain has no _ldap._tcp SRV
  • BZ 732935: ldap_sasl_canonicalize vs reverse DNS with GSSAPI over ldaps://IP

Uses client.tools.dig and client.tools.getent.ahostsv4 (sssd-test-framework).

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new system tests for SSSD's LDAP and Kerberos integration, specifically covering DNS SRV discovery, backup URI failover, and SASL canonicalization behavior with GSSAPI. The review feedback highlights a need to handle IPv6 addresses correctly in LDAP URIs by using square brackets and suggests reordering test logic to ensure the test skips appropriately when the environment cannot reproduce the specific canonicalization issue.


client.sssd.common.krb5_auth(kdc)
client.sssd.domain["ldap_sasl_mech"] = "GSSAPI"
client.sssd.domain["ldap_uri"] = f"ldaps://{ldap_ip}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The LDAP URI construction does not account for IPv6 addresses. If ldap_ip is an IPv6 address, it must be enclosed in square brackets (e.g., ldaps://[2001:db8::1]) to be a valid URI. Using a raw IPv6 address will cause SSSD or libldap to fail parsing the URI due to the ambiguous colons.

Suggested change
client.sssd.domain["ldap_uri"] = f"ldaps://{ldap_ip}"
ldap_uri = f"ldaps://[{ldap_ip}]" if ":" in ldap_ip else f"ldaps://{ldap_ip}"
client.sssd.domain["ldap_uri"] = ldap_uri

Comment on lines +325 to +335
broken = client.tools.id("puser1") is None

client.sssd.domain["ldap_sasl_canonicalize"] = "false"
client.sssd.restart(clean=True)
assert client.tools.id("puser1") is not None, "id should succeed with ldap_sasl_canonicalize=false"

if not broken:
pytest.skip(
"Reverse DNS for LDAP IP matches expected hostname; cannot reproduce BZ 732935 "
"canonicalize failure in this environment"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The test logic for skipping when the environment cannot reproduce the issue is flawed. The check if not broken is performed after a second SSSD restart and an assertion. If the environment has a working reverse DNS (i.e., broken is False), the test should skip immediately after the first id call. Otherwise, if the second id call fails for unrelated reasons, the test will incorrectly report a failure instead of skipping.

    broken = client.tools.id("puser1") is None
    if not broken:
        pytest.skip(
            "Reverse DNS for LDAP IP matches expected hostname; cannot reproduce BZ 732935 "
            "canonicalize failure in this environment"
        )

    client.sssd.domain["ldap_sasl_canonicalize"] = "false"
    client.sssd.restart(clean=True)
    assert client.tools.id("puser1") is not None, "id should succeed with ldap_sasl_canonicalize=false"

Add three pytest system tests to test_ldap_krb5.py:

- DNS SRV discovery for LDAP (Trac 754): dns_discovery_domain without ldap_uri
- BZ 700805: ldap_backup_uri when discovery domain has no _ldap._tcp SRV
- BZ 732935: ldap_sasl_canonicalize vs reverse DNS with GSSAPI over ldaps://IP

Uses client.tools.dig and client.tools.getent.ahostsv4 (sssd-test-framework).

Signed-off-by: Madhuri Upadhye <mupadhye@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants