1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Remove old non working e2e tests

This commit is contained in:
Elsa Chelala 2021-08-30 15:28:32 -04:00
parent 55441ecd77
commit ab1b51534f
7 changed files with 20 additions and 202 deletions

View file

@ -1,89 +0,0 @@
package alibaba
import (
// nolint
. "github.com/onsi/ginkgo"
// nolint
. "github.com/onsi/ginkgo/extensions/table"
"github.com/external-secrets/external-secrets/e2e/framework"
"github.com/external-secrets/external-secrets/e2e/suite/common"
)
var _ = Describe("[alibaba] ", func() {
f := framework.New("eso-alibaba")
DescribeTable("sync secrets",
framework.TableFunc(f,
newVaultProvider(f)),
// uses token auth
compose("with token auth", f, common.JSONDataFromSync, useTokenAuth),
compose("with token auth", f, common.JSONDataWithProperty, useTokenAuth),
compose("with token auth", f, common.JSONDataWithTemplate, useTokenAuth),
compose("with token auth", f, common.DataPropertyDockerconfigJSON, useTokenAuth),
// use cert auth
compose("with cert auth", f, common.JSONDataFromSync, useCertAuth),
compose("with cert auth", f, common.JSONDataWithProperty, useCertAuth),
compose("with cert auth", f, common.JSONDataWithTemplate, useCertAuth),
compose("with cert auth", f, common.DataPropertyDockerconfigJSON, useCertAuth),
// use approle auth
compose("with appRole auth", f, common.JSONDataFromSync, useApproleAuth),
compose("with appRole auth", f, common.JSONDataWithProperty, useApproleAuth),
compose("with appRole auth", f, common.JSONDataWithTemplate, useApproleAuth),
compose("with appRole auth", f, common.DataPropertyDockerconfigJSON, useApproleAuth),
// use v1 provider
compose("with v1 kv provider", f, common.JSONDataFromSync, useV1Provider),
compose("with v1 kv provider", f, common.JSONDataWithProperty, useV1Provider),
compose("with v1 kv provider", f, common.JSONDataWithTemplate, useV1Provider),
compose("with v1 kv provider", f, common.DataPropertyDockerconfigJSON, useV1Provider),
// use jwt provider
compose("with jwt provider", f, common.JSONDataFromSync, useJWTProvider),
compose("with jwt provider", f, common.JSONDataWithProperty, useJWTProvider),
compose("with jwt provider", f, common.JSONDataWithTemplate, useJWTProvider),
compose("with jwt provider", f, common.DataPropertyDockerconfigJSON, useJWTProvider),
// use kubernetes provider
compose("with kubernetes provider", f, common.JSONDataFromSync, useKubernetesProvider),
compose("with kubernetes provider", f, common.JSONDataWithProperty, useKubernetesProvider),
compose("with kubernetes provider", f, common.JSONDataWithTemplate, useKubernetesProvider),
compose("with kubernetes provider", f, common.DataPropertyDockerconfigJSON, useKubernetesProvider),
)
})
func compose(descAppend string, f *framework.Framework, fn func(f *framework.Framework) (string, func(*framework.TestCase)), tweaks ...func(*framework.TestCase)) TableEntry {
desc, tfn := fn(f)
tweaks = append(tweaks, tfn)
te := Entry(desc + " " + descAppend)
// need to convert []func to []interface{}
ifs := make([]interface{}, len(tweaks))
for i := 0; i < len(tweaks); i++ {
ifs[i] = tweaks[i]
}
te.Parameters = ifs
return te
}
func useTokenAuth(tc *framework.TestCase) {
tc.ExternalSecret.Spec.SecretStoreRef.Name = tc.Framework.Namespace.Name
}
func useCertAuth(tc *framework.TestCase) {
tc.ExternalSecret.Spec.SecretStoreRef.Name = certAuthProviderName
}
func useApproleAuth(tc *framework.TestCase) {
tc.ExternalSecret.Spec.SecretStoreRef.Name = appRoleAuthProviderName
}
func useV1Provider(tc *framework.TestCase) {
tc.ExternalSecret.Spec.SecretStoreRef.Name = kvv1ProviderName
}
func useJWTProvider(tc *framework.TestCase) {
tc.ExternalSecret.Spec.SecretStoreRef.Name = jwtProviderName
}
func useKubernetesProvider(tc *framework.TestCase) {
tc.ExternalSecret.Spec.SecretStoreRef.Name = kubernetesProviderName
}

