Skip to content

Commit

Permalink
reproduce successfully
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Jan 10, 2025
1 parent 45a839a commit 811ce3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
16 changes: 15 additions & 1 deletion integration/auth_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func TestOIDCReloginSameNode(t *testing.T) {

oidcConfig, err := scenario.runMockOIDC(defaultAccessTTL, mockusers)
assertNoErrf(t, "failed to run mock OIDC server: %s", err)
defer scenario.mockOIDC.Close()
// defer scenario.mockOIDC.Close()

oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": oidcConfig.Issuer,
Expand Down Expand Up @@ -745,6 +745,12 @@ func TestOIDCReloginSameNode(t *testing.T) {

time.Sleep(5 * time.Second)

// TODO(kradalby): Not sure why we need to logout twice, but it fails and
// logs in immediately after the first logout and I cannot reproduce it
// manually.
err = ts.Logout()
assertNoErr(t, err)

u, err = ts.LoginWithURL(headscale.GetEndpoint())
assertNoErr(t, err)

Expand Down Expand Up @@ -813,6 +819,14 @@ func TestOIDCReloginSameNode(t *testing.T) {
err = ts.Logout()
assertNoErr(t, err)

time.Sleep(5 * time.Second)

// TODO(kradalby): Not sure why we need to logout twice, but it fails and
// logs in immediately after the first logout and I cannot reproduce it
// manually.
err = ts.Logout()
assertNoErr(t, err)

u, err = ts.LoginWithURL(headscale.GetEndpoint())
assertNoErr(t, err)

Expand Down
13 changes: 11 additions & 2 deletions integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,18 @@ func (t *TailscaleInContainer) LoginWithURL(
"--accept-routes=false",
}

_, stderr, err := t.Execute(command)
stdout, stderr, err := t.Execute(command)
if errors.Is(err, errTailscaleNotLoggedIn) {
return nil, errTailscaleCannotUpWithoutAuthkey
}

urlStr := strings.ReplaceAll(stderr, "\nTo authenticate, visit:\n\n\t", "")
urlStr := strings.ReplaceAll(stdout+stderr, "\nTo authenticate, visit:\n\n\t", "")
urlStr = strings.TrimSpace(urlStr)

if urlStr == "" {
return nil, fmt.Errorf("failed to get login URL: stdout: %s, stderr: %s", stdout, stderr)
}

// parse URL
loginURL, err := url.Parse(urlStr)
if err != nil {
Expand All @@ -503,6 +507,11 @@ func (t *TailscaleInContainer) Logout() error {
return err
}

stdout, stderr, _ = t.Execute([]string{"tailscale", "status"})
if !strings.Contains(stdout+stderr, "Logged out.") {
return fmt.Errorf("failed to logout, stdout: %s, stderr: %s", stdout, stderr)
}

return t.waitForBackendState("NeedsLogin")
}

Expand Down

0 comments on commit 811ce3d

Please sign in to comment.