From 8fba019c85f9bd3c03aece2648dfc91a629f1e54 Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Mon, 17 Jun 2024 19:02:42 +0530 Subject: [PATCH 1/6] client registration with capsule based on setting value --- tests/foreman/cli/test_host.py | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index ad9a7d0b49b..d68deace783 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2683,3 +2683,71 @@ 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('8') +@pytest.mark.parametrize( + 'setting_update', ['validate_host_lce_content_source_coherence'], indirect=False +) +def test_positive_host_registration_with_capsule( + target_sat, + setting_update, + function_sca_manifest_org, + function_activation_key, + rhel_contenthost, + 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 + + :BZ: 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 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 + + :CaseImportance: Medium + """ + # set a new proxy + target_sat.cli.Capsule.update( + {'name': capsule_configured.hostname, 'organization-ids': function_sca_manifest_org.id} + ) + # Register client with capsule when settings "validate_host_lce_content_source_coherence" is set to Yes + target_sat.cli.Settings.set( + {'name': 'validate_host_lce_content_source_coherence', 'value': 'true'} + ) + result = rhel_contenthost.register( + function_sca_manifest_org, None, function_activation_key.name, capsule_configured + ) + 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 str(result.stderr[1]), f"Error is: {result.stderr}" + assert "HTTP error code 422" in str(result.stderr[1]), f"Error is: {result.stderr}" + rhel_contenthost.unregister() + + # Re-register client with settings "validate_host_lce_content_source_coherence" is set to No + target_sat.cli.Settings.set( + {'name': 'validate_host_lce_content_source_coherence', 'value': 'false'} + ) + result = rhel_contenthost.register( + function_sca_manifest_org, None, function_activation_key.name, capsule_configured + ) + 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 str(result.stderr[1]), f"Error is: {result.stderr}" + assert "HTTP error code 422" not in str(result.stderr[1]), f"Error is: {result.stderr}" + rhel_contenthost.unregister() From 4217856029fb9f9a10ee8e435d91f9943ec4d4a5 Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Wed, 19 Jun 2024 10:14:52 +0530 Subject: [PATCH 2/6] client registration with capsule based on setting value, fixed error --- tests/foreman/cli/test_host.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index d68deace783..111b6dfe9a8 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2734,8 +2734,8 @@ def test_positive_host_registration_with_capsule( 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 str(result.stderr[1]), f"Error is: {result.stderr}" - assert "HTTP error code 422" in str(result.stderr[1]), f"Error is: {result.stderr}" + assert 'Validation failed' in result.stderr, f'Error is: {result.stderr}' + assert 'HTTP error code 422' in result.stderr, f'Error is: {result.stderr}' rhel_contenthost.unregister() # Re-register client with settings "validate_host_lce_content_source_coherence" is set to No @@ -2748,6 +2748,6 @@ def test_positive_host_registration_with_capsule( 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 str(result.stderr[1]), f"Error is: {result.stderr}" - assert "HTTP error code 422" not in str(result.stderr[1]), f"Error is: {result.stderr}" + assert 'Validation failed' not in result.stderr, f'Error is: {result.stderr}' + assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}' rhel_contenthost.unregister() From 5358fb7a2f7e319bc451f504ae176f43de89f81c Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Fri, 21 Jun 2024 15:46:45 +0530 Subject: [PATCH 3/6] worked on minor review comments --- tests/foreman/cli/test_host.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index 111b6dfe9a8..c2cd3e3afe2 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2685,8 +2685,7 @@ def test_positive_create_host_with_lifecycle_environment_name( assert found_host, 'Assertion failed: host not found' -@pytest.mark.no_containers -@pytest.mark.rhel_ver_match('8') +@pytest.mark.rhel_ver_match('^6') @pytest.mark.parametrize( 'setting_update', ['validate_host_lce_content_source_coherence'], indirect=False ) @@ -2702,23 +2701,26 @@ def test_positive_host_registration_with_capsule( :id: 17dbec62-eed4-4a51-9927-80919457a124 - :BZ: SAT-22048 + :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 any error like "Validation failed" or "HTTP error code 422" + 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 - :CaseImportance: Medium + :parametrized: yes + + :CaseImportance: High """ # set a new proxy target_sat.cli.Capsule.update( @@ -2729,25 +2731,31 @@ def test_positive_host_registration_with_capsule( {'name': 'validate_host_lce_content_source_coherence', 'value': 'true'} ) result = rhel_contenthost.register( - function_sca_manifest_org, None, function_activation_key.name, capsule_configured + function_sca_manifest_org, + None, + function_activation_key.name, + 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}' assert 'HTTP error code 422' in result.stderr, f'Error is: {result.stderr}' - rhel_contenthost.unregister() # Re-register client with settings "validate_host_lce_content_source_coherence" is set to No target_sat.cli.Settings.set( {'name': 'validate_host_lce_content_source_coherence', 'value': 'false'} ) result = rhel_contenthost.register( - function_sca_manifest_org, None, function_activation_key.name, capsule_configured + function_sca_manifest_org, + None, + function_activation_key.name, + 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}' assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}' - rhel_contenthost.unregister() From 2b2c5d74191229c064f7c44b77ee7521bb6ea9be Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Sun, 23 Jun 2024 12:06:26 +0530 Subject: [PATCH 4/6] bypass assertion for rhel7 version --- tests/foreman/cli/test_host.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index c2cd3e3afe2..153b2ba2fa2 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2741,7 +2741,8 @@ def test_positive_host_registration_with_capsule( # 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}' - assert 'HTTP error code 422' in result.stderr, f'Error is: {result.stderr}' + if '7' not in rhel_contenthost.deploy_rhel_version: + 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 target_sat.cli.Settings.set( @@ -2758,4 +2759,5 @@ def test_positive_host_registration_with_capsule( # 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}' - assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}' + if '7' not in rhel_contenthost.deploy_rhel_version: + assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}' From 5e6dfe44e49d9dda8496aa74486ed53ca0145d45 Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Thu, 27 Jun 2024 17:41:59 +0530 Subject: [PATCH 5/6] resolve issue, which bypass rhel7 version --- tests/foreman/cli/test_host.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index 153b2ba2fa2..39ed5a71b01 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2684,12 +2684,11 @@ def test_positive_create_host_with_lifecycle_environment_name( found_host = any(new_host.name in i.values() for i in hosts) assert found_host, 'Assertion failed: host not found' - @pytest.mark.rhel_ver_match('^6') @pytest.mark.parametrize( 'setting_update', ['validate_host_lce_content_source_coherence'], indirect=False ) -def test_positive_host_registration_with_capsule( +def test_host_registration_with_capsule_using_content_coherence( target_sat, setting_update, function_sca_manifest_org, @@ -2741,7 +2740,7 @@ def test_positive_host_registration_with_capsule( # 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 '7' not in rhel_contenthost.deploy_rhel_version: + if not 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 @@ -2759,5 +2758,5 @@ def test_positive_host_registration_with_capsule( # 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 '7' not in rhel_contenthost.deploy_rhel_version: - assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}' + if not rhel_contenthost.os_version.major == 7: + assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}' \ No newline at end of file From 099be8d959e00df6933001560f59becfa5b2739e Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Fri, 28 Jun 2024 15:43:19 +0530 Subject: [PATCH 6/6] used module level fixture instead of function level --- tests/foreman/cli/test_host.py | 38 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index 39ed5a71b01..977d3754bf5 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -2684,17 +2684,19 @@ def test_positive_create_host_with_lifecycle_environment_name( found_host = any(new_host.name in i.values() for i in hosts) assert found_host, 'Assertion failed: host not found' -@pytest.mark.rhel_ver_match('^6') + +@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( - target_sat, + module_target_sat, setting_update, - function_sca_manifest_org, - function_activation_key, + module_sca_manifest_org, + module_activation_key, rhel_contenthost, - capsule_configured, + module_capsule_configured, ): """Register client with capsule when settings "validate_host_lce_content_source_coherence" is set to Yes/No @@ -2722,41 +2724,41 @@ def test_host_registration_with_capsule_using_content_coherence( :CaseImportance: High """ # set a new proxy - target_sat.cli.Capsule.update( - {'name': capsule_configured.hostname, 'organization-ids': function_sca_manifest_org.id} + 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 - target_sat.cli.Settings.set( + module_target_sat.cli.Settings.set( {'name': 'validate_host_lce_content_source_coherence', 'value': 'true'} ) result = rhel_contenthost.register( - function_sca_manifest_org, + module_sca_manifest_org, None, - function_activation_key.name, - capsule_configured, + 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 not rhel_contenthost.os_version.major == 7: + 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 - target_sat.cli.Settings.set( + module_target_sat.cli.Settings.set( {'name': 'validate_host_lce_content_source_coherence', 'value': 'false'} ) result = rhel_contenthost.register( - function_sca_manifest_org, + module_sca_manifest_org, None, - function_activation_key.name, - capsule_configured, + 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 not rhel_contenthost.os_version.major == 7: - assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}' \ No newline at end of file + if rhel_contenthost.os_version.major != 7: + assert 'HTTP error code 422' not in result.stderr, f'Error is: {result.stderr}'