Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions internal/flavors/assetinventory/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/elastic/cloudbeat/internal/config"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)
Expand Down Expand Up @@ -138,7 +137,7 @@ func TestStrategyPicks(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
s := strategy{
logger: clog.NewLogger("strategy_test"),
logger: testhelper.NewLogger(t),
cfg: tc.cfg,
}
ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond)
Expand Down
4 changes: 2 additions & 2 deletions internal/flavors/benchmark/aws_org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func Test_getAwsAccounts(t *testing.T) {
IdentityProvider: nil,
AccountProvider: tt.accountProvider,
}
log := clog.NewLogger("test")
log := testhelper.NewLogger(t)
got, err := a.getAwsAccounts(t.Context(), log, aws.Config{}, &tt.rootIdentity)
if tt.wantErr != "" {
require.ErrorContains(t, err, tt.wantErr)
Expand Down Expand Up @@ -262,7 +262,7 @@ func Test_pickManagementAccountRole(t *testing.T) {
zapcore.DebugLevel,
)
})
log = clog.NewLogger("test").WithOptions(replacement)
log = testhelper.NewLogger(t).WithOptions(replacement)
}

stsClient := &mockStsClient{}
Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_ec2_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
ec2beat "github.com/elastic/cloudbeat/internal/resources/providers/awslib/ec2"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestEC2InstanceFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestEC2InstanceFetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_ec2")
logger := testhelper.NewLogger(t)
provider := newMockEc2InstancesProvider(t)
provider.EXPECT().DescribeInstances(mock.Anything).Return(in, nil)

Expand Down
6 changes: 3 additions & 3 deletions internal/inventory/awsfetcher/fetcher_elb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/elb"
elbv2 "github.com/elastic/cloudbeat/internal/resources/providers/awslib/elb_v2"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestELBv1Fetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestELBv1Fetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_elb_v1")
logger := testhelper.NewLogger(t)
providerv1 := newMockV1Provider(t)
providerv1.EXPECT().DescribeAllLoadBalancers(mock.Anything).Return(in, nil)
providerv2 := newMockV2Provider(t)
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestELBv2Fetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_elb_v2")
logger := testhelper.NewLogger(t)
providerv1 := newMockV1Provider(t)
providerv1.EXPECT().DescribeAllLoadBalancers(mock.Anything).Return(nil, nil)
providerv2 := newMockV2Provider(t)
Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_iam_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/iam"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestIAMPolicyFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestIAMPolicyFetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_iam_role")
logger := testhelper.NewLogger(t)
provider := newMockIamPolicyProvider(t)
provider.EXPECT().GetPolicies(mock.Anything).Return(in, nil)

Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_iam_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/iam"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestIAMRoleFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestIAMRoleFetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_iam_role")
logger := testhelper.NewLogger(t)
provider := newMockIamRoleProvider(t)
provider.EXPECT().ListRoles(mock.Anything).Return(in, nil)

Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_iam_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/iam"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestIAMUserFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestIAMUserFetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_iam_user")
logger := testhelper.NewLogger(t)
provider := newMockIamUserProvider(t)
provider.EXPECT().GetUsers(mock.Anything).Return(in, nil)

Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/lambda"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestLambdaFunction_Fetch(t *testing.T) {
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestLambdaFunction_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_lambda")
logger := testhelper.NewLogger(t)
provider := newMockLambdaProvider(t)

provider.On("ListEventSourceMappings", mock.Anything, mock.Anything).Return([]awslib.AwsResource{}, nil)
Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/rds"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestRDSInstanceFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestRDSInstanceFetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_rds_instance")
logger := testhelper.NewLogger(t)
provider := newMockRdsProvider(t)
provider.EXPECT().DescribeDBInstances(mock.Anything).Return(in, nil)

Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/s3"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestS3BucketFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestS3BucketFetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_s3_bucket")
logger := testhelper.NewLogger(t)
provider := newMockS3BucketProvider(t)
provider.EXPECT().DescribeBuckets(mock.Anything).Return(in, nil)

Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/awsfetcher/fetcher_sns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib"
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/sns"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestSNSFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestSNSFetcher_Fetch(t *testing.T) {
),
}

