Skip to content

Commit 44e558e

Browse files
samrosestaaldraad
authored andcommitted
test: more fixes to test`
1 parent bae4e0b commit 44e558e

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
@@ -630,6 +630,22 @@ def test_libpq5_version(host):
630630

631631
def test_jit_pam_module_installed(host):
632632
"""Test that the JIT PAM module (pam_jit_pg.so) is properly installed."""
633+
# Check PostgreSQL version first
634+
result = run_ssh_command(
635+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
636+
)
637+
pg_major_version = 15 # Default
638+
if result["succeeded"] and result["stdout"].strip():
639+
try:
640+
pg_major_version = int(result["stdout"].strip())
641+
except ValueError:
642+
pass
643+
644+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
645+
if pg_major_version == 15:
646+
print("\nSkipping JIT PAM module test for PostgreSQL 15 (not installed)")
647+
return
648+
633649
# Check if gatekeeper is installed via Nix
634650
result = run_ssh_command(
635651
host["ssh"],
@@ -713,6 +729,22 @@ def test_pam_postgresql_config(host):
713729

714730
def test_jit_pam_gatekeeper_profile(host):
715731
"""Test that the gatekeeper package is properly installed in the postgres user's Nix profile."""
732+
# Check PostgreSQL version first
733+
result = run_ssh_command(
734+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
735+
)
736+
pg_major_version = 15 # Default
737+
if result["succeeded"] and result["stdout"].strip():
738+
try:
739+
pg_major_version = int(result["stdout"].strip())
740+
except ValueError:
741+
pass
742+
743+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
744+
if pg_major_version == 15:
745+
print("\nSkipping gatekeeper profile test for PostgreSQL 15 (not installed)")
746+
return
747+
716748
# Check if gatekeeper is in the postgres user's Nix profile
717749
result = run_ssh_command(
718750
host["ssh"],
@@ -747,6 +779,24 @@ def test_jit_pam_gatekeeper_profile(host):
747779

748780
def test_jit_pam_module_dependencies(host):
749781
"""Test that the JIT PAM module has all required dependencies."""
782+
# Check PostgreSQL version first
783+
result = run_ssh_command(
784+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
785+
)
786+
pg_major_version = 15 # Default
787+
if result["succeeded"] and result["stdout"].strip():
788+
try:
789+
pg_major_version = int(result["stdout"].strip())
790+
except ValueError:
791+
pass
792+
793+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
794+
if pg_major_version == 15:
795+
print(
796+
"\nSkipping JIT PAM module dependencies test for PostgreSQL 15 (not installed)"
797+
)
798+
return
799+
750800
# Check dependencies of the PAM module
751801
result = run_ssh_command(
752802
host["ssh"],

0 commit comments

Comments
 (0)