From f2f816fe73bc5b9c6d8d99528b662bdd7b27ffd0 Mon Sep 17 00:00:00 2001 From: kubasobon Date: Mon, 22 Apr 2024 14:21:51 +0200 Subject: [PATCH] use correct type for Azure Role Definitions --- .../fetching/fetchers/azure/assets_fetcher.go | 2 +- .../fetchers/azure/assets_fetcher_test.go | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/resources/fetching/fetchers/azure/assets_fetcher.go b/internal/resources/fetching/fetchers/azure/assets_fetcher.go index cfde7b185a..8625fc35e3 100644 --- a/internal/resources/fetching/fetchers/azure/assets_fetcher.go +++ b/internal/resources/fetching/fetchers/azure/assets_fetcher.go @@ -201,7 +201,7 @@ func (r *AzureResource) GetElasticCommonData() (map[string]any, error) { } m["host.hostname"] = computerName } - case fetching.AzureRoleDefinitionType: + case inventory.RoleDefinitionsType: { m["user.effective.id"] = r.Asset.Id m["user.effective.name"] = r.Asset.Name diff --git a/internal/resources/fetching/fetchers/azure/assets_fetcher_test.go b/internal/resources/fetching/fetchers/azure/assets_fetcher_test.go index e8a4e5c8a0..bee5f30beb 100644 --- a/internal/resources/fetching/fetchers/azure/assets_fetcher_test.go +++ b/internal/resources/fetching/fetchers/azure/assets_fetcher_test.go @@ -220,9 +220,19 @@ func (s *AzureAssetsFetcherTestSuite) TestFetcher_Fetch() { ecs, err := result.GetElasticCommonData() s.Require().NoError(err) - if expected.Type == inventory.VirtualMachineAssetType { - s.Contains(ecs, "host.name") - } else { + switch expected.Type { + case inventory.VirtualMachineAssetType: + { + s.GreaterOrEqual(len(ecs), 1) + s.Contains(ecs, "host.name") + } + case inventory.RoleDefinitionsType: + { + s.Len(ecs, 2) + s.Contains(ecs, "user.effective.id") + s.Contains(ecs, "user.effective.name") + } + default: s.Empty(ecs) } })