2026-05-11 22:37:05 -07:00
|
|
|
// Copyright IBM Corp. 2021, 2026
|
2023-06-05 09:52:48 -07:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2023-03-20 11:02:17 -07:00
|
|
|
package host
|
|
|
|
|
|
|
|
|
|
import (
|
2023-07-04 11:03:24 -07:00
|
|
|
"context"
|
2023-03-20 11:02:17 -07:00
|
|
|
"testing"
|
|
|
|
|
|
2026-10-12 10:27:59 -07:00
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold-plugin-aws/internal/credential"
|
2023-09-22 12:26:08 -07:00
|
|
|
"github.com/hashicorp/go-secure-stdlib/awsutil/v2"
|
2023-03-20 11:02:17 -07:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestAwsCatalogPersistedStateEC2Client(t *testing.T) {
|
|
|
|
|
require := require.New(t)
|
|
|
|
|
cred, err := credential.NewAwsCredentialPersistedState(
|
2023-07-18 16:33:24 -07:00
|
|
|
credential.WithCredentialsConfig(&awsutil.CredentialsConfig{
|
|
|
|
|
Region: "us-west-2",
|
|
|
|
|
AccessKey: "foobar",
|
|
|
|
|
SecretKey: "barfoo",
|
|
|
|
|
}),
|
2023-03-20 11:02:17 -07:00
|
|
|
)
|
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
|
|
state, err := newAwsCatalogPersistedState(
|
|
|
|
|
withCredentials(cred),
|
|
|
|
|
withTestEC2APIFunc(newTestMockEC2(nil)),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
2023-09-22 12:26:08 -07:00
|
|
|
clientRaw, err := state.EC2Client(context.Background())
|
2023-03-20 11:02:17 -07:00
|
|
|
require.NoError(err)
|
|
|
|
|
require.NotNil(clientRaw)
|
|
|
|
|
client, ok := clientRaw.(*testMockEC2)
|
|
|
|
|
require.True(ok)
|
|
|
|
|
require.NotNil(client)
|
|
|
|
|
require.Equal("us-west-2", client.Region)
|
|
|
|
|
}
|