Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: e2e test by updating Secret output TemplateData #467

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
punkwalker marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
Loading