mirror of
https://github.com/juanfont/headscale.git
synced 2025-09-29 17:54:59 +02:00
fix: apply code review suggestions
This commit is contained in:
parent
07a3314059
commit
d626f43889
@ -96,7 +96,7 @@ func DERPVerify(
|
|||||||
region tailcfg.DERPRegion,
|
region tailcfg.DERPRegion,
|
||||||
expectSuccess bool,
|
expectSuccess bool,
|
||||||
) {
|
) {
|
||||||
IntegrationSkip(t)
|
t.Helper()
|
||||||
|
|
||||||
c := derphttp.NewRegionClient(nodeKey, t.Logf, netmon.NewStatic(), func() *tailcfg.DERPRegion {
|
c := derphttp.NewRegionClient(nodeKey, t.Logf, netmon.NewStatic(), func() *tailcfg.DERPRegion {
|
||||||
return ®ion
|
return ®ion
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
"tailscale.com/tailcfg"
|
||||||
|
"tailscale.com/types/key"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -13,8 +15,6 @@ import (
|
|||||||
"github.com/juanfont/headscale/integration/hsic"
|
"github.com/juanfont/headscale/integration/hsic"
|
||||||
"github.com/juanfont/headscale/integration/tsic"
|
"github.com/juanfont/headscale/integration/tsic"
|
||||||
"github.com/ory/dockertest/v3"
|
"github.com/ory/dockertest/v3"
|
||||||
"tailscale.com/tailcfg"
|
|
||||||
"tailscale.com/types/key"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientsSpec struct {
|
type ClientsSpec struct {
|
||||||
@ -50,6 +50,28 @@ func TestDERPServerScenario(t *testing.T) {
|
|||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hsServer, err := scenario.Headscale()
|
||||||
|
assertNoErrGetHeadscale(t, err)
|
||||||
|
|
||||||
|
derpRegion := tailcfg.DERPRegion{
|
||||||
|
RegionCode: "test-derpverify",
|
||||||
|
RegionName: "TestDerpVerify",
|
||||||
|
Nodes: []*tailcfg.DERPNode{
|
||||||
|
{
|
||||||
|
Name: "TestDerpVerify",
|
||||||
|
RegionID: 900,
|
||||||
|
HostName: hsServer.GetHostname(),
|
||||||
|
STUNPort: 3478,
|
||||||
|
STUNOnly: false,
|
||||||
|
DERPPort: 443,
|
||||||
|
InsecureForTests: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
fakeKey := key.NewNode()
|
||||||
|
DERPVerify(t, fakeKey, derpRegion, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,34 +210,6 @@ func derpServerScenario(
|
|||||||
|
|
||||||
t.Logf("Run2: %d successful pings out of %d", success, len(allClients)*len(allHostnames))
|
t.Logf("Run2: %d successful pings out of %d", success, len(allClients)*len(allHostnames))
|
||||||
|
|
||||||
hsServer, err := scenario.Headscale()
|
|
||||||
assertNoErrGetHeadscale(t, err)
|
|
||||||
|
|
||||||
derpRegion := tailcfg.DERPRegion{
|
|
||||||
RegionCode: "test-derpverify",
|
|
||||||
RegionName: "TestDerpVerify",
|
|
||||||
Nodes: []*tailcfg.DERPNode{
|
|
||||||
{
|
|
||||||
Name: "TestDerpVerify",
|
|
||||||
RegionID: 900,
|
|
||||||
HostName: hsServer.GetHostname(),
|
|
||||||
STUNPort: 3478,
|
|
||||||
STUNOnly: false,
|
|
||||||
DERPPort: 443,
|
|
||||||
InsecureForTests: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
fakeKey := key.NewNode()
|
|
||||||
DERPVerify(t, fakeKey, derpRegion, false)
|
|
||||||
|
|
||||||
for _, client := range allClients {
|
|
||||||
nodeKey, err := client.GetNodePrivateKey()
|
|
||||||
assertNoErr(t, err)
|
|
||||||
DERPVerify(t, *nodeKey, derpRegion, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, check := range furtherAssertions {
|
for _, check := range furtherAssertions {
|
||||||
check(&scenario)
|
check(&scenario)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user