@@ -2,19 +2,31 @@ package awl
22
33import (
44 "context"
5- "runtime"
65 "testing"
76 "time"
87
98 "github.com/anywherelan/awl/config"
109 "github.com/anywherelan/awl/entity"
10+ "github.com/anywherelan/awl/service"
1111)
1212
1313const (
1414 gatewayTestPacketSize = 500
1515 internetIP = "8.8.8.8"
1616)
1717
18+ // skipIfVPNGatewayUnsupported skips tests that drive the VPN gateway runtime API
19+ // (client/server enable) or its startup wiring. The feature is implemented only
20+ // on Linux; on Windows and macOS the API returns an error and startup wiring is
21+ // a no-op, so these tests don't apply there. service.VPNGatewaySupported is the
22+ // single source of truth for platform support.
23+ func skipIfVPNGatewayUnsupported (t * testing.T ) {
24+ t .Helper ()
25+ if err := service .VPNGatewaySupported (); err != nil {
26+ t .Skipf ("VPN gateway is only supported on Linux: %v" , err )
27+ }
28+ }
29+
1830// setupGatewayPeers creates two peers that are friends and configures them for gateway mode.
1931// peer1 = gateway client, peer2 = exit node.
2032// Returns the peers and peer1's assigned IP in peer2's config.
@@ -642,6 +654,7 @@ func TestGatewayAPIEnableNotAllowed(t *testing.T) {
642654// /settings/peer_info (the canonical status surface — there is no dedicated
643655// /gateway/status endpoint).
644656func TestGatewayPeerInfoStatus (t * testing.T ) {
657+ skipIfVPNGatewayUnsupported (t )
645658 ts := NewTestSuite (t )
646659 client , exitNode , _ := setupGatewayPeers (ts )
647660
@@ -675,6 +688,7 @@ func TestGatewayAPIListAvailableGateways(t *testing.T) {
675688// atomic-switch case: an enable with a different exit-node ID while already
676689// enabled must rebind the tunnel without tearing routes down and back up.
677690func TestGatewayAPIRuntimeToggle (t * testing.T ) {
691+ skipIfVPNGatewayUnsupported (t )
678692 ts := NewTestSuite (t )
679693 client , exitNode , _ := setupGatewayPeers (ts )
680694
@@ -734,6 +748,7 @@ func TestGatewayAPIRuntimeToggle(t *testing.T) {
734748// applies and tears down the server-side state at runtime, persisting the
735749// flag and propagating it to peers via the next status exchange.
736750func TestGatewayAPIExitNodeMode (t * testing.T ) {
751+ skipIfVPNGatewayUnsupported (t )
737752 ts := NewTestSuite (t )
738753 peer1 := ts .NewTestPeer (true )
739754 peer2 := ts .NewTestPeer (true )
@@ -1034,9 +1049,7 @@ func TestGatewayListAvailableGatewaysFiltersToVPNGatewayOnly(t *testing.T) {
10341049// KnownPeers, OS-level apply failure, etc.) propagates from EnableClient and
10351050// fails Init — see TestGatewayUnknownPeerIDAtStartupFailsBoot.
10361051func TestGatewayInvalidPeerIDAtStartupClearsGracefully (t * testing.T ) {
1037- if runtime .GOOS == "windows" {
1038- t .Skip ("VPN gateway mode is gated off on Windows; setupGateway returns early" )
1039- }
1052+ skipIfVPNGatewayUnsupported (t )
10401053 ts := NewTestSuite (t )
10411054
10421055 // Malformed peer ID: not a valid multihash, so peer.Decode returns an
@@ -1066,9 +1079,7 @@ func TestGatewayInvalidPeerIDAtStartupClearsGracefully(t *testing.T) {
10661079// SetupAtStartup wraps it, and Init fails. The persisted config is left
10671080// untouched so a human can investigate why the peer disappeared.
10681081func TestGatewayUnknownPeerIDAtStartupFailsBoot (t * testing.T ) {
1069- if runtime .GOOS == "windows" {
1070- t .Skip ("VPN gateway mode is gated off on Windows; setupGateway returns early" )
1071- }
1082+ skipIfVPNGatewayUnsupported (t )
10721083 ts := NewTestSuite (t )
10731084
10741085 // Valid-format peer ID that won't be in KnownPeers.
0 commit comments