diff --git a/pytest_fixtures/api_fixtures.py b/pytest_fixtures/api_fixtures.py index 14b26352dca..0f8f3213261 100644 --- a/pytest_fixtures/api_fixtures.py +++ b/pytest_fixtures/api_fixtures.py @@ -5,10 +5,7 @@ from wrapanapi import AzureSystem from wrapanapi import GoogleCloudSystem -<<<<<<< HEAD from robottelo.api.utils import publish_puppet_module -======= ->>>>>>> Add ansible, oscap, smartproxy and user component fixtures from robottelo.constants import AZURERM_RG_DEFAULT from robottelo.constants import AZURERM_RHEL7_FT_BYOS_IMG_URN from robottelo.constants import AZURERM_RHEL7_FT_CUSTOM_IMG_URN @@ -434,7 +431,6 @@ def default_contentview(module_org): ) -<<<<<<< HEAD @skip_if(not settings.repos_hosting_url) @pytest.fixture(scope='module') def module_cv_with_puppet_module(module_org): @@ -448,13 +444,10 @@ def module_cv_with_puppet_module(module_org): ) -======= ->>>>>>> Add ansible, oscap, smartproxy and user component fixtures @pytest.fixture(scope='session') def default_pxetemplate(): pxe_template = entities.ProvisioningTemplate().search(query={'search': DEFAULT_PXE_TEMPLATE}) return pxe_template[0].read() -<<<<<<< HEAD @pytest.fixture(scope='module') @@ -504,5 +497,3 @@ def module_puppet_classes(module_env_search): @pytest.fixture(scope="function") def function_role(): return entities.Role().create() -======= ->>>>>>> Add ansible, oscap, smartproxy and user component fixtures diff --git a/pytest_fixtures/user_fixtures.py b/pytest_fixtures/user_fixtures.py index 765a24fc20e..a11209c4984 100644 --- a/pytest_fixtures/user_fixtures.py +++ b/pytest_fixtures/user_fixtures.py @@ -4,7 +4,7 @@ @pytest.fixture(scope='module') -def module_viewer_user(module_org, default_location): +def default_viewer_role(module_org, default_location): """Custom user with viewer role for tests validating visibility of entities or fields created by some other user. Created only when accessed, unlike `module_user`. """ diff --git a/tests/foreman/cli/test_oscap.py b/tests/foreman/cli/test_oscap.py index caeb58ee896..1e14b170199 100644 --- a/tests/foreman/cli/test_oscap.py +++ b/tests/foreman/cli/test_oscap.py @@ -93,7 +93,7 @@ def test_positive_list_default_content_with_admin(self): @tier1 def test_negative_list_default_content_with_viewer_role( - self, scap_content, module_viewer_user + self, scap_content, default_viewer_role ): """List the default scap content by user with viewer role @@ -117,11 +117,11 @@ def test_negative_list_default_content_with_viewer_role( :CaseImportance: Critical """ result = Scapcontent.with_user( - module_viewer_user.login, module_viewer_user.password + default_viewer_role.login, default_viewer_role.password ).list() assert len(result) == 0 with pytest.raises(CLIReturnCodeError): - Scapcontent.with_user(module_viewer_user.login, module_viewer_user.password).info( + Scapcontent.with_user(default_viewer_role.login, default_viewer_role.password).info( {'title': scap_content['title']} ) diff --git a/tests/foreman/ui/conftest.py b/tests/foreman/ui/conftest.py index 0b9355a9dd5..ae9ad48ea18 100644 --- a/tests/foreman/ui/conftest.py +++ b/tests/foreman/ui/conftest.py @@ -71,28 +71,6 @@ def module_user(request, module_org, module_loc): LOGGER.warning('Unable to delete session user: %s', str(err)) -@fixture(scope='module') -def module_viewer_user(module_org): - """Custom user with viewer role for tests validating visibility of entities or fields created - by some other user. Created only when accessed, unlike `module_user`. - """ - viewer_role = nailgun.entities.Role().search(query={'search': 'name="Viewer"'})[0] - default_loc_id = ( - nailgun.entities.Location().search(query={'search': 'name="{}"'.format(DEFAULT_LOC)})[0].id - ) - custom_password = gen_string('alphanumeric') - custom_user = nailgun.entities.User( - admin=False, - default_organization=module_org, - location=[default_loc_id], - organization=[module_org], - role=[viewer_role], - password=custom_password, - ).create() - custom_user.password = custom_password - return custom_user - - @fixture() def test_name(request): """Returns current test full name, prefixed by module name and test class diff --git a/tests/foreman/ui/test_bookmarks.py b/tests/foreman/ui/test_bookmarks.py index 9823038ae6e..d84daa212a3 100644 --- a/tests/foreman/ui/test_bookmarks.py +++ b/tests/foreman/ui/test_bookmarks.py @@ -119,7 +119,7 @@ def test_positive_end_to_end(session, random_entity): @tier2 -def test_positive_create_bookmark_public(session, random_entity, module_viewer_user, test_name): +def test_positive_create_bookmark_public(session, random_entity, default_viewer_role, test_name): """Create and check visibility of the (non)public bookmarks :id: 93139529-7690-429b-83fe-3dcbac4f91dc @@ -153,14 +153,14 @@ def test_positive_create_bookmark_public(session, random_entity, module_viewer_u {'name': name, 'query': gen_string('alphanumeric'), 'public': name == public_name} ) assert session.bookmark.search(name)[0]['Name'] == name - with Session(test_name, module_viewer_user.login, module_viewer_user.password) as session: + with Session(test_name, default_viewer_role.login, default_viewer_role.password) as session: assert session.bookmark.search(public_name)[0]['Name'] == public_name assert not session.bookmark.search(nonpublic_name) @tier2 def test_positive_update_bookmark_public( - session, random_entity, module_viewer_user, module_user, test_name + session, random_entity, default_viewer_role, module_user, test_name ): """Update and save a bookmark public state @@ -209,7 +209,7 @@ def test_positive_update_bookmark_public( cfg, name=name, controller=random_entity['controller'], public=name == public_name ).create() with Session( - test_name, module_viewer_user.login, module_viewer_user.password + test_name, default_viewer_role.login, default_viewer_role.password ) as non_admin_session: assert non_admin_session.bookmark.search(public_name)[0]['Name'] == public_name assert not non_admin_session.bookmark.search(nonpublic_name) @@ -217,14 +217,14 @@ def test_positive_update_bookmark_public( session.bookmark.update(public_name, {'public': False}) session.bookmark.update(nonpublic_name, {'public': True}) with Session( - test_name, module_viewer_user.login, module_viewer_user.password + test_name, default_viewer_role.login, default_viewer_role.password ) as non_admin_session: assert non_admin_session.bookmark.search(nonpublic_name)[0]['Name'] == nonpublic_name assert not non_admin_session.bookmark.search(public_name) @tier2 -def test_negative_delete_bookmark(random_entity, module_viewer_user, test_name): +def test_negative_delete_bookmark(random_entity, default_viewer_role, test_name): """Simple removal of a bookmark query without permissions :id: 1a94bf2b-bcc6-4663-b70d-e13244a0783b @@ -247,7 +247,7 @@ def test_negative_delete_bookmark(random_entity, module_viewer_user, test_name): """ bookmark = entities.Bookmark(controller=random_entity['controller'], public=True).create() with Session( - test_name, module_viewer_user.login, module_viewer_user.password + 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 with raises(NoSuchElementException): diff --git a/tests/foreman/ui/test_contenthost.py b/tests/foreman/ui/test_contenthost.py index b3281ba9b61..4adce9649c6 100644 --- a/tests/foreman/ui/test_contenthost.py +++ b/tests/foreman/ui/test_contenthost.py @@ -495,7 +495,7 @@ def test_actions_katello_host_package_update_timeout(session, vm): @tier3 -def test_positive_search_errata_non_admin(session, vm, module_org, test_name, module_viewer_user): +def test_positive_search_errata_non_admin(session, vm, module_org, test_name, default_viewer_role): """Search for host's errata by non-admin user with enough permissions :id: 5b8887d2-987f-4bce-86a1-8f65ca7e1195 @@ -511,7 +511,7 @@ def test_positive_search_errata_non_admin(session, vm, module_org, test_name, mo """ vm.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) with Session( - test_name, user=module_viewer_user.login, password=module_viewer_user.password + test_name, user=default_viewer_role.login, password=default_viewer_role.password ) as session: chost = session.contenthost.read(vm.hostname, widget_names='errata') assert FAKE_2_ERRATA_ID in {errata['Id'] for errata in chost['errata']['table']}