|
@@ -329,7 +329,9 @@ func (f fakeRef) GetRemoteKey() string {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func TestSetSecret(t *testing.T) {
|
|
func TestSetSecret(t *testing.T) {
|
|
|
|
|
+ managedBy := "managed-by"
|
|
|
secretValue := []byte("fake-value")
|
|
secretValue := []byte("fake-value")
|
|
|
|
|
+ externalSecrets := "external-secrets"
|
|
|
noPermission := errors.New("no permission")
|
|
noPermission := errors.New("no permission")
|
|
|
arn := "arn:aws:secretsmanager:us-east-1:702902267788:secret:foo-bar5-Robbgh"
|
|
arn := "arn:aws:secretsmanager:us-east-1:702902267788:secret:foo-bar5-Robbgh"
|
|
|
|
|
|
|
@@ -340,6 +342,18 @@ func TestSetSecret(t *testing.T) {
|
|
|
ARN: &arn,
|
|
ARN: &arn,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ externalSecretsTag := []*awssm.Tag{
|
|
|
|
|
+ &awssm.Tag{
|
|
|
|
|
+ Key: &managedBy,
|
|
|
|
|
+ Value: &externalSecrets,
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ tagSecretOutput := &awssm.DescribeSecretOutput{
|
|
|
|
|
+ ARN: &arn,
|
|
|
|
|
+ Tags: externalSecretsTag,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
secretValueOutput := &awssm.GetSecretValueOutput{
|
|
secretValueOutput := &awssm.GetSecretValueOutput{
|
|
|
ARN: &arn,
|
|
ARN: &arn,
|
|
|
}
|
|
}
|
|
@@ -376,6 +390,7 @@ func TestSetSecret(t *testing.T) {
|
|
|
GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput, nil),
|
|
GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput, nil),
|
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(secretOutput, nil),
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(secretOutput, nil),
|
|
|
PutSecretValueWithContextFn: fakesm.NewPutSecretValueWithContextFn(putSecretOutput, nil),
|
|
PutSecretValueWithContextFn: fakesm.NewPutSecretValueWithContextFn(putSecretOutput, nil),
|
|
|
|
|
+ DescribeSecretWithContextFn: fakesm.NewDescribeSecretWithContextFn(tagSecretOutput, nil),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
want: want{
|
|
want: want{
|
|
@@ -400,9 +415,8 @@ 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),
|
|
|
|
|
|
|
+ GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(blankSecretValueOutput, &getSecretCorrectErr),
|
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(nil, noPermission),
|
|
CreateSecretWithContextFn: fakesm.NewCreateSecretWithContextFn(nil, noPermission),
|
|
|
- PutSecretValueWithContextFn: fakesm.NewPutSecretValueWithContextFn(putSecretOutput, nil),
|
|
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
want: want{
|
|
want: want{
|
|
@@ -427,6 +441,7 @@ func TestSetSecret(t *testing.T) {
|
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
store: makeValidSecretStore().Spec.Provider.AWS,
|
|
|
client: fakesm.Client{
|
|
client: fakesm.Client{
|
|
|
GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput2, nil),
|
|
GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput2, nil),
|
|
|
|
|
+ DescribeSecretWithContextFn: fakesm.NewDescribeSecretWithContextFn(tagSecretOutput, nil),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
want: want{
|
|
want: want{
|
|
@@ -440,6 +455,7 @@ func TestSetSecret(t *testing.T) {
|
|
|
client: fakesm.Client{
|
|
client: fakesm.Client{
|
|
|
GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput, nil),
|
|
GetSecretValueWithContextFn: fakesm.NewGetSecretValueWithContextFn(secretValueOutput, nil),
|
|
|
PutSecretValueWithContextFn: fakesm.NewPutSecretValueWithContextFn(nil, noPermission),
|
|
PutSecretValueWithContextFn: fakesm.NewPutSecretValueWithContextFn(nil, noPermission),
|
|
|
|
|
+ DescribeSecretWithContextFn: fakesm.NewDescribeSecretWithContextFn(tagSecretOutput, nil),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
want: want{
|
|
want: want{
|