mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 10:13:58 +00:00
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
|
|
def test_init_kerberos_waits_for_ad_forwarder_ready_and_endpoints():
|
|
"""Regression: Kerberos test must not run against an AD forwarder Service with no endpoints.
|
|
|
|
Historically `init_kerberos.sh` would `kubectl apply` the AD forwarder Deployment/Service and then
|
|
proceed immediately (or ignore rollout failures), which could yield `kinit: Cannot contact any KDC`.
|
|
"""
|
|
|
|
text = Path("etc/init_kerberos.sh").read_text(encoding="utf-8")
|
|
|
|
assert "wait_for_ad_forwarder_ready" in text
|
|
assert "wait_for_ad_forwarder_ready \"$KRB5_AD_NAMESPACE\" \"$KRB5_AD_PROXY_NAME\" \"$KRB5_AD_SERVICE_NAME\"" in text
|
|
|
|
# Ensure we don't silently ignore readiness.
|
|
assert "rollout status deploy/${KRB5_AD_PROXY_NAME} --timeout=120s || true" not in text
|
|
|
|
|
|
def test_check_kerberos_cleanup_handles_missing_namespace(tmp_path):
|
|
"""Regression: cleanup path should not crash when PROLE_NAMESPACE is unset."""
|
|
|
|
knoe_conf = tmp_path / "conf"
|
|
knoe_conf.mkdir()
|
|
(knoe_conf / "knoe.cfg").write_text("[Global]\nDEPLOYMENT_MODE = k3s\n", encoding="utf-8")
|
|
|
|
home_dir = tmp_path / "home"
|
|
home_dir.mkdir()
|
|
|
|
env = os.environ.copy()
|
|
env.pop("PROLE_NAMESPACE", None)
|
|
env.pop("NAMESPACE", None)
|
|
env.pop("SERVICE_NAMESPACE", None)
|
|
env["KNOE_CONF"] = str(knoe_conf)
|
|
env["KNOE_HOME"] = ""
|
|
env["HOME"] = str(home_dir)
|
|
|
|
repo_root = Path(__file__).resolve().parents[1]
|
|
script = repo_root / "scripts/validation/check_kerberos.sh"
|
|
result = subprocess.run(
|
|
["bash", str(script), "cleanup"],
|
|
cwd=repo_root,
|
|
env=env,
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
assert result.returncode == 0, result.stderr
|
|
assert "No test pods to cleanup" in result.stdout
|