Skip to content

Commit

Permalink
Extend the scan case with authenticated remote
Browse files Browse the repository at this point in the history
  • Loading branch information
vsedmik committed Dec 9, 2024
1 parent 9326b19 commit ab64bf1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
4 changes: 3 additions & 1 deletion robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,12 @@
'Fedora': {
'url': 'https://registry.fedoraproject.org',
'index_url': 'https://registry.fedoraproject.org/index/static?label:org.flatpak.ref:exists=1&tag=latest',
'authenticated': False,
},
'RedHat': {
'url': 'https://flatpaks.redhat.io',
'url': 'https://flatpaks.redhat.io/rhel/',
'index_url': 'https://flatpaks.redhat.io/rhel/index/static?label:org.flatpak.ref:exists=1&tag=latest',
'authenticated': True,
},
}

Expand Down
41 changes: 27 additions & 14 deletions tests/foreman/cli/test_flatpak.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import pytest
import requests

from robottelo.config import settings
from robottelo.constants import FLATPAK_REMOTES
from robottelo.exceptions import CLIReturnCodeError
from robottelo.utils.datafactory import gen_string
Expand Down Expand Up @@ -107,15 +108,19 @@ def test_CRUD_and_sync_flatpak_remote_with_permissions(
}
)
)
res = target_sat.cli.FlatpakRemote().with_user(usr, pwd).info({'name': remote['name']})
res = (
target_sat.cli.FlatpakRemote()
.with_user(usr, pwd)
.info({'organization-id': function_org.id, 'name': remote['name']})
)
assert res == remote, 'Read values differ from the created ones'

# 3. Ensure that remotes can be updated and scanned only with proper permissions.
p = 'edit_flatpak_remotes'
desc = gen_string('alpha')
with pytest.raises(CLIReturnCodeError) as e:
target_sat.cli.FlatpakRemote().with_user(usr, pwd).update(
{'name': remote['name'], 'description': desc}
{'organization-id': function_org.id, 'name': remote['name'], 'description': desc}
)
assert emsg.format(p) in str(e)
with pytest.raises(CLIReturnCodeError) as e:
Expand All @@ -124,10 +129,14 @@ def test_CRUD_and_sync_flatpak_remote_with_permissions(

target_sat.api_factory.create_role_permissions(function_role, {'Katello::FlatpakRemote': [p]})
target_sat.cli.FlatpakRemote().with_user(usr, pwd).update(
{'name': remote['name'], 'description': desc}
{'organization-id': function_org.id, 'name': remote['name'], 'description': desc}
)
target_sat.cli.FlatpakRemote().with_user(usr, pwd).scan({'name': remote['name']})
res = target_sat.cli.FlatpakRemote().with_user(usr, pwd).info({'name': remote['name']})
res = (
target_sat.cli.FlatpakRemote()
.with_user(usr, pwd)
.info({'organization-id': function_org.id, 'name': remote['name']})
)
assert res['description'] == desc, 'Description was not updated'
assert 'http' in res['registry-url'], 'Scan of flatpak remote failed'

Expand All @@ -145,11 +154,14 @@ def test_CRUD_and_sync_flatpak_remote_with_permissions(
assert 'Error: flatpak_remote not found' in str(e)


def test_scan_flatpak_remote(target_sat, function_org, function_product):
@pytest.mark.parametrize('remote', FLATPAK_REMOTES.values(), ids=FLATPAK_REMOTES)
def test_scan_flatpak_remote(target_sat, function_org, function_product, remote):
"""Verify flatpak remote scan detects all repos available in the remote index.
:id: 3dff23f3-f415-4fb2-a41c-7cdcae617bb0
:parametrized: yes
:steps:
1. Create a flatpak remote and scan it.
2. Read the remote index via its API.
Expand All @@ -159,16 +171,17 @@ def test_scan_flatpak_remote(target_sat, function_org, function_product):
1. Repos scanned by flatpak remote match the repos available in the remote index.
"""
remote = FLATPAK_REMOTES['Fedora']

# 1. Create a flatpak remote and scan it.
fr = target_sat.cli.FlatpakRemote().create(
{
'organization-id': function_org.id,
'url': remote['url'],
'name': gen_string('alpha'),
}
)
create_opts = {
'organization-id': function_org.id,
'url': remote['url'],
'name': gen_string('alpha'),
}
if remote['authenticated']:
create_opts['username'] = settings.container_repo.registries.redhat.username
create_opts['token'] = settings.container_repo.registries.redhat.password

fr = target_sat.cli.FlatpakRemote().create(create_opts)
target_sat.cli.FlatpakRemote().scan({'id': fr['id']})

scanned_repos = target_sat.cli.FlatpakRemote().repository_list({'flatpak-remote-id': fr['id']})
Expand Down

0 comments on commit ab64bf1

Please sign in to comment.