Skip to content

Commit

Permalink
Ensure Login for each Analysis test case (#247)
Browse files Browse the repository at this point in the history
It turned out, that the refresh token has an expiration in Keycloak (30
mins by default), multiple analysis test cases were added to TIER0, so
it might fail on this.

Adding force login before each analysis test cases to work-around it.

Signed-off-by: Marek Aufart <[email protected]>
  • Loading branch information
aufi authored Jan 14, 2025
1 parent 5b10476 commit d13f701
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ func TestApplicationAnalysis(t *testing.T) {
t.Parallel()
}

// Ensure API Login and tokens for each test_case
err := RichClient.Login(os.Getenv(Username), os.Getenv(Password))
if err != nil {
panic(fmt.Sprintf("Cannot login to API: %v.", err.Error()))
}

// Prepare Identities, e.g. for Maven repo
for idx := range tc.Identities {
identity := tc.Identities[idx]
Expand Down Expand Up @@ -122,7 +128,6 @@ func TestApplicationAnalysis(t *testing.T) {
_, debug := os.LookupEnv("DEBUG")
// Wait until task finishes
var task *api.Task
var err error
for i := 0; i < Retry; i++ {
task, err = RichClient.Task.Get(tc.Task.ID)
if err != nil || task.State == "Succeeded" || task.State == "Failed" {
Expand Down
5 changes: 5 additions & 0 deletions analysis/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"github.com/konveyor/tackle2-hub/test/api/client"
)

const (
Username = "HUB_USERNAME"
Password = "HUB_PASSWORD"
)

var (
// Setup Hub API client
Client *binding.Client
Expand Down

0 comments on commit d13f701

Please sign in to comment.