more login debug output in tests

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2025-01-17 16:59:37 +01:00
parent 609203a9b9
commit 9097d57eea
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View file

@ -222,11 +222,12 @@ func (s *AuthWebFlowScenario) CreateHeadscaleEnv(
func (s *AuthWebFlowScenario) runTailscaleUp(
userStr, loginServer string,
) error {
log.Printf("running tailscale up for user %s", userStr)
log.Printf("running tailscale up for user %q", userStr)
if user, ok := s.users[userStr]; ok {
for _, client := range user.Clients {
c := client
user.joinWaitGroup.Go(func() error {
log.Printf("logging %q into %q", c.Hostname(), loginServer)
loginURL, err := c.LoginWithURL(loginServer)
if err != nil {
log.Printf("failed to run tailscale up (%s): %s", c.Hostname(), err)

View file

@ -466,7 +466,7 @@ func (t *TailscaleInContainer) Login(
// This login mechanism uses web + command line flow for authentication.
func (t *TailscaleInContainer) LoginWithURL(
loginServer string,
) (*url.URL, error) {
) (loginURL *url.URL, err error) {
command := []string{
"tailscale",
"up",
@ -480,6 +480,12 @@ func (t *TailscaleInContainer) LoginWithURL(
return nil, errTailscaleCannotUpWithoutAuthkey
}
defer func() {
if err != nil {
log.Printf("join command: %q", strings.Join(command, " "))
}
}()
urlStr := strings.ReplaceAll(stdout+stderr, "\nTo authenticate, visit:\n\n\t", "")
urlStr = strings.TrimSpace(urlStr)
@ -488,11 +494,8 @@ func (t *TailscaleInContainer) LoginWithURL(
}
// parse URL
loginURL, err := url.Parse(urlStr)
loginURL, err = url.Parse(urlStr)
if err != nil {
log.Printf("Could not parse login URL: %s", err)
log.Printf("Original join command result: %s", stderr)
return nil, err
}