fake.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package fake
  13. import (
  14. "context"
  15. )
  16. type AkeylessMockClient struct {
  17. getSecret func(secretName, token string, version int32) (string, error)
  18. }
  19. func (mc *AkeylessMockClient) TokenFromSecretRef(_ context.Context) (string, error) {
  20. return "newToken", nil
  21. }
  22. func (mc *AkeylessMockClient) GetSecretByType(_ context.Context, secretName, token string, version int32) (string, error) {
  23. return mc.getSecret(secretName, token, version)
  24. }
  25. func (mc *AkeylessMockClient) ListSecrets(_ context.Context, _, _, _ string) ([]string, error) {
  26. return nil, nil
  27. }
  28. func (mc *AkeylessMockClient) WithValue(_ *Input, out *Output) {
  29. if mc != nil {
  30. mc.getSecret = func(secretName, token string, version int32) (string, error) {
  31. return out.Value, out.Err
  32. }
  33. }
  34. }
  35. type Input struct {
  36. SecretName string
  37. Token string
  38. Version int32
  39. }
  40. type Output struct {
  41. Value string
  42. Err error
  43. }