mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-01 19:23:05 +00:00
Move integration tests to net/netip
This commit is contained in:
parent
51abf90db6
commit
d5cc5b2bc8
2 changed files with 15 additions and 15 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -15,7 +16,6 @@ import (
|
|||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||
"github.com/ory/dockertest/v3"
|
||||
"github.com/ory/dockertest/v3/docker"
|
||||
"inet.af/netaddr"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -26,8 +26,8 @@ const (
|
|||
var (
|
||||
errEnvVarEmpty = errors.New("getenv: environment variable empty")
|
||||
|
||||
IpPrefix4 = netaddr.MustParseIPPrefix("100.64.0.0/10")
|
||||
IpPrefix6 = netaddr.MustParseIPPrefix("fd7a:115c:a1e0::/48")
|
||||
IpPrefix4 = netip.MustParsePrefix("100.64.0.0/10")
|
||||
IpPrefix6 = netip.MustParsePrefix("fd7a:115c:a1e0::/48")
|
||||
|
||||
tailscaleVersions = []string{
|
||||
// "head",
|
||||
|
@ -195,8 +195,8 @@ func getDockerBuildOptions(version string) *dockertest.BuildOptions {
|
|||
|
||||
func getIPs(
|
||||
tailscales map[string]dockertest.Resource,
|
||||
) (map[string][]netaddr.IP, error) {
|
||||
ips := make(map[string][]netaddr.IP)
|
||||
) (map[string][]netip.Addr, error) {
|
||||
ips := make(map[string][]netip.Addr)
|
||||
for hostname, tailscale := range tailscales {
|
||||
command := []string{"tailscale", "ip"}
|
||||
|
||||
|
@ -214,7 +214,7 @@ func getIPs(
|
|||
if len(address) < 1 {
|
||||
continue
|
||||
}
|
||||
ip, err := netaddr.ParseIP(address)
|
||||
ip, err := netip.ParseAddr(address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
@ -22,7 +23,6 @@ import (
|
|||
"github.com/ory/dockertest/v3/docker"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/client/tailscale/apitype"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
)
|
||||
|
@ -477,8 +477,8 @@ func (s *IntegrationTestSuite) TestGetIpAddresses() {
|
|||
// }
|
||||
// }
|
||||
|
||||
func getIPsfromIPNstate(status ipnstate.Status) []netaddr.IP {
|
||||
ips := make([]netaddr.IP, 0)
|
||||
func getIPsfromIPNstate(status ipnstate.Status) []netip.Addr {
|
||||
ips := make([]netip.Addr, 0)
|
||||
|
||||
for _, peer := range status.Peer {
|
||||
ips = append(ips, peer.TailscaleIPs...)
|
||||
|
@ -563,14 +563,14 @@ func (s *IntegrationTestSuite) TestTailDrop() {
|
|||
continue
|
||||
}
|
||||
|
||||
var ip4 netaddr.IP
|
||||
var ip4 netip.Addr
|
||||
for _, ip := range ips[peername] {
|
||||
if ip.Is4() {
|
||||
ip4 = ip
|
||||
break
|
||||
}
|
||||
}
|
||||
if ip4.IsZero() {
|
||||
if ip4.IsUnspecified() {
|
||||
panic("no ipv4 address found")
|
||||
}
|
||||
|
||||
|
@ -748,8 +748,8 @@ func (s *IntegrationTestSuite) TestMagicDNS() {
|
|||
|
||||
func getAPIURLs(
|
||||
tailscales map[string]dockertest.Resource,
|
||||
) (map[netaddr.IP]string, error) {
|
||||
fts := make(map[netaddr.IP]string)
|
||||
) (map[netip.Addr]string, error) {
|
||||
fts := make(map[netip.Addr]string)
|
||||
for _, tailscale := range tailscales {
|
||||
command := []string{
|
||||
"curl",
|
||||
|
@ -773,11 +773,11 @@ func getAPIURLs(
|
|||
for _, ft := range pft {
|
||||
n := ft.Node
|
||||
for _, a := range n.Addresses { // just add all the addresses
|
||||
if _, ok := fts[a.IP()]; !ok {
|
||||
if _, ok := fts[a.Addr()]; !ok {
|
||||
if ft.PeerAPIURL == "" {
|
||||
return nil, errors.New("api url is empty")
|
||||
}
|
||||
fts[a.IP()] = ft.PeerAPIURL
|
||||
fts[a.Addr()] = ft.PeerAPIURL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue