schema_test.go 1.7 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 schema
  13. import (
  14. "context"
  15. "testing"
  16. "github.com/stretchr/testify/assert"
  17. "sigs.k8s.io/controller-runtime/pkg/client"
  18. esv1alpha1 "github.com/external-secrets/external-secrets/api/v1alpha1"
  19. "github.com/external-secrets/external-secrets/pkg/provider"
  20. )
  21. type PP struct{}
  22. // New constructs a SecretsManager Provider.
  23. func (p *PP) New(ctx context.Context, store esv1alpha1.SecretStoreProvider, kube client.Client, namespace string) (provider.Provider, error) {
  24. return p, nil
  25. }
  26. // GetSecret returns a single secret from the provider.
  27. func (p *PP) GetSecret(ctx context.Context, ref esv1alpha1.ExternalSecretDataRemoteRef) ([]byte, error) {
  28. return []byte("NOOP"), nil
  29. }
  30. // GetSecretMap returns multiple k/v pairs from the provider.
  31. func (p *PP) GetSecretMap(ctx context.Context, ref esv1alpha1.ExternalSecretDataRemoteRef) (map[string][]byte, error) {
  32. return map[string][]byte{}, nil
  33. }
  34. func TestRegister(t *testing.T) {
  35. p, ok := GetProviderByName("awssm")
  36. assert.Nil(t, p)
  37. assert.False(t, ok)
  38. ForceRegister(&PP{}, &esv1alpha1.SecretStoreProvider{
  39. AWSSM: &esv1alpha1.AWSSMProvider{},
  40. })
  41. p, ok = GetProviderByName("awssm")
  42. assert.NotNil(t, p)
  43. assert.True(t, ok)
  44. }