From a08be4082c893edf9032a6a5a498a66b549eaed1 Mon Sep 17 00:00:00 2001 From: Alessio Biancalana Date: Fri, 13 Sep 2024 15:03:33 +0200 Subject: [PATCH] fixup! Filter out non-registered hosts from affected systems in SUMA patch detail --- .../software_updates/adapter/mock_suma.ex | 4 ++-- .../controllers/v1/suse_manager_controller.ex | 10 ++++------ test/e2e/cypress/e2e/suse_manager_overviews.cy.js | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/trento/infrastructure/software_updates/adapter/mock_suma.ex b/lib/trento/infrastructure/software_updates/adapter/mock_suma.ex index 5f5a51a624..de6e7e6f7f 100644 --- a/lib/trento/infrastructure/software_updates/adapter/mock_suma.ex +++ b/lib/trento/infrastructure/software_updates/adapter/mock_suma.ex @@ -128,9 +128,9 @@ defmodule Trento.Infrastructure.SoftwareUpdates.MockSuma do {:ok, [ %{ - name: "test" + name: "vmdbrbddev01" }, - %{name: "test2"} + %{name: "vmdrbddev02"} ]} @impl true diff --git a/lib/trento_web/controllers/v1/suse_manager_controller.ex b/lib/trento_web/controllers/v1/suse_manager_controller.ex index 3c8b6d9a55..15763a97bd 100644 --- a/lib/trento_web/controllers/v1/suse_manager_controller.ex +++ b/lib/trento_web/controllers/v1/suse_manager_controller.ex @@ -112,17 +112,15 @@ defmodule TrentoWeb.V1.SUSEManagerController do {:ok, fixes} <- Discovery.get_bugzilla_fixes(advisory_name), {:ok, affected_packages} <- Discovery.get_affected_packages(advisory_name), {:ok, affected_systems} <- Discovery.get_affected_systems(advisory_name) do - filtered_affected_systems = - Enum.filter(affected_systems, fn %{name: system} -> - Enum.member?(registered_hosts, system) - end) - render(conn, %{ errata_details: errata_details, cves: cves, fixes: fixes, affected_packages: affected_packages, - affected_systems: filtered_affected_systems + affected_systems: + Enum.filter(affected_systems, fn %{name: system} -> + Enum.member?(registered_hosts, system) + end) }) end end diff --git a/test/e2e/cypress/e2e/suse_manager_overviews.cy.js b/test/e2e/cypress/e2e/suse_manager_overviews.cy.js index c2911563c5..1accf80d64 100644 --- a/test/e2e/cypress/e2e/suse_manager_overviews.cy.js +++ b/test/e2e/cypress/e2e/suse_manager_overviews.cy.js @@ -62,8 +62,8 @@ context('SUSE Manager overviews', () => { cy.contains('Affected Packages').next().should('contain', 'kernel'); cy.contains('Affected Systems') .next() - .should('contain', 'test') - .should('contain', 'test2'); + .should('contain', 'vmdrbddev01') + .should('contain', 'vmdrbddev02'); cy.clearSUMASettings(); });