diff --git a/SOURCES/0024-Add-unittest-for-setting-up-repo-with-empty-keyfile-RhBug1994614.patch b/SOURCES/0024-Add-unittest-for-setting-up-repo-with-empty-keyfile-RhBug1994614.patch new file mode 100644 index 0000000..38ed66b --- /dev/null +++ b/SOURCES/0024-Add-unittest-for-setting-up-repo-with-empty-keyfile-RhBug1994614.patch @@ -0,0 +1,58 @@ +From 551a83052ff92fa975f1015e2fc25b174f85b0e6 Mon Sep 17 00:00:00 2001 +From: Aleš Matěj +Date: Tue, 26 Oct 2021 09:33:51 +0200 +Subject: [PATCH] Add unittest for setting up repo with empty keyfile (RhBug:1994614) + +The test ensures we don't crash when the keyfile is empty/not loaded. +Test for: https://github.com/rpm-software-management/libdnf/commit/be66d0908d939ddaf3022c5489012bd1dbdb0075 + +RHEL bug: +https://bugzilla.redhat.com/show_bug.cgi?id=1994614 +Fedora bug: +https://bugzilla.redhat.com/show_bug.cgi?id=1946024 +--- + tests/libdnf/dnf-self-test.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/tests/libdnf/dnf-self-test.c b/tests/libdnf/dnf-self-test.c +index 32a21e6..5295837 100644 +--- a/tests/libdnf/dnf-self-test.c ++++ b/tests/libdnf/dnf-self-test.c +@@ -199,6 +199,26 @@ ch_test_repo_func(void) + g_object_unref(context); + } + ++static void ++dnf_repo_setup_with_empty_keyfile(void) ++{ ++ DnfContext *context = dnf_context_new(); ++ dnf_context_set_release_ver(context, "33"); ++ DnfRepo *repo = dnf_repo_new(context); ++ GKeyFile *empty_key_file = g_key_file_new(); ++ ++ dnf_repo_set_keyfile(repo, empty_key_file); ++ ++ GError *error = NULL; ++ // Empty key file is not an errror, there is just no configuration to be loaded. ++ g_assert(dnf_repo_setup(repo, &error)); ++ g_assert_no_error(error); ++ ++ g_object_unref(repo); ++ g_object_unref(context); ++ g_key_file_free(empty_key_file); ++} ++ + static guint _allow_cancel_updates = 0; + static guint _action_updates = 0; + static guint _package_progress_updates = 0; +@@ -1217,6 +1237,7 @@ main(int argc, char **argv) + g_test_add_func("/libdnf/lock", dnf_lock_func); + g_test_add_func("/libdnf/lock[threads]", dnf_lock_threads_func); + g_test_add_func("/libdnf/repo", ch_test_repo_func); ++ g_test_add_func("/libdnf/repo_empty_keyfile", dnf_repo_setup_with_empty_keyfile); + g_test_add_func("/libdnf/state", dnf_state_func); + g_test_add_func("/libdnf/state[child]", dnf_state_child_func); + g_test_add_func("/libdnf/state[parent-1-step]", dnf_state_parent_one_step_proxy_func); +-- +libgit2 1.1.0 + diff --git a/SPECS/libdnf.spec b/SPECS/libdnf.spec index 2dcb150..51117cc 100644 --- a/SPECS/libdnf.spec +++ b/SPECS/libdnf.spec @@ -56,7 +56,7 @@ Name: libdnf Version: %{libdnf_major_version}.%{libdnf_minor_version}.%{libdnf_micro_version} -Release: 4%{?dist} +Release: 5%{?dist} Summary: Library providing simplified C and Python API to libsolv License: LGPLv2+ URL: https://github.com/rpm-software-management/libdnf @@ -84,6 +84,7 @@ Patch20: 0020-Fix-dnf_context_module_install-memory-leaks.patch Patch21: 0021-covscan-remove-unused-vars-mark-private-func-static-return-values.patch Patch22: 0022-hawkey-surrogateescape-error-handler-to-decode-UTF-8-strings-RhBug1893176.patch Patch23: 0023-Turn-off-strict-validation-of-modulemd-documents-RhBug200485320071662007167.patch +Patch24: 0024-Add-unittest-for-setting-up-repo-with-empty-keyfile-RhBug1994614.patch BuildRequires: cmake BuildRequires: gcc @@ -328,6 +329,9 @@ popd %endif %changelog +* Mon Nov 29 2021 Pavla Kratochvilova - 0.63.0-5 +- Add unittest for setting up repo with empty keyfile (RhBug:1994614) + * Tue Nov 09 2021 Pavla Kratochvilova - 0.63.0-4 - Bump release number because of conflicting version of 8.5 build