logger := clog.NewLogger("test_fetcher_sns_instance")
logger := testhelper.NewLogger(t)
provider := newMockSnsProvider(t)
provider.EXPECT().ListTopicsWithSubscriptions(mock.Anything).Return(in, nil)

Expand Down
6 changes: 3 additions & 3 deletions internal/inventory/azurefetcher/fetcher_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (

"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
azurelib_inventory "github.com/elastic/cloudbeat/internal/resources/providers/azurelib/inventory"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestAccountFetcher_Fetch_Tenants(t *testing.T) {
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestAccountFetcher_Fetch_Tenants(t *testing.T) {
}

// setup
logger := clog.NewLogger("azurefetcher_test")
logger := testhelper.NewLogger(t)
provider := newMockAccountProvider(t)
provider.EXPECT().ListTenants(mock.Anything).Return(azureAssets, nil)
provider.EXPECT().ListSubscriptions(mock.Anything).Return(nil, nil)
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestAccountFetcher_Fetch_Subscriptions(t *testing.T) {
}

// setup
logger := clog.NewLogger("azurefetcher_test")
logger := testhelper.NewLogger(t)
provider := newMockAccountProvider(t)
provider.EXPECT().ListTenants(mock.Anything).Return(nil, nil)
provider.EXPECT().ListSubscriptions(mock.Anything).Return(azureAssets, nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestActiveDirectoryFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -137,7 +138,7 @@ func TestActiveDirectoryFetcher_Fetch(t *testing.T) {
}

// setup
logger := clog.NewLogger("azurefetcher_test")
logger := testhelper.NewLogger(t)
provider := newMockActivedirectoryProvider(t)

provider.EXPECT().ListServicePrincipals(mock.Anything).Maybe().Return(
Expand Down Expand Up @@ -170,7 +171,7 @@ func TestActiveDirectoryFetcher_FetchError(t *testing.T) {
zapcore.DebugLevel,
)
})
log = clog.NewLogger("test").WithOptions(replacement)
log = testhelper.NewLogger(t).WithOptions(replacement)
}

provider := newMockActivedirectoryProvider(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
azurelib_inventory "github.com/elastic/cloudbeat/internal/resources/providers/azurelib/inventory"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestResourceGraphFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) {
}

// setup
logger := clog.NewLogger("azurefetcher_test")
logger := testhelper.NewLogger(t)
provider := newMockResourceGraphProvider(t)

provider.EXPECT().ListAllAssetTypesByName(
Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/azurefetcher/fetcher_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (

"github.com/stretchr/testify/mock"

"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
azurelib_inventory "github.com/elastic/cloudbeat/internal/resources/providers/azurelib/inventory"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestStorageFetcher_Fetch(t *testing.T) {
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestStorageFetcher_Fetch(t *testing.T) {
}

// setup
logger := clog.NewLogger("azurefetcher_test")
logger := testhelper.NewLogger(t)
provider := newMockStorageProvider(t)

provider.EXPECT().ListSubscriptions(
Expand Down
4 changes: 2 additions & 2 deletions internal/inventory/gcpfetcher/fetcher_assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import (
"github.com/stretchr/testify/mock"
"google.golang.org/protobuf/types/known/structpb"

"github.com/elastic/cloudbeat/internal/infra/clog"
"github.com/elastic/cloudbeat/internal/inventory"
"github.com/elastic/cloudbeat/internal/inventory/testutil"
"github.com/elastic/cloudbeat/internal/resources/fetching"
gcpinventory "github.com/elastic/cloudbeat/internal/resources/providers/gcplib/inventory"
"github.com/elastic/cloudbeat/internal/resources/utils/testhelper"
)

func TestAccountFetcher_Fetch_Assets(t *testing.T) {
logger := clog.NewLogger("gcpfetcher_test")
logger := testhelper.NewLogger(t)
createAsset := func(assetType string) *gcpinventory.ExtendedGcpAsset {
return &gcpinventory.ExtendedGcpAsset{
Asset: &assetpb.Asset{
Expand Down
Loading