From 9c4abb8c69699c32601a27303a0c799d05fd0ca5 Mon Sep 17 00:00:00 2001 From: Vladimir Sedmik Date: Thu, 5 Dec 2024 17:49:34 +0100 Subject: [PATCH] Extend the scan case with authenticated remote --- robottelo/constants/__init__.py | 4 +++- tests/foreman/cli/test_flatpak.py | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 62630a565d..57fc0114ba 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -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, }, } diff --git a/tests/foreman/cli/test_flatpak.py b/tests/foreman/cli/test_flatpak.py index c38f84031f..308f554d7d 100644 --- a/tests/foreman/cli/test_flatpak.py +++ b/tests/foreman/cli/test_flatpak.py @@ -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 @@ -145,11 +146,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. @@ -159,16 +163,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']})