View file

@ -1,88 +0,0 @@
package alibaba
import (
"context"
//nolint
. "github.com/onsi/ginkgo"
//nolint
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
esmeta "github.com/external-secrets/external-secrets/apis/meta/v1"
"github.com/external-secrets/external-secrets/e2e/framework"
"github.com/external-secrets/external-secrets/pkg/provider/alibaba"
)
type alibabaProvider struct {
url string
client *alibaba.KeyManagementService
framework *framework.Framework
}
const (
certAuthProviderName = "cert-auth-provider"
appRoleAuthProviderName = "app-role-provider"
kvv1ProviderName = "kv-v1-provider"
jwtProviderName = "jwt-provider"
kubernetesProviderName = "kubernetes-provider"
)
func newAlibabaProvider(f *framework.Framework) *alibabaProvider {
prov := &alibabaProvider{
framework: f,
}
BeforeEach(prov.BeforeEach)
return prov
}
// CreateSecret creates a secret in both kv v1 and v2 provider.
func (s *alibabaProvider) CreateSecret(key, val string) {
}
func (s *alibabaProvider) DeleteSecret(key string) {
_, err := s.client.DeleteSecret("")
Expect(err).ToNot(HaveOccurred())
}
func (s *alibabaProvider) BeforeEach() {
//Creating an Alibaba secret
alibabaCreds := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "provider-secret",
Namespace: s.framework.Namespace.Name,
},
StringData: map[string]string{
//secret
},
}
err := s.framework.CRClient.Create(context.Background(), alibabaCreds)
Expect(err).ToNot(HaveOccurred())
//Creating Alibaba secret store
secretStore := &esv1alpha1.SecretStore{
ObjectMeta: metav1.ObjectMeta{
Name: s.framework.Namespace.Name,
Namespace: s.framework.Namespace.Name,
},
Spec: esv1alpha1.SecretStoreSpec{
Provider: &esv1alpha1.SecretStoreProvider{
Alibaba: &esv1alpha1.AlibabaProvider{
Auth: &esv1alpha1.AlibabaAuth{
SecretRef: esv1alpha1.AlibabaAuthSecretRef{
AccessKeyID: esmeta.SecretKeySelector{
Name: "external-secret",
Key: "",
},
},
},
},
},
},
}
err = s.framework.CRClient.Create(context.Background(), secretStore)
Expect(err).ToNot(HaveOccurred())
}

View file

