Skip to content

PMM. Fix auth tests #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions pmm_psmdb_diffauth_setup/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@

def run_test(add_db_command):
try:
docker_pmm_client.check_output('pmm-admin remove mongodb psmdb-server', timeout=30)
except AssertionError:
pass
output = docker_pmm_client.check_output('pmm-admin list --json', timeout=30)
services_info = json.loads(output)
except (AssertionError, json.JSONDecodeError):
pytest.fail("Failed to get or parse service list from pmm-admin")
services_to_remove = []
for service in services_info.get("service", []):
service_type = service.get("service_type")
service_name = service.get("service_name", "")
if service_type == "SERVICE_TYPE_MONGODB_SERVICE" and service_name.startswith("psmdb-server"):
services_to_remove.append(service_name)
for service_name in services_to_remove:
try:
docker_pmm_client.check_output(f'pmm-admin remove mongodb {service_name}', timeout=30)
except AssertionError:
pass
try:
docker_pmm_client.check_output(add_db_command, timeout=30)
except AssertionError:
Expand All @@ -26,7 +38,7 @@ def run_test(add_db_command):
pmm_admin_list = json.loads(docker_pmm_client.check_output('pmm-admin list --json', timeout=30))
for agent in pmm_admin_list['agent']:
if agent['agent_type'] == 'AGENT_TYPE_MONGODB_EXPORTER':
agent_id = "mypass"
agent_id = "mypass" if "GSSAPI" not in add_db_command else agent['agent_id']
agent_port = agent['port']
break
try:
Expand Down Expand Up @@ -93,12 +105,14 @@ def test_ldap_auth_tls():
'--tls --tls-certificate-key-file=/mongodb_certs/client.pem --tls-ca-file=/mongodb_certs/ca-certs.pem '
'--cluster=mycluster')

@pytest.mark.skip(reason="Kerberos support in PMM was reverted")
def test_kerberos_auth_wo_tls():
run_test('pmm-admin add mongodb psmdb-server --username="[email protected]" --password=password1 '
'--host=psmdb-server --port 27017 '
'--authentication-mechanism=GSSAPI --authentication-database=\'$external\' '
'--cluster=mycluster')

@pytest.mark.skip(reason="Kerberos support in PMM was reverted")
def test_kerberos_auth_tls():
run_test('pmm-admin add mongodb psmdb-server --username="[email protected]" --password=password1 '
'--host=psmdb-server --port 27017 '
Expand Down
Loading