tests(verify-client): perfer to use CreateHeadscaleEnv

This commit is contained in:
ArcticLampyrid 2024-11-15 03:07:00 +08:00
parent 28a40c0019
commit bb79471139
No known key found for this signature in database
GPG key ID: DC72A2519E77D6CF

View file

@ -65,37 +65,14 @@ func TestDERPVerifyEndpoint(t *testing.T) {
}, },
} }
headscale, err := scenario.Headscale( err = scenario.CreateHeadscaleEnv(spec, []tsic.Option{tsic.WithCACert(derper.GetCert())},
hsic.WithHostname(hostname), hsic.WithHostname(hostname),
hsic.WithPort(headscalePort), hsic.WithPort(headscalePort),
hsic.WithCustomTLS(certHeadscale, keyHeadscale), hsic.WithCustomTLS(certHeadscale, keyHeadscale),
hsic.WithHostnameAsServerURL(), hsic.WithHostnameAsServerURL(),
hsic.WithDERPConfig(derpMap), hsic.WithDERPConfig(derpMap))
)
assertNoErrHeadscaleEnv(t, err) assertNoErrHeadscaleEnv(t, err)
for userName, clientCount := range spec {
err = scenario.CreateUser(userName)
if err != nil {
t.Fatalf("failed to create user %s: %s", userName, err)
}
err = scenario.CreateTailscaleNodesInUser(userName, "all", clientCount, tsic.WithCACert(derper.GetCert()))
if err != nil {
t.Fatalf("failed to create tailscale nodes in user %s: %s", userName, err)
}
key, err := scenario.CreatePreAuthKey(userName, true, true)
if err != nil {
t.Fatalf("failed to create pre-auth key for user %s: %s", userName, err)
}
err = scenario.RunTailscaleUp(userName, headscale.GetEndpoint(), key.GetKey())
if err != nil {
t.Fatalf("failed to run tailscale up for user %s: %s", userName, err)
}
}
allClients, err := scenario.ListTailscaleClients() allClients, err := scenario.ListTailscaleClients()
assertNoErrListClients(t, err) assertNoErrListClients(t, err)