@ -12,9 +12,9 @@ func (mc *AlibabaMockClient) GetSecretValue(*kmssdk.GetSecretValueRequest) (resu
return mc.getSecretValue(&kmssdk.GetSecretValueRequest{})
}
func (sm *AlibabaMockClient) WithValue(in *kmssdk.GetSecretValueRequest, val *kmssdk.GetSecretValueResponse, err error) {
if sm != nil {
sm.getSecretValue = func(paramIn *kmssdk.GetSecretValueRequest) (*kmssdk.GetSecretValueResponse, error) {
func (mc *AlibabaMockClient) WithValue(in *kmssdk.GetSecretValueRequest, val *kmssdk.GetSecretValueResponse, err error) {
if mc != nil {
mc.getSecretValue = func(paramIn *kmssdk.GetSecretValueRequest) (*kmssdk.GetSecretValueResponse, error) {
return val, err
}
}

View file

@ -32,20 +32,14 @@ import (
)
const (
SecretsManagerEndpointEnv = "Alibaba_SECRETSMANAGER_ENDPOINT"
STSEndpointEnv = "Alibaba_STS_ENDPOINT"
SSMEndpointEnv = "Alibaba_SSM_ENDPOINT"
errAlibabaClient = "cannot setup new Alibaba client: %w"
errAlibabaCredSecretName = "invalid Alibaba SecretStore resource: missing Alibaba APIKey"
errUninitalizedAlibabaProvider = "provider Alibaba is not initialized"
errInvalidClusterStoreMissingAKIDNamespace = "invalid ClusterStore, missing AccessKeyID namespace"
errInvalidClusterStoreMissingSKNamespace = "invalid ClusterStore, missing namespace"
errFetchSAKSecret = "could not fetch AccessSecretKey secret: %w"
errFetchAKIDSecret = "could not fetch AccessKeyID secret: %w"
errMissingSAK = "missing AccessSecretKey"
errMissingAKID = "missing AccessKeyID"
errJSONSecretUnmarshal = "unable to unmarshal secret: %w"
)
type Client struct {
@ -187,7 +181,7 @@ func (kms *KeyManagementService) NewClient(ctx context.Context, store esv1alpha1
return kms, nil
}
func (kms *KeyManagementService) Close() error {
func (kms *KeyManagementService) Close(ctx context.Context) error {
return nil
}

View file

@ -13,6 +13,11 @@ import (
fakesm "github.com/external-secrets/external-secrets/pkg/provider/alibaba/fake"
)
const (
secretName = "test-example"
secretValue = "value"
)
type keyManagementServiceTestCase struct {
mockClient *fakesm.AlibabaMockClient
apiInput *kmssdk.GetSecretValueRequest
@ -42,13 +47,13 @@ func makeValidKMSTestCase() *keyManagementServiceTestCase {
func makeValidRef() *esv1alpha1.ExternalSecretDataRemoteRef {
return &esv1alpha1.ExternalSecretDataRemoteRef{
Key: "test-example",
Key: secretName,
}
}
func makeValidAPIInput() *kmssdk.GetSecretValueRequest {
return &kmssdk.GetSecretValueRequest{
SecretName: "test-example",
SecretName: secretName,
}
}
@ -56,7 +61,7 @@ func makeValidAPIOutput() *kmssdk.GetSecretValueResponse {
kmsresponse := &kmssdk.GetSecretValueResponse{
BaseResponse: &responses.BaseResponse{},
RequestId: "",
SecretName: "test-example",
SecretName: secretName,
VersionId: "",
CreateTime: "",
SecretData: "",
@ -95,21 +100,21 @@ func TestAlibabaKMSGetSecret(t *testing.T) {
secretData := make(map[string]interface{})
secretValue := "changedvalue"
secretData["payload"] = secretValue
// good case: default version is set
//key is passed in, output is sent back
// key is passed in, output is sent back
setSecretString := func(kmstc *keyManagementServiceTestCase) {
kmstc.apiOutput.SecretName = "test-example"
kmstc.apiOutput.SecretData = "value"
kmstc.expectedSecret = "value"
kmstc.apiOutput.SecretName = secretName
kmstc.apiOutput.SecretData = secretValue
kmstc.expectedSecret = secretValue
}
// // good case: custom version set
// good case: custom version set
setCustomKey := func(kmstc *keyManagementServiceTestCase) {
kmstc.apiOutput.SecretName = "test-example-other"
kmstc.ref.Key = "test-example-other"
kmstc.apiOutput.SecretData = "value"
kmstc.expectedSecret = "value"
kmstc.apiOutput.SecretData = secretValue
kmstc.expectedSecret = secretValue
}
successCases := []*keyManagementServiceTestCase{

View file

@ -34,8 +34,6 @@ type SecretsManager struct {
cache map[string]*awssm.GetSecretValueOutput
}
// SMInterface is a subset of the smiface api.
// see: https://docs.aws.amazon.com/sdk-for-go/api/service/secretsmanager/secretsmanageriface/
type SMInterface interface {

View file

@ -103,8 +103,6 @@ func getProviderName(storeSpec *esv1alpha1.SecretStoreProvider) (string, error)
}
if len(storeMap) != 1 {
fmt.Println(storeSpec)
fmt.Println(storeBytes)
return "", fmt.Errorf("secret stores must only have exactly one backend specified, found %d", len(storeMap))
}