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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 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
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
Comment on lines -278 to 282
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are probably unmarshaing to wrong type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the right type, the sec slice is made from TemplateData struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it, Now using Secret struct from entity package

}
}
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