fake.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Copyright © 2025 ESO Maintainer Team
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package fake
  14. import (
  15. "errors"
  16. "net/url"
  17. "github.com/google/go-cmp/cmp"
  18. "github.com/external-secrets/external-secrets/providers/v1/onboardbase/client"
  19. )
  20. type OnboardbaseClient struct {
  21. getSecret func(request client.SecretRequest) (*client.SecretResponse, error)
  22. }
  23. func (obbc *OnboardbaseClient) BaseURL() *url.URL {
  24. return &url.URL{Scheme: "https", Host: "public.onboardbase.com"}
  25. }
  26. func (obbc *OnboardbaseClient) Authenticate() error {
  27. return nil
  28. }
  29. func (obbc *OnboardbaseClient) GetSecret(request client.SecretRequest) (*client.SecretResponse, error) {
  30. return obbc.getSecret(request)
  31. }
  32. func (obbc *OnboardbaseClient) GetSecrets(_ client.SecretsRequest) (*client.SecretsResponse, error) {
  33. return &client.SecretsResponse{}, nil
  34. }
  35. func (obbc *OnboardbaseClient) DeleteSecret(_ client.SecretRequest) error {
  36. return nil
  37. }
  38. func (obbc *OnboardbaseClient) WithValue(request client.SecretRequest, response *client.SecretResponse, err error) {
  39. if obbc != nil {
  40. obbc.getSecret = func(requestIn client.SecretRequest) (*client.SecretResponse, error) {
  41. if !cmp.Equal(requestIn, request) {
  42. return nil, errors.New("unexpected test argument")
  43. }
  44. return response, err
  45. }
  46. }
  47. }