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/cli/test_satellitesync.py b/tests/foreman/cli/test_satellitesync.py index 82d2addafff..d4ad2e93eb4 100644 --- a/tests/foreman/cli/test_satellitesync.py +++ b/tests/foreman/cli/test_satellitesync.py @@ -2050,8 +2050,6 @@ def test_positive_custom_cdn_with_credential( :expectedresults: 1. Repository can be enabled and synced from Upstream to Downstream Satellite. - :CaseLevel: System - :BZ: 2112098 :customerscenario: true diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index 2142df9d9f0..4242b9fdff3 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 f742454a114..0aa59e545c0 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, @@ -83,9 +83,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) @@ -602,7 +602,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 @@ -618,7 +618,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) @@ -765,7 +765,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 @@ -798,9 +800,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() ) @@ -809,7 +811,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 @@ -826,7 +828,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'] @@ -863,8 +865,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 @@ -935,7 +937,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. @@ -948,7 +952,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', @@ -1725,7 +1729,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. @@ -1739,7 +1743,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_dashboard.py b/tests/foreman/ui/test_dashboard.py index 2cdd9494008..49119056c90 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 9c97f93ff5c..d9d46d29a38 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -11,11 +11,10 @@ :CaseImportance: High """ -from airgun.session import Session + from broker import Broker from fauxfactory import gen_string from manifester import Manifester -from nailgun import entities import pytest from robottelo.config import settings @@ -50,9 +49,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) @@ -140,9 +139,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 @@ -389,7 +388,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 @@ -407,23 +406,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 @@ -567,14 +568,16 @@ def test_positive_filter_by_environment( ) assert _install_client_package(client, FAKE_1_CUSTOM_PACKAGE, errata_applicability=True) # 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, @@ -615,7 +618,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 @@ -638,14 +641,16 @@ def test_positive_content_host_previous_env( hostname = vm.hostname assert _install_client_package(vm, FAKE_1_CUSTOM_PACKAGE, errata_applicability=True) # 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, @@ -913,7 +918,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=[ @@ -930,16 +935,16 @@ def test_positive_filtered_errata_status_installable_param( assert _install_client_package(client, FAKE_1_CUSTOM_PACKAGE, errata_applicability=True) # 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 c50ce4e8b9d..3f7dcfad6a7 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 @@ -481,7 +480,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') @@ -530,7 +529,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': []}) @@ -585,7 +584,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: @@ -694,7 +693,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', {})) @@ -2316,7 +2315,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( { 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 594815422f9..023e9c2fded 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() @@ -734,7 +738,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)' @@ -774,7 +778,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. @@ -784,9 +788,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)) @@ -1154,7 +1161,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 @@ -1170,7 +1177,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, @@ -1186,7 +1193,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 @@ -1198,7 +1205,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, @@ -1213,7 +1220,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 @@ -1225,7 +1232,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 a67f34cdcd6..810fa73f8cd 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 @@ -24,7 +22,7 @@ @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 @@ -44,8 +42,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( { @@ -155,7 +153,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 @@ -177,7 +177,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: @@ -221,7 +221,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, @@ -238,7 +238,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 @@ -261,9 +263,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( { @@ -292,7 +294,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): @@ -301,7 +303,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 @@ -326,9 +330,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') @@ -377,7 +381,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( @@ -484,7 +488,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 @@ -500,10 +504,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, @@ -511,7 +515,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( @@ -522,7 +526,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 @@ -539,9 +543,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], @@ -549,7 +553,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 aa120bed5d3..72bcf9223f0 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: @@ -260,9 +262,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. ' @@ -375,7 +377,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 ce6ac5bcdd6..15e4de7c96c 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 @@ -98,7 +96,7 @@ def test_positive_end_to_end(session, target_sat): 'subscriptions to hosts and activation keys.', 'This action should only be taken in extreme circumstances or 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: @@ -155,8 +153,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, { @@ -170,14 +168,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 @@ -201,20 +199,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 @@ -238,23 +236,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( @@ -298,7 +296,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)], @@ -357,7 +355,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'] @@ -520,13 +518,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) @@ -542,6 +542,6 @@ 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 f2b35897a5a..48f04cd5a06 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 @@ -82,7 +81,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}) @@ -90,7 +89,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) @@ -299,7 +298,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