Skip to content

Commit

Permalink
fix: e2e test by updating Secret output TemplateData (#467)
Browse files Browse the repository at this point in the history
Signed-off-by: punkwalker <[email protected]>
  • Loading branch information
punkwalker authored Jan 3, 2025
1 parent 6f834bc commit 57bedf9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
13 changes: 4 additions & 9 deletions pkg/cmd/get/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package get
import (
"context"
"fmt"
"github.com/cnoe-io/idpbuilder/pkg/entity"
"github.com/cnoe-io/idpbuilder/pkg/printer"
"io"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"os"
"path/filepath"
"strings"

"github.com/cnoe-io/idpbuilder/pkg/entity"
"github.com/cnoe-io/idpbuilder/pkg/printer"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/cnoe-io/idpbuilder/api/v1alpha1"
"github.com/cnoe-io/idpbuilder/pkg/build"
"github.com/cnoe-io/idpbuilder/pkg/k8s"
Expand Down Expand Up @@ -45,12 +46,6 @@ var (
}
)

type TemplateData struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Data map[string]string `json:"data"`
}

func getSecretsE(cmd *cobra.Command, args []string) error {
ctx, ctxCancel := context.WithCancel(cmd.Context())
defer ctxCancel()
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"code.gitea.io/sdk/gitea"
argov1alpha1 "github.com/cnoe-io/argocd-api/api/argo/application/v1alpha1"
"github.com/cnoe-io/idpbuilder/pkg/cmd/get"
"github.com/cnoe-io/idpbuilder/pkg/entity"
"github.com/cnoe-io/idpbuilder/pkg/k8s"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -268,17 +268,17 @@ func GetBasicAuth(ctx context.Context, name string) (BasicAuth, error) {
}

out := BasicAuth{}
secs := make([]get.TemplateData, 2)
secs := make([]entity.Secret, 2)
if err = json.Unmarshal(b, &secs); err != nil {
lastErr = err
time.Sleep(httpRetryDelay)
continue
}

for i := range secs {
if secs[i].Name == name {
out.Password = secs[i].Data["password"]
out.Username = secs[i].Data["username"]
for _, sec := range secs {
if sec.Name == name {
out.Password = sec.Password
out.Username = sec.Username
break
}
}
Expand Down Expand Up @@ -383,13 +383,13 @@ func TestGiteaRegistry(ctx context.Context, t *testing.T, cmd, giteaHost, giteaP
b, err := RunCommand(ctx, fmt.Sprintf("%s get secrets -o json -p gitea", IdpbuilderBinaryLocation), 10*time.Second)
assert.NoError(t, err)

secs := make([]get.TemplateData, 2)
secs := make([]entity.Secret, 1)
err = json.Unmarshal(b, &secs)
assert.NoError(t, err)

sec := secs[0]
user := sec.Data["username"]
pass := sec.Data["password"]
user := sec.Username
pass := sec.Password

login, err := RunCommand(ctx, fmt.Sprintf("%s login %s:%s -u %s -p %s", cmd, giteaHost, giteaPort, user, pass), 10*time.Second)
require.NoErrorf(t, err, "%s login err: %s", cmd, login)
Expand Down

0 comments on commit 57bedf9

Please sign in to comment.