|
@@ -328,13 +328,24 @@ func (f fakeRef) GetRemoteKey() string {
|
|
|
return f.key
|
|
return f.key
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
func TestSetSecret(t *testing.T) {
|
|
func TestSetSecret(t *testing.T) {
|
|
|
secretName := "fake-key"
|
|
secretName := "fake-key"
|
|
|
noPermission := errors.New("no permission")
|
|
noPermission := errors.New("no permission")
|
|
|
|
|
+ versionId := "384898A7-A5AE-4775-A08D-B417B059ED11"
|
|
|
|
|
+ versionStages := "AWSCURRENT"
|
|
|
|
|
+ versionOutput := []*string{&versionStages}
|
|
|
|
|
+
|
|
|
secretOutput := &awssm.CreateSecretOutput{
|
|
secretOutput := &awssm.CreateSecretOutput{
|
|
|
Name: &secretName,
|
|
Name: &secretName,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ secretValueOutput := &awssm.GetSecretValueOutput{
|
|
|
|
|
+ Name: &secretName,
|
|
|
|
|
+ VersionId: &versionId,
|
|
|
|
|
+ VersionStages: versionOutput,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
type args struct {
|
|
type args struct {
|
|
|
store *esv1beta1.AWSProvider
|
|
store *esv1beta1.AWSProvider
|
|
|
client fakesm.Client
|
|
client fakesm.Client
|
|
@@ -353,6 +364,7 @@ func TestSetSecret(t *testing.T) {
|
|
|
args: args{
|
|
args: args{
|
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
|
client: fakesm.Client{
|
|
client: fakesm.Client{
|
|
|
|
|
+ GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput, nil),
|
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(secretOutput, nil),
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(secretOutput, nil),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -365,6 +377,7 @@ func TestSetSecret(t *testing.T) {
|
|
|
args: args{
|
|
args: args{
|
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
|
client: fakesm.Client{
|
|
client: fakesm.Client{
|
|
|
|
|
+ GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput, nil),
|
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(nil, noPermission),
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(nil, noPermission),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -372,6 +385,18 @@ func TestSetSecret(t *testing.T) {
|
|
|
err: noPermission,
|
|
err: noPermission,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ "SetSecretGetSecretFails": {
|
|
|
|
|
+ reason: "GetSecretValueWithContext returns an error if it fails",
|
|
|
|
|
+ args: args {
|
|
|
|
|
+ store: makeValidSecretStore().Spec.Provider.AWS,
|
|
|
|
|
+ client: fakesm.Client{
|
|
|
|
|
+ GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(nil, noPermission),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ want: want{
|
|
|
|
|
+ err: noPermission,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for name, tc := range tests {
|
|
for name, tc := range tests {
|