2023-06-05 09:52:48 -07:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// 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"
|
|
|
|
|
|
2023-06-02 08:55:14 -07:00
|
|
|
"github.com/hashicorp/boundary-plugin-aws/internal/credential"
|
2023-07-18 16:33:24 -07:00
|
|
|
"github.com/hashicorp/go-secure-stdlib/awsutil"
|
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-07-04 11:03:24 -07:00
|
|
|
clientRaw, err := state.EC2Client(context.Background(), WithRegion("us-west-2"))
|
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)
|
|
|
|
|
}
|