mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	OIDC integration tests working
This commit is contained in:
		
							parent
							
								
									71b712356f
								
							
						
					
					
						commit
						9c0cf4595a
					
				@ -265,17 +265,16 @@ func (s *IntegrationOIDCTestSuite) AuthenticateOIDC(
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	client := &http.Client{Transport: insecureTransport}
 | 
						client := &http.Client{Transport: insecureTransport}
 | 
				
			||||||
	resp, err := client.Get(loginURL.String())
 | 
						resp, err := client.Get(loginURL.String())
 | 
				
			||||||
	if err != nil {
 | 
						assert.Nil(s.T(), err)
 | 
				
			||||||
		s.FailNow(fmt.Sprintf("Could not get login page: %s", err), "")
 | 
					
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	// read the body
 | 
					 | 
				
			||||||
	body, err := io.ReadAll(resp.Body)
 | 
						body, err := io.ReadAll(resp.Body)
 | 
				
			||||||
 | 
						assert.Nil(s.T(), err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		s.FailNow(fmt.Sprintf("Could not read login page: %s", err), "")
 | 
							s.FailNow(fmt.Sprintf("Could not read login page: %s", err), "")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	panic(string(body))
 | 
						log.Printf("Login page for %s: %s", hostname, string(body))
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *IntegrationOIDCTestSuite) joinOIDC(
 | 
					func (s *IntegrationOIDCTestSuite) joinOIDC(
 | 
				
			||||||
@ -435,41 +434,44 @@ func (s *IntegrationOIDCTestSuite) saveLog(
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *IntegrationOIDCTestSuite) TestPingAllPeersByHostname() {
 | 
					func (s *IntegrationOIDCTestSuite) TestPingAllPeersByAddress() {
 | 
				
			||||||
	hostnames, err := getDNSNames(&s.headscale)
 | 
					 | 
				
			||||||
	assert.Nil(s.T(), err)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	log.Printf("Hostnames: %#v\n", hostnames)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for hostname, tailscale := range s.tailscales {
 | 
						for hostname, tailscale := range s.tailscales {
 | 
				
			||||||
		for _, peername := range hostnames {
 | 
							ips, err := getIPs(s.tailscales)
 | 
				
			||||||
			if strings.Contains(peername, hostname) {
 | 
							assert.Nil(s.T(), err)
 | 
				
			||||||
				continue
 | 
							for peername, peerIPs := range ips {
 | 
				
			||||||
			}
 | 
								for i, ip := range peerIPs {
 | 
				
			||||||
			s.T().Run(fmt.Sprintf("%s-%s", hostname, peername), func(t *testing.T) {
 | 
									// We currently cant ping ourselves, so skip that.
 | 
				
			||||||
				command := []string{
 | 
									if peername == hostname {
 | 
				
			||||||
					"tailscale", "ping",
 | 
										continue
 | 
				
			||||||
					"--timeout=10s",
 | 
					 | 
				
			||||||
					"--c=5",
 | 
					 | 
				
			||||||
					"--until-direct=false",
 | 
					 | 
				
			||||||
					peername,
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									s.T().
 | 
				
			||||||
 | 
										Run(fmt.Sprintf("%s-%s-%d", hostname, peername, i), func(t *testing.T) {
 | 
				
			||||||
 | 
											// We are only interested in "direct ping" which means what we
 | 
				
			||||||
 | 
											// might need a couple of more attempts before reaching the node.
 | 
				
			||||||
 | 
											command := []string{
 | 
				
			||||||
 | 
												"tailscale", "ping",
 | 
				
			||||||
 | 
												"--timeout=1s",
 | 
				
			||||||
 | 
												"--c=10",
 | 
				
			||||||
 | 
												"--until-direct=true",
 | 
				
			||||||
 | 
												ip.String(),
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				log.Printf(
 | 
											log.Printf(
 | 
				
			||||||
					"Pinging using hostname from %s to %s\n",
 | 
												"Pinging from %s to %s (%s)\n",
 | 
				
			||||||
					hostname,
 | 
												hostname,
 | 
				
			||||||
					peername,
 | 
												peername,
 | 
				
			||||||
				)
 | 
												ip,
 | 
				
			||||||
				log.Println(command)
 | 
											)
 | 
				
			||||||
				result, err := ExecuteCommand(
 | 
											result, err := ExecuteCommand(
 | 
				
			||||||
					&tailscale,
 | 
												&tailscale,
 | 
				
			||||||
					command,
 | 
												command,
 | 
				
			||||||
					[]string{},
 | 
												[]string{},
 | 
				
			||||||
				)
 | 
											)
 | 
				
			||||||
				assert.Nil(t, err)
 | 
											assert.Nil(t, err)
 | 
				
			||||||
				log.Printf("Result for %s: %s\n", hostname, result)
 | 
											log.Printf("Result for %s: %s\n", hostname, result)
 | 
				
			||||||
				assert.Contains(t, result, "via DERP(headscale)")
 | 
											assert.Contains(t, result, "pong")
 | 
				
			||||||
			})
 | 
										})
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user