summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pyproject.toml1
-rw-r--r--tests/test_adcli.py120
-rw-r--r--tests/topology_controllers.py19
3 files changed, 140 insertions, 0 deletions
diff --git a/tests/pyproject.toml b/tests/pyproject.toml
index e2c6da9..0fff440 100644
--- a/tests/pyproject.toml
+++ b/tests/pyproject.toml
@@ -1,5 +1,6 @@
[tool.mypy]
exclude = "docs"
+disable_error_code = ["attr-defined"]
[[tool.mypy.overrides]]
module = "jc.*"
diff --git a/tests/test_adcli.py b/tests/test_adcli.py
index fe73b7e..00c11e1 100644
--- a/tests/test_adcli.py
+++ b/tests/test_adcli.py
@@ -1848,3 +1848,123 @@ def test_adcli_join_custom_keytab_location(client: Client, provider: GenericADPr
# Cleanup: remove custom keytab and destroy ticket cache
client.host.conn.run(f"rm -f {custom_keytab_path}", raise_on_error=False)
client.host.conn.run("kdestroy", raise_on_error=False)
+
+
+@pytest.mark.importance("high")
+@pytest.mark.ticket(bz=[1762420, 1883467])
+@pytest.mark.topology(KnownTopologyGroup.AnyAD)
+def test_adcli__join_and_update_with_ldaps(client: Client, provider: GenericADProvider):
+ """
+ :title: adcli join and update work over LDAPS when port 389 is blocked
+ :description:
+ When outbound LDAP (port 389) is blocked, adcli must be able to join
+ the domain and update the computer account using LDAPS (port 636) via
+ the --use-ldaps flag. The domain root CA certificate is pre-installed
+ on the client by the topology controller during setup.
+ :setup:
+ 1. Block outbound TCP port 389 on the client to force LDAPS
+ :steps:
+ 1. Join the domain using adcli with --use-ldaps
+ 2. Run adcli update with --use-ldaps and set a description
+ 3. Verify the description was updated in AD using adcli show-computer
+ :expectedresults:
+ 1. adcli join succeeds over LDAPS with port 389 blocked
+ 2. adcli update succeeds over LDAPS
+ 3. Description is set correctly in AD
+ :customerscenario: True
+ """
+ description = "updated via ldaps"
+ domain = provider.host.domain
+ dc = provider.host.hostname
+ adminuser = provider.host.adminuser
+ adminpw = provider.host.adminpw
+
+ client.firewall.outbound.drop_port(389)
+
+ join_cmd = client.adcli.join(
+ domain=domain,
+ login_user=adminuser,
+ password=adminpw,
+ args=["--verbose", "--use-ldaps", f"--domain-controller={dc}"],
+ krb=True,
+ )
+ assert join_cmd.rc == 0, f"adcli join --use-ldaps failed with port 389 blocked: {join_cmd.stderr}"
+
+ update_cmd = client.adcli.update(
+ domain=domain,
+ login_user=adminuser,
+ password=adminpw,
+ args=["--verbose", "--use-ldaps", f"--domain-controller={dc}", f"--description={description}"],
+ )
+ assert update_cmd.rc == 0, f"adcli update --use-ldaps failed (rc={update_cmd.rc}):\n{update_cmd.stderr}"
+
+ show_cmd = client.adcli.show_computer(
+ domain=domain,
+ login_user=adminuser,
+ password=adminpw,
+ args=["--verbose", "--use-ldaps", f"--domain-controller={dc}"],
+ krb=True,
+ )
+ assert show_cmd.rc == 0, f"adcli show-computer failed: {show_cmd.stderr}"
+ output = show_cmd.stdout + show_cmd.stderr
+ assert re.search(rf"description:\n.*{description}", output, re.IGNORECASE), (
+ f"Description '{description}' not found in show-computer output!"
+ )
+
+
+@pytest.mark.importance("high")
+@pytest.mark.ticket(bz=[1762420, 1883467])
+@pytest.mark.topology(KnownTopologyGroup.AnyAD)
+def test_adcli__delete_computer_with_ldaps(client: Client, provider: GenericADProvider):
+ """
+ :title: adcli delete-computer works over LDAPS when port 389 is blocked
+ :description:
+ When outbound LDAP (port 389) is blocked, adcli must be able to join
+ the domain and then delete the computer account using LDAPS (port 636)
+ via the --use-ldaps flag. The domain root CA certificate is pre-installed
+ on the client by the topology controller during setup.
+ :setup:
+ 1. Block outbound TCP port 389 on the client to force LDAPS
+ :steps:
+ 1. Join the domain using adcli with --use-ldaps
+ 2. Delete the computer account using adcli delete-computer with --use-ldaps
+ 3. Verify the computer account no longer exists using adcli show-computer
+ :expectedresults:
+ 1. adcli join succeeds over LDAPS with port 389 blocked
+ 2. adcli delete-computer succeeds over LDAPS
+ 3. adcli show-computer fails because the account was removed
+ :customerscenario: True
+ """
+ domain = provider.host.domain
+ dc = provider.host.hostname
+ adminuser = provider.host.adminuser
+ adminpw = provider.host.adminpw
+
+ client.firewall.outbound.drop_port(389)
+
+ join_cmd = client.adcli.join(
+ domain=domain,
+ login_user=adminuser,
+ password=adminpw,
+ args=["--verbose", "--use-ldaps", f"--domain-controller={dc}"],
+ krb=True,
+ )
+ assert join_cmd.rc == 0, f"adcli join --use-ldaps failed with port 389 blocked: {join_cmd.stderr}"
+
+ delete_cmd = client.adcli.delete_computer(
+ domain=domain,
+ login_user=adminuser,
+ password=adminpw,
+ args=["--verbose", "--use-ldaps", f"--domain-controller={dc}"],
+ krb=True,
+ )
+ assert delete_cmd.rc == 0, f"adcli delete-computer --use-ldaps failed: {delete_cmd.stderr}"
+
+ show_cmd = client.adcli.show_computer(
+ domain=domain,
+ login_user=adminuser,
+ password=adminpw,
+ args=["--verbose", "--use-ldaps", f"--domain-controller={dc}"],
+ krb=True,
+ )
+ assert show_cmd.rc != 0, "adcli show-computer should have failed after delete but succeeded"
diff --git a/tests/topology_controllers.py b/tests/topology_controllers.py
index 8105d68..a188101 100644
--- a/tests/topology_controllers.py
+++ b/tests/topology_controllers.py
@@ -5,6 +5,7 @@ from sssd_test_framework.config import SSSDMultihostConfig
from sssd_test_framework.hosts.ad import ADHost
from sssd_test_framework.hosts.client import ClientHost
from sssd_test_framework.hosts.samba import SambaHost
+from sssd_test_framework.utils.tools import OpenSSLUtils
__all__ = [
"ADTopologyController",
@@ -55,6 +56,18 @@ class ADTopologyController(ProvisionedBackupTopologyController):
@BackupTopologyController.restore_vanilla_on_error
def topology_setup(self, client: ClientHost, provider: ADHost) -> None:
+ # Install the provider CA certificate on the client.
+ if isinstance(provider, ADHost):
+ if not client.fs.exists("/etc/pki/ca-trust/source/anchors/ad-ca.crt"):
+ openssl = OpenSSLUtils(client, client.fs)
+ try:
+ openssl.install_ca_cert(provider.get_ca_cert(), name="ad-ca.crt")
+ except RuntimeError:
+ try:
+ openssl.install_ca_cert_from_server(provider.hostname, name="ad-ca.crt")
+ except Exception as e:
+ self.logger.warning(f"Unable to install AD CA certificate on {client.hostname}: {e}")
+
if self.provisioned:
self.logger.info(f"Topology '{self.name}' is already provisioned")
return
@@ -75,6 +88,12 @@ class SambaTopologyController(ADTopologyController):
@BackupTopologyController.restore_vanilla_on_error
def topology_setup(self, client: ClientHost, provider: SambaHost) -> None:
+ # Install the provider CA certificate on the client.
+ if not client.fs.exists("/etc/pki/ca-trust/source/anchors/samba-ca.crt"):
+ ca_cert_path = provider.config.get("ca_cert_path", "/var/data/certs/ca.crt")
+ if provider.fs.exists(ca_cert_path):
+ OpenSSLUtils(client, client.fs).install_ca_cert(provider.fs.read(ca_cert_path), name="samba-ca.crt")
+
if self.provisioned:
self.logger.info(f"Topology '{self.name}' is already provisioned")
return