Skip to content

Commit 804a2dc

Browse files
committed
test: more fixes to test`
1 parent 90f48c5 commit 804a2dc

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

testinfra/test_ami_nix.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,22 @@ def test_libpq5_version(host):
619619

620620
def test_jit_pam_module_installed(host):
621621
"""Test that the JIT PAM module (pam_jit_pg.so) is properly installed."""
622+
# Check PostgreSQL version first
623+
result = run_ssh_command(
624+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
625+
)
626+
pg_major_version = 15 # Default
627+
if result["succeeded"] and result["stdout"].strip():
628+
try:
629+
pg_major_version = int(result["stdout"].strip())
630+
except ValueError:
631+
pass
632+
633+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
634+
if pg_major_version == 15:
635+
print("\nSkipping JIT PAM module test for PostgreSQL 15 (not installed)")
636+
return
637+
622638
# Check if gatekeeper is installed via Nix
623639
result = run_ssh_command(
624640
host["ssh"],
@@ -702,6 +718,22 @@ def test_pam_postgresql_config(host):
702718

703719
def test_jit_pam_gatekeeper_profile(host):
704720
"""Test that the gatekeeper package is properly installed in the postgres user's Nix profile."""
721+
# Check PostgreSQL version first
722+
result = run_ssh_command(
723+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
724+
)
725+
pg_major_version = 15 # Default
726+
if result["succeeded"] and result["stdout"].strip():
727+
try:
728+
pg_major_version = int(result["stdout"].strip())
729+
except ValueError:
730+
pass
731+
732+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
733+
if pg_major_version == 15:
734+
print("\nSkipping gatekeeper profile test for PostgreSQL 15 (not installed)")
735+
return
736+
705737
# Check if gatekeeper is in the postgres user's Nix profile
706738
result = run_ssh_command(
707739
host["ssh"],
@@ -736,6 +768,24 @@ def test_jit_pam_gatekeeper_profile(host):
736768

737769
def test_jit_pam_module_dependencies(host):
738770
"""Test that the JIT PAM module has all required dependencies."""
771+
# Check PostgreSQL version first
772+
result = run_ssh_command(
773+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
774+
)
775+
pg_major_version = 15 # Default
776+
if result["succeeded"] and result["stdout"].strip():
777+
try:
778+
pg_major_version = int(result["stdout"].strip())
779+
except ValueError:
780+
pass
781+
782+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
783+
if pg_major_version == 15:
784+
print(
785+
"\nSkipping JIT PAM module dependencies test for PostgreSQL 15 (not installed)"
786+
)
787+
return
788+
739789
# Check dependencies of the PAM module
740790
result = run_ssh_command(
741791
host["ssh"],

0 commit comments

Comments
 (0)