diff --git a/tests/foreman/destructive/test_installer.py b/tests/foreman/destructive/test_installer.py index da213102b87..58a8524a102 100644 --- a/tests/foreman/destructive/test_installer.py +++ b/tests/foreman/destructive/test_installer.py @@ -140,3 +140,43 @@ def test_positive_installer_certs_regenerate(target_sat): ) assert result.status == 0 assert 'FAIL' not in target_sat.cli.Base.ping() + + +def test_handle_invalid_certificate(cert_setup_destructive_teardown): + """Satellite installer should not do any harmful changes to existing satellite after attempt + to use invalid certificates. + + :id: 97b72faf-4684-4d8c-ae0e-1ebd5085620b + + :steps: + 1. Launch satellite installer and attempt to use invalid certificates + + :expectedresults: Satellite installer should fail and Satellite should be running + + :BZ: 2221621, 2238363 + + :customerscenario: true + + """ + cert_data, satellite = cert_setup_destructive_teardown + + # check if satellite is running + result = satellite.execute('hammer ping') + assert result.status == 0, f'Hammer Ping failed:\n{result.stderr}' + + # attempt to use invalid certificates + result = satellite.install( + InstallerCommand( + 'certs-update-server', + 'certs-update-server-ca', + scenario='satellite', + certs_server_cert='"/root/certs/invalid.crt"', + certs_server_key='"/root/certs/invalid.key"', + certs_server_ca_cert=f'"/root/{cert_data["ca_bundle_file_name"]}"', + ) + ) + # installer should fail with non-zero value + assert result.status != 0 + + result = satellite.execute('hammer ping') + assert result.status == 0, f'Hammer Ping failed:\n{result.stderr}'