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

AK UI test fix #17631

Merged
merged 3 commits into from
Feb 20, 2025
Merged
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
29 changes: 17 additions & 12 deletions tests/foreman/ui/test_activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,10 @@ def test_positive_delete_with_system(session, rhel_contenthost, target_sat):


@pytest.mark.tier3
def test_negative_usage_limit(session, module_org, target_sat, module_promoted_cv, module_lce):
@pytest.mark.rhel_ver_match('N-2')
def test_negative_usage_limit(
session, module_org, target_sat, module_promoted_cv, module_lce, mod_content_hosts
):
"""Test that Usage limit actually limits usage

:id: 9fe2d661-66f8-46a4-ae3f-0a9329494bdd
Expand All @@ -940,23 +943,25 @@ def test_negative_usage_limit(session, module_org, target_sat, module_promoted_c
"""
name = gen_string('alpha')
hosts_limit = '1'
with session:
with target_sat.ui_session() as session:
session.location.select(constants.DEFAULT_LOC)
session.organization.select(module_org.name)
session.activationkey.create(
{'name': name, 'lce': {module_lce.name: True}, 'content_view': module_promoted_cv.name}
)
assert session.activationkey.search(name)[0]['Name'] == name
session.activationkey.update(name, {'details.hosts_limit': hosts_limit})
session.activationkey.update_ak_host_limit(name, int(hosts_limit))
ak = session.activationkey.read(name, widget_names='details')
assert ak['details']['hosts_limit'] == hosts_limit
with Broker(nick='rhel6', host_class=ContentHost, _count=2) as hosts:
vm1, vm2 = hosts
result = vm1.register(module_org, None, name, target_sat)
assert result.status == 0, f'Failed to register host: {result.stderr}'
assert vm1.subscribed
result = vm2.register(module_org, None, name, target_sat)
assert not vm2.subscribed
assert len(result.stderr)
assert f'Max Hosts ({hosts_limit}) reached for activation key' in str(result.stderr)

vm1, vm2 = mod_content_hosts
result = vm1.register(module_org, None, name, target_sat)
assert result.status == 0, f'Failed to register host: {result.stderr}'
assert vm1.subscribed
result = vm2.register(module_org, None, name, target_sat)
assert not vm2.subscribed
assert result.status
assert f'Max Hosts ({hosts_limit}) reached for activation key' in str(result.stderr)


@pytest.mark.no_containers
Expand Down