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