Skip to content
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
29 changes: 29 additions & 0 deletions reports/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,35 @@ def test_process_repo_json_rpm(self):
# RPM priority is negated
self.assertEqual(priority, -99)

def test_process_repo_no_rename_on_existing_mirror(self):
"""Repo found by mirror URL should keep its original name.

Repo names are set at creation and should not be overwritten by
client reports — the admin may have renamed the repo in the UI.
"""
repo, _ = process_repo(
r_type=Repository.RPM,
r_name='Zabbix Official Repository - x86_64 x86_64',
r_id='zabbix',
r_priority=-99,
urls=['https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64'],
arch='x86_64',
)
self.assertEqual(repo.name, 'Zabbix Official Repository - x86_64 x86_64')

# updated client reports same URL with corrected name
repo2, _ = process_repo(
r_type=Repository.RPM,
r_name='Zabbix Official Repository - x86_64',
r_id='zabbix',
r_priority=-99,
urls=['https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64'],
arch='x86_64',
)
# should return the same repo, name unchanged
self.assertEqual(repo2.id, repo.id)
self.assertEqual(repo2.name, 'Zabbix Official Repository - x86_64 x86_64')


@override_settings(
CELERY_TASK_ALWAYS_EAGER=True,
Expand Down
3 changes: 0 additions & 3 deletions reports/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ def process_repo(r_type, r_name, r_id, r_priority, urls, arch):
if r_id and repository.repo_id != r_id:
repository.repo_id = r_id

if r_name and repository.name != r_name:
repository.name = r_name

for url in unknown:
Mirror.objects.create(repo=repository, url=url.rstrip('/'))

Expand Down
Loading