|
@@ -22,6 +22,7 @@ import (
|
|
|
"testing"
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
|
|
|
+ "github.com/aws/aws-sdk-go/private/protocol"
|
|
|
awssm "github.com/aws/aws-sdk-go/service/secretsmanager"
|
|
awssm "github.com/aws/aws-sdk-go/service/secretsmanager"
|
|
|
"github.com/crossplane/crossplane-runtime/pkg/test"
|
|
"github.com/crossplane/crossplane-runtime/pkg/test"
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"github.com/google/go-cmp/cmp"
|
|
@@ -345,6 +346,13 @@ func TestSetSecret(t *testing.T) {
|
|
|
VersionStages: versionOutput,
|
|
VersionStages: versionOutput,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ notFoundErr := &awssm.ResourceExistsException{
|
|
|
|
|
+ RespMetadata: protocol.ResponseMetadata{
|
|
|
|
|
+ StatusCode: 400,
|
|
|
|
|
+ RequestID: secretName,
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
type args struct {
|
|
type args struct {
|
|
|
store *esv1beta1.AWSProvider
|
|
store *esv1beta1.AWSProvider
|
|
|
client fakesm.Client
|
|
client fakesm.Client
|
|
@@ -358,8 +366,8 @@ func TestSetSecret(t *testing.T) {
|
|
|
args args
|
|
args args
|
|
|
want want
|
|
want want
|
|
|
}{
|
|
}{
|
|
|
- "SetSecretSucceeds": {
|
|
|
|
|
- reason: "a secret can be puahed to aws secrets manager",
|
|
|
|
|
|
|
+ "SetSecretSucceedsWithExistingSecret": {
|
|
|
|
|
+ reason: "a secret can be pushed to aws secrets manager when it already exists",
|
|
|
args: args{
|
|
args: args{
|
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
|
client: fakesm.Client{
|
|
client: fakesm.Client{
|
|
@@ -371,6 +379,19 @@ func TestSetSecret(t *testing.T) {
|
|
|
err: nil,
|
|
err: nil,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ "SetSecretSucceedsWithNewSecret": {
|
|
|
|
|
+ reason: "a secret can be pushed to aws secrets manager if it doesn't already exist",
|
|
|
|
|
+ args: args{
|
|
|
|
|
+ store: makeValidSecretStore().Spec.Provider.AWS,
|
|
|
|
|
+ client: fakesm.Client{
|
|
|
|
|
+ GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(nil, notFoundErr),
|
|
|
|
|
+ CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(secretOutput, nil),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ want: want{
|
|
|
|
|
+ err: nil,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
"SetSecretCreateSecretFails": {
|
|
"SetSecretCreateSecretFails": {
|
|
|
reason: "CreateSecretWithContext returns an error if it fails",
|
|
reason: "CreateSecretWithContext returns an error if it fails",
|
|
|
args: args{
|
|
args: args{
|