From 3918777dbde34646f0e2afe410f1faaecb5dc331 Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Thu, 14 Dec 2023 15:01:08 +0530 Subject: [PATCH 1/9] Audit: Check for Default values on Global Registration Template --- tests/foreman/ui/test_registration.py | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/foreman/ui/test_registration.py diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py new file mode 100644 index 00000000000..686a9e85a29 --- /dev/null +++ b/tests/foreman/ui/test_registration.py @@ -0,0 +1,62 @@ +"""Tests for registration. + +:Requirement: Registration + +:CaseLevel: Acceptance + +:CaseComponent: Registration + +:CaseAutomation: Automated + +:CaseImportance: Critical + +:Team: Rocket + +:TestType: Functional + +:Upstream: No +""" +from robottelo.utils.datafactory import gen_string + +def test_positive_verify_default_values_for_global_registration( + session, + target_sat, + default_org, + default_location, + default_os, +): + """Check for all the Default values pre-populated in the global registration template + + :id: 34122bf3-ae23-47ca-ba3d-da0653d8fd33 + + :expectedresults: Some of the fields in the form should be populated + e.g. organizatoin, location,remote-execution, insights setup. + + :CaseLevel: Integration + + :steps: + 1.Check for the default values in the global registration template + """ + ak = target_sat.cli_factory.make_activation_key( + {'organization-id': default_org.id, 'name': gen_string('alpha')} + ) + with session: + session.organization.select(org_name=default_org.name) + session.location.select(loc_name=default_location.name) + cmd = session.host.get_register_command({'general.activation_keys': ak.name, 'general.operating_system': default_os.title}, full_read=True) + + assert cmd['general']['organization'] == 'Default Organization' + assert cmd['general']['location'] == 'Default Location' + assert cmd['advanced']['setup_rex'] == 'Inherit from host parameter (yes)' + assert cmd['advanced']['setup_insights'] == 'Inherit from host parameter (yes)' + assert cmd['advanced']['token_life_time'] == '4' + assert cmd['advanced']['rex_pull_mode'] == 'Inherit from host parameter (no)' + assert cmd['general']['capsule'] == 'Nothing to select.' + assert cmd['advanced']['update_packages'] == False + assert cmd['advanced']['ignore_error'] == False + assert cmd['advanced']['force'] == False + + + + + From b5c9b91b9faec2026a04a4ce132839232d2182b2 Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Thu, 14 Dec 2023 15:06:31 +0530 Subject: [PATCH 2/9] mend --- pytest_fixtures/core/xdist.py | 6 +++--- robottelo/hosts.py | 15 +++++++-------- tests/foreman/ui/test_registration.py | 7 +------ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index 4d02fe026d0..ac8f52ab663 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -30,9 +30,9 @@ def align_to_satellite(request, worker_id, satellite_factory): worker_pos = int(worker_id.replace('gw', '')) # attempt to add potential satellites from the broker inventory file - if settings.server.inventory_filter: - hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) - settings.server.hostnames += [host.hostname for host in hosts] + # if settings.server.inventory_filter: + # hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) + # settings.server.hostnames += [host.hostname for host in hosts] # attempt to align a worker to a satellite if settings.server.xdist_behavior == 'run-on-one' and settings.server.hostnames: diff --git a/robottelo/hosts.py b/robottelo/hosts.py index b167d1eba26..d2e82303989 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1818,7 +1818,6 @@ def omit_credentials(self): yield self.omitting_credentials = False - @contextmanager def ui_session(self, testname=None, user=None, password=None, url=None, login=True): """Initialize an airgun Session object and store it as self.ui_session""" @@ -1840,15 +1839,15 @@ def get_caller(): hostname=self.hostname, login=login, ) - yield ui_session + return ui_session except Exception: raise - finally: - video_url = settings.ui.grid_url.replace( - ':4444', f'/videos/{ui_session.ui_session_id}.mp4' - ) - self.record_property('video_url', video_url) - self.record_property('session_id', ui_session.ui_session_id) + # finally: + # video_url = settings.ui.grid_url.replace( + # ':4444', f'/videos/{ui_session.ui_session_id}.mp4' + # ) + # self.record_property('video_url', video_url) + # self.record_property('session_id', ui_session.ui_session_id) @property def satellite(self): diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index 686a9e85a29..b77013576cb 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -54,9 +54,4 @@ def test_positive_verify_default_values_for_global_registration( assert cmd['general']['capsule'] == 'Nothing to select.' assert cmd['advanced']['update_packages'] == False assert cmd['advanced']['ignore_error'] == False - assert cmd['advanced']['force'] == False - - - - - + assert cmd['advanced']['force'] == False \ No newline at end of file From a027846523099d30d609cec898b4d5acb48dab4c Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Thu, 14 Dec 2023 15:09:53 +0530 Subject: [PATCH 3/9] mend --- pytest_fixtures/core/xdist.py | 6 +++--- robottelo/hosts.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index ac8f52ab663..4d02fe026d0 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -30,9 +30,9 @@ def align_to_satellite(request, worker_id, satellite_factory): worker_pos = int(worker_id.replace('gw', '')) # attempt to add potential satellites from the broker inventory file - # if settings.server.inventory_filter: - # hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) - # settings.server.hostnames += [host.hostname for host in hosts] + if settings.server.inventory_filter: + hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) + settings.server.hostnames += [host.hostname for host in hosts] # attempt to align a worker to a satellite if settings.server.xdist_behavior == 'run-on-one' and settings.server.hostnames: diff --git a/robottelo/hosts.py b/robottelo/hosts.py index d2e82303989..b167d1eba26 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1818,6 +1818,7 @@ def omit_credentials(self): yield self.omitting_credentials = False + @contextmanager def ui_session(self, testname=None, user=None, password=None, url=None, login=True): """Initialize an airgun Session object and store it as self.ui_session""" @@ -1839,15 +1840,15 @@ def get_caller(): hostname=self.hostname, login=login, ) - return ui_session + yield ui_session except Exception: raise - # finally: - # video_url = settings.ui.grid_url.replace( - # ':4444', f'/videos/{ui_session.ui_session_id}.mp4' - # ) - # self.record_property('video_url', video_url) - # self.record_property('session_id', ui_session.ui_session_id) + finally: + video_url = settings.ui.grid_url.replace( + ':4444', f'/videos/{ui_session.ui_session_id}.mp4' + ) + self.record_property('video_url', video_url) + self.record_property('session_id', ui_session.ui_session_id) @property def satellite(self): From cd2ec331cff2025ad493c9901c2e70af1fd0ee0a Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Thu, 14 Dec 2023 15:13:29 +0530 Subject: [PATCH 4/9] mend --- tests/foreman/ui/test_registration.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index b77013576cb..df6dca78aa0 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -18,6 +18,7 @@ """ from robottelo.utils.datafactory import gen_string + def test_positive_verify_default_values_for_global_registration( session, target_sat, @@ -43,8 +44,11 @@ def test_positive_verify_default_values_for_global_registration( with session: session.organization.select(org_name=default_org.name) session.location.select(loc_name=default_location.name) - cmd = session.host.get_register_command({'general.activation_keys': ak.name, 'general.operating_system': default_os.title}, full_read=True) - + cmd = session.host.get_register_command( + {'general.activation_keys': ak.name, 'general.operating_system': default_os.title}, + full_read=True, + ) + assert cmd['general']['organization'] == 'Default Organization' assert cmd['general']['location'] == 'Default Location' assert cmd['advanced']['setup_rex'] == 'Inherit from host parameter (yes)' @@ -52,6 +56,6 @@ def test_positive_verify_default_values_for_global_registration( assert cmd['advanced']['token_life_time'] == '4' assert cmd['advanced']['rex_pull_mode'] == 'Inherit from host parameter (no)' assert cmd['general']['capsule'] == 'Nothing to select.' - assert cmd['advanced']['update_packages'] == False - assert cmd['advanced']['ignore_error'] == False - assert cmd['advanced']['force'] == False \ No newline at end of file + assert cmd['advanced']['update_packages'] is False + assert cmd['advanced']['ignore_error'] is False + assert cmd['advanced']['force'] is False From 4efa0591fddf31fc82f3a8a6381664b89cdde3e4 Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Fri, 15 Dec 2023 12:51:37 +0530 Subject: [PATCH 5/9] mend --- pytest_fixtures/core/xdist.py | 6 +++--- tests/foreman/ui/test_registration.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index 4d02fe026d0..ac8f52ab663 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -30,9 +30,9 @@ def align_to_satellite(request, worker_id, satellite_factory): worker_pos = int(worker_id.replace('gw', '')) # attempt to add potential satellites from the broker inventory file - if settings.server.inventory_filter: - hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) - settings.server.hostnames += [host.hostname for host in hosts] + # if settings.server.inventory_filter: + # hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) + # settings.server.hostnames += [host.hostname for host in hosts] # attempt to align a worker to a satellite if settings.server.xdist_behavior == 'run-on-one' and settings.server.hostnames: diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index df6dca78aa0..1bb6e40b1f7 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -21,7 +21,7 @@ def test_positive_verify_default_values_for_global_registration( session, - target_sat, + module_target_sat, default_org, default_location, default_os, @@ -31,14 +31,14 @@ def test_positive_verify_default_values_for_global_registration( :id: 34122bf3-ae23-47ca-ba3d-da0653d8fd33 :expectedresults: Some of the fields in the form should be populated - e.g. organizatoin, location,remote-execution, insights setup. + e.g. organization, location,remote-execution, insights setup. - :CaseLevel: Integration + :CaseLevel: Component :steps: 1.Check for the default values in the global registration template """ - ak = target_sat.cli_factory.make_activation_key( + ak = module_target_sat.cli_factory.make_activation_key( {'organization-id': default_org.id, 'name': gen_string('alpha')} ) with session: @@ -58,4 +58,4 @@ def test_positive_verify_default_values_for_global_registration( assert cmd['general']['capsule'] == 'Nothing to select.' assert cmd['advanced']['update_packages'] is False assert cmd['advanced']['ignore_error'] is False - assert cmd['advanced']['force'] is False + assert cmd['advanced']['force'] is False \ No newline at end of file From 83faca63c39bb331a1b2d4f1fad8c95c4c4dc83e Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Fri, 15 Dec 2023 12:54:56 +0530 Subject: [PATCH 6/9] mend --- tests/foreman/ui/test_registration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index 1bb6e40b1f7..09c069a7313 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -58,4 +58,4 @@ def test_positive_verify_default_values_for_global_registration( assert cmd['general']['capsule'] == 'Nothing to select.' assert cmd['advanced']['update_packages'] is False assert cmd['advanced']['ignore_error'] is False - assert cmd['advanced']['force'] is False \ No newline at end of file + assert cmd['advanced']['force'] is False From ad1fa4ce7bf4e698f595ec8aa6e35cb3bfec16e1 Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Fri, 15 Dec 2023 21:29:12 +0530 Subject: [PATCH 7/9] mend --- pytest_fixtures/core/xdist.py | 6 +++--- tests/foreman/ui/test_registration.py | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index ac8f52ab663..4d02fe026d0 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -30,9 +30,9 @@ def align_to_satellite(request, worker_id, satellite_factory): worker_pos = int(worker_id.replace('gw', '')) # attempt to add potential satellites from the broker inventory file - # if settings.server.inventory_filter: - # hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) - # settings.server.hostnames += [host.hostname for host in hosts] + if settings.server.inventory_filter: + hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter) + settings.server.hostnames += [host.hostname for host in hosts] # attempt to align a worker to a satellite if settings.server.xdist_behavior == 'run-on-one' and settings.server.hostnames: diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index 09c069a7313..24804b50971 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -20,42 +20,39 @@ def test_positive_verify_default_values_for_global_registration( - session, module_target_sat, default_org, default_location, - default_os, ): """Check for all the Default values pre-populated in the global registration template :id: 34122bf3-ae23-47ca-ba3d-da0653d8fd33 - :expectedresults: Some of the fields in the form should be populated - e.g. organization, location,remote-execution, insights setup. + :expectedresults: Default fields in the form should be auto-populated + e.g. organization, location, rex, insights setup, etc :CaseLevel: Component :steps: - 1.Check for the default values in the global registration template + 1. Check for the default values in the global registration template """ - ak = module_target_sat.cli_factory.make_activation_key( + module_target_sat.cli_factory.make_activation_key( {'organization-id': default_org.id, 'name': gen_string('alpha')} ) - with session: + with module_target_sat.ui_session() as session: session.organization.select(org_name=default_org.name) session.location.select(loc_name=default_location.name) cmd = session.host.get_register_command( - {'general.activation_keys': ak.name, 'general.operating_system': default_os.title}, full_read=True, ) assert cmd['general']['organization'] == 'Default Organization' assert cmd['general']['location'] == 'Default Location' + assert cmd['general']['capsule'] == 'Nothing to select.' assert cmd['advanced']['setup_rex'] == 'Inherit from host parameter (yes)' assert cmd['advanced']['setup_insights'] == 'Inherit from host parameter (yes)' assert cmd['advanced']['token_life_time'] == '4' assert cmd['advanced']['rex_pull_mode'] == 'Inherit from host parameter (no)' - assert cmd['general']['capsule'] == 'Nothing to select.' assert cmd['advanced']['update_packages'] is False assert cmd['advanced']['ignore_error'] is False assert cmd['advanced']['force'] is False From fc4fc268b8c7de72a293555ad8b31e6efb4a4d8a Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Tue, 19 Dec 2023 16:04:49 +0530 Subject: [PATCH 8/9] mend --- tests/foreman/ui/test_registration.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index 24804b50971..288dc066bc1 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -22,7 +22,6 @@ def test_positive_verify_default_values_for_global_registration( module_target_sat, default_org, - default_location, ): """Check for all the Default values pre-populated in the global registration template @@ -40,12 +39,9 @@ def test_positive_verify_default_values_for_global_registration( {'organization-id': default_org.id, 'name': gen_string('alpha')} ) with module_target_sat.ui_session() as session: - session.organization.select(org_name=default_org.name) - session.location.select(loc_name=default_location.name) cmd = session.host.get_register_command( full_read=True, ) - assert cmd['general']['organization'] == 'Default Organization' assert cmd['general']['location'] == 'Default Location' assert cmd['general']['capsule'] == 'Nothing to select.' From e54bffa030ca72785403295e72efa79298a882db Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Tue, 19 Dec 2023 16:29:20 +0530 Subject: [PATCH 9/9] mend --- tests/foreman/ui/test_registration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/foreman/ui/test_registration.py b/tests/foreman/ui/test_registration.py index 288dc066bc1..1af25fe7a40 100644 --- a/tests/foreman/ui/test_registration.py +++ b/tests/foreman/ui/test_registration.py @@ -45,6 +45,9 @@ def test_positive_verify_default_values_for_global_registration( assert cmd['general']['organization'] == 'Default Organization' assert cmd['general']['location'] == 'Default Location' assert cmd['general']['capsule'] == 'Nothing to select.' + assert cmd['general']['operating_system'] == '' + assert cmd['general']['host_group'] == 'Nothing to select.' + assert cmd['general']['insecure'] is False assert cmd['advanced']['setup_rex'] == 'Inherit from host parameter (yes)' assert cmd['advanced']['setup_insights'] == 'Inherit from host parameter (yes)' assert cmd['advanced']['token_life_time'] == '4'