diff --git a/test/fixtures/discovery/subscriptions_discovery.json b/test/fixtures/discovery/subscriptions_discovery.json new file mode 100644 index 0000000000..9bae3f3971 --- /dev/null +++ b/test/fixtures/discovery/subscriptions_discovery.json @@ -0,0 +1,56 @@ +{ + "agent_id": "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + "discovery_type": "subscription_discovery", + "payload": [ + { + "arch": "x86_64", + "type": "internal", + "status": "Registered", + "version": "15.3", + "starts_at": "2021-10-18 06:23:46 UTC", + "expires_at": "2026-10-18 06:23:46 UTC", + "identifier": "SLES_SAP", + "subscription_status": "ACTIVE" + }, + { + "arch": "x86_64", + "status": "Registered", + "version": "15.3", + "identifier": "sle-module-basesystem" + }, + { + "arch": "x86_64", + "status": "Registered", + "version": "15.3", + "identifier": "sle-module-desktop-applications" + }, + { + "arch": "x86_64", + "status": "Registered", + "version": "15.3", + "identifier": "sle-module-server-applications" + }, + { + "arch": "x86_64", + "type": "internal", + "status": "Registered", + "version": "15.3", + "starts_at": "2021-10-18 06:23:46 UTC", + "expires_at": "2026-10-18 06:23:46 UTC", + "identifier": "sle-ha", + "subscription_status": "ACTIVE" + }, + { + "arch": "x86_64", + "status": "Registered", + "version": "15.3", + "identifier": "sle-module-sap-applications" + }, + { + "arch": "x86_64", + "status": "Registered", + "version": "15.3", + "identifier": "sle-module-public-cloud" + } + ] +} diff --git a/test/tronto/monitoring/integration/discovery_test.exs b/test/tronto/monitoring/integration/discovery_test.exs index ae9f53090e..b1c617b109 100644 --- a/test/tronto/monitoring/integration/discovery_test.exs +++ b/test/tronto/monitoring/integration/discovery_test.exs @@ -11,7 +11,7 @@ defmodule Tronto.Monitoring.Integration.DiscoveryTest do test "cloud_discovery payload with azure provider should return the expected commands" do assert { :ok, - %Tronto.Monitoring.Domain.Commands.UpdateProvider{ + %UpdateProvider{ host_id: "0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4", provider: "azure" } diff --git a/test/tronto/monitoring/integration/subscriptions_test.exs b/test/tronto/monitoring/integration/subscriptions_test.exs new file mode 100644 index 0000000000..fde37c239b --- /dev/null +++ b/test/tronto/monitoring/integration/subscriptions_test.exs @@ -0,0 +1,102 @@ +defmodule Tronto.Monitoring.Integration.SubscriptionsTest do + use ExUnit.Case + + import Tronto.DiscoveryFixturesHelper + + alias Tronto.Monitoring.Integration.Discovery + alias Tronto.Monitoring.Domain.SlesSubscription + alias Tronto.Monitoring.Domain.Commands.UpdateSlesSubscriptions + + describe "cloud_discovery" do + test "cloud_discovery payload with azure provider should return the expected commands" do + assert { + :ok, + %UpdateSlesSubscriptions{ + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + subscriptions: [ + %SlesSubscription{ + arch: "x86_64", + expires_at: "2026-10-18 06:23:46 UTC", + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + identifier: "SLES_SAP", + starts_at: "2021-10-18 06:23:46 UTC", + status: "Registered", + subscription_status: "ACTIVE", + type: "internal", + version: "15.3" + }, + %SlesSubscription{ + arch: "x86_64", + expires_at: nil, + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + identifier: "sle-module-basesystem", + starts_at: nil, + status: "Registered", + subscription_status: nil, + type: nil, + version: "15.3" + }, + %SlesSubscription{ + arch: "x86_64", + expires_at: nil, + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + identifier: "sle-module-desktop-applications", + starts_at: nil, + status: "Registered", + subscription_status: nil, + type: nil, + version: "15.3" + }, + %SlesSubscription{ + arch: "x86_64", + expires_at: nil, + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + identifier: "sle-module-server-applications", + starts_at: nil, + status: "Registered", + subscription_status: nil, + type: nil, + version: "15.3" + }, + %SlesSubscription{ + arch: "x86_64", + expires_at: "2026-10-18 06:23:46 UTC", + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + identifier: "sle-ha", + starts_at: "2021-10-18 06:23:46 UTC", + status: "Registered", + subscription_status: "ACTIVE", + type: "internal", + version: "15.3" + }, + %SlesSubscription{ + arch: "x86_64", + expires_at: nil, + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + identifier: "sle-module-sap-applications", + starts_at: nil, + status: "Registered", + subscription_status: nil, + type: nil, + version: "15.3" + }, + %Tronto.Monitoring.Domain.SlesSubscription{ + arch: "x86_64", + expires_at: nil, + host_id: "0fc07435-7ee2-54ca-b0de-fb27ffdc5deb", + identifier: "sle-module-public-cloud", + starts_at: nil, + status: "Registered", + subscription_status: nil, + type: nil, + version: "15.3" + } + ] + } + } = + "subscriptions_discovery" + |> load_discovery_event_fixture() + |> Discovery.handle_discovery_event() + end + end +end