Просмотр исходного кода

fix(e2e): repair the akeyless suite so it can create a SecretStore

The suite could not run. Every spec failed in BeforeEach on admission:

  SecretStore "e2e-tests-eso-akeyless-przfl" is invalid:
  [spec.provider.akeyless.akeylessGWApiURL: Required value]

AkeylessProvider.AkeylessGWApiURL has no omitempty, so the CRD requires it,
and the store was built without it. Point it at the same gateway the suite's
own API client already uses, so the operator and the harness talk to one
endpoint rather than two that can drift.

The auth references were also wrong. BeforeEach creates one Secret named
provider-secret holding all three values, while the store asked for
access-id-secret, access-type-secret and access-type-param-secert, none of
which exist, the last of which is a typo. All three now name the Secret that
is actually created.

Neither of these could have worked since akeylessGWApiURL became required,
which is consistent with the suite never having been compiled into the suite
binary or run.

Also replace a non-constant format string in getCloudID. go test runs vet, so
it was failing the build of any test in this package.

Verified against a live Akeyless account: 13 of 13 specs pass.

Refs: external-secrets/external-secrets#6756
Signed-off-by: Alexander Chernov <alexander@chernov.it>
Alexander Chernov 1 месяц назад
Родитель
Сommit
cb8f3fc886
1 измененных файлов с 13 добавлено и 5 удалено
  1. 13 5
      e2e/suites/provider/cases/akeyless/provider.go

+ 13 - 5
e2e/suites/provider/cases/akeyless/provider.go

@@ -54,6 +54,10 @@ var apiErr akeyless.GenericOpenAPIError
 
 const DefServiceAccountFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
 
+// akeylessGWAPIURL is the public Akeyless gateway. Both the suite's own API
+// client and the SecretStore it creates point here.
+var akeylessGWAPIURL = "https://api.akeyless.io"
+
 func newAkeylessProvider(f *framework.Framework, accessID, accessType, accessTypeParam string) *akeylessProvider {
 	prov := &akeylessProvider{
 		accessID:        accessID,
@@ -65,7 +69,7 @@ func newAkeylessProvider(f *framework.Framework, accessID, accessType, accessTyp
 	restAPIClient := akeyless.NewAPIClient(&akeyless.Configuration{
 		Servers: []akeyless.ServerConfiguration{
 			{
-				URL: "https://api.akeyless.io",
+				URL: akeylessGWAPIURL,
 			},
 		},
 	}).V2Api
@@ -136,18 +140,22 @@ func (a *akeylessProvider) BeforeEach() {
 		Spec: esv1.SecretStoreSpec{
 			Provider: &esv1.SecretStoreProvider{
 				Akeyless: &esv1.AkeylessProvider{
+					// Required by the CRD. Points at the same gateway the
+					// suite's own client uses, so the operator and the test
+					// harness talk to one endpoint.
+					AkeylessGWApiURL: &akeylessGWAPIURL,
 					Auth: &esv1.AkeylessAuth{
 						SecretRef: esv1.AkeylessAuthSecretRef{
 							AccessID: esmeta.SecretKeySelector{
-								Name: "access-id-secret",
+								Name: "provider-secret",
 								Key:  "access-id",
 							},
 							AccessType: esmeta.SecretKeySelector{
-								Name: "access-type-secret",
+								Name: "provider-secret",
 								Key:  "access-type",
 							},
 							AccessTypeParam: esmeta.SecretKeySelector{
-								Name: "access-type-param-secert",
+								Name: "provider-secret",
 								Key:  "access-type-param",
 							},
 						},
@@ -178,7 +186,7 @@ func (a *akeylessProvider) GetToken() (string, error) {
 	} else {
 		cloudID, err := a.getCloudID(a.accessType, a.accessTypeParam)
 		if err != nil {
-			return "", fmt.Errorf("Require Cloud ID " + err.Error())
+			return "", fmt.Errorf("require Cloud ID: %w", err)
 		}
 		authBody.AccessType = akeyless.PtrString(a.accessType)
 		authBody.CloudId = akeyless.PtrString(cloudID)