From 35a5e406bab403cd1b299f2028f4fb0bb6392fd8 Mon Sep 17 00:00:00 2001 From: Chris Townsend Date: Mon, 11 Dec 2023 13:26:05 -0500 Subject: [PATCH 1/3] [daemon/find] Filter out snapcraft remote by default Fixes #3274 --- src/daemon/daemon.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 864a56895b..886ff27c71 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1649,7 +1649,8 @@ try // clang-format on std::unordered_set images_found; auto action = [&images_found, &default_remote, request, &response](const std::string& remote, const mp::VMImageInfo& info) { - if ((info.supported || request->allow_unsupported()) && !info.aliases.empty() && + if (!(remote == mp::snapcraft_remote) && (info.supported || request->allow_unsupported()) && + !info.aliases.empty() && images_found.find(info.release_title.toStdString()) == images_found.end()) { add_aliases(response.mutable_images_info(), remote, info, default_remote); From 08e873c4d133df6f1f507f6f240e0e7b1284636f Mon Sep 17 00:00:00 2001 From: Chris Townsend Date: Mon, 11 Dec 2023 15:27:06 -0500 Subject: [PATCH 2/3] [tests] Fix test that includes filtered snapcraft remote --- tests/test_daemon_find.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_daemon_find.cpp b/tests/test_daemon_find.cpp index d368ca6959..e5992cea43 100644 --- a/tests/test_daemon_find.cpp +++ b/tests/test_daemon_find.cpp @@ -89,14 +89,16 @@ TEST_F(DaemonFind, blankQueryReturnsAllData) EXPECT_THAT(stream.str(), AllOf(HasSubstr(mpt::default_alias), HasSubstr(mpt::default_release_info), HasSubstr(mpt::another_alias), HasSubstr(mpt::another_release_info), - HasSubstr(fmt::format("{}:{}", mpt::snapcraft_remote, mpt::snapcraft_alias)), - HasSubstr(mpt::snapcraft_release_info), HasSubstr(fmt::format("{}:{}", mpt::custom_remote, mpt::custom_alias)), HasSubstr(mpt::custom_release_info), HasSubstr(blueprint1_name), HasSubstr(blueprint_description_for(blueprint1_name)), HasSubstr(blueprint2_name), HasSubstr(blueprint_description_for(blueprint2_name)))); - EXPECT_EQ(total_lines_of_output(stream), 10); + EXPECT_THAT(stream.str(), + Not(AllOf(HasSubstr(fmt::format("{}:{}", mpt::snapcraft_remote, mpt::snapcraft_alias)), + HasSubstr(mpt::snapcraft_release_info)))); + + EXPECT_EQ(total_lines_of_output(stream), 9); } TEST_F(DaemonFind, queryForDefaultReturnsExpectedData) From 85dc6cb5e953db1beb59da2a4aced5b1e2a37402 Mon Sep 17 00:00:00 2001 From: Chris Townsend Date: Tue, 12 Dec 2023 08:30:25 -0500 Subject: [PATCH 3/3] Use better logic to compare snapcraft remote Co-authored-by: Ricardo Abreu <6698114+ricab@users.noreply.github.com> Signed-off-by: Chris Townsend --- src/daemon/daemon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 886ff27c71..6944bdcac3 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1649,7 +1649,7 @@ try // clang-format on std::unordered_set images_found; auto action = [&images_found, &default_remote, request, &response](const std::string& remote, const mp::VMImageInfo& info) { - if (!(remote == mp::snapcraft_remote) && (info.supported || request->allow_unsupported()) && + if (remote != mp::snapcraft_remote && (info.supported || request->allow_unsupported()) && !info.aliases.empty() && images_found.find(info.release_title.toStdString()) == images_found.end()) {