Skip to content

Commit

Permalink
rename fixture module_viewer_user
Browse files Browse the repository at this point in the history
  • Loading branch information
jameerpathan111 committed Oct 23, 2020
1 parent 2479604 commit 18b54b3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 44 deletions.
9 changes: 0 additions & 9 deletions pytest_fixtures/api_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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')
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion pytest_fixtures/user_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/foreman/cli/test_oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']}
)

Expand Down
22 changes: 0 additions & 22 deletions tests/foreman/ui/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions tests/foreman/ui/test_bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -209,22 +209,22 @@ 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)
with session:
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
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/foreman/ui/test_contenthost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']}
Expand Down

0 comments on commit 18b54b3

Please sign in to comment.