Skip to content

Commit

Permalink
fix AWS & GCP test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kubasobon committed Apr 16, 2024
1 parent 6e8f5cc commit e157186
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 6 additions & 1 deletion internal/resources/fetching/fetchers/aws/iam_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,12 @@ func (s *IamFetcherTestSuite) TestIamResource_GetMetadata() {

m, err := iamResource.GetElasticCommonData()
s.Require().NoError(err)
s.Len(m, 1)
switch iamResource.GetResourceType() {
case fetching.IAMUserType, fetching.PolicyType:
s.Len(m, 3)
default:
s.Len(m, 1)
}
s.Contains(m, "cloud.service.name")
})
}
Expand Down
9 changes: 3 additions & 6 deletions internal/resources/fetching/fetchers/azure/assets_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,9 @@ func (r *AzureResource) GetMetadata() (fetching.ResourceMetadata, error) {
func (r *AzureResource) GetElasticCommonData() (map[string]any, error) {
m := map[string]any{}

switch r.Asset.Type {
case fetching.AzureRoleDefinitionType:
{
m["user.effective.id"] = r.Asset.Id
m["user.effective.name"] = r.Asset.Name
}
if r.Asset.Type == fetching.AzureRoleDefinitionType {
m["user.effective.id"] = r.Asset.Id
m["user.effective.name"] = r.Asset.Name
}

return m, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/resources/fetching/fetchers/gcp/assets_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/elastic/elastic-agent-libs/logp"
"github.com/huandu/xstrings"
structpb "google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/structpb"

"github.com/elastic/cloudbeat/internal/resources/fetching"
"github.com/elastic/cloudbeat/internal/resources/fetching/cycle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,10 @@ func (s *GcpAssetsFetcherTestSuite) TestFetcher_Fetch() {
s.Equal("prjId", cloudAccountMetadata.AccountId)
s.Equal("orgId", cloudAccountMetadata.OrganisationId)
s.Equal("orgName", cloudAccountMetadata.OrganizationName)
if metadata.Type == fetching.CloudIdentity {
m, err := r.GetElasticCommonData()
s.Require().NoError(err, "error getting Elastic Common Data")
s.Len(m, 2)
}
})
}

0 comments on commit e157186

Please sign in to comment.