Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.15.z] fix server config from user and role test module #13502

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions tests/foreman/api/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def test_negative_access_entities_from_org_admin(
sc = self.user_config(user, target_sat)
# Getting the domain from user
with pytest.raises(HTTPError):
target_sat.api.Domain(sc, id=domain.id).read()
target_sat.api.Domain(server_config=sc, id=domain.id).read()

@pytest.mark.tier3
def test_negative_access_entities_from_user(
Expand Down Expand Up @@ -620,7 +620,7 @@ def test_negative_access_entities_from_user(
sc = self.user_config(user, target_sat)
# Getting the domain from user
with pytest.raises(HTTPError):
target_sat.api.Domain(sc, id=domain.id).read()
target_sat.api.Domain(server_config=sc, id=domain.id).read()

@pytest.mark.tier2
def test_positive_override_cloned_role_filter(self, role_taxonomies, target_sat):
Expand Down Expand Up @@ -1018,22 +1018,22 @@ def test_positive_user_group_users_access_as_org_admin(self, role_taxonomies, ta
auth=(login, password), url=target_sat.url, verify=settings.server.verify_ca
)
try:
target_sat.api.Domain(sc).search(
target_sat.api.Domain(server_config=sc).search(
query={
'organization-id': role_taxonomies['org'].id,
'location-id': role_taxonomies['loc'].id,
}
)
target_sat.api.Subnet(sc).search(
target_sat.api.Subnet(server_config=sc).search(
query={
'organization-id': role_taxonomies['org'].id,
'location-id': role_taxonomies['loc'].id,
}
)
except HTTPError as err:
pytest.fail(str(err))
assert domain.id in [dom.id for dom in target_sat.api.Domain(sc).search()]
assert subnet.id in [sub.id for sub in target_sat.api.Subnet(sc).search()]
assert domain.id in [dom.id for dom in target_sat.api.Domain(server_config=sc).search()]
assert subnet.id in [sub.id for sub in target_sat.api.Subnet(server_config=sc).search()]

@pytest.mark.tier3
def test_positive_user_group_users_access_contradict_as_org_admins(self):
Expand Down Expand Up @@ -1098,7 +1098,7 @@ def test_negative_assign_org_admin_to_user_group(
for user in [user_one, user_two]:
sc = self.user_config(user, target_sat)
with pytest.raises(HTTPError):
target_sat.api.Domain(sc, id=dom.id).read()
target_sat.api.Domain(server_config=sc, id=dom.id).read()

@pytest.mark.tier2
def test_negative_assign_taxonomies_by_org_admin(
Expand Down Expand Up @@ -1149,7 +1149,7 @@ def test_negative_assign_taxonomies_by_org_admin(
auth=(user_login, user_pass), url=target_sat.url, verify=settings.server.verify_ca
)
# Getting the domain from user1
dom = target_sat.api.Domain(sc, id=dom.id).read()
dom = target_sat.api.Domain(server_config=sc, id=dom.id).read()
dom.organization = [filter_taxonomies['org']]
with pytest.raises(HTTPError):
dom.update(['organization'])
Expand Down Expand Up @@ -1319,7 +1319,7 @@ def test_negative_create_roles_by_org_admin(self, role_taxonomies, target_sat):
role_name = gen_string('alpha')
with pytest.raises(HTTPError):
target_sat.api.Role(
sc,
server_config=sc,
name=role_name,
organization=[role_taxonomies['org']],
location=[role_taxonomies['loc']],
Expand All @@ -1346,7 +1346,7 @@ def test_negative_modify_roles_by_org_admin(self, role_taxonomies, target_sat):
)
test_role = target_sat.api.Role().create()
sc = self.user_config(user, target_sat)
test_role = target_sat.api.Role(sc, id=test_role.id).read()
test_role = target_sat.api.Role(server_config=sc, id=test_role.id).read()
test_role.organization = [role_taxonomies['org']]
test_role.location = [role_taxonomies['loc']]
with pytest.raises(HTTPError):
Expand Down Expand Up @@ -1386,7 +1386,7 @@ def test_negative_admin_permissions_to_org_admin(self, role_taxonomies, target_s
auth=(user_login, user_pass), url=target_sat.url, verify=settings.server.verify_ca
)
with pytest.raises(HTTPError):
target_sat.api.User(sc, id=1).read()
target_sat.api.User(server_config=sc, id=1).read()

@pytest.mark.tier2
@pytest.mark.upgrade
Expand Down Expand Up @@ -1435,7 +1435,7 @@ def test_positive_create_user_by_org_admin(self, role_taxonomies, target_sat):
user_login = gen_string('alpha')
user_pass = gen_string('alphanumeric')
user = target_sat.api.User(
sc_user,
server_config=sc_user,
login=user_login,
password=user_pass,
role=[org_admin.id],
Expand Down Expand Up @@ -1476,7 +1476,7 @@ def test_positive_access_users_inside_org_admin_taxonomies(self, role_taxonomies
test_user = self.create_simple_user(filter_taxos=role_taxonomies)
sc = self.user_config(user, target_sat)
try:
target_sat.api.User(sc, id=test_user.id).read()
target_sat.api.User(server_config=sc, id=test_user.id).read()
except HTTPError as err:
pytest.fail(str(err))

Expand Down Expand Up @@ -1518,7 +1518,9 @@ def test_positive_create_nested_location(self, role_taxonomies, target_sat):
auth=(user_login, user_pass), url=target_sat.url, verify=settings.server.verify_ca
)
name = gen_string('alphanumeric')
location = target_sat.api.Location(sc, name=name, parent=role_taxonomies['loc'].id).create()
location = target_sat.api.Location(
server_config=sc, name=name, parent=role_taxonomies['loc'].id
).create()
assert location.name == name

@pytest.mark.tier2
Expand Down Expand Up @@ -1550,7 +1552,7 @@ def test_negative_access_users_outside_org_admin_taxonomies(
test_user = self.create_simple_user(filter_taxos=filter_taxonomies)
sc = self.user_config(user, target_sat)
with pytest.raises(HTTPError):
target_sat.api.User(sc, id=test_user.id).read()
target_sat.api.User(server_config=sc, id=test_user.id).read()

@pytest.mark.tier1
def test_negative_create_taxonomies_by_org_admin(self, role_taxonomies, target_sat):
Expand Down Expand Up @@ -1586,11 +1588,11 @@ def test_negative_create_taxonomies_by_org_admin(self, role_taxonomies, target_s
auth=(user_login, user_pass), url=target_sat.url, verify=settings.server.verify_ca
)
with pytest.raises(HTTPError):
target_sat.api.Organization(sc, name=gen_string('alpha')).create()
target_sat.api.Organization(server_config=sc, name=gen_string('alpha')).create()
if not is_open("BZ:1825698"):
try:
loc_name = gen_string('alpha')
loc = target_sat.api.Location(sc, name=loc_name).create()
loc = target_sat.api.Location(server_config=sc, name=loc_name).create()
except HTTPError as err:
pytest.fail(str(err))
assert loc_name == loc.name
Expand Down Expand Up @@ -1643,7 +1645,7 @@ def test_positive_access_all_global_entities_by_org_admin(
target_sat.api.Errata,
target_sat.api.OperatingSystem,
]:
entity(sc).search()
entity(server_config=sc).search()
except HTTPError as err:
pytest.fail(str(err))

Expand Down Expand Up @@ -1684,15 +1686,15 @@ def test_negative_access_entities_from_ldap_org_admin(
verify=settings.server.verify_ca,
)
with pytest.raises(HTTPError):
target_sat.api.Architecture(sc).search()
target_sat.api.Architecture(server_config=sc).search()
user = target_sat.api.User().search(
query={'search': f"login={create_ldap['ldap_user_name']}"}
)[0]
user.role = [target_sat.api.Role(id=org_admin.id).read()]
user.update(['role'])
# Trying to access the domain resource created in org admin role
with pytest.raises(HTTPError):
target_sat.api.Domain(sc, id=domain.id).read()
target_sat.api.Domain(server_config=sc, id=domain.id).read()

@pytest.mark.tier3
def test_negative_access_entities_from_ldap_user(
Expand Down Expand Up @@ -1729,15 +1731,15 @@ def test_negative_access_entities_from_ldap_user(
verify=settings.server.verify_ca,
)
with pytest.raises(HTTPError):
target_sat.api.Architecture(sc).search()
target_sat.api.Architecture(server_config=sc).search()
user = target_sat.api.User().search(
query={'search': f"login={create_ldap['ldap_user_name']}"}
)[0]
user.role = [target_sat.api.Role(id=org_admin.id).read()]
user.update(['role'])
# Trying to access the Domain resource
with pytest.raises(HTTPError):
target_sat.api.Domain(sc, id=domain.id).read()
target_sat.api.Domain(server_config=sc, id=domain.id).read()

@pytest.mark.tier3
def test_positive_assign_org_admin_to_ldap_user_group(
Expand Down Expand Up @@ -1800,7 +1802,7 @@ def test_positive_assign_org_admin_to_ldap_user_group(
verify=settings.server.verify_ca,
)
# Accessing the Domain resource
target_sat.api.Domain(sc, id=domain.id).read()
target_sat.api.Domain(server_config=sc, id=domain.id).read()

@pytest.mark.tier3
def test_negative_assign_org_admin_to_ldap_user_group(
Expand Down Expand Up @@ -1861,7 +1863,7 @@ def test_negative_assign_org_admin_to_ldap_user_group(
)
# Trying to access the Domain resource
with pytest.raises(HTTPError):
target_sat.api.Domain(sc, id=domain.id).read()
target_sat.api.Domain(server_config=sc, id=domain.id).read()


class TestRoleSearchFilter:
Expand Down
20 changes: 12 additions & 8 deletions tests/foreman/api/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,12 @@ def test_positive_table_preferences(self, module_target_sat):
sc = ServerConfig(
auth=(user.login, password), url=module_target_sat.url, verify=settings.server.verify_ca
)
module_target_sat.api.TablePreferences(sc, user=user, name=name, columns=columns).create()
table_preferences = module_target_sat.api.TablePreferences(sc, user=user).search()
module_target_sat.api.TablePreferences(
server_config=sc, user=user, name=name, columns=columns
).create()
table_preferences = module_target_sat.api.TablePreferences(
server_config=sc, user=user
).search()
assert len(table_preferences) == 1
tp = table_preferences[0]
assert hasattr(tp, 'name')
Expand Down Expand Up @@ -732,7 +736,7 @@ def test_positive_ad_basic_no_roles(self, create_ldap, target_sat):
verify=settings.server.verify_ca,
)
with pytest.raises(HTTPError):
target_sat.api.Architecture(sc).search()
target_sat.api.Architecture(server_config=sc).search()

@pytest.mark.tier3
@pytest.mark.upgrade
Expand Down Expand Up @@ -783,7 +787,7 @@ def test_positive_access_entities_from_ldap_org_admin(self, create_ldap, module_
verify=settings.server.verify_ca,
)
with pytest.raises(HTTPError):
module_target_sat.api.Architecture(sc).search()
module_target_sat.api.Architecture(server_config=sc).search()
user = module_target_sat.api.User().search(
query={'search': 'login={}'.format(create_ldap['ldap_user_name'])}
)[0]
Expand All @@ -800,7 +804,7 @@ def test_positive_access_entities_from_ldap_org_admin(self, create_ldap, module_
module_target_sat.api.Errata,
module_target_sat.api.OperatingSystem,
]:
entity(sc).search()
entity(server_config=sc).search()


@pytest.mark.run_in_one_thread
Expand Down Expand Up @@ -865,7 +869,7 @@ def test_positive_ipa_basic_no_roles(self, create_ldap, target_sat):
verify=settings.server.verify_ca,
)
with pytest.raises(HTTPError):
target_sat.api.Architecture(sc).search()
target_sat.api.Architecture(server_config=sc).search()

@pytest.mark.tier3
@pytest.mark.upgrade
Expand Down Expand Up @@ -906,7 +910,7 @@ def test_positive_access_entities_from_ipa_org_admin(self, create_ldap, target_s
verify=settings.server.verify_ca,
)
with pytest.raises(HTTPError):
target_sat.api.Architecture(sc).search()
target_sat.api.Architecture(server_config=sc).search()
user = target_sat.api.User().search(
query={'search': 'login={}'.format(create_ldap['username'])}
)[0]
Expand All @@ -923,7 +927,7 @@ def test_positive_access_entities_from_ipa_org_admin(self, create_ldap, target_s
target_sat.api.Errata,
target_sat.api.OperatingSystem,
]:
entity(sc).search()
entity(server_config=sc).search()


class TestPersonalAccessToken:
Expand Down