mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-23 00:17:38 +00: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,32 +434,34 @@ 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)
|
||||||
|
for peername, peerIPs := range ips {
|
||||||
|
for i, ip := range peerIPs {
|
||||||
|
// We currently cant ping ourselves, so skip that.
|
||||||
|
if peername == hostname {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
s.T().Run(fmt.Sprintf("%s-%s", hostname, peername), func(t *testing.T) {
|
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{
|
command := []string{
|
||||||
"tailscale", "ping",
|
"tailscale", "ping",
|
||||||
"--timeout=10s",
|
"--timeout=1s",
|
||||||
"--c=5",
|
"--c=10",
|
||||||
"--until-direct=false",
|
"--until-direct=true",
|
||||||
peername,
|
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,
|
||||||
@ -468,8 +469,9 @@ func (s *IntegrationOIDCTestSuite) TestPingAllPeersByHostname() {
|
|||||||
)
|
)
|
||||||
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…
x
Reference in New Issue
Block a user