diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index f9260637123..c9bac2e2e3a 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2731,3 +2731,82 @@ def test_positive_create_host_with_lifecycle_environment_name( hosts = module_target_sat.cli.Host.list({'organization-id': module_org.id}) found_host = any(new_host.name in i.values() for i in hosts) assert found_host, 'Assertion failed: host not found' + + +@pytest.mark.no_containers +@pytest.mark.rhel_ver_match('9') +@pytest.mark.parametrize( + 'setting_update', ['validate_host_lce_content_source_coherence'], indirect=False +) +def test_host_registration_with_capsule_using_content_coherence( + module_target_sat, + setting_update, + module_sca_manifest_org, + module_activation_key, + rhel_contenthost, + module_capsule_configured, +): + """Register client with capsule when settings "validate_host_lce_content_source_coherence" is set to Yes/No + + :id: 17dbec62-eed4-4a51-9927-80919457a124 + + :Verifies: SAT-22048 + + :setup: + 1. Create AK which is associated with the organization + 2. Configure capsule with satellite + + :steps: + 1. Register client with capsule when settings "validate_host_lce_content_source_coherence" is set to Yes + 2. Check output for "HTTP error code 422: Validation failed: Content view environment content facets is invalid" + 3. Re-register client with settings "validate_host_lce_content_source_coherence" is set to No + 4. Check output there should not be any error like "Validation failed" or "HTTP error code 422" + + :expectedresults: Host registration success with error when settings set to Yes and Host registration success when + settings set to No + + :customerscenario: true + + :parametrized: yes + + :CaseImportance: High + """ + # set a new proxy + module_target_sat.cli.Capsule.update( + {'name': module_capsule_configured.hostname, 'organization-ids': module_sca_manifest_org.id} + ) + # Register client with capsule when settings "validate_host_lce_content_source_coherence" is set to Yes + module_target_sat.cli.Settings.set( + {'name': 'validate_host_lce_content_source_coherence', 'value': 'true'} + ) + result = rhel_contenthost.register( + module_sca_manifest_org, + None, + module_activation_key.name, + module_capsule_configured, + force=True, + ) + assert result.status == 0, f'Failed to register host: {result.stderr}' + + # Check output for "HTTP error code 422: Validation failed: Content view environment content facets is invalid" + assert 'Validation failed' in result.stderr, f'Error is: {result.stderr}' + if rhel_contenthost.os_version.major != 7: + assert 'HTTP error code 422' in result.stderr, f'Error is: {result.stderr}' + + # Re-register client with settings "validate_host_lce_content_source_coherence" is set to No + module_target_sat.cli.Settings.set( + {'name': 'validate_host_lce_content_source_coherence', 'value': 'false'} + ) + result = rhel_contenthost.register( + module_sca_manifest_org, + None, + module_activation_key.name, + module_capsule_configured, + force=True, + ) + assert result.status == 0, f'Failed to register host: {result.stderr}' + + # Check output there should not any error like "Validation failed" or "HTTP error code 422" + assert 'Validation failed' not in result.stderr, f'Error is: {result.stderr}' + if rhel_contenthost.os_version.major != 7: + assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}'