Skip to content

Commit 7673932

Browse files
samrosestaaldraad
authored andcommitted
test: more fixes to test`
1 parent e953383 commit 7673932

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

626626
def test_jit_pam_module_installed(host):
627627
"""Test that the JIT PAM module (pam_jit_pg.so) is properly installed."""
628+
# Check PostgreSQL version first
629+
result = run_ssh_command(
630+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
631+
)
632+
pg_major_version = 15 # Default
633+
if result["succeeded"] and result["stdout"].strip():
634+
try:
635+
pg_major_version = int(result["stdout"].strip())
636+
except ValueError:
637+
pass
638+
639+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
640+
if pg_major_version == 15:
641+
print("\nSkipping JIT PAM module test for PostgreSQL 15 (not installed)")
642+
return
643+
628644
# Check if gatekeeper is installed via Nix
629645
result = run_ssh_command(
630646
host["ssh"],
@@ -708,6 +724,22 @@ def test_pam_postgresql_config(host):
708724

709725
def test_jit_pam_gatekeeper_profile(host):
710726
"""Test that the gatekeeper package is properly installed in the postgres user's Nix profile."""
727+
# Check PostgreSQL version first
728+
result = run_ssh_command(
729+
host["ssh"], "sudo -u postgres psql --version | grep -oE '[0-9]+' | head -1"
730+
)
731+
pg_major_version = 15 # Default
732+
if result["succeeded"] and result["stdout"].strip():
733+
try:
734+
pg_major_version = int(result["stdout"].strip())
735+
except ValueError:
736+
pass
737+
738+
# Skip test for PostgreSQL 15 as gatekeeper is not installed for PG15
739+
if pg_major_version == 15:
740+
print("\nSkipping gatekeeper profile test for PostgreSQL 15 (not installed)")
741+
return
742+
711743
# Check if gatekeeper is in the postgres user's Nix profile
712744
result = run_ssh_command(
713745
host["ssh"],
@@ -742,6 +774,24 @@ def test_jit_pam_gatekeeper_profile(host):
742774

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

0 commit comments

Comments
 (0)