From 865e2a869afa7a0437c7b9d4d7e024abe321b354 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:03:35 -0500 Subject: [PATCH] [6.15.z] fixing the incorrect recording video url (#13722) fixing the incorrect recording video url (#13714) fixing the recording video url (cherry picked from commit de84bd3e1d30074534ac42c7e66718ec73e19929) Co-authored-by: Omkar Khatavkar --- pytest_fixtures/core/ui.py | 29 + tests/foreman/ui/test_activationkey.py | 140 ++-- tests/foreman/ui/test_bookmarks.py | 28 +- tests/foreman/ui/test_branding.py | 3 +- tests/foreman/ui/test_contenthost.py | 48 +- tests/foreman/ui/test_contentview_old.py | 606 +++++++++++------- tests/foreman/ui/test_dashboard.py | 42 +- tests/foreman/ui/test_discoveryrule.py | 9 +- tests/foreman/ui/test_errata.py | 52 +- tests/foreman/ui/test_host.py | 15 +- tests/foreman/ui/test_ldap_authentication.py | 183 +++--- tests/foreman/ui/test_lifecycleenvironment.py | 3 +- tests/foreman/ui/test_repository.py | 113 ++-- tests/foreman/ui/test_role.py | 60 +- tests/foreman/ui/test_settings.py | 22 +- tests/foreman/ui/test_subscription.py | 52 +- tests/foreman/ui/test_user.py | 7 +- tests/foreman/virtwho/conftest.py | 9 +- tests/foreman/virtwho/ui/test_esx.py | 17 +- 19 files changed, 827 insertions(+), 611 deletions(-) diff --git a/pytest_fixtures/core/ui.py b/pytest_fixtures/core/ui.py index f87f4cec0ad..298632f59f6 100644 --- a/pytest_fixtures/core/ui.py +++ b/pytest_fixtures/core/ui.py @@ -2,6 +2,7 @@ import pytest from requests.exceptions import HTTPError +from robottelo.hosts import Satellite from robottelo.logging import logger @@ -70,3 +71,31 @@ def test_foo(autosession): """ with target_sat.ui_session(test_name, ui_user.login, ui_user.password) as started_session: yield started_session + + +@pytest.fixture(autouse=True) +def ui_session_record_property(request, record_property): + """ + Autouse fixture to set the record_property attribute for Satellite instances in the test. + + This fixture iterates over all fixtures in the current test node + (excluding the current fixture) and sets the record_property attribute + for instances of the Satellite class. + + Args: + request: The pytest request object. + record_property: The value to set for the record_property attribute. + """ + test_directories = [ + 'tests/foreman/destructive', + 'tests/foreman/ui', + 'tests/foreman/sanity', + 'tests/foreman/virtwho', + ] + test_file_path = request.node.fspath.strpath + if any(directory in test_file_path for directory in test_directories): + for fixture in request.node.fixturenames: + if request.fixturename != fixture: + if isinstance(request.getfixturevalue(fixture), Satellite): + sat = request.getfixturevalue(fixture) + sat.record_property = record_property diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index dd2d77f5795..7630a1761b9 100644 --- a/tests/foreman/ui/test_activationkey.py +++ b/tests/foreman/ui/test_activationkey.py @@ -13,10 +13,8 @@ """ import random -from airgun.session import Session from broker import Broker from fauxfactory import gen_string -from nailgun import entities import pytest from robottelo import constants @@ -28,7 +26,7 @@ @pytest.mark.e2e @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_end_to_end_crud(session, module_org): +def test_positive_end_to_end_crud(session, module_org, module_target_sat): """Perform end to end testing for activation key component :id: b6b98c45-e41e-4c7a-9be4-997273b7e24d @@ -39,7 +37,7 @@ def test_positive_end_to_end_crud(session, module_org): """ name = gen_string('alpha') new_name = gen_string('alpha') - cv = entities.ContentView(organization=module_org).create() + cv = module_target_sat.api.ContentView(organization=module_org).create() cv.publish() with session: # Create activation key with content view and LCE assigned @@ -89,7 +87,7 @@ def test_positive_end_to_end_register( :CaseImportance: High """ org = function_entitlement_manifest_org - lce = entities.LifecycleEnvironment(organization=org).create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() repos_collection.setup_content(org.id, lce.id, upload_manifest=False) ak_name = repos_collection.setup_content_data['activation_key']['name'] @@ -171,7 +169,7 @@ def test_positive_search_scoped(session, module_org, target_sat): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_create_with_host_collection(session, module_org): +def test_positive_create_with_host_collection(session, module_org, module_target_sat): """Create Activation key with Host Collection :id: 0e4ad2b4-47a7-4087-828f-2b0535a97b69 @@ -179,7 +177,7 @@ def test_positive_create_with_host_collection(session, module_org): :expectedresults: Activation key is created """ name = gen_string('alpha') - hc = entities.HostCollection(organization=module_org).create() + hc = module_target_sat.api.HostCollection(organization=module_org).create() with session: session.activationkey.create({'name': name, 'lce': {constants.ENVIRONMENT: True}}) assert session.activationkey.search(name)[0]['Name'] == name @@ -226,21 +224,21 @@ def test_positive_add_host_collection_non_admin(module_org, test_name, target_sa :BZ: 1473212 """ ak_name = gen_string('alpha') - hc = entities.HostCollection(organization=module_org).create() + hc = target_sat.api.HostCollection(organization=module_org).create() # Create non-admin user with specified permissions - roles = [entities.Role().create()] + roles = [target_sat.api.Role().create()] user_permissions = { 'Katello::ActivationKey': constants.PERMISSIONS['Katello::ActivationKey'], 'Katello::HostCollection': constants.PERMISSIONS['Katello::HostCollection'], } - viewer_role = entities.Role().search(query={'search': 'name="Viewer"'})[0] + viewer_role = target_sat.api.Role().search(query={'search': 'name="Viewer"'})[0] roles.append(viewer_role) target_sat.api_factory.create_role_permissions(roles[0], user_permissions) password = gen_string('alphanumeric') - user = entities.User( + user = target_sat.api.User( admin=False, role=roles, password=password, organization=[module_org] ).create() - with Session(test_name, user=user.login, password=password) as session: + with target_sat.ui_session(test_name, user=user.login, password=password) as session: session.activationkey.create({'name': ak_name, 'lce': {constants.ENVIRONMENT: True}}) assert session.activationkey.search(ak_name)[0]['Name'] == ak_name session.activationkey.add_host_collection(ak_name, hc.name) @@ -260,21 +258,21 @@ def test_positive_remove_host_collection_non_admin(module_org, test_name, target listed """ ak_name = gen_string('alpha') - hc = entities.HostCollection(organization=module_org).create() + hc = target_sat.api.HostCollection(organization=module_org).create() # Create non-admin user with specified permissions - roles = [entities.Role().create()] + roles = [target_sat.api.Role().create()] user_permissions = { 'Katello::ActivationKey': constants.PERMISSIONS['Katello::ActivationKey'], 'Katello::HostCollection': constants.PERMISSIONS['Katello::HostCollection'], } - viewer_role = entities.Role().search(query={'search': 'name="Viewer"'})[0] + viewer_role = target_sat.api.Role().search(query={'search': 'name="Viewer"'})[0] roles.append(viewer_role) target_sat.api_factory.create_role_permissions(roles[0], user_permissions) password = gen_string('alphanumeric') - user = entities.User( + user = target_sat.api.User( admin=False, role=roles, password=password, organization=[module_org] ).create() - with Session(test_name, user=user.login, password=password) as session: + with target_sat.ui_session(test_name, user=user.login, password=password) as session: session.activationkey.create({'name': ak_name, 'lce': {constants.ENVIRONMENT: True}}) assert session.activationkey.search(ak_name)[0]['Name'] == ak_name session.activationkey.add_host_collection(ak_name, hc.name) @@ -545,8 +543,8 @@ def test_positive_add_rh_and_custom_products( custom_product_name = gen_string('alpha') repo_name = gen_string('alpha') org = function_entitlement_manifest_org - product = entities.Product(name=custom_product_name, organization=org).create() - repo = entities.Repository(name=repo_name, product=product).create() + product = target_sat.api.Product(name=custom_product_name, organization=org).create() + repo = target_sat.api.Repository(name=repo_name, product=product).create() rhel_repo_id = target_sat.api_factory.enable_rhrepo_and_fetchid( basearch=rh_repo['basearch'], org_id=org.id, @@ -556,7 +554,7 @@ def test_positive_add_rh_and_custom_products( releasever=rh_repo['releasever'], ) for repo_id in [rhel_repo_id, repo.id]: - entities.Repository(id=repo_id).sync() + target_sat.api.Repository(id=repo_id).sync() with session: session.organization.select(org.name) session.activationkey.create( @@ -599,19 +597,21 @@ def test_positive_fetch_product_content(target_sat, function_entitlement_manifes reposet=constants.REPOSET['rhst7'], releasever=None, ) - rh_repo = entities.Repository(id=rh_repo_id).read() + rh_repo = target_sat.api.Repository(id=rh_repo_id).read() rh_repo.sync() - custom_product = entities.Product(organization=org).create() - custom_repo = entities.Repository( + custom_product = target_sat.api.Product(organization=org).create() + custom_repo = target_sat.api.Repository( name=gen_string('alphanumeric').upper(), # first letter is always # uppercase on product content page, workarounding it for # successful checks product=custom_product, ).create() custom_repo.sync() - cv = entities.ContentView(organization=org, repository=[rh_repo_id, custom_repo.id]).create() + cv = target_sat.api.ContentView( + organization=org, repository=[rh_repo_id, custom_repo.id] + ).create() cv.publish() - ak = entities.ActivationKey(content_view=cv, organization=org).create() + ak = target_sat.api.ActivationKey(content_view=cv, organization=org).create() with session: session.organization.select(org.name) for subscription in (constants.DEFAULT_SUBSCRIPTION_NAME, custom_product.name): @@ -624,7 +624,7 @@ def test_positive_fetch_product_content(target_sat, function_entitlement_manifes @pytest.mark.e2e @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_access_non_admin_user(session, test_name): +def test_positive_access_non_admin_user(session, test_name, target_sat): """Access activation key that has specific name and assigned environment by user that has filter configured for that specific activation key @@ -639,24 +639,26 @@ def test_positive_access_non_admin_user(session, test_name): """ ak_name = gen_string('alpha') non_searchable_ak_name = gen_string('alpha') - org = entities.Organization().create() + org = target_sat.api.Organization().create() envs_list = ['STAGING', 'DEV', 'IT', 'UAT', 'PROD'] for name in envs_list: - entities.LifecycleEnvironment(name=name, organization=org).create() + target_sat.api.LifecycleEnvironment(name=name, organization=org).create() env_name = random.choice(envs_list) - cv = entities.ContentView(organization=org).create() + cv = target_sat.api.ContentView(organization=org).create() cv.publish() content_view_version = cv.read().version[0] content_view_version.promote( - data={'environment_ids': [entities.LifecycleEnvironment(name=env_name).search()[0].id]} + data={ + 'environment_ids': [target_sat.api.LifecycleEnvironment(name=env_name).search()[0].id] + } ) # Create new role - role = entities.Role().create() + role = target_sat.api.Role().create() # Create filter with predefined activation keys search criteria envs_condition = ' or '.join(['environment = ' + s for s in envs_list]) - entities.Filter( + target_sat.api.Filter( organization=[org], - permission=entities.Permission().search( + permission=target_sat.api.Permission().search( filters={'name': 'view_activation_keys'}, query={'search': 'resource_type="Katello::ActivationKey"'}, ), @@ -665,20 +667,24 @@ def test_positive_access_non_admin_user(session, test_name): ).create() # Add permissions for Organization and Location - entities.Filter( - permission=entities.Permission().search(query={'search': 'resource_type="Organization"'}), + target_sat.api.Filter( + permission=target_sat.api.Permission().search( + query={'search': 'resource_type="Organization"'} + ), role=role, ).create() - entities.Filter( - permission=entities.Permission().search(query={'search': 'resource_type="Location"'}), + target_sat.api.Filter( + permission=target_sat.api.Permission().search(query={'search': 'resource_type="Location"'}), role=role, ).create() # Create new user with a configured role - default_loc = entities.Location().search(query={'search': f'name="{constants.DEFAULT_LOC}"'})[0] + default_loc = target_sat.api.Location().search( + query={'search': f'name="{constants.DEFAULT_LOC}"'} + )[0] user_login = gen_string('alpha') user_password = gen_string('alpha') - entities.User( + target_sat.api.User( role=[role], admin=False, login=user_login, @@ -699,7 +705,7 @@ def test_positive_access_non_admin_user(session, test_name): env_name ][env_name] - with Session(test_name, user=user_login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user_login, password=user_password) as session: session.organization.select(org.name) session.location.select(constants.DEFAULT_LOC) assert session.activationkey.search(ak_name)[0]['Name'] == ak_name @@ -710,7 +716,7 @@ def test_positive_access_non_admin_user(session, test_name): @pytest.mark.tier2 -def test_positive_remove_user(session, module_org, test_name): +def test_positive_remove_user(session, module_org, test_name, module_target_sat): """Delete any user who has previously created an activation key and check that activation key still exists @@ -723,9 +729,11 @@ def test_positive_remove_user(session, module_org, test_name): ak_name = gen_string('alpha') # Create user password = gen_string('alpha') - user = entities.User(admin=True, default_organization=module_org, password=password).create() + user = module_target_sat.api.User( + admin=True, default_organization=module_org, password=password + ).create() # Create Activation Key using new user credentials - with Session(test_name, user.login, password) as non_admin_session: + with module_target_sat.ui_session(test_name, user.login, password) as non_admin_session: non_admin_session.activationkey.create( {'name': ak_name, 'lce': {constants.ENVIRONMENT: True}} ) @@ -737,7 +745,7 @@ def test_positive_remove_user(session, module_org, test_name): @pytest.mark.tier2 -def test_positive_add_docker_repo_cv(session, module_org): +def test_positive_add_docker_repo_cv(session, module_org, module_target_sat): """Add docker repository to a non-composite content view and publish it. Then create an activation key and associate it with the Docker content view. @@ -747,13 +755,13 @@ def test_positive_add_docker_repo_cv(session, module_org): :expectedresults: Content view with docker repo can be added to activation key """ - lce = entities.LifecycleEnvironment(organization=module_org).create() - repo = entities.Repository( + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + repo = module_target_sat.api.Repository( content_type=constants.REPO_TYPE['docker'], - product=entities.Product(organization=module_org).create(), + product=module_target_sat.api.Product(organization=module_org).create(), url=constants.CONTAINER_REGISTRY_HUB, ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() @@ -770,7 +778,7 @@ def test_positive_add_docker_repo_cv(session, module_org): @pytest.mark.tier2 -def test_positive_add_docker_repo_ccv(session, module_org): +def test_positive_add_docker_repo_ccv(session, module_org, module_target_sat): """Add docker repository to a non-composite content view and publish it. Then add this content view to a composite content view and publish it. Create an activation key and associate it with the composite Docker content @@ -781,19 +789,19 @@ def test_positive_add_docker_repo_ccv(session, module_org): :expectedresults: Docker-based content view can be added to activation key """ - lce = entities.LifecycleEnvironment(organization=module_org).create() - repo = entities.Repository( + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + repo = module_target_sat.api.Repository( content_type=constants.REPO_TYPE['docker'], - product=entities.Product(organization=module_org).create(), + product=module_target_sat.api.Product(organization=module_org).create(), url=constants.CONTAINER_REGISTRY_HUB, ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() cvv = content_view.read().version[0].read() cvv.promote(data={'environment_ids': lce.id, 'force': False}) - composite_cv = entities.ContentView( + composite_cv = module_target_sat.api.ContentView( component=[cvv], composite=True, organization=module_org ).create() composite_cv.publish() @@ -825,8 +833,8 @@ def test_positive_add_host(session, module_org, rhel6_contenthost, target_sat): :parametrized: yes """ - ak = entities.ActivationKey( - environment=entities.LifecycleEnvironment( + ak = target_sat.api.ActivationKey( + environment=target_sat.api.LifecycleEnvironment( name=constants.ENVIRONMENT, organization=module_org ).search()[0], organization=module_org, @@ -863,7 +871,7 @@ def test_positive_delete_with_system(session, rhel6_contenthost, target_sat): cv_name = gen_string('alpha') env_name = gen_string('alpha') product_name = gen_string('alpha') - org = entities.Organization().create() + org = target_sat.api.Organization().create() # Helper function to create and promote CV to next environment repo_id = target_sat.api_factory.create_sync_custom_repo( product_name=product_name, org_id=org.id @@ -994,12 +1002,12 @@ def test_positive_host_associations(session, target_sat): :BZ: 1344033, 1372826, 1394388 """ - org = entities.Organization().create() + org = target_sat.api.Organization().create() org_entities = target_sat.cli_factory.setup_org_for_a_custom_repo( {'url': settings.repos.yum_1.url, 'organization-id': org.id} ) - ak1 = entities.ActivationKey(id=org_entities['activationkey-id']).read() - ak2 = entities.ActivationKey( + ak1 = target_sat.api.ActivationKey(id=org_entities['activationkey-id']).read() + ak2 = target_sat.api.ActivationKey( content_view=org_entities['content-view-id'], environment=org_entities['lifecycle-environment-id'], organization=org.id, @@ -1060,10 +1068,10 @@ def test_positive_service_level_subscription_with_custom_product( entities_ids = target_sat.cli_factory.setup_org_for_a_custom_repo( {'url': settings.repos.yum_1.url, 'organization-id': org.id} ) - product = entities.Product(id=entities_ids['product-id']).read() - activation_key = entities.ActivationKey(id=entities_ids['activationkey-id']).read() + product = target_sat.api.Product(id=entities_ids['product-id']).read() + activation_key = target_sat.api.ActivationKey(id=entities_ids['activationkey-id']).read() # add the default RH subscription - subscription = entities.Subscription(organization=org).search( + subscription = target_sat.api.Subscription(organization=org).search( query={'search': f'name="{constants.DEFAULT_SUBSCRIPTION_NAME}"'} )[0] activation_key.add_subscriptions(data={'quantity': 1, 'subscription_id': subscription.id}) @@ -1093,7 +1101,7 @@ def test_positive_service_level_subscription_with_custom_product( @pytest.mark.run_in_one_thread @pytest.mark.tier2 -def test_positive_delete_manifest(session, function_entitlement_manifest_org): +def test_positive_delete_manifest(session, function_entitlement_manifest_org, target_sat): """Check if deleting a manifest removes it from Activation key :id: 512d8e41-b937-451e-a9c6-840457d3d7d4 @@ -1108,9 +1116,9 @@ def test_positive_delete_manifest(session, function_entitlement_manifest_org): """ org = function_entitlement_manifest_org # Create activation key - activation_key = entities.ActivationKey(organization=org).create() + activation_key = target_sat.api.ActivationKey(organization=org).create() # Associate a manifest to the activation key - subscription = entities.Subscription(organization=org).search( + subscription = target_sat.api.Subscription(organization=org).search( query={'search': f'name="{constants.DEFAULT_SUBSCRIPTION_NAME}"'} )[0] activation_key.add_subscriptions(data={'quantity': 1, 'subscription_id': subscription.id}) diff --git a/tests/foreman/ui/test_bookmarks.py b/tests/foreman/ui/test_bookmarks.py index 94e10d4f911..f2622ae84a8 100644 --- a/tests/foreman/ui/test_bookmarks.py +++ b/tests/foreman/ui/test_bookmarks.py @@ -12,9 +12,7 @@ """ from airgun.exceptions import NoSuchElementException -from airgun.session import Session from fauxfactory import gen_string -from nailgun import entities import pytest from robottelo.config import user_nailgun_config @@ -91,7 +89,9 @@ def test_positive_end_to_end(session, ui_entity): @pytest.mark.tier2 -def test_positive_create_bookmark_public(session, ui_entity, default_viewer_role, test_name): +def test_positive_create_bookmark_public( + session, ui_entity, default_viewer_role, test_name, module_target_sat +): """Create and check visibility of the (non)public bookmarks :id: 93139529-7690-429b-83fe-3dcbac4f91dc @@ -123,7 +123,9 @@ def test_positive_create_bookmark_public(session, ui_entity, default_viewer_role {'name': name, 'query': gen_string('alphanumeric'), 'public': name == public_name} ) assert any(d['Name'] == name for d in session.bookmark.search(name)) - with Session(test_name, default_viewer_role.login, default_viewer_role.password) as session: + with module_target_sat.ui_session( + test_name, default_viewer_role.login, default_viewer_role.password + ) as session: assert any(d['Name'] == public_name for d in session.bookmark.search(public_name)) assert not session.bookmark.search(nonpublic_name) @@ -182,7 +184,7 @@ def test_positive_update_bookmark_public( controller=ui_entity['controller'], public=name == public_name, ).create() - with Session( + with target_sat.ui_session( test_name, default_viewer_role.login, default_viewer_role.password ) as non_admin_session: assert any(d['Name'] == public_name for d in non_admin_session.bookmark.search(public_name)) @@ -190,7 +192,7 @@ def test_positive_update_bookmark_public( with session: session.bookmark.update(public_name, {'public': False}) session.bookmark.update(nonpublic_name, {'public': True}) - with Session( + with target_sat.ui_session( test_name, default_viewer_role.login, default_viewer_role.password ) as non_admin_session: assert any( @@ -200,7 +202,7 @@ def test_positive_update_bookmark_public( @pytest.mark.tier2 -def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name): +def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name, module_target_sat): """Simple removal of a bookmark query without permissions :id: 1a94bf2b-bcc6-4663-b70d-e13244a0783b @@ -219,8 +221,10 @@ def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name): :expectedresults: The delete buttons are not displayed """ - bookmark = entities.Bookmark(controller=ui_entity['controller'], public=True).create() - with Session( + bookmark = module_target_sat.api.Bookmark( + controller=ui_entity['controller'], public=True + ).create() + with module_target_sat.ui_session( test_name, default_viewer_role.login, default_viewer_role.password ) as non_admin_session: assert non_admin_session.bookmark.search(bookmark.name)[0]['Name'] == bookmark.name @@ -230,7 +234,7 @@ def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name): @pytest.mark.tier2 -def test_negative_create_with_duplicate_name(session, ui_entity): +def test_negative_create_with_duplicate_name(session, ui_entity, module_target_sat): """Create bookmark with duplicate name :id: 18168c9c-bdd1-4839-a506-cf9b06c4ab44 @@ -248,7 +252,9 @@ def test_negative_create_with_duplicate_name(session, ui_entity): :BZ: 1920566, 1992652 """ query = gen_string('alphanumeric') - bookmark = entities.Bookmark(controller=ui_entity['controller'], public=True).create() + bookmark = module_target_sat.api.Bookmark( + controller=ui_entity['controller'], public=True + ).create() with session: existing_bookmark = session.bookmark.search(bookmark.name)[0] assert existing_bookmark['Name'] == bookmark.name diff --git a/tests/foreman/ui/test_branding.py b/tests/foreman/ui/test_branding.py index a7e08659d8b..8fe30b1c2ef 100644 --- a/tests/foreman/ui/test_branding.py +++ b/tests/foreman/ui/test_branding.py @@ -11,7 +11,6 @@ :CaseImportance: High """ -from airgun.session import Session import pytest @@ -31,7 +30,7 @@ def test_verify_satellite_login_screen_info(target_sat): :BZ: 1315849, 1367495, 1372436, 1502098, 1540710, 1582476, 1724738, 1959135, 2076979, 1687250, 1686540, 1742872, 1805642, 2105949 """ - with Session(login=False) as session: + with target_sat.ui_session(login=False) as session: version = session.login.read_sat_version() assert f'Version {target_sat.version}' == version['login_text'] assert 'Beta' not in version['login_text'], '"Beta" should not be there' diff --git a/tests/foreman/ui/test_contenthost.py b/tests/foreman/ui/test_contenthost.py index 3abe1d25a17..ffbe571c5b2 100644 --- a/tests/foreman/ui/test_contenthost.py +++ b/tests/foreman/ui/test_contenthost.py @@ -15,9 +15,7 @@ import re from urllib.parse import urlparse -from airgun.session import Session from fauxfactory import gen_integer, gen_string -from nailgun import entities import pytest from robottelo.config import setting_is_set, settings @@ -44,8 +42,10 @@ @pytest.fixture(scope='module', autouse=True) -def host_ui_default(): - settings_object = entities.Setting().search(query={'search': 'name=host_details_ui'})[0] +def host_ui_default(module_target_sat): + settings_object = module_target_sat.api.Setting().search( + query={'search': 'name=host_details_ui'} + )[0] settings_object.value = 'No' settings_object.update({'value'}) yield @@ -54,10 +54,10 @@ def host_ui_default(): @pytest.fixture(scope='module') -def module_org(): - org = entities.Organization(simple_content_access=False).create() +def module_org(module_target_sat): + org = module_target_sat.api.Organization(simple_content_access=False).create() # adding remote_execution_connect_by_ip=Yes at org level - entities.Parameter( + module_target_sat.api.Parameter( name='remote_execution_connect_by_ip', value='Yes', organization=org.id, @@ -82,9 +82,9 @@ def vm_module_streams(module_repos_collection_with_manifest, rhel8_contenthost, return rhel8_contenthost -def set_ignore_facts_for_os(value=False): +def set_ignore_facts_for_os(module_target_sat, value=False): """Helper to set 'ignore_facts_for_operatingsystem' setting""" - ignore_setting = entities.Setting().search( + ignore_setting = module_target_sat.api.Setting().search( query={'search': 'name="ignore_facts_for_operatingsystem"'} )[0] ignore_setting.value = str(value) @@ -659,7 +659,7 @@ def test_positive_remove_package_group(session, default_location, vm): indirect=True, ) def test_positive_search_errata_non_admin( - session, default_location, vm, test_name, default_viewer_role + default_location, vm, test_name, default_viewer_role, module_target_sat ): """Search for host's errata by non-admin user with enough permissions @@ -675,7 +675,7 @@ def test_positive_search_errata_non_admin( :parametrized: yes """ vm.run(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}') - with Session( + with module_target_sat.ui_session( test_name, user=default_viewer_role.login, password=default_viewer_role.password ) as session: session.location.select(default_location.name) @@ -822,7 +822,9 @@ def test_positive_host_re_registration_with_host_rename( ], indirect=True, ) -def test_positive_check_ignore_facts_os_setting(session, default_location, vm, module_org, request): +def test_positive_check_ignore_facts_os_setting( + session, default_location, vm, module_org, request, module_target_sat +): """Verify that 'Ignore facts for operating system' setting works properly @@ -855,9 +857,9 @@ def test_positive_check_ignore_facts_os_setting(session, default_location, vm, m major = str(gen_integer(15, 99)) minor = str(gen_integer(1, 9)) expected_os = f'RedHat {major}.{minor}' - set_ignore_facts_for_os(False) + set_ignore_facts_for_os(module_target_sat, False) host = ( - entities.Host() + module_target_sat.api.Host() .search(query={'search': f'name={vm.hostname} and organization_id={module_org.id}'})[0] .read() ) @@ -866,7 +868,7 @@ def test_positive_check_ignore_facts_os_setting(session, default_location, vm, m # Get host current operating system value os = session.contenthost.read(vm.hostname, widget_names='details')['details']['os'] # Change necessary setting to true - set_ignore_facts_for_os(True) + set_ignore_facts_for_os(module_target_sat, True) # Add cleanup function to roll back setting to default value request.addfinalizer(set_ignore_facts_for_os) # Read all facts for corresponding host @@ -883,7 +885,7 @@ def test_positive_check_ignore_facts_os_setting(session, default_location, vm, m # Check that host OS was not changed due setting was set to true assert os == updated_os # Put it to false and re-run the process - set_ignore_facts_for_os(False) + set_ignore_facts_for_os(module_target_sat, False) host.upload_facts(data={'name': vm.hostname, 'facts': facts}) session.contenthost.search('') updated_os = session.contenthost.read(vm.hostname, widget_names='details')['details']['os'] @@ -920,8 +922,8 @@ def test_positive_virt_who_hypervisor_subscription_status( :parametrized: yes """ - org = entities.Organization().create() - lce = entities.LifecycleEnvironment(organization=org).create() + org = target_sat.api.Organization().create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() # TODO move this to either hack around virt-who service or use an env-* compute resource provisioning_server = settings.libvirt.libvirt_hostname # Create a new virt-who config @@ -992,7 +994,9 @@ def test_positive_virt_who_hypervisor_subscription_status( ], indirect=True, ) -def test_module_stream_actions_on_content_host(session, default_location, vm_module_streams): +def test_module_stream_actions_on_content_host( + session, default_location, vm_module_streams, module_target_sat +): """Check remote execution for module streams actions e.g. install, remove, disable works on content host. Verify that correct stream module stream get installed/removed. @@ -1005,7 +1009,7 @@ def test_module_stream_actions_on_content_host(session, default_location, vm_mod """ stream_version = '5.21' run_remote_command_on_content_host('dnf -y upload-profile', vm_module_streams) - entities.Parameter( + module_target_sat.api.Parameter( name='remote_execution_connect_by_ip', value='Yes', parameter_type='boolean', @@ -1782,7 +1786,7 @@ def test_pagination_multiple_hosts_multiple_pages(session, module_host_template, @pytest.mark.tier3 -def test_search_for_virt_who_hypervisors(session, default_location): +def test_search_for_virt_who_hypervisors(session, default_location, module_target_sat): """ Search the virt_who hypervisors with hypervisor=True or hypervisor=False. @@ -1796,7 +1800,7 @@ def test_search_for_virt_who_hypervisors(session, default_location): :CaseImportance: Medium """ - org = entities.Organization().create() + org = module_target_sat.api.Organization().create() with session: session.organization.select(org.name) session.location.select(default_location.name) diff --git a/tests/foreman/ui/test_contentview_old.py b/tests/foreman/ui/test_contentview_old.py index e69931568fa..0b846771257 100644 --- a/tests/foreman/ui/test_contentview_old.py +++ b/tests/foreman/ui/test_contentview_old.py @@ -18,8 +18,6 @@ from random import randint from airgun.exceptions import InvalidElementStateException, NoSuchElementException -from airgun.session import Session -from nailgun import entities from nailgun.entity_mixins import call_entity_method_with_timeout from navmazing import NavigationTriesExceeded from productmd.common import parse_nvra @@ -54,17 +52,17 @@ @pytest.fixture(scope='module') -def module_org(): - return entities.Organization().create() +def module_org(module_target_sat): + return module_target_sat.api.Organization().create() @pytest.fixture(scope='module') -def module_prod(module_org): - return entities.Product(organization=module_org).create() +def module_prod(module_org, module_target_sat): + return module_target_sat.api.Product(organization=module_org).create() @pytest.mark.tier2 -def test_positive_add_custom_content(session): +def test_positive_add_custom_content(session, module_target_sat): """Associate custom content in a view :id: 7128fc8b-0e8c-4f00-8541-2ca2399650c8 @@ -75,11 +73,11 @@ def test_positive_add_custom_content(session): :CaseImportance: Critical """ - org = entities.Organization().create() + org = module_target_sat.api.Organization().create() cv_name = gen_string('alpha') repo_name = gen_string('alpha') - product = entities.Product(organization=org).create() - entities.Repository(name=repo_name, product=product).create() + product = module_target_sat.api.Product(organization=org).create() + module_target_sat.api.Repository(name=repo_name, product=product).create() with session: session.organization.select(org_name=org.name) session.contentview.create({'name': cv_name}) @@ -91,7 +89,7 @@ def test_positive_add_custom_content(session): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_end_to_end(session, module_org, target_sat): +def test_positive_end_to_end(session, module_target_sat, module_org, target_sat): """Create content view with yum repo, publish it and promote it to Library +1 env @@ -129,7 +127,7 @@ def test_positive_end_to_end(session, module_org, target_sat): @pytest.mark.tier2 -def test_positive_publish_version_changes_in_source_env(session, module_org): +def test_positive_publish_version_changes_in_source_env(session, module_target_sat, module_org): """When publishing new version to environment, version gets updated :id: 576ac8b4-7efe-4267-a672-868a5f3eb28a @@ -143,8 +141,8 @@ def test_positive_publish_version_changes_in_source_env(session, module_org): :CaseImportance: High """ - lce = entities.LifecycleEnvironment(organization=module_org).create() - cv = entities.ContentView(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + cv = module_target_sat.api.ContentView(organization=module_org).create() with session: result = session.contentview.publish(cv.name) assert result['Version'] == 'Version 1.0' @@ -180,7 +178,7 @@ def test_positive_publish_version_changes_in_source_env(session, module_org): @pytest.mark.tier2 -def test_positive_repo_count_for_composite_cv(session, module_org, target_sat): +def test_positive_repo_count_for_composite_cv(session, module_target_sat, module_org, target_sat): """Create some content views with synchronized repositories and promoted to one lce. Add them to composite content view and check repo count for it. @@ -194,7 +192,7 @@ def test_positive_repo_count_for_composite_cv(session, module_org, target_sat): :CaseImportance: High """ - lce = entities.LifecycleEnvironment(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() ccv_name = gen_string('alpha') repo_name = gen_string('alpha') # Create a product and sync'ed repository @@ -204,7 +202,7 @@ def test_positive_repo_count_for_composite_cv(session, module_org, target_sat): session.contentview.create({'name': ccv_name, 'composite_view': True}) # Create three content-views and add synced repo to them for _ in range(3): - cv_name = entities.ContentView(organization=module_org).create().name + cv_name = module_target_sat.api.ContentView(organization=module_org).create().name assert session.contentview.search(cv_name)[0]['Name'] == cv_name # Add repository to selected CV session.contentview.add_yum_repo(cv_name, repo_name) @@ -252,7 +250,7 @@ def test_positive_create_composite( 'basearch': 'x86_64', 'releasever': None, } - docker_repo = entities.Repository( + docker_repo = target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() @@ -282,7 +280,9 @@ def test_positive_create_composite( @pytest.mark.run_in_one_thread @pytest.mark.skip_if_not_set('fake_manifest') @pytest.mark.tier2 -def test_positive_add_rh_content(session, function_entitlement_manifest_org, target_sat): +def test_positive_add_rh_content( + session, module_target_sat, function_entitlement_manifest_org, target_sat +): """Add Red Hat content to a content view :id: c370fd79-0c0d-4685-99cb-848556c786c1 @@ -315,7 +315,7 @@ def test_positive_add_rh_content(session, function_entitlement_manifest_org, tar @pytest.mark.tier2 -def test_positive_add_docker_repo(session, module_org, module_prod): +def test_positive_add_docker_repo(session, module_target_sat, module_org, module_prod): """Add one Docker-type repository to a non-composite content view :id: 2868cfd5-d27e-4db9-b4a3-2827e31d1601 @@ -324,8 +324,10 @@ def test_positive_add_docker_repo(session, module_org, module_prod): :CaseImportance: High """ - content_view = entities.ContentView(composite=False, organization=module_org).create() - repo = entities.Repository( + content_view = module_target_sat.api.ContentView( + composite=False, organization=module_org + ).create() + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() with session: @@ -335,7 +337,7 @@ def test_positive_add_docker_repo(session, module_org, module_prod): @pytest.mark.tier2 -def test_positive_add_docker_repos(session, module_org, module_prod): +def test_positive_add_docker_repos(session, module_target_sat, module_org, module_prod): """Add multiple Docker-type repositories to a non-composite content view. @@ -346,9 +348,11 @@ def test_positive_add_docker_repos(session, module_org, module_prod): :CaseImportance: Low """ - content_view = entities.ContentView(composite=False, organization=module_org).create() + content_view = module_target_sat.api.ContentView( + composite=False, organization=module_org + ).create() repos = [ - entities.Repository( + module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() for _ in range(randint(2, 3)) @@ -363,7 +367,7 @@ def test_positive_add_docker_repos(session, module_org, module_prod): @pytest.mark.tier2 -def test_positive_add_synced_docker_repo(session, module_org, module_prod): +def test_positive_add_synced_docker_repo(session, module_target_sat, module_org, module_prod): """Create and sync a docker repository, then add it to content view :id: 338a7ed4-9e10-4bc0-8666-5c8cd0ff0504 @@ -373,8 +377,10 @@ def test_positive_add_synced_docker_repo(session, module_org, module_prod): :CaseImportance: High """ - content_view = entities.ContentView(composite=False, organization=module_org).create() - repo = entities.Repository( + content_view = module_target_sat.api.ContentView( + composite=False, organization=module_org + ).create() + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() with session: @@ -387,7 +393,7 @@ def test_positive_add_synced_docker_repo(session, module_org, module_prod): @pytest.mark.tier2 -def test_positive_add_docker_repo_to_ccv(session, module_org, module_prod): +def test_positive_add_docker_repo_to_ccv(session, module_target_sat, module_org, module_prod): """Add one docker repository to a composite content view :id: 76b68407-b429-4ad7-b8b5-bfde327a0404 @@ -397,9 +403,13 @@ def test_positive_add_docker_repo_to_ccv(session, module_org, module_prod): :CaseImportance: High """ - content_view = entities.ContentView(composite=False, organization=module_org).create() - composite_cv = entities.ContentView(composite=True, organization=module_org).create() - repo = entities.Repository( + content_view = module_target_sat.api.ContentView( + composite=False, organization=module_org + ).create() + composite_cv = module_target_sat.api.ContentView( + composite=True, organization=module_org + ).create() + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() with session: @@ -413,7 +423,7 @@ def test_positive_add_docker_repo_to_ccv(session, module_org, module_prod): @pytest.mark.tier2 -def test_positive_add_docker_repos_to_ccv(session, module_org, module_prod): +def test_positive_add_docker_repos_to_ccv(session, module_target_sat, module_org, module_prod): """Add multiple docker repositories to a composite content view. :id: 30187102-7106-45de-a68b-e32fbaecedb9 @@ -425,15 +435,17 @@ def test_positive_add_docker_repos_to_ccv(session, module_org, module_prod): """ cvs = [] for _ in range(randint(2, 3)): - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() cvs.append(content_view.name) - composite_cv = entities.ContentView(composite=True, organization=module_org).create() + composite_cv = module_target_sat.api.ContentView( + composite=True, organization=module_org + ).create() with session: for cv in cvs: session.contentview.add_cv(composite_cv.name, cv) @@ -446,7 +458,7 @@ def test_positive_add_docker_repos_to_ccv(session, module_org, module_prod): @pytest.mark.tier2 -def test_positive_publish_with_docker_repo(session, module_org, module_prod): +def test_positive_publish_with_docker_repo(session, module_target_sat, module_org, module_prod): """Add docker repository to content view and publish it once. :id: 2004b2d4-177b-47de-9e61-bcfb58f05f88 @@ -456,8 +468,10 @@ def test_positive_publish_with_docker_repo(session, module_org, module_prod): :CaseImportance: High """ - content_view = entities.ContentView(composite=False, organization=module_org).create() - repo = entities.Repository( + content_view = module_target_sat.api.ContentView( + composite=False, organization=module_org + ).create() + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() with session: @@ -469,7 +483,9 @@ def test_positive_publish_with_docker_repo(session, module_org, module_prod): @pytest.mark.tier2 -def test_positive_publish_with_docker_repo_composite(session, module_org, module_prod): +def test_positive_publish_with_docker_repo_composite( + session, module_target_sat, module_org, module_prod +): """Add docker repository to composite content view and publish it once. :id: 7aad525a-a9d3-4100-9611-ca02c6a95a22 @@ -480,14 +496,16 @@ def test_positive_publish_with_docker_repo_composite(session, module_org, module :CaseImportance: High """ - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() - composite_cv = entities.ContentView(composite=True, organization=module_org).create() + composite_cv = module_target_sat.api.ContentView( + composite=True, organization=module_org + ).create() with session: session.contentview.add_cv(composite_cv.name, content_view.name) result = session.contentview.publish(composite_cv.name) @@ -497,7 +515,9 @@ def test_positive_publish_with_docker_repo_composite(session, module_org, module @pytest.mark.tier2 -def test_positive_publish_multiple_with_docker_repo(session, module_org, module_prod): +def test_positive_publish_multiple_with_docker_repo( + session, module_target_sat, module_org, module_prod +): """Add docker repository to content view and publish it multiple times. :id: acc703b7-6e99-48d7-96ce-ea0985409ef9 @@ -507,10 +527,10 @@ def test_positive_publish_multiple_with_docker_repo(session, module_org, module_ :CaseImportance: Low """ - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() with session: @@ -520,7 +540,9 @@ def test_positive_publish_multiple_with_docker_repo(session, module_org, module_ @pytest.mark.tier2 -def test_positive_publish_multiple_with_docker_repo_composite(session, module_org, module_prod): +def test_positive_publish_multiple_with_docker_repo_composite( + session, module_target_sat, module_org, module_prod +): """Add docker repository to composite content view and publish it multiple times. :id: 07755bff-9071-45e5-b861-77a5c2fed3d9 @@ -530,14 +552,16 @@ def test_positive_publish_multiple_with_docker_repo_composite(session, module_or :CaseImportance: Low """ - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() - composite_cv = entities.ContentView(composite=True, organization=module_org).create() + composite_cv = module_target_sat.api.ContentView( + composite=True, organization=module_org + ).create() with session: session.contentview.add_cv(composite_cv.name, content_view.name) for version in range(randint(2, 5)): @@ -546,7 +570,7 @@ def test_positive_publish_multiple_with_docker_repo_composite(session, module_or @pytest.mark.tier2 -def test_positive_promote_with_docker_repo(session, module_org, module_prod): +def test_positive_promote_with_docker_repo(session, module_target_sat, module_org, module_prod): """Add docker repository to content view and publish it. Then promote it to the next available lifecycle environment. @@ -557,11 +581,11 @@ def test_positive_promote_with_docker_repo(session, module_org, module_prod): :CaseImportance: High """ - lce = entities.LifecycleEnvironment(organization=module_org).create() - repo = entities.Repository( + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() @@ -572,7 +596,9 @@ def test_positive_promote_with_docker_repo(session, module_org, module_prod): @pytest.mark.tier2 -def test_positive_promote_multiple_with_docker_repo(session, module_org, module_prod): +def test_positive_promote_multiple_with_docker_repo( + session, module_target_sat, module_org, module_prod +): """Add docker repository to content view and publish it. Then promote it to multiple available lifecycle-environments. @@ -583,23 +609,25 @@ def test_positive_promote_multiple_with_docker_repo(session, module_org, module_ :CaseImportance: Low """ - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() with session: for _ in range(randint(2, 3)): - lce = entities.LifecycleEnvironment(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() result = session.contentview.promote(content_view.name, VERSION, lce.name) assert f'Promoted to {lce.name}' in result['Status'] assert lce.name in result['Environments'] @pytest.mark.tier2 -def test_positive_promote_with_docker_repo_composite(session, module_org, module_prod): +def test_positive_promote_with_docker_repo_composite( + session, module_target_sat, module_org, module_prod +): """Add docker repository to composite content view and publish it. Then promote it to the next available lifecycle-environment. @@ -610,16 +638,16 @@ def test_positive_promote_with_docker_repo_composite(session, module_org, module :CaseImportance: High """ - lce = entities.LifecycleEnvironment(organization=module_org).create() - repo = entities.Repository( + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() content_view = content_view.read() - composite_cv = entities.ContentView( + composite_cv = module_target_sat.api.ContentView( component=[content_view.version[-1]], composite=True, organization=module_org ).create() composite_cv.publish() @@ -631,7 +659,9 @@ def test_positive_promote_with_docker_repo_composite(session, module_org, module @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_promote_multiple_with_docker_repo_composite(session, module_org, module_prod): +def test_positive_promote_multiple_with_docker_repo_composite( + session, module_target_sat, module_org, module_prod +): """Add docker repository to composite content view and publish it Then promote it to the multiple available lifecycle environments. @@ -642,28 +672,28 @@ def test_positive_promote_multiple_with_docker_repo_composite(session, module_or :CaseImportance: Low """ - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( composite=False, organization=module_org, repository=[repo] ).create() content_view.publish() content_view = content_view.read() - composite_cv = entities.ContentView( + composite_cv = module_target_sat.api.ContentView( component=[content_view.version[-1]], composite=True, organization=module_org ).create() composite_cv.publish() with session: for _ in range(randint(2, 3)): - lce = entities.LifecycleEnvironment(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() result = session.contentview.promote(composite_cv.name, VERSION, lce.name) assert f'Promoted to {lce.name}' in result['Status'] assert lce.name in result['Environments'] @pytest.mark.tier2 -def test_negative_add_components_to_non_composite(session): +def test_negative_add_components_to_non_composite(session, module_target_sat): """Attempt to associate components to a non-composite content view :id: fa3e6aea-7ee3-46a6-a5ba-248de3c20a8f @@ -685,7 +715,7 @@ def test_negative_add_components_to_non_composite(session): @pytest.mark.tier2 -def test_positive_add_unpublished_cv_to_composite(session): +def test_positive_add_unpublished_cv_to_composite(session, module_target_sat): """Attempt to associate unpublished non-composite content view with composite content view. @@ -716,7 +746,7 @@ def test_positive_add_unpublished_cv_to_composite(session): @pytest.mark.tier3 -def test_positive_add_non_composite_cv_to_composite(session): +def test_positive_add_non_composite_cv_to_composite(session, module_target_sat): """Attempt to associate both published and unpublished non-composite content views with composite content view. @@ -775,7 +805,7 @@ def test_positive_add_non_composite_cv_to_composite(session): @pytest.mark.tier3 -def test_positive_check_composite_cv_addition_list_versions(session): +def test_positive_check_composite_cv_addition_list_versions(session, module_target_sat): """Create new content view and publish two times. After that remove first content view version from the list and try to add that view to composite one. Check what content view version is going to be added @@ -814,7 +844,7 @@ def test_positive_check_composite_cv_addition_list_versions(session): @pytest.mark.tier2 -def test_negative_add_dupe_repos(session, module_org, target_sat): +def test_negative_add_dupe_repos(session, module_target_sat, module_org, target_sat): """attempt to associate the same repo multiple times within a content view @@ -839,7 +869,7 @@ def test_negative_add_dupe_repos(session, module_org, target_sat): @pytest.mark.tier2 -def test_positive_publish_with_custom_content(session, module_org, target_sat): +def test_positive_publish_with_custom_content(session, module_target_sat, module_org, target_sat): """Attempt to publish a content view containing custom content :id: 66b5efc7-2e43-438e-bd80-a754814222f9 @@ -866,7 +896,9 @@ def test_positive_publish_with_custom_content(session, module_org, target_sat): @pytest.mark.run_in_one_thread @pytest.mark.skip_if_not_set('fake_manifest') @pytest.mark.tier2 -def test_positive_publish_with_rh_content(session, function_entitlement_manifest_org, target_sat): +def test_positive_publish_with_rh_content( + session, module_target_sat, function_entitlement_manifest_org, target_sat +): """Attempt to publish a content view containing RH content :id: bd24dc13-b6c4-4a9b-acb2-cd6df30f436c @@ -923,7 +955,7 @@ def test_positive_publish_composite_with_custom_content( custom_repo1_url = settings.repos.yum_0.url custom_repo2_url = settings.repos.yum_1.url org = function_entitlement_manifest_org - product = entities.Product(organization=org).create() + product = target_sat.api.Product(organization=org).create() rh7_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], @@ -932,10 +964,10 @@ def test_positive_publish_composite_with_custom_content( 'releasever': None, } # Create docker repos and sync - docker_repo1 = entities.Repository( + docker_repo1 = target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=product, content_type=REPO_TYPE['docker'] ).create() - docker_repo2 = entities.Repository( + docker_repo2 = target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=product, content_type=REPO_TYPE['docker'] ).create() docker_repo1.sync() @@ -985,7 +1017,9 @@ def test_positive_publish_composite_with_custom_content( @pytest.mark.tier2 -def test_positive_publish_version_changes_in_target_env(session, module_org, target_sat): +def test_positive_publish_version_changes_in_target_env( + session, module_target_sat, module_org, target_sat +): # Dev notes: # If Dev has version x, then when I promote version y into # Dev, version x goes away (ie when I promote version 1 to Dev, @@ -1010,7 +1044,7 @@ def test_positive_publish_version_changes_in_target_env(session, module_org, tar versions_count = 3 versions = (f'Version {ver + 1}.0' for ver in range(versions_count)) # create environment lifecycle - lce = entities.LifecycleEnvironment(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() repo_names = [gen_string('alphanumeric') for _ in range(versions_count)] # before each content view publishing add a new repository for repo_name in repo_names: @@ -1043,7 +1077,7 @@ def test_positive_publish_version_changes_in_target_env(session, module_org, tar @pytest.mark.tier2 -def test_positive_promote_with_custom_content(session, module_org, target_sat): +def test_positive_promote_with_custom_content(session, module_target_sat, module_org, target_sat): """Attempt to promote a content view containing custom content, check dashboard @@ -1059,7 +1093,7 @@ def test_positive_promote_with_custom_content(session, module_org, target_sat): """ repo_name = gen_string('alpha') cv_name = gen_string('alpha') - lce = entities.LifecycleEnvironment(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) with session: session.contentview.create({'name': cv_name}) @@ -1079,7 +1113,7 @@ def test_positive_promote_with_custom_content(session, module_org, target_sat): assert cv_name in values['content_views'][1]['Content View'] assert values['content_views'][1]['Task'] == 'Published new version' assert 'Success' in values['content_views'][1]['Status'] - entities.LifecycleEnvironment(id=lce.id).delete() + module_target_sat.api.LifecycleEnvironment(id=lce.id).delete() values = session.dashboard.search(f'lifecycle_environment={lce.name}') assert cv_name in values['ContentViews']['content_views'][0]['Content View'] @@ -1087,7 +1121,9 @@ def test_positive_promote_with_custom_content(session, module_org, target_sat): @pytest.mark.run_in_one_thread @pytest.mark.skip_if_not_set('fake_manifest') @pytest.mark.tier2 -def test_positive_promote_with_rh_content(session, function_entitlement_manifest_org, target_sat): +def test_positive_promote_with_rh_content( + session, module_target_sat, function_entitlement_manifest_org, target_sat +): """Attempt to promote a content view containing RH content :id: 82f71639-3580-49fd-bd5a-8dba568b98d1 @@ -1108,7 +1144,7 @@ def test_positive_promote_with_rh_content(session, function_entitlement_manifest } org = function_entitlement_manifest_org target_sat.api_factory.enable_sync_redhat_repo(rh_repo, org.id) - lce = entities.LifecycleEnvironment(organization=org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=org).create() with session: session.organization.select(org.name) session.contentview.create({'name': cv_name}) @@ -1147,7 +1183,7 @@ def test_positive_promote_composite_with_custom_content( custom_repo1_url = settings.repos.yum_0.url custom_repo2_url = settings.repos.yum_1.url org = function_entitlement_manifest_org - product = entities.Product(organization=org).create() + product = target_sat.api.Product(organization=org).create() rh7_repo = { 'name': REPOS['rhst7']['name'], 'product': PRDS['rhel'], @@ -1156,7 +1192,7 @@ def test_positive_promote_composite_with_custom_content( 'releasever': None, } # create a life cycle environment - lce = entities.LifecycleEnvironment(organization=org).create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() # Enable and sync RH repository target_sat.api_factory.enable_sync_redhat_repo(rh7_repo, org.id) # Create custom yum repositories @@ -1166,10 +1202,10 @@ def test_positive_promote_composite_with_custom_content( ): target_sat.api_factory.create_sync_custom_repo(repo_name=name, repo_url=url, org_id=org.id) # Create docker repo and sync - docker_repo1 = entities.Repository( + docker_repo1 = target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=product, content_type=REPO_TYPE['docker'] ).create() - docker_repo2 = entities.Repository( + docker_repo2 = target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=product, content_type=REPO_TYPE['docker'], @@ -1217,7 +1253,9 @@ def test_positive_promote_composite_with_custom_content( @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.run_in_one_thread @pytest.mark.tier2 -def test_positive_publish_rh_content_with_errata_by_date_filter(session, target_sat): +def test_positive_publish_rh_content_with_errata_by_date_filter( + session, module_target_sat, target_sat +): """Publish a CV, containing only RH repo, having errata excluding by date filter @@ -1234,19 +1272,21 @@ def test_positive_publish_rh_content_with_errata_by_date_filter(session, target_ :CaseImportance: High """ version = 'Version 2.0' - org = entities.Organization().create() - lce = entities.LifecycleEnvironment(organization=org).create() + org = module_target_sat.api.Organization().create() + lce = module_target_sat.api.LifecycleEnvironment(organization=org).create() repos_collection = target_sat.cli_factory.RepositoryCollection( distro='rhel6', repositories=[target_sat.cli_factory.VirtualizationAgentsRepository()] ) repos_collection.setup_content( org.id, lce.id, download_policy='immediate', upload_manifest=True ) - cv = entities.ContentView(id=repos_collection.setup_content_data['content_view']['id']).read() - cvf = entities.ErratumContentViewFilter( + cv = module_target_sat.api.ContentView( + id=repos_collection.setup_content_data['content_view']['id'] + ).read() + cvf = module_target_sat.api.ErratumContentViewFilter( content_view=cv, inclusion=False, repository=[repos_collection.repos_info[0]['id']] ).create() - entities.ContentViewFilterRule( + module_target_sat.api.ContentViewFilterRule( content_view_filter=cvf, start_date='2011-01-01', types=['security', 'enhancement', 'bugfix'], @@ -1260,7 +1300,7 @@ def test_positive_publish_rh_content_with_errata_by_date_filter(session, target_ @pytest.mark.tier3 -def test_negative_add_same_package_filter_twice(session, module_org, target_sat): +def test_negative_add_same_package_filter_twice(session, module_target_sat, module_org, target_sat): """Update version of package inside exclusive cv package filter :id: 5a97de5a-679e-4150-adf7-b4a28290b834 @@ -1297,7 +1337,9 @@ def test_negative_add_same_package_filter_twice(session, module_org, target_sat) @pytest.mark.tier2 -def test_positive_remove_cv_version_from_default_env(session, module_org, target_sat): +def test_positive_remove_cv_version_from_default_env( + session, module_target_sat, module_org, target_sat +): """Remove content view version from Library environment :id: 43c83c15-c883-45a7-be05-d9b26da99e3c @@ -1335,7 +1377,9 @@ def test_positive_remove_cv_version_from_default_env(session, module_org, target @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_promoted_cv_version_from_default_env(session, module_org, target_sat): +def test_positive_remove_promoted_cv_version_from_default_env( + session, module_target_sat, module_org, target_sat +): """Remove promoted content view version from Library environment :id: a8649444-b063-4fb4-b932-a3fae7d4021d @@ -1380,7 +1424,9 @@ def test_positive_remove_promoted_cv_version_from_default_env(session, module_or @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier2 -def test_positive_remove_qe_promoted_cv_version_from_default_env(session, module_org, target_sat): +def test_positive_remove_qe_promoted_cv_version_from_default_env( + session, module_target_sat, module_org, target_sat +): """Remove QE promoted content view version from Library environment :id: 71ad8b72-68c4-4c98-9387-077f54ef0184 @@ -1399,8 +1445,10 @@ def test_positive_remove_qe_promoted_cv_version_from_default_env(session, module :CaseImportance: Low """ - dev_lce = entities.LifecycleEnvironment(organization=module_org).create() - qe_lce = entities.LifecycleEnvironment(organization=module_org, prior=dev_lce).create() + dev_lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + qe_lce = module_target_sat.api.LifecycleEnvironment( + organization=module_org, prior=dev_lce + ).create() repo = target_sat.cli_factory.RepositoryCollection( repositories=[ target_sat.cli_factory.DockerRepository( @@ -1411,7 +1459,7 @@ def test_positive_remove_qe_promoted_cv_version_from_default_env(session, module repo.setup(module_org.id) repo_name = repo.repos_info[0]['name'] cv, lce = repo.setup_content_view(module_org.id, dev_lce.id) - cvv = entities.ContentView(id=cv['id']).read().version[0] + cvv = module_target_sat.api.ContentView(id=cv['id']).read().version[0] cvv.promote(data={'environment_ids': qe_lce.id}) with session: cv_values = session.contentview.read(cv['name']) @@ -1448,7 +1496,9 @@ def test_positive_remove_qe_promoted_cv_version_from_default_env(session, module ], indirect=True, ) -def test_positive_remove_cv_version_from_env(session, module_org, repos_collection): +def test_positive_remove_cv_version_from_env( + session, module_target_sat, module_org, repos_collection +): """Remove promoted content view version from environment :id: d1da23ee-a5db-4990-9572-1a0919a9fe1c @@ -1468,8 +1518,10 @@ def test_positive_remove_cv_version_from_env(session, module_org, repos_collecti :CaseImportance: High """ - dev_lce = entities.LifecycleEnvironment(organization=module_org).create() - qe_lce = entities.LifecycleEnvironment(organization=module_org, prior=dev_lce).create() + dev_lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + qe_lce = module_target_sat.api.LifecycleEnvironment( + organization=module_org, prior=dev_lce + ).create() repos_collection.setup(module_org.id) yum_repo_name = [ repo['name'] for repo in repos_collection.repos_info if repo['content-type'] == 'yum' @@ -1478,7 +1530,7 @@ def test_positive_remove_cv_version_from_env(session, module_org, repos_collecti repo['name'] for repo in repos_collection.repos_info if repo['content-type'] == 'docker' ][0] cv, lce = repos_collection.setup_content_view(module_org.id, dev_lce.id) - cvv = entities.ContentView(id=cv['id']).read().version[0] + cvv = module_target_sat.api.ContentView(id=cv['id']).read().version[0] cvv.promote(data={'environment_ids': qe_lce.id}) with session: cvv = session.contentview.read_version(cv['name'], VERSION) @@ -1505,7 +1557,9 @@ def test_positive_remove_cv_version_from_env(session, module_org, repos_collecti @pytest.mark.upgrade @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_delete_cv_promoted_to_multi_env(session, module_org, target_sat): +def test_positive_delete_cv_promoted_to_multi_env( + session, module_target_sat, module_org, target_sat +): """Delete published content view with version promoted to multiple environments @@ -1548,7 +1602,7 @@ def test_positive_delete_cv_promoted_to_multi_env(session, module_org, target_sa @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_delete_composite_version(session, module_org, target_sat): +def test_positive_delete_composite_version(session, module_target_sat, module_org, target_sat): """Delete a composite content-view version associated to 'Library' :id: b2d9b21d-1e0d-40f1-9bbc-3c88cddd4f5e @@ -1583,7 +1637,7 @@ def test_positive_delete_composite_version(session, module_org, target_sat): @pytest.mark.tier2 -def test_positive_delete_non_default_version(session, target_sat): +def test_positive_delete_non_default_version(session, module_target_sat, target_sat): """Delete a content-view version associated to non-default environment @@ -1594,11 +1648,13 @@ def test_positive_delete_non_default_version(session, target_sat): :CaseImportance: Critical """ repo_name = gen_string('alpha') - org = entities.Organization().create() + org = module_target_sat.api.Organization().create() target_sat.api_factory.create_sync_custom_repo(org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': org.id})[0] - cv = entities.ContentView(organization=org, repository=[repo]).create() - lce = entities.LifecycleEnvironment(organization=org).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=org, repository=[repo]).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=org).create() with session: session.organization.select(org.name) # Publish and promote CV to next environment @@ -1616,7 +1672,7 @@ def test_positive_delete_non_default_version(session, target_sat): @pytest.mark.upgrade @pytest.mark.tier2 -def test_positive_delete_version_with_ak(session): +def test_positive_delete_version_with_ak(session, module_target_sat): """Delete a content-view version that had associated activation key to it :id: 0da50b26-f82b-4663-9372-4c39270d4323 @@ -1625,13 +1681,13 @@ def test_positive_delete_version_with_ak(session): :CaseImportance: High """ - org = entities.Organization().create() - cv = entities.ContentView(organization=org).create() + org = module_target_sat.api.Organization().create() + cv = module_target_sat.api.ContentView(organization=org).create() cv.publish() cvv = cv.read().version[0].read() - lc_env = entities.LifecycleEnvironment(organization=org).create() + lc_env = module_target_sat.api.LifecycleEnvironment(organization=org).create() cvv.promote(data={'environment_ids': lc_env.id}) - ak = entities.ActivationKey( + ak = module_target_sat.api.ActivationKey( name=gen_string('alphanumeric'), environment=lc_env.id, organization=org, content_view=cv ).create() with session: @@ -1652,7 +1708,7 @@ def test_positive_delete_version_with_ak(session): @pytest.mark.tier2 -def test_positive_clone_within_same_env(session, module_org, target_sat): +def test_positive_clone_within_same_env(session, module_target_sat, module_org, target_sat): """attempt to create new content view based on existing view within environment @@ -1682,7 +1738,7 @@ def test_positive_clone_within_same_env(session, module_org, target_sat): @pytest.mark.tier2 -def test_positive_clone_within_diff_env(session, module_org, target_sat): +def test_positive_clone_within_diff_env(session, module_target_sat, module_org, target_sat): """attempt to create new content view based on existing view, inside a different environment @@ -1698,10 +1754,12 @@ def test_positive_clone_within_diff_env(session, module_org, target_sat): repo_name = gen_string('alpha') copy_cv_name = gen_string('alpha') target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() - lce = entities.LifecycleEnvironment(organization=module_org).create() - copy_lce = entities.LifecycleEnvironment(organization=module_org).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() + copy_lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() with session: # publish the content view result = session.contentview.publish(cv.name) @@ -1724,7 +1782,7 @@ def test_positive_clone_within_diff_env(session, module_org, target_sat): @pytest.mark.tier2 -def test_positive_remove_filter(session, module_org): +def test_positive_remove_filter(session, module_target_sat, module_org): """Create empty content views filter and remove it :id: 6c6deae7-13f1-4638-a960-d3565d93fd64 @@ -1734,7 +1792,7 @@ def test_positive_remove_filter(session, module_org): :CaseImportance: Low """ filter_name = gen_string('alpha') - cv = entities.ContentView(organization=module_org).create() + cv = module_target_sat.api.ContentView(organization=module_org).create() with session: session.contentviewfilter.create( cv.name, @@ -1750,7 +1808,7 @@ def test_positive_remove_filter(session, module_org): @pytest.mark.tier2 -def test_positive_add_package_filter(session, module_org, target_sat): +def test_positive_add_package_filter(session, module_target_sat, module_org, target_sat): """Add package to content views filter :id: 1cc8d921-92e5-4b51-8050-a7e775095f97 @@ -1769,8 +1827,10 @@ def test_positive_add_package_filter(session, module_org, target_sat): filter_name = gen_string('alpha') repo_name = gen_string('alpha') target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -1792,7 +1852,9 @@ def test_positive_add_package_filter(session, module_org, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 -def test_positive_add_package_inclusion_filter_and_publish(session, module_org, target_sat): +def test_positive_add_package_inclusion_filter_and_publish( + session, module_target_sat, module_org, target_sat +): """Add package to inclusion content views filter, publish CV and verify package was actually filtered @@ -1807,8 +1869,10 @@ def test_positive_add_package_inclusion_filter_and_publish(session, module_org, package1_name = 'cow' package2_name = 'bear' target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -1836,7 +1900,9 @@ def test_positive_add_package_inclusion_filter_and_publish(session, module_org, @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 -def test_positive_add_package_exclusion_filter_and_publish(session, module_org, target_sat): +def test_positive_add_package_exclusion_filter_and_publish( + session, module_target_sat, module_org, target_sat +): """Add package to exclusion content views filter, publish CV and verify package was actually filtered @@ -1851,8 +1917,10 @@ def test_positive_add_package_exclusion_filter_and_publish(session, module_org, package1_name = 'cow' package2_name = 'bear' target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -1881,7 +1949,9 @@ def test_positive_add_package_exclusion_filter_and_publish(session, module_org, @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_package_from_exclusion_filter(session, module_org, target_sat): +def test_positive_remove_package_from_exclusion_filter( + session, module_target_sat, module_org, target_sat +): """Remove package from content view exclusion filter :id: 2f0adc16-2305-4adf-8582-82e6110fa385 @@ -1928,7 +1998,9 @@ def test_positive_remove_package_from_exclusion_filter(session, module_org, targ @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 -def test_positive_update_inclusive_filter_package_version(session, module_org, target_sat): +def test_positive_update_inclusive_filter_package_version( + session, module_target_sat, module_org, target_sat +): """Update version of package inside inclusive cv package filter :id: 8d6801de-ab82-49d6-bdeb-0f6e5c95b906 @@ -1942,8 +2014,10 @@ def test_positive_update_inclusive_filter_package_version(session, module_org, t repo_name = gen_string('alpha') package_name = 'walrus' target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -1990,7 +2064,9 @@ def test_positive_update_inclusive_filter_package_version(session, module_org, t @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 -def test_positive_update_exclusive_filter_package_version(session, module_org, target_sat): +def test_positive_update_exclusive_filter_package_version( + session, module_target_sat, module_org, target_sat +): """Update version of package inside exclusive cv package filter :id: a8aa8864-190a-46c3-aeed-4953c8f3f601 @@ -2004,8 +2080,10 @@ def test_positive_update_exclusive_filter_package_version(session, module_org, t repo_name = gen_string('alpha') package_name = 'walrus' target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -2053,7 +2131,9 @@ def test_positive_update_exclusive_filter_package_version(session, module_org, t @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_add_all_security_errata_by_date_range_filter(session, module_org, target_sat): +def test_positive_add_all_security_errata_by_date_range_filter( + session, module_target_sat, module_org, target_sat +): """Create erratum date range filter to include only security errata and publish new content view version @@ -2104,7 +2184,7 @@ def test_positive_add_all_security_errata_by_date_range_filter(session, module_o @pytest.mark.run_in_one_thread @pytest.mark.skip_if_not_set('fake_manifest') @pytest.mark.tier3 -def test_positive_edit_rh_custom_spin(session, target_sat): +def test_positive_edit_rh_custom_spin(session, module_target_sat, target_sat): """Edit content views for a custom rh spin. For example, modify a filter. :id: 05639074-ef6d-4c6b-8ff6-53033821e686 @@ -2117,13 +2197,15 @@ def test_positive_edit_rh_custom_spin(session, target_sat): filter_name = gen_string('alpha') start_date = datetime.date(2016, 1, 1) end_date = datetime.date(2016, 6, 1) - org = entities.Organization().create() - lce = entities.LifecycleEnvironment(organization=org).create() + org = module_target_sat.api.Organization().create() + lce = module_target_sat.api.LifecycleEnvironment(organization=org).create() repos_collection = target_sat.cli_factory.RepositoryCollection( distro='rhel7', repositories=[target_sat.cli_factory.SatelliteToolsRepository()] ) repos_collection.setup_content(org.id, lce.id, upload_manifest=True) - cv = entities.ContentView(id=repos_collection.setup_content_data['content_view']['id']).read() + cv = module_target_sat.api.ContentView( + id=repos_collection.setup_content_data['content_view']['id'] + ).read() with session: session.organization.select(org.name) session.contentviewfilter.create( @@ -2163,7 +2245,7 @@ def test_positive_edit_rh_custom_spin(session, target_sat): @pytest.mark.skip_if_not_set('fake_manifest') @pytest.mark.upgrade @pytest.mark.tier2 -def test_positive_promote_with_rh_custom_spin(session, target_sat): +def test_positive_promote_with_rh_custom_spin(session, module_target_sat, target_sat): """attempt to promote a content view containing a custom RH spin - i.e., contains filters. @@ -2174,13 +2256,15 @@ def test_positive_promote_with_rh_custom_spin(session, target_sat): :CaseImportance: Critical """ filter_name = gen_string('alpha') - org = entities.Organization().create() - lce = entities.LifecycleEnvironment(organization=org).create() + org = module_target_sat.api.Organization().create() + lce = module_target_sat.api.LifecycleEnvironment(organization=org).create() repos_collection = target_sat.cli_factory.RepositoryCollection( distro='rhel7', repositories=[target_sat.cli_factory.SatelliteToolsRepository()] ) repos_collection.setup_content(org.id, lce.id, upload_manifest=True) - cv = entities.ContentView(id=repos_collection.setup_content_data['content_view']['id']).read() + cv = module_target_sat.api.ContentView( + id=repos_collection.setup_content_data['content_view']['id'] + ).read() with session: session.organization.select(org.name) # add a package exclude filter @@ -2208,7 +2292,7 @@ def test_positive_promote_with_rh_custom_spin(session, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_add_all_security_errata_by_id_filter(session, module_org): +def test_positive_add_all_security_errata_by_id_filter(session, module_target_sat, module_org): """Create erratum filter to include only security errata and publish new content view version @@ -2224,10 +2308,12 @@ def test_positive_add_all_security_errata_by_id_filter(session, module_org): """ version = 'Version 2.0' filter_name = gen_string('alphanumeric') - product = entities.Product(organization=module_org).create() - repo = entities.Repository(product=product, url=settings.repos.yum_9.url).create() + product = module_target_sat.api.Product(organization=module_org).create() + repo = module_target_sat.api.Repository(product=product, url=settings.repos.yum_9.url).create() repo.sync() - content_view = entities.ContentView(organization=module_org, repository=[repo]).create() + content_view = module_target_sat.api.ContentView( + organization=module_org, repository=[repo] + ).create() content_view.publish() with session: session.contentviewfilter.create( @@ -2253,7 +2339,7 @@ def test_positive_add_all_security_errata_by_id_filter(session, module_org): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 -def test_positive_add_errata_filter(session, module_org, target_sat): +def test_positive_add_errata_filter(session, module_target_sat, module_org, target_sat): """add errata to content views filter :id: bb9eef30-62c4-435c-9573-9f31210b8d7d @@ -2266,8 +2352,10 @@ def test_positive_add_errata_filter(session, module_org, target_sat): filter_name = gen_string('alpha') repo_name = gen_string('alpha') target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -2290,7 +2378,7 @@ def test_positive_add_errata_filter(session, module_org, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_add_module_stream_filter(session, module_org, target_sat): +def test_positive_add_module_stream_filter(session, module_target_sat, module_org, target_sat): """add module stream filter in a content view :id: 343c543e-5773-4ea4-aff4-27e0ed6be19e @@ -2305,8 +2393,10 @@ def test_positive_add_module_stream_filter(session, module_org, target_sat): target_sat.api_factory.create_sync_custom_repo( module_org.id, repo_name=repo_name, repo_url=settings.repos.module_stream_1.url ) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -2329,7 +2419,7 @@ def test_positive_add_module_stream_filter(session, module_org, target_sat): @pytest.mark.tier3 -def test_positive_add_package_group_filter(session, module_org, target_sat): +def test_positive_add_package_group_filter(session, module_target_sat, module_org, target_sat): """add package group to content views filter :id: 8c02a432-8b2a-4ba3-9613-7070b2dc2bcb @@ -2343,8 +2433,10 @@ def test_positive_add_package_group_filter(session, module_org, target_sat): repo_name = gen_string('alpha') package_group = 'mammals' target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo_name) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -2362,7 +2454,7 @@ def test_positive_add_package_group_filter(session, module_org, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_update_filter_affected_repos(session, module_org, target_sat): +def test_positive_update_filter_affected_repos(session, module_target_sat, module_org, target_sat): """Update content view package filter affected repos :id: 8f095b11-fd63-4a23-9586-a85d6191314f @@ -2382,9 +2474,15 @@ def test_positive_update_filter_affected_repos(session, module_org, target_sat): module_org.id, repo_name=repo1_name, repo_url=settings.repos.yum_3.url ) target_sat.api_factory.create_sync_custom_repo(module_org.id, repo_name=repo2_name) - repo1 = entities.Repository(name=repo1_name).search(query={'organization_id': module_org.id})[0] - repo2 = entities.Repository(name=repo2_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo1, repo2]).create() + repo1 = module_target_sat.api.Repository(name=repo1_name).search( + query={'organization_id': module_org.id} + )[0] + repo2 = module_target_sat.api.Repository(name=repo2_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView( + organization=module_org, repository=[repo1, repo2] + ).create() with session: # create a filter that affects a subset of repos in the cv session.contentviewfilter.create( @@ -2424,7 +2522,7 @@ def test_positive_update_filter_affected_repos(session, module_org, target_sat): @pytest.mark.tier3 -def test_positive_search_composite(session): +def test_positive_search_composite(session, module_target_sat): """Search for content view by its composite property criteria :id: 214a721b-3993-4251-9b7c-0f6d2446c1d1 @@ -2446,7 +2544,9 @@ def test_positive_search_composite(session): @pytest.mark.tier3 -def test_positive_publish_with_repo_with_disabled_http(session, module_org, target_sat): +def test_positive_publish_with_repo_with_disabled_http( + session, module_target_sat, module_org, target_sat +): """Attempt to publish content view with repository that set 'Unprotected' to False @@ -2516,8 +2616,8 @@ def test_positive_subscribe_system_with_custom_content( :CaseImportance: High """ - org = entities.Organization().create() - lce = entities.LifecycleEnvironment(organization=org).create() + org = target_sat.api.Organization().create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() repos_collection.setup_content(org.id, lce.id, upload_manifest=True) repos_collection.setup_virtual_machine(rhel7_contenthost) assert rhel7_contenthost.subscribed @@ -2550,16 +2650,16 @@ def test_positive_delete_with_kickstart_repo_and_host_group( """ hg_name = gen_string('alpha') sat_hostname = target_sat.hostname - org = entities.Organization().create() + org = target_sat.api.Organization().create() # Create a new Lifecycle environment - lc_env = entities.LifecycleEnvironment(organization=org).create() + lc_env = target_sat.api.LifecycleEnvironment(organization=org).create() # Create a Product and Kickstart Repository for OS distribution content - product = entities.Product(organization=org).create() - repo = entities.Repository(product=product, url=settings.repos.rhel7_os).create() + product = target_sat.api.Product(organization=org).create() + repo = target_sat.api.Repository(product=product, url=settings.repos.rhel7_os).create() # Repo sync procedure call_entity_method_with_timeout(repo.sync, timeout=3600) # Create, Publish and promote CV - content_view = entities.ContentView(organization=org).create() + content_view = target_sat.api.ContentView(organization=org).create() content_view.repository = [repo] content_view = content_view.update(['repository']) content_view.publish() @@ -2567,13 +2667,15 @@ def test_positive_delete_with_kickstart_repo_and_host_group( content_view.version[0].promote(data={'environment_ids': lc_env.id}) cv_name = content_view.name # Get the Partition table ID - ptable = entities.PartitionTable().search(query={'search': f'name="{DEFAULT_PTABLE}"'})[0] + ptable = target_sat.api.PartitionTable().search(query={'search': f'name="{DEFAULT_PTABLE}"'})[0] # Get the arch ID arch = ( - entities.Architecture().search(query={'search': f'name="{DEFAULT_ARCHITECTURE}"'})[0].read() + target_sat.api.Architecture() + .search(query={'search': f'name="{DEFAULT_ARCHITECTURE}"'})[0] + .read() ) # Get the OS ID - os = entities.OperatingSystem().search( + os = target_sat.api.OperatingSystem().search( query={'search': 'name="RedHat" AND (major="6" OR major="7")'} )[0] # Update the OS to associate arch and ptable @@ -2626,7 +2728,7 @@ def test_positive_rh_mixed_content_end_to_end( :CaseImportance: High """ cv_name = gen_string('alpha') - docker_repo = entities.Repository( + docker_repo = target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=module_prod, content_type=REPO_TYPE['docker'] ).create() rh_st_repo = { @@ -2638,7 +2740,7 @@ def test_positive_rh_mixed_content_end_to_end( } target_sat.api_factory.enable_sync_redhat_repo(rh_st_repo, module_entitlement_manifest_org.id) docker_repo.sync() - lce = entities.LifecycleEnvironment(organization=module_entitlement_manifest_org).create() + lce = target_sat.api.LifecycleEnvironment(organization=module_entitlement_manifest_org).create() with session: session.organization.select(module_org.name) session.contentview.create({'name': cv_name}) @@ -2661,7 +2763,7 @@ def test_positive_rh_mixed_content_end_to_end( @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_errata_inc_update_list_package(session, target_sat): +def test_positive_errata_inc_update_list_package(session, module_target_sat, target_sat): """Publish incremental update with a new errata for a custom repo :BZ: 1489778 @@ -2675,11 +2777,11 @@ def test_positive_errata_inc_update_list_package(session, target_sat): :CaseImportance: High """ - org = entities.Organization().create() - product = entities.Product(organization=org).create() + org = module_target_sat.api.Organization().create() + product = module_target_sat.api.Product(organization=org).create() yum_repo_name = gen_string('alpha') # Creates custom yum repository - yum_repo = entities.Repository( + yum_repo = module_target_sat.api.Repository( name=yum_repo_name, url=settings.repos.yum_1.url, content_type=REPO_TYPE['yum'], @@ -2687,18 +2789,18 @@ def test_positive_errata_inc_update_list_package(session, target_sat): ).create() product.sync() # creating cv, cv filter, and publish cv - cv = entities.ContentView(organization=org, repository=[yum_repo]).create() - cvf = entities.RPMContentViewFilter( + cv = module_target_sat.api.ContentView(organization=org, repository=[yum_repo]).create() + cvf = module_target_sat.api.RPMContentViewFilter( content_view=cv, inclusion=True, name=gen_string('alphanumeric') ).create() - entities.ContentViewFilterRule( + module_target_sat.api.ContentViewFilterRule( content_view_filter=cvf, name='walrus', version='0.71', ).create() cv.publish() # Get published content-view version info - cvvs = entities.ContentView(id=cv.id).read().version + cvvs = module_target_sat.api.ContentView(id=cv.id).read().version assert len(cvvs) == 1 cvv = cvvs[0].read() result = ContentView.version_incremental_update( @@ -2707,7 +2809,7 @@ def test_positive_errata_inc_update_list_package(session, target_sat): result = [line.strip() for line_dict in result for line in line_dict.values()] with session: session.organization.select(org.name) - cvv = entities.ContentView(id=cv.id).read().version[1].read() + cvv = module_target_sat.api.ContentView(id=cv.id).read().version[1].read() version = session.contentview.read_version(cv.name, f'Version {cvv.version}') errata = version['errata']['table'] assert len(errata) == 1 @@ -2721,7 +2823,9 @@ def test_positive_errata_inc_update_list_package(session, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_composite_child_inc_update(session, rhel7_contenthost, target_sat): +def test_positive_composite_child_inc_update( + session, module_target_sat, rhel7_contenthost, target_sat +): """Incremental update with a new errata on a child content view should trigger incremental update of parent composite content view @@ -2761,12 +2865,12 @@ def test_positive_composite_child_inc_update(session, rhel7_contenthost, target_ :parametrized: yes """ - org = entities.Organization().create() - lce = entities.LifecycleEnvironment(organization=org).create() - product = entities.Product(organization=org).create() + org = module_target_sat.api.Organization().create() + lce = module_target_sat.api.LifecycleEnvironment(organization=org).create() + product = module_target_sat.api.Product(organization=org).create() yum_repo_name = gen_string('alpha') # Creates custom yum repository - yum_repo = entities.Repository( + yum_repo = module_target_sat.api.Repository( name=yum_repo_name, url=settings.repos.yum_1.url, content_type=REPO_TYPE['yum'], @@ -2774,17 +2878,17 @@ def test_positive_composite_child_inc_update(session, rhel7_contenthost, target_ ).create() product.sync() # creating cv, cv filter, and publish cv - cv = entities.ContentView(organization=org, repository=[yum_repo]).create() - cvf = entities.RPMContentViewFilter( + cv = module_target_sat.api.ContentView(organization=org, repository=[yum_repo]).create() + cvf = module_target_sat.api.RPMContentViewFilter( content_view=cv, inclusion=False, name=gen_string('alphanumeric') ).create() - entities.ContentViewFilterRule( + module_target_sat.api.ContentViewFilterRule( content_view_filter=cvf, name='walrus', version='5.21', ).create() cv.publish() - cvv = entities.ContentView(id=cv.id).read().version[0] + cvv = module_target_sat.api.ContentView(id=cv.id).read().version[0] cvv.promote(data={'environment_ids': lce.id}) # Setup tools repo and add it to ak repos_collection = target_sat.cli_factory.RepositoryCollection( @@ -2801,10 +2905,10 @@ def test_positive_composite_child_inc_update(session, rhel7_contenthost, target_ result = target_sat.execute(command) assert result.status == 0 # Create composite cv - composite_cv = entities.ContentView(composite=True, organization=org).create() + composite_cv = module_target_sat.api.ContentView(composite=True, organization=org).create() # Adds all repos to composite cv composite_cv.component = [ - entities.ContentView(id=content_data['content_view']['id']).read().version[0], + module_target_sat.api.ContentView(id=content_data['content_view']['id']).read().version[0], cvv, ] composite_cv = composite_cv.update(['component']) @@ -2812,7 +2916,7 @@ def test_positive_composite_child_inc_update(session, rhel7_contenthost, target_ composite_cv.publish() composite_cv.read().version[0].promote(data={'environment_ids': lce.id}) # Update AK to use composite cv - entities.ActivationKey( + module_target_sat.api.ActivationKey( id=content_data['activation_key']['id'], content_view=composite_cv ).update(['content_view']) repos_collection.setup_virtual_machine(rhel7_contenthost) @@ -2838,7 +2942,7 @@ def test_positive_composite_child_inc_update(session, rhel7_contenthost, target_ @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_module_stream_end_to_end(session, module_org, target_sat): +def test_positive_module_stream_end_to_end(session, module_target_sat, module_org, target_sat): """Create content view with custom module_stream contents, publish and promote it to Library +1 env. Then disassociate repository from that content view @@ -2886,7 +2990,9 @@ def test_positive_module_stream_end_to_end(session, module_org, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_search_module_streams_in_content_view(session, module_org, target_sat): +def test_positive_search_module_streams_in_content_view( + session, module_target_sat, module_org, target_sat +): """Search module streams in content view version :id: 7f5273ff-e80f-459d-adf4-b517b6d60fdc @@ -2901,8 +3007,10 @@ def test_positive_search_module_streams_in_content_view(session, module_org, tar target_sat.api_factory.create_sync_custom_repo( module_org.id, repo_name=repo_name, repo_url=settings.repos.module_stream_1.url ) - repo = entities.Repository(name=repo_name).search(query={'organization_id': module_org.id})[0] - cv = entities.ContentView(organization=module_org, repository=[repo]).create() + repo = module_target_sat.api.Repository(name=repo_name).search( + query={'organization_id': module_org.id} + )[0] + cv = module_target_sat.api.ContentView(organization=module_org, repository=[repo]).create() with session: result = session.contentview.publish(cv.name) assert result['Version'] == VERSION @@ -2918,7 +3026,9 @@ def test_positive_search_module_streams_in_content_view(session, module_org, tar @pytest.mark.tier2 -def test_positive_non_admin_user_actions(session, module_org, test_name, target_sat): +def test_positive_non_admin_user_actions( + session, module_target_sat, module_org, test_name, target_sat +): """Attempt to manage content views :id: c4d270fc-a3e6-4ae2-a338-41d864a5622a @@ -2946,9 +3056,9 @@ def test_positive_non_admin_user_actions(session, module_org, test_name, target_ cv_copy_name = gen_string('alpha') user_login = gen_string('alpha') user_password = gen_string('alphanumeric') - lce = entities.LifecycleEnvironment(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() # create a role with all content views permissions - role = entities.Role().create() + role = module_target_sat.api.Role().create() target_sat.api_factory.create_role_permissions( role, {'Katello::ContentView': PERMISSIONS['Katello::ContentView']} ) @@ -2963,7 +3073,7 @@ def test_positive_non_admin_user_actions(session, module_org, test_name, target_ search=f'name = {ENVIRONMENT} or name = {lce.name}', ) # create a user and assign the above created role - entities.User( + module_target_sat.api.User( default_organization=module_org, organization=[module_org], role=[role], @@ -2981,7 +3091,7 @@ def test_positive_non_admin_user_actions(session, module_org, test_name, target_ session.contentview.copy(cv_name, cv_copy_name) assert session.contentview.search(cv_copy_name)[0]['Name'] == cv_copy_name # login as the user created above - with Session(test_name, user=user_login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user_login, password=user_password) as session: with pytest.raises(NavigationTriesExceeded): session.organization.create({'name': gen_string('alpha'), 'label': gen_string('alpha')}) # assert the user can view all the content views created @@ -3030,13 +3140,13 @@ def test_positive_readonly_user_actions(module_org, test_name, target_sat): user_login = gen_string('alpha') user_password = gen_string('alphanumeric') # create a role with content views read only permissions - role = entities.Role().create() + role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions( role, {'Katello::ContentView': ['view_content_views']} ) target_sat.api_factory.create_role_permissions(role, {'Katello::Product': ['view_products']}) # create a user and assign the above created role - entities.User( + target_sat.api.User( default_organization=module_org, organization=[module_org], role=[role], @@ -3044,11 +3154,11 @@ def test_positive_readonly_user_actions(module_org, test_name, target_sat): password=user_password, ).create() repo_id = target_sat.api_factory.create_sync_custom_repo(module_org.id) - yum_repo = entities.Repository(id=repo_id).read() - cv = entities.ContentView(organization=module_org, repository=[yum_repo]).create() + yum_repo = target_sat.api.Repository(id=repo_id).read() + cv = target_sat.api.ContentView(organization=module_org, repository=[yum_repo]).create() cv.publish() # login as the user created above - with Session(test_name, user=user_login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user_login, password=user_password) as session: with pytest.raises(NavigationTriesExceeded): session.location.create({'name': gen_string('alpha'), 'label': gen_string('alpha')}) assert session.contentview.search(cv.name)[0]['Name'] == cv.name @@ -3059,7 +3169,9 @@ def test_positive_readonly_user_actions(module_org, test_name, target_sat): @pytest.mark.tier2 -def test_negative_read_only_user_actions(session, module_org, test_name, target_sat): +def test_negative_read_only_user_actions( + session, module_target_sat, module_org, test_name, target_sat +): """Attempt to manage content views :id: aae6eede-b40e-4e06-a5f7-59d9251aa35d @@ -3084,9 +3196,9 @@ def test_negative_read_only_user_actions(session, module_org, test_name, target_ # promote_or_remove_content_views_to_environments user_login = gen_string('alpha') user_password = gen_string('alphanumeric') - lce = entities.LifecycleEnvironment(organization=module_org).create() + lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() # create a role with content views read only permissions - role = entities.Role().create() + role = module_target_sat.api.Role().create() target_sat.api_factory.create_role_permissions( role, {'Katello::ContentView': ['view_content_views']} ) @@ -3101,7 +3213,7 @@ def test_negative_read_only_user_actions(session, module_org, test_name, target_ search=f'name = {ENVIRONMENT} or name = {lce.name}', ) # create a user and assign the above created role - entities.User( + module_target_sat.api.User( default_organization=module_org, organization=[module_org], role=[role], @@ -3109,11 +3221,13 @@ def test_negative_read_only_user_actions(session, module_org, test_name, target_ password=user_password, ).create() repo_id = target_sat.api_factory.create_sync_custom_repo(module_org.id) - yum_repo = entities.Repository(id=repo_id).read() + yum_repo = module_target_sat.api.Repository(id=repo_id).read() repo_name = 'fakerepo01' - cv = entities.ContentView(organization=module_org, repository=[yum_repo]).create() + cv = module_target_sat.api.ContentView(organization=module_org, repository=[yum_repo]).create() # login as the user created above - with Session(test_name, user=user_login, password=user_password) as custom_session: + with target_sat.ui_session( + test_name, user=user_login, password=user_password + ) as custom_session: with pytest.raises(NavigationTriesExceeded): custom_session.location.create( {'name': gen_string('alpha'), 'label': gen_string('alpha')} @@ -3129,7 +3243,7 @@ def test_negative_read_only_user_actions(session, module_org, test_name, target_ with session: result = session.contentview.publish(cv.name) assert result['Version'] == VERSION - with Session(test_name, user=user_login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user_login, password=user_password) as session: # Cannot create content view with pytest.raises(NoSuchElementException) as context: session.contentview.create({'name': gen_string('alpha')}) @@ -3185,9 +3299,9 @@ def test_negative_non_readonly_user_actions(module_org, test_name, target_sat): user_password = gen_string('alphanumeric') # create a role with all content views permissions except # view_content_views - lce = entities.LifecycleEnvironment(organization=module_org).create() - cv = entities.ContentView(organization=module_org).create() - role = entities.Role().create() + lce = target_sat.api.LifecycleEnvironment(organization=module_org).create() + cv = target_sat.api.ContentView(organization=module_org).create() + role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions( role, { @@ -3211,7 +3325,7 @@ def test_negative_non_readonly_user_actions(module_org, test_name, target_sat): search=f'name = {ENVIRONMENT} or name = {lce.name}', ) # create a user and assign the above created role - entities.User( + target_sat.api.User( default_organization=module_org, organization=[module_org], role=[role], @@ -3219,7 +3333,7 @@ def test_negative_non_readonly_user_actions(module_org, test_name, target_sat): password=user_password, ).create() # login as the user created above - with Session(test_name, user=user_login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user_login, password=user_password) as session: with pytest.raises(NavigationTriesExceeded): session.user.create( { @@ -3237,7 +3351,9 @@ def test_negative_non_readonly_user_actions(module_org, test_name, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_conservative_solve_dependencies(session, module_org, target_sat): +def test_positive_conservative_solve_dependencies( + session, module_target_sat, module_org, target_sat +): """Performing solve dependencies on a package that is required by another package. Then performing solve dependencies on a root package with its corresponding dependency. @@ -3386,7 +3502,7 @@ def test_positive_conservative_dep_solving_with_multiversion_packages( @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_depsolve_with_module_errata(session, module_org, target_sat): +def test_positive_depsolve_with_module_errata(session, module_target_sat, module_org, target_sat): """Allowing users to filter module streams in content views. This test case does not test against RHEL8 repos because it is known that RHEL8 filtering with depsolving creates inconsistent results. The custom repo used in this test case has consistent results based @@ -3463,7 +3579,7 @@ def test_positive_depsolve_with_module_errata(session, module_org, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier2 -def test_positive_filter_by_pkg_group_name(session, module_org, target_sat): +def test_positive_filter_by_pkg_group_name(session, module_target_sat, module_org, target_sat): """Publish a filtered version of a Content View, filtering on the package group's name. :id: c7021f46-0168-44f7-a863-4aa34533efdb @@ -3504,7 +3620,7 @@ def test_positive_filter_by_pkg_group_name(session, module_org, target_sat): @pytest.mark.skip_if_open('BZ:2086957') @pytest.mark.tier3 -def test_positive_inc_update_should_not_fail(session, module_org): +def test_positive_inc_update_should_not_fail(session, module_target_sat, module_org): """Incremental update after removing a package should not give a 400 error code :BZ: 2041497 @@ -3525,10 +3641,10 @@ def test_positive_inc_update_should_not_fail(session, module_org): :CaseImportance: High """ package1_name = 'bear' - product = entities.Product(organization=module_org).create() + product = module_target_sat.api.Product(organization=module_org).create() yum_repo_name = gen_string('alpha') # Creates custom yum repository - yum_repo = entities.Repository( + yum_repo = module_target_sat.api.Repository( name=yum_repo_name, url=settings.repos.yum_1.url, content_type=REPO_TYPE['yum'], @@ -3539,9 +3655,9 @@ def test_positive_inc_update_should_not_fail(session, module_org): package_id = yum_repo.packages()['results'][0]['id'] yum_repo.remove_content(data={'ids': [package_id]}) assert yum_repo.packages()['total'] == 31 - cv = entities.ContentView(organization=module_org, repository=[yum_repo]).create() + cv = module_target_sat.api.ContentView(organization=module_org, repository=[yum_repo]).create() cv.publish() - cvvs = entities.ContentView(id=cv.id).read().version + cvvs = module_target_sat.api.ContentView(id=cv.id).read().version assert len(cvvs) == 1 yum_repo.sync() assert yum_repo.packages()['total'] == 32 @@ -3552,7 +3668,7 @@ def test_positive_inc_update_should_not_fail(session, module_org): result = [line.strip() for line_dict in result for line in line_dict.values()] assert result[2] == FAKE_0_CUSTOM_PACKAGE with session: - cvv = entities.ContentView(id=cv.id).read().version[1].read() + cvv = module_target_sat.api.ContentView(id=cv.id).read().version[1].read() assert cvv.version == '1.1' packages = session.contentview.search_version_package( cv.name, 'Version 1.1', f'name= "{package1_name}"' @@ -3679,7 +3795,7 @@ def test_positive_no_duplicate_key_violate_unique_constraint_using_filters( @pytest.mark.tier2 -def test_positive_inc_publish_cv(session, module_org): +def test_positive_inc_publish_cv(session, module_target_sat, module_org): """Ensure that the content count gets updated when doing incremental update :BZ: 2032098 @@ -3700,17 +3816,17 @@ def test_positive_inc_publish_cv(session, module_org): :CaseImportance: High """ package_name = 'bear' - product = entities.Product(organization=module_org).create() + product = module_target_sat.api.Product(organization=module_org).create() yum_repo_name = gen_string('alpha') filter_name = gen_string('alpha') - yum_repo = entities.Repository( + yum_repo = module_target_sat.api.Repository( name=yum_repo_name, url=settings.repos.yum_1.url, content_type=REPO_TYPE['yum'], product=product, ).create() yum_repo.sync() - cv = entities.ContentView(organization=module_org, repository=[yum_repo]).create() + cv = module_target_sat.api.ContentView(organization=module_org, repository=[yum_repo]).create() with session: session.contentviewfilter.create( cv.name, @@ -3724,10 +3840,10 @@ def test_positive_inc_publish_cv(session, module_org): cv.name, filter_name, package_name, None, ('Equal To', '4.1-1') ) session.contentview.publish(cv.name) - cvv = entities.ContentView(id=cv.id).read().version[0].read() + cvv = module_target_sat.api.ContentView(id=cv.id).read().version[0].read() assert cvv.package_count == 31 ContentView.version_incremental_update( {'content-view-version-id': cvv.id, 'errata-ids': settings.repos.yum_1.errata[0]} ) - cvv = entities.ContentView(id=cv.id).read().version[1].read() + cvv = module_target_sat.api.ContentView(id=cv.id).read().version[1].read() assert cvv.package_count == 32 diff --git a/tests/foreman/ui/test_dashboard.py b/tests/foreman/ui/test_dashboard.py index e417868e744..b55891475ef 100644 --- a/tests/foreman/ui/test_dashboard.py +++ b/tests/foreman/ui/test_dashboard.py @@ -11,8 +11,6 @@ :CaseImportance: High """ -from airgun.session import Session -from nailgun import entities from nailgun.entity_mixins import TaskFailedError import pytest @@ -23,7 +21,7 @@ @pytest.mark.tier2 -def test_positive_host_configuration_status(session): +def test_positive_host_configuration_status(session, target_sat): """Check if the Host Configuration Status Widget links are working :id: ffb0a6a1-2b65-4578-83c7-61492122d865 @@ -41,9 +39,9 @@ def test_positive_host_configuration_status(session): :BZ: 1631219 """ - org = entities.Organization().create() - loc = entities.Location().create() - host = entities.Host(organization=org, location=loc).create() + org = target_sat.api.Organization().create() + loc = target_sat.api.Location().create() + host = target_sat.api.Host(organization=org, location=loc).create() criteria_list = [ 'Hosts that had performed modifications without error', 'Hosts in error state', @@ -94,7 +92,7 @@ def test_positive_host_configuration_status(session): @pytest.mark.tier2 -def test_positive_host_configuration_chart(session): +def test_positive_host_configuration_chart(session, target_sat): """Check if the Host Configuration Chart is working in the Dashboard UI :id: b03314aa-4394-44e5-86da-c341c783003d @@ -107,9 +105,9 @@ def test_positive_host_configuration_chart(session): :expectedresults: Chart showing correct data """ - org = entities.Organization().create() - loc = entities.Location().create() - entities.Host(organization=org, location=loc).create() + org = target_sat.api.Organization().create() + loc = target_sat.api.Location().create() + target_sat.api.Host(organization=org, location=loc).create() with session: session.organization.select(org_name=org.name) session.location.select(loc_name=loc.name) @@ -120,7 +118,7 @@ def test_positive_host_configuration_chart(session): @pytest.mark.upgrade @pytest.mark.run_in_one_thread @pytest.mark.tier2 -def test_positive_task_status(session): +def test_positive_task_status(session, target_sat): """Check if the Task Status is working in the Dashboard UI and filter from Tasks index page is working correctly @@ -141,9 +139,11 @@ def test_positive_task_status(session): :BZ: 1718889 """ url = 'www.non_existent_repo_url.org' - org = entities.Organization().create() - product = entities.Product(organization=org).create() - repo = entities.Repository(url=f'http://{url}', product=product, content_type='yum').create() + org = target_sat.api.Organization().create() + product = target_sat.api.Product(organization=org).create() + repo = target_sat.api.Repository( + url=f'http://{url}', product=product, content_type='yum' + ).create() with pytest.raises(TaskFailedError): repo.sync() with session: @@ -222,9 +222,9 @@ def test_positive_user_access_with_host_filter( user_login = gen_string('alpha') user_password = gen_string('alphanumeric') org = function_entitlement_manifest_org - lce = entities.LifecycleEnvironment(organization=org).create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() # create a role with necessary permissions - role = entities.Role().create() + role = target_sat.api.Role().create() user_permissions = { 'Organization': ['view_organizations'], 'Location': ['view_locations'], @@ -233,7 +233,7 @@ def test_positive_user_access_with_host_filter( } target_sat.api_factory.create_role_permissions(role, user_permissions) # create a user and assign the above created role - entities.User( + target_sat.api.User( default_organization=org, organization=[org], default_location=module_location, @@ -242,7 +242,7 @@ def test_positive_user_access_with_host_filter( login=user_login, password=user_password, ).create() - with Session(test_name, user=user_login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user_login, password=user_password) as session: assert session.dashboard.read('HostConfigurationStatus')['total_count'] == 0 assert len(session.dashboard.read('LatestErrata')['erratas']) == 0 rhel_contenthost.add_rex_key(target_sat) @@ -266,7 +266,7 @@ def test_positive_user_access_with_host_filter( @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_sync_overview_widget(session, module_org, module_product): +def test_positive_sync_overview_widget(session, module_product, module_target_sat): """Check if the Sync Overview widget is working in the Dashboard UI :id: 553fbe33-0f6f-46fb-8d80-5d1d9ed483cf @@ -280,7 +280,9 @@ def test_positive_sync_overview_widget(session, module_org, module_product): :BZ: 1995424 """ - repo = entities.Repository(url=settings.repos.yum_1.url, product=module_product).create() + repo = module_target_sat.api.Repository( + url=settings.repos.yum_1.url, product=module_product + ).create() with session: session.repository.synchronize(module_product.name, repo.name) sync_params = session.dashboard.read('SyncOverview')['syncs'] diff --git a/tests/foreman/ui/test_discoveryrule.py b/tests/foreman/ui/test_discoveryrule.py index e2b0fcef95e..0ca5af87129 100644 --- a/tests/foreman/ui/test_discoveryrule.py +++ b/tests/foreman/ui/test_discoveryrule.py @@ -11,7 +11,6 @@ :CaseImportance: High """ -from airgun.session import Session from fauxfactory import gen_integer, gen_ipaddr, gen_string import pytest @@ -82,7 +81,9 @@ def test_positive_crud_with_non_admin_user( new_priority = str(gen_integer(101, 200)) hg = module_target_sat.api.HostGroup(organization=[module_org]).create() new_hg_name = module_target_sat.api.HostGroup(organization=[module_org]).create() - with Session(user=manager_user.login, password=manager_user.password) as session: + with module_target_sat.ui_session( + user=manager_user.login, password=manager_user.password + ) as session: session.location.select(loc_name=module_location.name) session.discoveryrule.create( { @@ -145,7 +146,9 @@ def test_negative_delete_rule_with_non_admin_user( organization=[module_org], location=[module_location], ).create() - with Session(user=reader_user.login, password=reader_user.password) as session: + with module_target_sat.ui_session( + user=reader_user.login, password=reader_user.password + ) as session: with pytest.raises(ValueError): # noqa: PT011 - TODO Adarsh determine better exception session.discoveryrule.delete(dr.name) dr_val = session.discoveryrule.read_all() diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index 27683b22543..d7773533a89 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -13,12 +13,10 @@ """ from datetime import datetime -from airgun.session import Session from broker import Broker from dateutil.parser import parse from fauxfactory import gen_string from manifester import Manifester -from nailgun import entities import pytest from robottelo.config import settings @@ -54,9 +52,9 @@ pytestmark = [pytest.mark.run_in_one_thread] -def _generate_errata_applicability(hostname): +def _generate_errata_applicability(hostname, module_target_sat): """Force host to generate errata applicability""" - host = entities.Host().search(query={'search': f'name={hostname}'})[0].read() + host = module_target_sat.api.Host().search(query={'search': f'name={hostname}'})[0].read() host.errata_applicability(synchronous=False) @@ -123,9 +121,9 @@ def erratatype_vm(module_repos_collection_with_setup, target_sat): @pytest.fixture -def errata_status_installable(): +def errata_status_installable(module_target_sat): """Fixture to allow restoring errata_status_installable setting after usage""" - errata_status_installable = entities.Setting().search( + errata_status_installable = module_target_sat.api.Setting().search( query={'search': 'name="errata_status_installable"'} )[0] original_value = errata_status_installable.value @@ -530,7 +528,7 @@ def test_positive_list(session, function_org_with_parameter, lce, target_sat): indirect=True, ) def test_positive_list_permission( - test_name, module_org_with_parameter, module_repos_collection_with_setup + test_name, module_org_with_parameter, module_repos_collection_with_setup, module_target_sat ): """Show errata only if the User has permissions to view them @@ -548,23 +546,25 @@ def test_positive_list_permission( product only. """ module_org = module_org_with_parameter - role = entities.Role().create() - entities.Filter( + role = module_target_sat.api.Role().create() + module_target_sat.api.Filter( organization=[module_org], - permission=entities.Permission().search( + permission=module_target_sat.api.Permission().search( query={'search': 'resource_type="Katello::Product"'} ), role=role, search='name = "{}"'.format(PRDS['rhel']), ).create() user_password = gen_string('alphanumeric') - user = entities.User( + user = module_target_sat.api.User( default_organization=module_org, organization=[module_org], role=[role], password=user_password, ).create() - with Session(test_name, user=user.login, password=user_password) as session: + with module_target_sat.ui_session( + test_name, user=user.login, password=user_password + ) as session: assert ( session.errata.search(RHVA_ERRATA_ID, applicable=False)[0]['Errata ID'] == RHVA_ERRATA_ID @@ -704,14 +704,16 @@ def test_positive_filter_by_environment( module_repos_collection_with_setup.setup_virtual_machine(client) assert client.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 # Promote the latest content view version to a new lifecycle environment - content_view = entities.ContentView( + content_view = target_sat.api.ContentView( id=module_repos_collection_with_setup.setup_content_data['content_view']['id'] ).read() content_view_version = content_view.version[-1].read() lce = content_view_version.environment[-1].read() - new_lce = entities.LifecycleEnvironment(organization=module_org, prior=lce).create() + new_lce = target_sat.api.LifecycleEnvironment(organization=module_org, prior=lce).create() content_view_version.promote(data={'environment_ids': new_lce.id}) - host = entities.Host().search(query={'search': f'name={clients[0].hostname}'})[0].read() + host = ( + target_sat.api.Host().search(query={'search': f'name={clients[0].hostname}'})[0].read() + ) host.content_facet_attributes = { 'content_view_id': content_view.id, 'lifecycle_environment_id': new_lce.id, @@ -752,7 +754,7 @@ def test_positive_filter_by_environment( indirect=True, ) def test_positive_content_host_previous_env( - session, module_org_with_parameter, module_repos_collection_with_setup, vm + session, module_org_with_parameter, module_repos_collection_with_setup, vm, module_target_sat ): """Check if the applicable errata are available from the content host's previous environment @@ -775,14 +777,16 @@ def test_positive_content_host_previous_env( hostname = vm.hostname assert vm.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 # Promote the latest content view version to a new lifecycle environment - content_view = entities.ContentView( + content_view = module_target_sat.api.ContentView( id=module_repos_collection_with_setup.setup_content_data['content_view']['id'] ).read() content_view_version = content_view.version[-1].read() lce = content_view_version.environment[-1].read() - new_lce = entities.LifecycleEnvironment(organization=module_org, prior=lce).create() + new_lce = module_target_sat.api.LifecycleEnvironment( + organization=module_org, prior=lce + ).create() content_view_version.promote(data={'environment_ids': new_lce.id}) - host = entities.Host().search(query={'search': f'name={hostname}'})[0].read() + host = module_target_sat.api.Host().search(query={'search': f'name={hostname}'})[0].read() host.content_facet_attributes = { 'content_view_id': content_view.id, 'lifecycle_environment_id': new_lce.id, @@ -1050,7 +1054,7 @@ def test_positive_filtered_errata_status_installable_param( :CaseImportance: Medium """ org = function_entitlement_manifest_org - lce = entities.LifecycleEnvironment(organization=org).create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() repos_collection = target_sat.cli_factory.RepositoryCollection( distro='rhel7', repositories=[ @@ -1067,16 +1071,16 @@ def test_positive_filtered_errata_status_installable_param( assert client.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 # Adding content view filter and content view filter rule to exclude errata for the # installed package. - content_view = entities.ContentView( + content_view = target_sat.api.ContentView( id=repos_collection.setup_content_data['content_view']['id'] ).read() - cv_filter = entities.ErratumContentViewFilter( + cv_filter = target_sat.api.ErratumContentViewFilter( content_view=content_view, inclusion=False ).create() - errata = entities.Errata(content_view_version=content_view.version[-1]).search( + errata = target_sat.api.Errata(content_view_version=content_view.version[-1]).search( query=dict(search=f'errata_id="{CUSTOM_REPO_ERRATA_ID}"') )[0] - entities.ContentViewFilterRule(content_view_filter=cv_filter, errata=errata).create() + target_sat.api.ContentViewFilterRule(content_view_filter=cv_filter, errata=errata).create() content_view.publish() content_view = content_view.read() content_view_version = content_view.version[-1] diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index 53913c09016..65dfb73d688 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -18,7 +18,6 @@ import re from airgun.exceptions import DisabledWidgetError, NoSuchElementException -from airgun.session import Session import pytest from wait_for import wait_for import yaml @@ -496,7 +495,7 @@ def test_positive_view_hosts_with_non_admin_user( created_host = target_sat.api.Host( location=smart_proxy_location, organization=module_org ).create() - with Session(test_name, user=user.login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user.login, password=user_password) as session: host = session.host.get_details(created_host.name, widget_names='breadcrumb') assert host['breadcrumb'] == created_host.name content_host = session.contenthost.read(created_host.name, widget_names='breadcrumb') @@ -545,7 +544,7 @@ def test_positive_remove_parameter_non_admin_user( organization=module_org, host_parameters_attributes=[parameter], ).create() - with Session(test_name, user=user.login, password=user_password) as session: + with target_sat.ui_seesion(test_name, user=user.login, password=user_password) as session: values = session.host.read(host.name, 'parameters') assert values['parameters']['host_params'][0] == parameter session.host.update(host.name, {'parameters.host_params': []}) @@ -600,7 +599,7 @@ def test_negative_remove_parameter_non_admin_user( organization=module_org, host_parameters_attributes=[parameter], ).create() - with Session(test_name, user=user.login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user.login, password=user_password) as session: values = session.host.read(host.name, 'parameters') assert values['parameters']['host_params'][0] == parameter with pytest.raises(NoSuchElementException) as context: @@ -709,7 +708,7 @@ def test_positive_check_permissions_affect_create_procedure( 'other_fields_values': {'host.lce': filter_lc_env.name}, }, ] - with Session(test_name, user=user.login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user.login, password=user_password) as session: for host_field in host_fields: values = {host_field['name']: host_field['unexpected_value']} values.update(host_field.get('other_fields_values', {})) @@ -2348,7 +2347,7 @@ def test_positive_host_registration_with_non_admin_user( role = target_sat.cli.Role.info({'name': 'Register hosts'}) target_sat.cli.User.add_role({'id': user.id, 'role-id': role['id']}) - with Session(test_name, user=user.login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user.login, password=user_password) as session: cmd = session.host_new.get_register_command( { @@ -2366,7 +2365,7 @@ def test_positive_host_registration_with_non_admin_user( @pytest.mark.tier2 -def test_all_hosts_delete(session, target_sat, function_org, function_location, new_host_ui): +def test_all_hosts_delete(target_sat, function_org, function_location, new_host_ui): """Create a host and delete it through All Hosts UI :id: 42b4560c-bb57-4c58-928e-e5fd5046b93f @@ -2385,7 +2384,7 @@ def test_all_hosts_delete(session, target_sat, function_org, function_location, @pytest.mark.tier2 -def test_all_hosts_bulk_delete(session, target_sat, function_org, function_location, new_host_ui): +def test_all_hosts_bulk_delete(target_sat, function_org, function_location, new_host_ui): """Create several hosts, and delete them via Bulk Actions in All Hosts UI :id: af1b4a66-dd83-47c3-904b-e8627119cc53 diff --git a/tests/foreman/ui/test_ldap_authentication.py b/tests/foreman/ui/test_ldap_authentication.py index e882f1c489d..8c799a72dc8 100644 --- a/tests/foreman/ui/test_ldap_authentication.py +++ b/tests/foreman/ui/test_ldap_authentication.py @@ -13,9 +13,7 @@ """ import os -from airgun.session import Session from fauxfactory import gen_url -from nailgun import entities from navmazing import NavigationTriesExceeded import pyotp import pytest @@ -55,43 +53,43 @@ def set_certificate_in_satellite(server_type, target_sat, hostname=None): @pytest.fixture -def ldap_usergroup_name(): +def ldap_usergroup_name(target_sat): """Return some random usergroup name, and attempt to delete such usergroup when test finishes. """ usergroup_name = gen_string('alphanumeric') yield usergroup_name - user_groups = entities.UserGroup().search(query={'search': f'name="{usergroup_name}"'}) + user_groups = target_sat.api.UserGroup().search(query={'search': f'name="{usergroup_name}"'}) if user_groups: user_groups[0].delete() @pytest.fixture -def ldap_tear_down(): +def ldap_tear_down(target_sat): """Teardown the all ldap settings user, usergroup and ldap delete""" yield - ldap_auth_sources = entities.AuthSourceLDAP().search() + ldap_auth_sources = target_sat.api.AuthSourceLDAP().search() for ldap_auth in ldap_auth_sources: - users = entities.User(auth_source=ldap_auth).search() + users = target_sat.api.User(auth_source=ldap_auth).search() for user in users: user.delete() ldap_auth.delete() @pytest.fixture -def external_user_count(): +def external_user_count(target_sat): """return the external auth source user count""" - users = entities.User().search() + users = target_sat.api.User().search() return len([user for user in users if user.auth_source_name == 'External']) @pytest.fixture -def groups_teardown(): +def groups_teardown(target_sat): """teardown for groups created for external/remote groups""" yield # tier down groups for group_name in ('sat_users', 'sat_admins', EXTERNAL_GROUP_NAME): - user_groups = entities.UserGroup().search(query={'search': f'name="{group_name}"'}) + user_groups = target_sat.api.UserGroup().search(query={'search': f'name="{group_name}"'}) if user_groups: user_groups[0].delete() @@ -172,7 +170,7 @@ def test_positive_end_to_end(session, ldap_auth_source, ldap_tear_down): @pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA', 'OPENLDAP'], indirect=True) @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_create_org_and_loc(session, ldap_auth_source, ldap_tear_down): +def test_positive_create_org_and_loc(session, ldap_auth_source, ldap_tear_down, target_sat): """Create LDAP auth_source with org and loc assigned. :id: 4f595af4-fc01-44c6-a614-a9ec827e3c3c @@ -190,8 +188,8 @@ def test_positive_create_org_and_loc(session, ldap_auth_source, ldap_tear_down): :parametrized: yes """ ldap_data, auth_source = ldap_auth_source - org = entities.Organization().create() - loc = entities.Location().create() + org = target_sat.api.Organization().create() + loc = target_sat.api.Location().create() ldap_auth_name = gen_string('alphanumeric') with session: session.ldapauthentication.create( @@ -256,7 +254,7 @@ def test_positive_add_katello_role( auth_source_name = f'LDAP-{auth_source.name}' ak_name = gen_string('alpha') user_permissions = {'Katello::ActivationKey': PERMISSIONS['Katello::ActivationKey']} - katello_role = entities.Role().create() + katello_role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions(katello_role, user_permissions) with session: session.usergroup.create( @@ -269,7 +267,9 @@ def test_positive_add_katello_role( ) assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name session.usergroup.refresh_external_group(ldap_usergroup_name, EXTERNAL_GROUP_NAME) - with Session(test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd']) as session: + with target_sat.ui_session( + test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] + ) as session: with pytest.raises(NavigationTriesExceeded): session.architecture.search('') session.activationkey.create({'name': ak_name}) @@ -308,8 +308,8 @@ def test_positive_update_external_roles( ak_name = gen_string('alpha') auth_source_name = f'LDAP-{auth_source.name}' location_name = gen_string('alpha') - foreman_role = entities.Role().create() - katello_role = entities.Role().create() + foreman_role = target_sat.api.Role().create() + katello_role = target_sat.api.Role().create() foreman_permissions = {'Location': PERMISSIONS['Location']} katello_permissions = {'Katello::ActivationKey': PERMISSIONS['Katello::ActivationKey']} target_sat.api_factory.create_role_permissions(foreman_role, foreman_permissions) @@ -324,19 +324,23 @@ def test_positive_update_external_roles( } ) assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded): ldapsession.architecture.search('') ldapsession.location.create({'name': location_name}) - location = entities.Location().search(query={'search': f'name="{location_name}"'})[0] + location = target_sat.api.Location().search( + query={'search': f'name="{location_name}"'} + )[0] assert location.name == location_name session.usergroup.update( ldap_usergroup_name, {'roles.resources.assigned': [katello_role.name]} ) session.usergroup.refresh_external_group(ldap_usergroup_name, EXTERNAL_GROUP_NAME) - with Session(test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd']) as session: + with target_sat.ui_session( + test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] + ) as session: session.activationkey.create({'name': ak_name}) assert session.activationkey.search(ak_name)[0]['Name'] == ak_name current_user = session.activationkey.read(ak_name, 'current_user')['current_user'] @@ -374,7 +378,7 @@ def test_positive_delete_external_roles( ldap_data, auth_source = ldap_auth_source auth_source_name = f'LDAP-{auth_source.name}' location_name = gen_string('alpha') - foreman_role = entities.Role().create() + foreman_role = target_sat.api.Role().create() foreman_permissions = {'Location': PERMISSIONS['Location']} target_sat.api_factory.create_role_permissions(foreman_role, foreman_permissions) with session: @@ -387,18 +391,20 @@ def test_positive_delete_external_roles( } ) assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded): ldapsession.architecture.search('') ldapsession.location.create({'name': location_name}) - location = entities.Location().search(query={'search': f'name="{location_name}"'})[0] + location = target_sat.api.Location().search( + query={'search': f'name="{location_name}"'} + )[0] assert location.name == location_name session.usergroup.update( ldap_usergroup_name, {'roles.resources.unassigned': [foreman_role.name]} ) - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded): @@ -441,8 +447,8 @@ def test_positive_update_external_user_roles( ak_name = gen_string('alpha') auth_source_name = f'LDAP-{auth_source.name}' location_name = gen_string('alpha') - foreman_role = entities.Role().create() - katello_role = entities.Role().create() + foreman_role = target_sat.api.Role().create() + katello_role = target_sat.api.Role().create() foreman_permissions = {'Location': PERMISSIONS['Location']} katello_permissions = {'Katello::ActivationKey': PERMISSIONS['Katello::ActivationKey']} target_sat.api_factory.create_role_permissions(foreman_role, foreman_permissions) @@ -457,17 +463,21 @@ def test_positive_update_external_user_roles( } ) assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: ldapsession.location.create({'name': location_name}) - location = entities.Location().search(query={'search': f'name="{location_name}"'})[0] + location = target_sat.api.Location().search( + query={'search': f'name="{location_name}"'} + )[0] assert location.name == location_name session.location.select(ANY_CONTEXT['location']) session.user.update( ldap_data['ldap_user_name'], {'roles.resources.assigned': [katello_role.name]} ) - with Session(test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd']) as session: + with target_sat.ui_session( + test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] + ) as session: with pytest.raises(NavigationTriesExceeded): ldapsession.architecture.search('') session.activationkey.create({'name': ak_name}) @@ -485,6 +495,7 @@ def test_positive_add_admin_role_with_org_loc( module_org, ldap_tear_down, ldap_auth_source, + target_sat, ): """Associate Admin role to User Group with org and loc set. [belonging to external User Group.] @@ -521,7 +532,9 @@ def test_positive_add_admin_role_with_org_loc( } ) assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name - with Session(test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd']) as session: + with target_sat.ui_session( + test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] + ) as session: session.location.create({'name': location_name}) assert session.location.search(location_name)[0]['Name'] == location_name location = session.location.read(location_name, ['current_user', 'primary']) @@ -576,7 +589,7 @@ def test_positive_add_foreman_role_with_org_loc( 'Location': ['assign_locations'], 'Organization': ['assign_organizations'], } - foreman_role = entities.Role().create() + foreman_role = module_target_sat.api.Role().create() module_target_sat.api_factory.create_role_permissions(foreman_role, user_permissions) with session: session.usergroup.create( @@ -589,7 +602,7 @@ def test_positive_add_foreman_role_with_org_loc( ) assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name session.usergroup.refresh_external_group(ldap_usergroup_name, EXTERNAL_GROUP_NAME) - with Session( + with module_target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded): @@ -641,9 +654,9 @@ def test_positive_add_katello_role_with_org( 'Location': ['assign_locations'], 'Organization': ['assign_organizations'], } - katello_role = entities.Role().create() + katello_role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions(katello_role, user_permissions) - different_org = entities.Organization().create() + different_org = target_sat.api.Organization().create() with session: session.usergroup.create( { @@ -655,7 +668,7 @@ def test_positive_add_katello_role_with_org( ) assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name session.usergroup.refresh_external_group(ldap_usergroup_name, EXTERNAL_GROUP_NAME) - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded): @@ -666,7 +679,7 @@ def test_positive_add_katello_role_with_org( session.organization.select(different_org.name) assert not session.activationkey.search(ak_name)[0]['Name'] == ak_name ak = ( - entities.ActivationKey(organization=module_org) + target_sat.api.ActivationKey(organization=module_org) .search(query={'search': f'name={ak_name}'})[0] .read() ) @@ -699,7 +712,7 @@ def test_positive_create_user_in_ldap_mode(session, ldap_auth_source, ldap_tear_ @pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA'], indirect=True) @pytest.mark.tier2 -def test_positive_login_user_no_roles(test_name, ldap_tear_down, ldap_auth_source): +def test_positive_login_user_no_roles(test_name, ldap_tear_down, ldap_auth_source, target_sat): """Login with LDAP Auth for user with no roles/rights :id: 7dc8d9a7-ff08-4d8e-a842-d370ffd69741 @@ -716,7 +729,7 @@ def test_positive_login_user_no_roles(test_name, ldap_tear_down, ldap_auth_sourc :parametrized: yes """ ldap_data, auth_source = ldap_auth_source - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: ldapsession.task.read_all() @@ -743,17 +756,17 @@ def test_positive_login_user_basic_roles( """ ldap_data, auth_source = ldap_auth_source name = gen_string('alpha') - role = entities.Role().create() + role = target_sat.api.Role().create() permissions = {'Architecture': PERMISSIONS['Architecture']} target_sat.api_factory.create_role_permissions(role, permissions) - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded): ldapsession.usergroup.search('') with session: session.user.update(ldap_data['ldap_user_name'], {'roles.resources.assigned': [role.name]}) - with Session( + with target_sat.ui_session( test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd'] ) as ldapsession: ldapsession.architecture.create({'name': name}) @@ -763,7 +776,7 @@ def test_positive_login_user_basic_roles( @pytest.mark.upgrade @pytest.mark.tier2 def test_positive_login_user_password_otp( - auth_source_ipa, default_ipa_host, test_name, ldap_tear_down + auth_source_ipa, default_ipa_host, test_name, ldap_tear_down, target_sat ): """Login with password with time based OTP @@ -781,16 +794,20 @@ def test_positive_login_user_password_otp( otp_pass = ( f"{default_ipa_host.ldap_user_passwd}{generate_otp(default_ipa_host.time_based_secret)}" ) - with Session(test_name, default_ipa_host.ipa_otp_username, otp_pass) as ldapsession: + with target_sat.ui_session( + test_name, default_ipa_host.ipa_otp_username, otp_pass + ) as ldapsession: with pytest.raises(NavigationTriesExceeded): ldapsession.user.search('') - users = entities.User().search(query={'search': f'login="{default_ipa_host.ipa_otp_username}"'}) + users = target_sat.api.User().search( + query={'search': f'login="{default_ipa_host.ipa_otp_username}"'} + ) assert users[0].login == default_ipa_host.ipa_otp_username @pytest.mark.tier2 def test_negative_login_user_with_invalid_password_otp( - auth_source_ipa, default_ipa_host, test_name, ldap_tear_down + auth_source_ipa, default_ipa_host, test_name, ldap_tear_down, target_sat ): """Login with password with time based OTP @@ -808,7 +825,9 @@ def test_negative_login_user_with_invalid_password_otp( password_with_otp = ( f"{default_ipa_host.ldap_user_passwd}{gen_string(str_type='numeric', length=6)}" ) - with Session(test_name, default_ipa_host.ipa_otp_username, password_with_otp) as ldapsession: + with target_sat.ui_session( + test_name, default_ipa_host.ipa_otp_username, password_with_otp + ) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: ldapsession.user.search('') assert error.typename == 'NavigationTriesExceeded' @@ -836,7 +855,7 @@ def test_positive_test_connection_functionality(session, ldap_auth_source): @pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA', 'OPENLDAP'], indirect=True) @pytest.mark.tier2 -def test_negative_login_with_incorrect_password(test_name, ldap_auth_source): +def test_negative_login_with_incorrect_password(test_name, ldap_auth_source, target_sat): """Attempt to login in Satellite an user with the wrong password :id: 3f09de90-a656-11ea-aa43-4ceb42ab8dbc @@ -853,7 +872,7 @@ def test_negative_login_with_incorrect_password(test_name, ldap_auth_source): """ ldap_data, auth_source = ldap_auth_source incorrect_password = gen_string('alphanumeric') - with Session( + with target_sat.ui_session( test_name, user=ldap_data['ldap_user_name'], password=incorrect_password ) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: @@ -862,7 +881,9 @@ def test_negative_login_with_incorrect_password(test_name, ldap_auth_source): @pytest.mark.tier2 -def test_negative_login_with_disable_user(default_ipa_host, auth_source_ipa, ldap_tear_down): +def test_negative_login_with_disable_user( + default_ipa_host, auth_source_ipa, ldap_tear_down, target_sat +): """Disabled IDM user cannot login :id: 49f28006-aa1f-11ea-90d3-4ceb42ab8dbc @@ -873,7 +894,7 @@ def test_negative_login_with_disable_user(default_ipa_host, auth_source_ipa, lda :expectedresults: Login fails """ - with Session( + with target_sat.ui_session( user=default_ipa_host.disabled_user_ipa, password=default_ipa_host.ldap_user_passwd ) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: @@ -883,7 +904,7 @@ def test_negative_login_with_disable_user(default_ipa_host, auth_source_ipa, lda @pytest.mark.tier2 def test_email_of_the_user_should_be_copied( - session, default_ipa_host, auth_source_ipa, ldap_tear_down + session, default_ipa_host, auth_source_ipa, ldap_tear_down, target_sat ): """Email of the user created in idm server ( set as external authorization source ) should be copied to the satellite. @@ -904,7 +925,7 @@ def test_email_of_the_user_should_be_copied( if 'Email' in line: _, result = line.split(': ', 2) break - with Session( + with target_sat.ui_session( user=default_ipa_host.ldap_user_name, password=default_ipa_host.ldap_user_passwd ) as ldapsession: ldapsession.bookmark.search('controller = hosts') @@ -931,10 +952,10 @@ def test_deleted_idm_user_should_not_be_able_to_login( """ test_user = gen_string('alpha') default_ipa_host.create_user(test_user) - with Session(user=test_user, password=settings.ipa.password) as ldapsession: + with target_sat.ui_session(user=test_user, password=settings.ipa.password) as ldapsession: ldapsession.bookmark.search('controller = hosts') default_ipa_host.delete_user(test_user) - with Session(user=test_user, password=settings.ipa.password) as ldapsession: + with target_sat.ui_session(user=test_user, password=settings.ipa.password) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: ldapsession.user.search('') assert error.typename == 'NavigationTriesExceeded' @@ -942,7 +963,7 @@ def test_deleted_idm_user_should_not_be_able_to_login( @pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA', 'OPENLDAP'], indirect=True) @pytest.mark.tier2 -def test_onthefly_functionality(session, ldap_auth_source, ldap_tear_down): +def test_onthefly_functionality(session, ldap_auth_source, ldap_tear_down, target_sat): """User will not be created automatically in Satellite if onthefly is disabled @@ -977,7 +998,7 @@ def test_onthefly_functionality(session, ldap_auth_source, ldap_tear_down): 'attribute_mappings.mail': LDAP_ATTR['mail'], } ) - with Session( + with target_sat.ui_session( user=ldap_data['ldap_user_name'], password=ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: @@ -1028,7 +1049,9 @@ def test_timeout_and_cac_card_ejection(): @pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA', 'OPENLDAP'], indirect=True) @pytest.mark.tier2 @pytest.mark.skip_if_open('BZ:1670397') -def test_verify_attribute_of_users_are_updated(session, ldap_auth_source, ldap_tear_down): +def test_verify_attribute_of_users_are_updated( + session, ldap_auth_source, ldap_tear_down, target_sat +): """Verify if attributes of LDAP user are updated upon first login when onthefly is disabled @@ -1076,7 +1099,7 @@ def test_verify_attribute_of_users_are_updated(session, ldap_auth_source, ldap_t 'roles.admin': True, } ) - with Session( + with target_sat.ui_session( user=ldap_data['ldap_user_name'], password=ldap_data['ldap_user_passwd'] ) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: @@ -1093,7 +1116,7 @@ def test_verify_attribute_of_users_are_updated(session, ldap_auth_source, ldap_t @pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA', 'OPENLDAP'], indirect=True) @pytest.mark.tier2 def test_login_failure_if_internal_user_exist( - session, test_name, ldap_auth_source, module_org, module_location, ldap_tear_down + session, test_name, ldap_auth_source, module_org, module_location, ldap_tear_down, target_sat ): """Verify the failure of login for the AD/IPA user in case same username internal user exists @@ -1115,19 +1138,21 @@ def test_login_failure_if_internal_user_exist( try: internal_username = ldap_data['ldap_user_name'] internal_password = gen_string('alphanumeric') - user = entities.User( + user = target_sat.api.User( admin=True, default_organization=module_org, default_location=module_location, login=internal_username, password=internal_password, ).create() - with Session(test_name, internal_username, ldap_data['ldap_user_passwd']) as ldapsession: + with target_sat.ui_session( + test_name, internal_username, ldap_data['ldap_user_passwd'] + ) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: ldapsession.user.search('') assert error.typename == 'NavigationTriesExceeded' finally: - entities.User(id=user.id).delete() + target_sat.api.User(id=user.id).delete() @pytest.mark.skip_if_open("BZ:1812688") @@ -1165,7 +1190,7 @@ def test_userlist_with_external_admin( auth_source_name = f'LDAP-{auth_source_ipa.name}' user_permissions = {'Katello::ActivationKey': PERMISSIONS['Katello::ActivationKey']} - katello_role = entities.Role().create() + katello_role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions(katello_role, user_permissions) with session: session.usergroup.create( @@ -1184,12 +1209,14 @@ def test_userlist_with_external_admin( 'external_groups.auth_source': auth_source_name, } ) - with Session(user=idm_user, password=settings.server.ssh_password) as ldapsession: + with target_sat.ui_session(user=idm_user, password=settings.server.ssh_password) as ldapsession: assert idm_user in ldapsession.task.read_all()['current_user'] # verify the users count with local admin and remote/external admin - with Session(user=idm_admin, password=settings.server.ssh_password) as remote_admin_session: - with Session( + with target_sat.ui_session( + user=idm_admin, password=settings.server.ssh_password + ) as remote_admin_session: + with target_sat.ui_session( user=settings.server.admin_username, password=settings.server.admin_password ) as local_admin_session: assert local_admin_session.user.search(idm_user)[0]['Username'] == idm_user @@ -1224,7 +1251,7 @@ def test_positive_group_sync_open_ldap_authsource( ak_name = gen_string('alpha') auth_source_name = f'LDAP-{auth_source_open_ldap.name}' user_permissions = {'Katello::ActivationKey': PERMISSIONS['Katello::ActivationKey']} - katello_role = entities.Role().create() + katello_role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions(katello_role, user_permissions) with session: session.usergroup.create( @@ -1238,7 +1265,7 @@ def test_positive_group_sync_open_ldap_authsource( assert session.usergroup.search(ldap_usergroup_name)[0]['Name'] == ldap_usergroup_name session.usergroup.refresh_external_group(ldap_usergroup_name, EXTERNAL_GROUP_NAME) user_name = open_ldap_data.open_ldap_user - with Session(test_name, user_name, open_ldap_data.password) as session: + with target_sat.ui_session(test_name, user_name, open_ldap_data.password) as session: with pytest.raises(NavigationTriesExceeded): session.architecture.search('') session.activationkey.create({'name': ak_name}) @@ -1274,7 +1301,7 @@ def test_verify_group_permissions( idm_users = settings.ipa.group_users auth_source_name = f'LDAP-{auth_source_ipa.name}' user_permissions = {None: ['access_dashboard']} - katello_role = entities.Role().create() + katello_role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions(katello_role, user_permissions) with session: session.usergroup.create( @@ -1294,15 +1321,17 @@ def test_verify_group_permissions( } ) location_name = gen_string('alpha') - with Session(user=idm_users[1], password=settings.server.ssh_password) as ldapsession: + with target_sat.ui_session( + user=idm_users[1], password=settings.server.ssh_password + ) as ldapsession: ldapsession.location.create({'name': location_name}) - location = entities.Location().search(query={'search': f'name="{location_name}"'})[0] + location = target_sat.api.Location().search(query={'search': f'name="{location_name}"'})[0] assert location.name == location_name @pytest.mark.tier2 def test_verify_ldap_filters_ipa( - session, ipa_add_user, auth_source_ipa, default_ipa_host, ldap_tear_down + session, ipa_add_user, auth_source_ipa, default_ipa_host, ldap_tear_down, target_sat ): """Verifying ldap filters in authsource to restrict access @@ -1319,7 +1348,9 @@ def test_verify_ldap_filters_ipa( # 'test_user' able to login before the filter is applied. test_user = ipa_add_user - with Session(user=test_user, password=default_ipa_host.ldap_user_passwd) as ldapsession: + with target_sat.ui_session( + user=test_user, password=default_ipa_host.ldap_user_passwd + ) as ldapsession: ldapsession.task.read_all() # updating the authsource with filter @@ -1328,7 +1359,9 @@ def test_verify_ldap_filters_ipa( session.ldapauthentication.update(auth_source_ipa.name, {'account.ldap_filter': ldap_data}) # 'test_user' not able login as it gets filtered out - with Session(user=test_user, password=default_ipa_host.ldap_user_passwd) as ldapsession: + with target_sat.ui_session( + user=test_user, password=default_ipa_host.ldap_user_passwd + ) as ldapsession: with pytest.raises(NavigationTriesExceeded) as error: ldapsession.user.search('') assert error.typename == 'NavigationTriesExceeded' diff --git a/tests/foreman/ui/test_lifecycleenvironment.py b/tests/foreman/ui/test_lifecycleenvironment.py index e99d9f9c895..9c389fdd19d 100644 --- a/tests/foreman/ui/test_lifecycleenvironment.py +++ b/tests/foreman/ui/test_lifecycleenvironment.py @@ -11,7 +11,6 @@ :CaseImportance: High """ -from airgun.session import Session from navmazing import NavigationTriesExceeded import pytest @@ -298,7 +297,7 @@ def test_positive_custom_user_view_lce(session, test_name, target_sat): lce_values = session.lifecycleenvironment.read_all() assert lce_name in lce_values['lce'] # ensure the created user also can find the created lifecycle environment link - with Session(test_name, user_login, user_password) as non_admin_session: + with target_sat.ui_session(test_name, user_login, user_password) as non_admin_session: # to ensure that the created user has only the assigned # permissions, check that hosts menu tab does not exist with pytest.raises(NavigationTriesExceeded): diff --git a/tests/foreman/ui/test_repository.py b/tests/foreman/ui/test_repository.py index 08d44cc052e..f5382f1ad00 100644 --- a/tests/foreman/ui/test_repository.py +++ b/tests/foreman/ui/test_repository.py @@ -14,8 +14,6 @@ from datetime import datetime, timedelta from random import randint, shuffle -from airgun.session import Session -from nailgun import entities from navmazing import NavigationTriesExceeded import pytest @@ -41,19 +39,19 @@ @pytest.fixture(scope='module') -def module_org(): - return entities.Organization().create() +def module_org(module_target_sat): + return module_target_sat.api.Organization().create() @pytest.fixture(scope='module') -def module_prod(module_org): - return entities.Product(organization=module_org).create() +def module_prod(module_org, module_target_sat): + return module_target_sat.api.Product(organization=module_org).create() @pytest.mark.tier2 @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_create_in_different_orgs(session, module_org): +def test_positive_create_in_different_orgs(session, module_org, module_target_sat): """Create repository in two different orgs with same name :id: 019c2242-8802-4bae-82c5-accf8f793dbc @@ -62,9 +60,9 @@ def test_positive_create_in_different_orgs(session, module_org): organizations """ repo_name = gen_string('alpha') - org2 = entities.Organization().create() - prod1 = entities.Product(organization=module_org).create() - prod2 = entities.Product(organization=org2).create() + org2 = module_target_sat.api.Organization().create() + prod1 = module_target_sat.api.Product(organization=module_org).create() + prod2 = module_target_sat.api.Product(organization=org2).create() with session: for org, prod in [[module_org, prod1], [org2, prod2]]: session.organization.select(org_name=org.name) @@ -107,9 +105,9 @@ def test_positive_create_as_non_admin_user(module_org, test_name, target_sat): 'sync_products', ], } - role = entities.Role().create() + role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions(role, user_permissions) - entities.User( + target_sat.api.User( login=user_login, password=user_password, role=[role], @@ -117,8 +115,8 @@ def test_positive_create_as_non_admin_user(module_org, test_name, target_sat): default_organization=module_org, organization=[module_org], ).create() - product = entities.Product(organization=module_org).create() - with Session(test_name, user=user_login, password=user_password) as session: + product = target_sat.api.Product(organization=module_org).create() + with target_sat.ui_session(test_name, user=user_login, password=user_password) as session: # ensure that the created user is not a global admin user # check administer->organizations page with pytest.raises(NavigationTriesExceeded): @@ -137,7 +135,7 @@ def test_positive_create_as_non_admin_user(module_org, test_name, target_sat): @pytest.mark.tier2 @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_create_yum_repo_same_url_different_orgs(session, module_prod): +def test_positive_create_yum_repo_same_url_different_orgs(session, module_prod, module_target_sat): """Create two repos with the same URL in two different organizations. :id: f4cb00ed-6faf-4c79-9f66-76cd333299cb @@ -145,12 +143,16 @@ def test_positive_create_yum_repo_same_url_different_orgs(session, module_prod): :expectedresults: Repositories are created and have equal number of packages. """ # Create first repository - repo = entities.Repository(product=module_prod, url=settings.repos.yum_0.url).create() + repo = module_target_sat.api.Repository( + product=module_prod, url=settings.repos.yum_0.url + ).create() repo.sync() # Create second repository - org = entities.Organization().create() - product = entities.Product(organization=org).create() - new_repo = entities.Repository(product=product, url=settings.repos.yum_0.url).create() + org = module_target_sat.api.Organization().create() + product = module_target_sat.api.Product(organization=org).create() + new_repo = module_target_sat.api.Repository( + product=product, url=settings.repos.yum_0.url + ).create() new_repo.sync() with session: # Check packages number in first repository @@ -194,9 +196,9 @@ def test_positive_create_as_non_admin_user_with_cv_published(module_org, test_na 'sync_products', ], } - role = entities.Role().create() + role = target_sat.api.Role().create() target_sat.api_factory.create_role_permissions(role, user_permissions) - entities.User( + target_sat.api.User( login=user_login, password=user_password, role=[role], @@ -204,14 +206,14 @@ def test_positive_create_as_non_admin_user_with_cv_published(module_org, test_na default_organization=module_org, organization=[module_org], ).create() - prod = entities.Product(organization=module_org).create() - repo = entities.Repository(product=prod, url=settings.repos.yum_2.url).create() + prod = target_sat.api.Product(organization=module_org).create() + repo = target_sat.api.Repository(product=prod, url=settings.repos.yum_2.url).create() repo.sync() - content_view = entities.ContentView(organization=module_org).create() + content_view = target_sat.api.ContentView(organization=module_org).create() content_view.repository = [repo] content_view = content_view.update(['repository']) content_view.publish() - with Session(test_name, user_login, user_password) as session: + with target_sat.ui_session(test_name, user_login, user_password) as session: # ensure that the created user is not a global admin user # check administer->users page pswd = gen_string('alphanumeric') @@ -243,7 +245,7 @@ def test_positive_create_as_non_admin_user_with_cv_published(module_org, test_na @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') @pytest.mark.usefixtures('allow_repo_discovery') -def test_positive_discover_repo_via_existing_product(session, module_org): +def test_positive_discover_repo_via_existing_product(session, module_org, module_target_sat): """Create repository via repo-discovery under existing product :id: 9181950c-a756-456f-a46a-059e7a2add3c @@ -251,7 +253,7 @@ def test_positive_discover_repo_via_existing_product(session, module_org): :expectedresults: Repository is discovered and created """ repo_name = 'fakerepo01' - product = entities.Product(organization=module_org).create() + product = module_target_sat.api.Product(organization=module_org).create() with session: session.organization.select(org_name=module_org.name) session.product.discover_repo( @@ -297,7 +299,9 @@ def test_positive_discover_repo_via_new_product(session, module_org): @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') @pytest.mark.usefixtures('allow_repo_discovery') -def test_positive_discover_module_stream_repo_via_existing_product(session, module_org): +def test_positive_discover_module_stream_repo_via_existing_product( + session, module_org, module_target_sat +): """Create repository with module streams via repo-discovery under an existing product. :id: e7b9e2c4-7ecd-4cde-8f74-961fbac8919c @@ -315,7 +319,7 @@ def test_positive_discover_module_stream_repo_via_existing_product(session, modu """ repo_name = gen_string('alpha') repo_label = gen_string('alpha') - product = entities.Product(organization=module_org).create() + product = module_target_sat.api.Product(organization=module_org).create() with session: session.organization.select(org_name=module_org.name) session.product.discover_repo( @@ -336,15 +340,15 @@ def test_positive_discover_module_stream_repo_via_existing_product(session, modu @pytest.mark.tier2 @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_sync_custom_repo_yum(session, module_org): +def test_positive_sync_custom_repo_yum(session, module_org, module_target_sat): """Create Custom yum repos and sync it via the repos page. :id: afa218f4-e97a-4240-a82a-e69538d837a1 :expectedresults: Sync procedure for specific yum repository is successful """ - product = entities.Product(organization=module_org).create() - repo = entities.Repository(url=settings.repos.yum_1.url, product=product).create() + product = module_target_sat.api.Product(organization=module_org).create() + repo = module_target_sat.api.Repository(url=settings.repos.yum_1.url, product=product).create() with session: result = session.repository.synchronize(product.name, repo.name) assert result['result'] == 'success' @@ -357,7 +361,7 @@ def test_positive_sync_custom_repo_yum(session, module_org): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_sync_custom_repo_docker(session, module_org): +def test_positive_sync_custom_repo_docker(session, module_org, module_target_sat): """Create Custom docker repos and sync it via the repos page. :id: 942e0b4f-3524-4f00-812d-bdad306f81de @@ -365,8 +369,8 @@ def test_positive_sync_custom_repo_docker(session, module_org): :expectedresults: Sync procedure for specific docker repository is successful """ - product = entities.Product(organization=module_org).create() - repo = entities.Repository( + product = module_target_sat.api.Product(organization=module_org).create() + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=product, content_type=REPO_TYPE['docker'] ).create() with session: @@ -376,7 +380,7 @@ def test_positive_sync_custom_repo_docker(session, module_org): @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_resync_custom_repo_after_invalid_update(session, module_org): +def test_positive_resync_custom_repo_after_invalid_update(session, module_org, module_target_sat): """Create Custom yum repo and sync it via the repos page. Then try to change repo url to invalid one and re-sync that repository @@ -389,8 +393,8 @@ def test_positive_resync_custom_repo_after_invalid_update(session, module_org): :BZ: 1487173, 1262313 """ - product = entities.Product(organization=module_org).create() - repo = entities.Repository(url=settings.repos.yum_1.url, product=product).create() + product = module_target_sat.api.Product(organization=module_org).create() + repo = module_target_sat.api.Repository(url=settings.repos.yum_1.url, product=product).create() with session: result = session.repository.synchronize(product.name, repo.name) assert result['result'] == 'success' @@ -408,7 +412,7 @@ def test_positive_resync_custom_repo_after_invalid_update(session, module_org): @pytest.mark.tier2 @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_resynchronize_rpm_repo(session, module_prod): +def test_positive_resynchronize_rpm_repo(session, module_prod, module_target_sat): """Check that repository content is resynced after packages were removed from repository @@ -418,7 +422,7 @@ def test_positive_resynchronize_rpm_repo(session, module_prod): :BZ: 1318004 """ - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=settings.repos.yum_1.url, content_type=REPO_TYPE['yum'], product=module_prod ).create() with session: @@ -442,7 +446,7 @@ def test_positive_resynchronize_rpm_repo(session, module_prod): @pytest.mark.tier2 @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_end_to_end_custom_yum_crud(session, module_org, module_prod): +def test_positive_end_to_end_custom_yum_crud(session, module_org, module_prod, module_target_sat): """Perform end to end testing for custom yum repository :id: 8baf11c9-019e-4625-a549-ec4cd9312f75 @@ -455,11 +459,11 @@ def test_positive_end_to_end_custom_yum_crud(session, module_org, module_prod): checksum_type = 'sha256' new_repo_name = gen_string('alphanumeric') new_checksum_type = 'sha1' - gpg_key = entities.GPGKey( + gpg_key = module_target_sat.api.GPGKey( content=DataFile.VALID_GPG_KEY_FILE.read_bytes(), organization=module_org, ).create() - new_gpg_key = entities.GPGKey( + new_gpg_key = module_target_sat.api.GPGKey( content=DataFile.VALID_GPG_KEY_BETA_FILE.read_bytes(), organization=module_org, ).create() @@ -758,7 +762,7 @@ def test_positive_reposet_disable_after_manifest_deleted( :BZ: 1344391 """ org = function_entitlement_manifest_org - sub = entities.Subscription(organization=org) + sub = target_sat.api.Subscription(organization=org) sat_tools_repo = target_sat.cli_factory.SatelliteToolsRepository(distro='rhel7', cdn=True) repository_name = sat_tools_repo.data['repository'] repository_name_orphaned = f'{repository_name} (Orphaned)' @@ -798,7 +802,7 @@ def test_positive_reposet_disable_after_manifest_deleted( @pytest.mark.tier2 -def test_positive_delete_random_docker_repo(session, module_org): +def test_positive_delete_random_docker_repo(session, module_org, module_target_sat): """Create Docker-type repositories on multiple products and delete a random repository from a random product. @@ -808,9 +812,12 @@ def test_positive_delete_random_docker_repo(session, module_org): without altering the other products. """ entities_list = [] - products = [entities.Product(organization=module_org).create() for _ in range(randint(2, 5))] + products = [ + module_target_sat.api.Product(organization=module_org).create() + for _ in range(randint(2, 5)) + ] for product in products: - repo = entities.Repository( + repo = module_target_sat.api.Repository( url=CONTAINER_REGISTRY_HUB, product=product, content_type=REPO_TYPE['docker'] ).create() entities_list.append((product.name, repo.name)) @@ -1178,7 +1185,7 @@ def test_positive_select_org_in_any_context(): @pytest.mark.tier2 @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_sync_repo_and_verify_checksum(session, module_org): +def test_positive_sync_repo_and_verify_checksum(session, module_org, module_target_sat): """Tests that Verify Content Checksum succeeds when executing from the products page :id: 577be1f8-7510-49d2-8b33-600db60bd960 @@ -1194,7 +1201,7 @@ def test_positive_sync_repo_and_verify_checksum(session, module_org): :expectedresults: Verify Content Checksum task succeeds """ repo_name = gen_string('alpha') - product = entities.Product(organization=module_org).create() + product = module_target_sat.api.Product(organization=module_org).create() with session: session.repository.create( product.name, @@ -1210,7 +1217,7 @@ def test_positive_sync_repo_and_verify_checksum(session, module_org): @pytest.mark.tier2 -def test_positive_sync_sha_repo(session, module_org): +def test_positive_sync_sha_repo(session, module_org, module_target_sat): """Sync 'sha' repo successfully :id: 6172035f-96c4-41e4-a79b-acfaa78ad734 @@ -1222,7 +1229,7 @@ def test_positive_sync_sha_repo(session, module_org): :SubComponent: Candlepin """ repo_name = gen_string('alpha') - product = entities.Product(organization=module_org).create() + product = module_target_sat.api.Product(organization=module_org).create() with session: session.repository.create( product.name, @@ -1237,7 +1244,7 @@ def test_positive_sync_sha_repo(session, module_org): @pytest.mark.tier2 -def test_positive_sync_third_party_repo(session, module_org): +def test_positive_sync_third_party_repo(session, module_org, module_target_sat): """Sync third part repo successfully :id: 655161e0-aa90-4c7c-9a0d-cb5b9f56eac3 @@ -1249,7 +1256,7 @@ def test_positive_sync_third_party_repo(session, module_org): :SubComponent: Pulp """ repo_name = gen_string('alpha') - product = entities.Product(organization=module_org).create() + product = module_target_sat.api.Product(organization=module_org).create() with session: session.repository.create( product.name, diff --git a/tests/foreman/ui/test_role.py b/tests/foreman/ui/test_role.py index dd7c9c9ddf3..652bdcbd4f6 100644 --- a/tests/foreman/ui/test_role.py +++ b/tests/foreman/ui/test_role.py @@ -13,8 +13,6 @@ """ import random -from airgun.session import Session -from nailgun import entities from navmazing import NavigationTriesExceeded import pytest @@ -25,7 +23,7 @@ @pytest.mark.e2e @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_end_to_end(session, module_org, module_location): +def test_positive_end_to_end(session, module_org, module_location, module_target_sat): """Perform end to end testing for role component :id: 3284016a-e2df-4a0e-aa24-c95ab132eec1 @@ -45,8 +43,8 @@ def test_positive_end_to_end(session, module_org, module_location): cloned_role_name = gen_string('alpha') new_role_name = gen_string('alpha') new_role_description = gen_string('alpha') - new_org = entities.Organization().create() - new_loc = entities.Location(organization=[new_org]).create() + new_org = module_target_sat.api.Organization().create() + new_loc = module_target_sat.api.Location(organization=[new_org]).create() with session: session.role.create( { @@ -156,7 +154,9 @@ def test_positive_delete_cloned_builtin(session): @pytest.mark.tier2 -def test_positive_create_filter_without_override(session, module_org, module_location, test_name): +def test_positive_create_filter_without_override( + session, module_org, module_location, test_name, module_target_sat +): """Create filter in role w/o overriding it :id: a7f76f6e-6c13-4b34-b38c-19501b65786f @@ -178,7 +178,7 @@ def test_positive_create_filter_without_override(session, module_org, module_loc role_name = gen_string('alpha') username = gen_string('alpha') password = gen_string('alpha') - subnet = entities.Subnet() + subnet = module_target_sat.api.Subnet() subnet.create_missing() subnet_name = subnet.name with session: @@ -222,7 +222,7 @@ def test_positive_create_filter_without_override(session, module_org, module_loc 'locations.resources.assigned': [module_location.name], } ) - with Session(test_name, user=username, password=password) as session: + with module_target_sat.ui_session(test_name, user=username, password=password) as session: session.subnet.create( { 'subnet.name': subnet_name, @@ -239,7 +239,9 @@ def test_positive_create_filter_without_override(session, module_org, module_loc @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_create_non_overridable_filter(session, module_org, module_location, test_name): +def test_positive_create_non_overridable_filter( + session, module_org, module_location, test_name, module_target_sat +): """Create non overridden filter in role :id: 5ee281cf-28fa-439d-888d-b1f9aacc6d57 @@ -262,9 +264,9 @@ def test_positive_create_non_overridable_filter(session, module_org, module_loca username = gen_string('alpha') password = gen_string('alpha') new_name = gen_string('alpha') - user_org = entities.Organization().create() - user_loc = entities.Location().create() - arch = entities.Architecture().create() + user_org = module_target_sat.api.Organization().create() + user_loc = module_target_sat.api.Location().create() + arch = module_target_sat.api.Architecture().create() with session: session.role.create( { @@ -293,7 +295,7 @@ def test_positive_create_non_overridable_filter(session, module_org, module_loca 'locations.resources.assigned': [user_loc.name], } ) - with Session(test_name, user=username, password=password) as session: + with module_target_sat.ui_session(test_name, user=username, password=password) as session: session.architecture.update(arch.name, {'name': new_name}) assert session.architecture.search(new_name)[0]['Name'] == new_name with pytest.raises(NavigationTriesExceeded): @@ -302,7 +304,9 @@ def test_positive_create_non_overridable_filter(session, module_org, module_loca @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_create_overridable_filter(session, module_org, module_location, test_name): +def test_positive_create_overridable_filter( + session, module_org, module_location, test_name, module_target_sat +): """Create overridden filter in role :id: 325e7e3e-60fc-4182-9585-0449d9660e8d @@ -327,9 +331,9 @@ def test_positive_create_overridable_filter(session, module_org, module_location role_name = gen_string('alpha') username = gen_string('alpha') password = gen_string('alpha') - role_org = entities.Organization().create() - role_loc = entities.Location().create() - subnet = entities.Subnet() + role_org = module_target_sat.api.Organization().create() + role_loc = module_target_sat.api.Location().create() + subnet = module_target_sat.api.Subnet() subnet.create_missing() subnet_name = subnet.name new_subnet_name = gen_string('alpha') @@ -378,7 +382,7 @@ def test_positive_create_overridable_filter(session, module_org, module_location 'locations.resources.assigned': [role_loc.name, module_location.name], } ) - with Session(test_name, user=username, password=password) as session: + with module_target_sat.ui_session(test_name, user=username, password=password) as session: session.organization.select(org_name=module_org.name) session.location.select(loc_name=module_location.name) session.subnet.create( @@ -485,7 +489,7 @@ def test_positive_create_with_sc_parameter_permission(session_puppet_enabled_sat @pytest.mark.tier2 -def test_positive_create_filter_admin_user_with_locs(test_name): +def test_positive_create_filter_admin_user_with_locs(test_name, module_target_sat): """Attempt to create a role filter by admin user, who has 6+ locations assigned. :id: 688ecb7d-1d49-494c-97cc-0d5e715f3bb1 @@ -501,10 +505,10 @@ def test_positive_create_filter_admin_user_with_locs(test_name): role_name = gen_string('alpha') resource_type = 'Architecture' permissions = ['view_architectures', 'edit_architectures'] - org = entities.Organization().create() - locations = [entities.Location(organization=[org]).create() for _ in range(6)] + org = module_target_sat.api.Organization().create() + locations = [module_target_sat.api.Location(organization=[org]).create() for _ in range(6)] password = gen_string('alphanumeric') - user = entities.User( + user = module_target_sat.api.User( admin=True, organization=[org], location=locations, @@ -512,7 +516,7 @@ def test_positive_create_filter_admin_user_with_locs(test_name): default_location=locations[0], password=password, ).create() - with Session(test_name, user=user.login, password=password) as session: + with module_target_sat.ui_session(test_name, user=user.login, password=password) as session: session.role.create({'name': role_name}) assert session.role.search(role_name)[0]['Name'] == role_name session.filter.create( @@ -523,7 +527,7 @@ def test_positive_create_filter_admin_user_with_locs(test_name): @pytest.mark.tier2 -def test_positive_create_filter_admin_user_with_orgs(test_name): +def test_positive_create_filter_admin_user_with_orgs(test_name, module_target_sat): """Attempt to create a role filter by admin user, who has 10 organizations assigned. :id: 04208e17-34b5-46b1-84dd-b8a973521d30 @@ -540,9 +544,9 @@ def test_positive_create_filter_admin_user_with_orgs(test_name): resource_type = 'Architecture' permissions = ['view_architectures', 'edit_architectures'] password = gen_string('alphanumeric') - organizations = [entities.Organization().create() for _ in range(10)] - loc = entities.Location(organization=[organizations[0]]).create() - user = entities.User( + organizations = [module_target_sat.api.Organization().create() for _ in range(10)] + loc = module_target_sat.api.Location(organization=[organizations[0]]).create() + user = module_target_sat.api.User( admin=True, organization=organizations, location=[loc], @@ -550,7 +554,7 @@ def test_positive_create_filter_admin_user_with_orgs(test_name): default_location=loc, password=password, ).create() - with Session(test_name, user=user.login, password=password) as session: + with module_target_sat.ui_session(test_name, user=user.login, password=password) as session: session.role.create({'name': role_name}) assert session.role.search(role_name)[0]['Name'] == role_name session.filter.create( diff --git a/tests/foreman/ui/test_settings.py b/tests/foreman/ui/test_settings.py index 87682a55db3..c3c233bf97e 100644 --- a/tests/foreman/ui/test_settings.py +++ b/tests/foreman/ui/test_settings.py @@ -13,9 +13,7 @@ """ import math -from airgun.session import Session from fauxfactory import gen_url -from nailgun import entities import pytest from robottelo.config import settings @@ -28,14 +26,14 @@ def invalid_settings_values(): return [' ', '-1', 'text', '0'] -def add_content_views_to_composite(composite_cv, org, repo): +def add_content_views_to_composite(composite_cv, org, repo, module_target_sat): """Add necessary number of content views to the composite one :param composite_cv: Composite content view object :param org: Organisation of satellite :param repo: repository need to added in content view """ - content_view = entities.ContentView(organization=org).create() + content_view = module_target_sat.api.ContentView(organization=org).create() content_view.repository = [repo] content_view.update(['repository']) content_view.publish() @@ -47,7 +45,9 @@ def add_content_views_to_composite(composite_cv, org, repo): @pytest.mark.run_in_one_thread @pytest.mark.tier3 @pytest.mark.parametrize('setting_update', ['restrict_composite_view'], indirect=True) -def test_positive_update_restrict_composite_view(session, setting_update, repo_setup): +def test_positive_update_restrict_composite_view( + session, setting_update, repo_setup, module_target_sat +): """Update settings parameter restrict_composite_view to Yes/True and ensure a composite content view may not be published or promoted, unless the component content view versions that it includes exist in the target environment. @@ -61,9 +61,11 @@ def test_positive_update_restrict_composite_view(session, setting_update, repo_s :CaseImportance: Critical """ property_name = setting_update.name - composite_cv = entities.ContentView(composite=True, organization=repo_setup['org']).create() + composite_cv = module_target_sat.api.ContentView( + composite=True, organization=repo_setup['org'] + ).create() content_view = add_content_views_to_composite( - composite_cv, repo_setup['org'], repo_setup['repo'] + composite_cv, repo_setup['org'], repo_setup['repo'], module_target_sat ) composite_cv.publish() with session: @@ -252,9 +254,9 @@ def test_negative_settings_access_to_non_admin(module_target_sat): """ login = gen_string('alpha') password = gen_string('alpha') - entities.User(admin=False, login=login, password=password).create() + module_target_sat.api.User(admin=False, login=login, password=password).create() try: - with Session(user=login, password=password) as session: + with module_target_sat.ui_session(user=login, password=password) as session: result = session.settings.permission_denied() assert ( result == 'Permission denied You are not authorized to perform this action. ' @@ -367,7 +369,7 @@ def test_positive_update_email_delivery_method_sendmail(session, target_sat): "send_welcome_email": "", } mail_config_default_param = { - content: entities.Setting().search(query={'search': f'name={content}'})[0] + content: target_sat.api.Setting().search(query={'search': f'name={content}'})[0] for content in mail_config_default_param } mail_config_new_params = { diff --git a/tests/foreman/ui/test_subscription.py b/tests/foreman/ui/test_subscription.py index f98a2ccde4b..9981e371cd8 100644 --- a/tests/foreman/ui/test_subscription.py +++ b/tests/foreman/ui/test_subscription.py @@ -14,9 +14,7 @@ from tempfile import mkstemp import time -from airgun.session import Session from fauxfactory import gen_string -from nailgun import entities import pytest from robottelo.config import settings @@ -44,18 +42,18 @@ def golden_ticket_host_setup(function_entitlement_manifest_org, module_target_sa reposet=REPOSET['rhst7'], releasever=None, ) - rh_repo = entities.Repository(id=rh_repo_id).read() + rh_repo = module_target_sat.api.Repository(id=rh_repo_id).read() rh_repo.sync() - custom_product = entities.Product(organization=org).create() - custom_repo = entities.Repository( + custom_product = module_target_sat.api.Product(organization=org).create() + custom_repo = module_target_sat.api.Repository( name=gen_string('alphanumeric').upper(), product=custom_product ).create() custom_repo.sync() - ak = entities.ActivationKey( + ak = module_target_sat.api.ActivationKey( content_view=org.default_content_view, max_hosts=100, organization=org, - environment=entities.LifecycleEnvironment(id=org.library.id), + environment=module_target_sat.api.LifecycleEnvironment(id=org.library.id), auto_attach=True, ).create() return org, ak @@ -93,7 +91,7 @@ def test_positive_end_to_end(session, target_sat): 'Note: Deleting a subscription manifest is STRONGLY discouraged.', 'This action should only be taken for debugging purposes.', ] - org = entities.Organization().create() + org = target_sat.api.Organization().create() _, temporary_local_manifest_path = mkstemp(prefix='manifest-', suffix='.zip') with clone() as manifest: with open(temporary_local_manifest_path, 'wb') as file_handler: @@ -147,8 +145,8 @@ def test_positive_access_with_non_admin_user_without_manifest(test_name, target_ :CaseImportance: Critical """ - org = entities.Organization().create() - role = entities.Role(organization=[org]).create() + org = target_sat.api.Organization().create() + role = target_sat.api.Role(organization=[org]).create() target_sat.api_factory.create_role_permissions( role, { @@ -162,14 +160,14 @@ def test_positive_access_with_non_admin_user_without_manifest(test_name, target_ }, ) user_password = gen_string('alphanumeric') - user = entities.User( + user = target_sat.api.User( admin=False, role=[role], password=user_password, organization=[org], default_organization=org, ).create() - with Session(test_name, user=user.login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user.login, password=user_password) as session: assert not session.subscription.has_manifest @@ -193,20 +191,20 @@ def test_positive_access_with_non_admin_user_with_manifest( :CaseImportance: Critical """ org = function_entitlement_manifest_org - role = entities.Role(organization=[org]).create() + role = target_sat.api.Role(organization=[org]).create() target_sat.api_factory.create_role_permissions( role, {'Katello::Subscription': ['view_subscriptions'], 'Organization': ['view_organizations']}, ) user_password = gen_string('alphanumeric') - user = entities.User( + user = target_sat.api.User( admin=False, role=[role], password=user_password, organization=[org], default_organization=org, ).create() - with Session(test_name, user=user.login, password=user_password) as session: + with target_sat.ui_session(test_name, user=user.login, password=user_password) as session: assert ( session.subscription.search(f'name = "{DEFAULT_SUBSCRIPTION_NAME}"')[0]['Name'] == DEFAULT_SUBSCRIPTION_NAME @@ -230,23 +228,23 @@ def test_positive_access_manifest_as_another_admin_user( :CaseImportance: High """ - org = entities.Organization().create() + org = target_sat.api.Organization().create() user1_password = gen_string('alphanumeric') - user1 = entities.User( + user1 = target_sat.api.User( admin=True, password=user1_password, organization=[org], default_organization=org ).create() user2_password = gen_string('alphanumeric') - user2 = entities.User( + user2 = target_sat.api.User( admin=True, password=user2_password, organization=[org], default_organization=org ).create() # use the first admin to upload a manifest - with Session(test_name, user=user1.login, password=user1_password) as session: + with target_sat.ui_session(test_name, user=user1.login, password=user1_password) as session: target_sat.upload_manifest(org.id, function_entitlement_manifest.content) assert session.subscription.has_manifest # store subscriptions that have "Red Hat" in the name for later rh_subs = session.subscription.search("Red Hat") # try to view and delete the manifest with another admin - with Session(test_name, user=user2.login, password=user2_password) as session: + with target_sat.ui_session(test_name, user=user2.login, password=user2_password) as session: assert session.subscription.has_manifest assert rh_subs == session.subscription.search("Red Hat") session.subscription.delete_manifest( @@ -290,7 +288,7 @@ def test_positive_view_vdc_subscription_products( :parametrized: yes """ org = function_entitlement_manifest_org - lce = entities.LifecycleEnvironment(organization=org).create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() repos_collection = target_sat.cli_factory.RepositoryCollection( distro='rhel7', repositories=[target_sat.cli_factory.RHELAnsibleEngineRepository(cdn=True)], @@ -348,7 +346,7 @@ def test_positive_view_vdc_guest_subscription_products( :parametrized: yes """ org = function_entitlement_manifest_org - lce = entities.LifecycleEnvironment(organization=org).create() + lce = target_sat.api.LifecycleEnvironment(organization=org).create() provisioning_server = settings.libvirt.libvirt_hostname rh_product_repository = target_sat.cli_factory.RHELAnsibleEngineRepository(cdn=True) product_name = rh_product_repository.data['product'] @@ -511,13 +509,15 @@ def test_positive_candlepin_events_processed_by_STOMP( :CaseImportance: High """ org = function_entitlement_manifest_org - repo = entities.Repository(product=entities.Product(organization=org).create()).create() + repo = target_sat.api.Repository( + product=target_sat.api.Product(organization=org).create() + ).create() repo.sync() - ak = entities.ActivationKey( + ak = target_sat.api.ActivationKey( content_view=org.default_content_view, max_hosts=100, organization=org, - environment=entities.LifecycleEnvironment(id=org.library.id), + environment=target_sat.api.LifecycleEnvironment(id=org.library.id), ).create() rhel7_contenthost.install_katello_ca(target_sat) rhel7_contenthost.register_contenthost(org.name, ak.name) @@ -533,7 +533,7 @@ def test_positive_candlepin_events_processed_by_STOMP( rhel7_contenthost.hostname, widget_names='details' )['details']['subscription_status'] assert 'Fully entitled' in updated_sub_status - response = entities.Ping().search_json()['services']['candlepin_events'] + response = target_sat.api.Ping().search_json()['services']['candlepin_events'] assert response['status'] == 'ok' assert '0 Failed' in response['message'] diff --git a/tests/foreman/ui/test_user.py b/tests/foreman/ui/test_user.py index 21147e88adc..a69b58250bf 100644 --- a/tests/foreman/ui/test_user.py +++ b/tests/foreman/ui/test_user.py @@ -13,7 +13,6 @@ """ import random -from airgun.session import Session from fauxfactory import gen_email, gen_string import pytest @@ -83,7 +82,7 @@ def test_positive_end_to_end(session, target_sat, test_name, module_org, module_ assert session.user.search(new_name)[0]['Username'] == new_name assert not session.user.search(name) # Login into application using new user - with Session(test_name, new_name, password) as newsession: + with target_sat.ui_session(test_name, new_name, password) as newsession: newsession.organization.select(module_org.name) newsession.location.select(module_location.name) newsession.activationkey.create({'name': ak_name}) @@ -91,7 +90,7 @@ def test_positive_end_to_end(session, target_sat, test_name, module_org, module_ current_user = newsession.activationkey.read(ak_name, 'current_user')['current_user'] assert current_user == f'{firstname} {lastname}' # Delete user - with Session('deletehostsession') as deletehostsession: + with target_sat.ui_session('deletehostsession') as deletehostsession: deletehostsession.user.delete(new_name) assert not deletehostsession.user.search(new_name) @@ -300,7 +299,7 @@ def test_positive_create_product_with_limited_user_permission( password=password, mail='test@test.com', ).create() - with Session(test_name, username, password) as newsession: + with target_sat.ui_session(test_name, username, password) as newsession: newsession.product.create( {'name': product_name, 'label': product_label, 'description': product_description} ) diff --git a/tests/foreman/virtwho/conftest.py b/tests/foreman/virtwho/conftest.py index 133fa0026a0..9b09a66c0fa 100644 --- a/tests/foreman/virtwho/conftest.py +++ b/tests/foreman/virtwho/conftest.py @@ -1,4 +1,3 @@ -from airgun.session import Session from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError @@ -37,7 +36,7 @@ def module_user(request, module_target_sat, default_org, default_location): @pytest.fixture -def session(test_name, module_user): +def session(test_name, module_user, module_target_sat): """Session fixture which automatically initializes (but does not start!) airgun UI session and correctly passes current test name to it. Uses shared module user credentials to log in. @@ -50,7 +49,7 @@ def test_foo(session): # your ui test steps here session.architecture.create({'name': 'bar'}) """ - return Session(test_name, module_user.login, module_user.password) + return module_target_sat.ui_session(test_name, module_user.login, module_user.password) @pytest.fixture(scope='module') @@ -84,7 +83,7 @@ def module_user_sca(request, module_target_sat, module_org, module_location): @pytest.fixture -def session_sca(test_name, module_user_sca): +def session_sca(test_name, module_user_sca, module_target_sat): """Session fixture which automatically initializes (but does not start!) airgun UI session and correctly passes current test name to it. Uses shared module user credentials to log in. @@ -97,4 +96,4 @@ def test_foo(session): # your ui test steps here session.architecture.create({'name': 'bar'}) """ - return Session(test_name, module_user_sca.login, module_user_sca.password) + return module_target_sat.ui_session(test_name, module_user_sca.login, module_user_sca.password) diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index 5baba61e97d..b81536ab211 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -13,7 +13,6 @@ """ from datetime import datetime -from airgun.session import Session from fauxfactory import gen_string import pytest @@ -369,7 +368,7 @@ def test_positive_delete_configure(self, default_org, org_session, form_data_ui) @pytest.mark.tier2 def test_positive_virtwho_reporter_role( - self, default_org, org_session, test_name, form_data_ui + self, default_org, org_session, test_name, form_data_ui, target_sat ): """Verify the virt-who reporter role can TRULY work. @@ -418,13 +417,15 @@ def test_positive_virtwho_reporter_role( assert user['roles']['resources']['assigned'] == ['Virt-who Reporter'] restart_virtwho_service() assert get_virtwho_status() == 'running' - with Session(test_name, username, password) as newsession: + with target_sat.ui_session(test_name, username, password) as newsession: assert not newsession.virtwho_configure.check_create_permission()['can_view'] org_session.user.delete(username) assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_virtwho_viewer_role(self, default_org, org_session, test_name, form_data_ui): + def test_positive_virtwho_viewer_role( + self, default_org, org_session, test_name, form_data_ui, target_sat + ): """Verify the virt-who viewer role can TRULY work. :id: bf3be2e4-3853-41cc-9b3e-c8677f0b8c5f @@ -469,7 +470,7 @@ def test_positive_virtwho_viewer_role(self, default_org, org_session, test_name, add_configure_option('rhsm_password', password, config_file) restart_virtwho_service() assert get_virtwho_status() == 'logerror' - with Session(test_name, username, password) as newsession: + with target_sat.ui_session(test_name, username, password) as newsession: create_permission = newsession.virtwho_configure.check_create_permission() update_permission = newsession.virtwho_configure.check_update_permission( config_name @@ -484,7 +485,9 @@ def test_positive_virtwho_viewer_role(self, default_org, org_session, test_name, assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_virtwho_manager_role(self, default_org, org_session, test_name, form_data_ui): + def test_positive_virtwho_manager_role( + self, default_org, org_session, test_name, form_data_ui, target_sat + ): """Verify the virt-who manager role can TRULY work. :id: a72023fb-7b23-4582-9adc-c5227dc7859c @@ -520,7 +523,7 @@ def test_positive_virtwho_manager_role(self, default_org, org_session, test_name org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Manager'] - with Session(test_name, username, password) as newsession: + with target_sat.ui_session(test_name, username, password) as newsession: # create_virt_who_config new_virt_who_name = gen_string('alpha') form_data_ui['name'] = new_virt_who_name