Skip to content

Commit

Permalink
update dependency path for integration
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby authored and juanfont committed May 10, 2023
1 parent d2413d0 commit 52ad138
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 76 deletions.
88 changes: 44 additions & 44 deletions integration/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/juanfont/headscale"
"github.com/juanfont/headscale/hscontrol"
"github.com/juanfont/headscale/integration/hsic"
"github.com/juanfont/headscale/integration/tsic"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -45,7 +45,7 @@ var veryLargeDestination = []string{
"208.0.0.0/4:*",
}

func aclScenario(t *testing.T, policy *headscale.ACLPolicy, clientsPerUser int) *Scenario {
func aclScenario(t *testing.T, policy *hscontrol.ACLPolicy, clientsPerUser int) *Scenario {
t.Helper()
scenario, err := NewScenario()
assert.NoError(t, err)
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestACLHostsInNetMapTable(t *testing.T) {
// they can access minus one (them self).
tests := map[string]struct {
users map[string]int
policy headscale.ACLPolicy
policy hscontrol.ACLPolicy
want map[string]int
}{
// Test that when we have no ACL, each client netmap has
Expand All @@ -102,8 +102,8 @@ func TestACLHostsInNetMapTable(t *testing.T) {
"user1": 2,
"user2": 2,
},
policy: headscale.ACLPolicy{
ACLs: []headscale.ACL{
policy: hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"*"},
Expand All @@ -123,8 +123,8 @@ func TestACLHostsInNetMapTable(t *testing.T) {
"user1": 2,
"user2": 2,
},
policy: headscale.ACLPolicy{
ACLs: []headscale.ACL{
policy: hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"user1"},
Expand All @@ -149,8 +149,8 @@ func TestACLHostsInNetMapTable(t *testing.T) {
"user1": 2,
"user2": 2,
},
policy: headscale.ACLPolicy{
ACLs: []headscale.ACL{
policy: hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"user1"},
Expand Down Expand Up @@ -186,8 +186,8 @@ func TestACLHostsInNetMapTable(t *testing.T) {
"user1": 2,
"user2": 2,
},
policy: headscale.ACLPolicy{
ACLs: []headscale.ACL{
policy: hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"user1"},
Expand All @@ -214,8 +214,8 @@ func TestACLHostsInNetMapTable(t *testing.T) {
"user1": 2,
"user2": 2,
},
policy: headscale.ACLPolicy{
ACLs: []headscale.ACL{
policy: hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"user1"},
Expand Down Expand Up @@ -282,8 +282,8 @@ func TestACLAllowUser80Dst(t *testing.T) {
IntegrationSkip(t)

scenario := aclScenario(t,
&headscale.ACLPolicy{
ACLs: []headscale.ACL{
&hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"user1"},
Expand Down Expand Up @@ -338,11 +338,11 @@ func TestACLDenyAllPort80(t *testing.T) {
IntegrationSkip(t)

scenario := aclScenario(t,
&headscale.ACLPolicy{
&hscontrol.ACLPolicy{
Groups: map[string][]string{
"group:integration-acl-test": {"user1", "user2"},
},
ACLs: []headscale.ACL{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"group:integration-acl-test"},
Expand Down Expand Up @@ -387,8 +387,8 @@ func TestACLAllowUserDst(t *testing.T) {
IntegrationSkip(t)

scenario := aclScenario(t,
&headscale.ACLPolicy{
ACLs: []headscale.ACL{
&hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"user1"},
Expand Down Expand Up @@ -445,8 +445,8 @@ func TestACLAllowStarDst(t *testing.T) {
IntegrationSkip(t)

scenario := aclScenario(t,
&headscale.ACLPolicy{
ACLs: []headscale.ACL{
&hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"user1"},
Expand Down Expand Up @@ -504,11 +504,11 @@ func TestACLNamedHostsCanReachBySubnet(t *testing.T) {
IntegrationSkip(t)

scenario := aclScenario(t,
&headscale.ACLPolicy{
Hosts: headscale.Hosts{
&hscontrol.ACLPolicy{
Hosts: hscontrol.Hosts{
"all": netip.MustParsePrefix("100.64.0.0/24"),
},
ACLs: []headscale.ACL{
ACLs: []hscontrol.ACL{
// Everyone can curl test3
{
Action: "accept",
Expand Down Expand Up @@ -603,16 +603,16 @@ func TestACLNamedHostsCanReach(t *testing.T) {
IntegrationSkip(t)

tests := map[string]struct {
policy headscale.ACLPolicy
policy hscontrol.ACLPolicy
}{
"ipv4": {
policy: headscale.ACLPolicy{
Hosts: headscale.Hosts{
policy: hscontrol.ACLPolicy{
Hosts: hscontrol.Hosts{
"test1": netip.MustParsePrefix("100.64.0.1/32"),
"test2": netip.MustParsePrefix("100.64.0.2/32"),
"test3": netip.MustParsePrefix("100.64.0.3/32"),
},
ACLs: []headscale.ACL{
ACLs: []hscontrol.ACL{
// Everyone can curl test3
{
Action: "accept",
Expand All @@ -629,13 +629,13 @@ func TestACLNamedHostsCanReach(t *testing.T) {
},
},
"ipv6": {
policy: headscale.ACLPolicy{
Hosts: headscale.Hosts{
policy: hscontrol.ACLPolicy{
Hosts: hscontrol.Hosts{
"test1": netip.MustParsePrefix("fd7a:115c:a1e0::1/128"),
"test2": netip.MustParsePrefix("fd7a:115c:a1e0::2/128"),
"test3": netip.MustParsePrefix("fd7a:115c:a1e0::3/128"),
},
ACLs: []headscale.ACL{
ACLs: []hscontrol.ACL{
// Everyone can curl test3
{
Action: "accept",
Expand Down Expand Up @@ -854,11 +854,11 @@ func TestACLDevice1CanAccessDevice2(t *testing.T) {
IntegrationSkip(t)

tests := map[string]struct {
policy headscale.ACLPolicy
policy hscontrol.ACLPolicy
}{
"ipv4": {
policy: headscale.ACLPolicy{
ACLs: []headscale.ACL{
policy: hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"100.64.0.1"},
Expand All @@ -868,8 +868,8 @@ func TestACLDevice1CanAccessDevice2(t *testing.T) {
},
},
"ipv6": {
policy: headscale.ACLPolicy{
ACLs: []headscale.ACL{
policy: hscontrol.ACLPolicy{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"fd7a:115c:a1e0::1"},
Expand All @@ -879,12 +879,12 @@ func TestACLDevice1CanAccessDevice2(t *testing.T) {
},
},
"hostv4cidr": {
policy: headscale.ACLPolicy{
Hosts: headscale.Hosts{
policy: hscontrol.ACLPolicy{
Hosts: hscontrol.Hosts{
"test1": netip.MustParsePrefix("100.64.0.1/32"),
"test2": netip.MustParsePrefix("100.64.0.2/32"),
},
ACLs: []headscale.ACL{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"test1"},
Expand All @@ -894,12 +894,12 @@ func TestACLDevice1CanAccessDevice2(t *testing.T) {
},
},
"hostv6cidr": {
policy: headscale.ACLPolicy{
Hosts: headscale.Hosts{
policy: hscontrol.ACLPolicy{
Hosts: hscontrol.Hosts{
"test1": netip.MustParsePrefix("fd7a:115c:a1e0::1/128"),
"test2": netip.MustParsePrefix("fd7a:115c:a1e0::2/128"),
},
ACLs: []headscale.ACL{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"test1"},
Expand All @@ -909,12 +909,12 @@ func TestACLDevice1CanAccessDevice2(t *testing.T) {
},
},
"group": {
policy: headscale.ACLPolicy{
policy: hscontrol.ACLPolicy{
Groups: map[string][]string{
"group:one": {"user1"},
"group:two": {"user2"},
},
ACLs: []headscale.ACL{
ACLs: []hscontrol.ACL{
{
Action: "accept",
Sources: []string{"group:one"},
Expand Down
8 changes: 4 additions & 4 deletions integration/auth_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"testing"
"time"

"github.com/juanfont/headscale"
"github.com/juanfont/headscale/hscontrol"
"github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/hsic"
"github.com/ory/dockertest/v3"
Expand Down Expand Up @@ -213,14 +213,14 @@ func (s *AuthOIDCScenario) CreateHeadscaleEnv(
return nil
}

func (s *AuthOIDCScenario) runMockOIDC(accessTTL time.Duration) (*headscale.OIDCConfig, error) {
func (s *AuthOIDCScenario) runMockOIDC(accessTTL time.Duration) (*hscontrol.OIDCConfig, error) {
port, err := dockertestutil.RandomFreeHostPort()
if err != nil {
log.Fatalf("could not find an open port: %s", err)
}
portNotation := fmt.Sprintf("%d/tcp", port)

hash, _ := headscale.GenerateRandomStringDNSSafe(hsicOIDCMockHashLength)
hash, _ := hscontrol.GenerateRandomStringDNSSafe(hsicOIDCMockHashLength)

hostname := fmt.Sprintf("hs-oidcmock-%s", hash)

Expand Down Expand Up @@ -287,7 +287,7 @@ func (s *AuthOIDCScenario) runMockOIDC(accessTTL time.Duration) (*headscale.OIDC

log.Printf("headscale mock oidc is ready for tests at %s", hostEndpoint)

return &headscale.OIDCConfig{
return &hscontrol.OIDCConfig{
Issuer: fmt.Sprintf(
"http://%s/oidc",
net.JoinHostPort(s.mockOIDC.GetIPInNetwork(s.network), strconv.Itoa(port)),
Expand Down
4 changes: 2 additions & 2 deletions integration/embedded_derp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"testing"

"github.com/juanfont/headscale"
"github.com/juanfont/headscale/hscontrol"
"github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/hsic"
"github.com/juanfont/headscale/integration/tsic"
Expand Down Expand Up @@ -110,7 +110,7 @@ func (s *EmbeddedDERPServerScenario) CreateHeadscaleEnv(
return err
}

hash, err := headscale.GenerateRandomStringDNSSafe(scenarioHashLength)
hash, err := hscontrol.GenerateRandomStringDNSSafe(scenarioHashLength)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions integration/hsic/hsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"time"

"github.com/davecgh/go-spew/spew"
"github.com/juanfont/headscale"
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/juanfont/headscale/hscontrol"
"github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/integrationutil"
"github.com/ory/dockertest/v3"
Expand Down Expand Up @@ -59,7 +59,7 @@ type HeadscaleInContainer struct {
port int
extraPorts []string
hostPortBindings map[string][]string
aclPolicy *headscale.ACLPolicy
aclPolicy *hscontrol.ACLPolicy
env map[string]string
tlsCert []byte
tlsKey []byte
Expand All @@ -70,9 +70,9 @@ type HeadscaleInContainer struct {
// Headscale instance.
type Option = func(c *HeadscaleInContainer)

// WithACLPolicy adds a headscale.ACLPolicy policy to the
// WithACLPolicy adds a hscontrol.ACLPolicy policy to the
// HeadscaleInContainer instance.
func WithACLPolicy(acl *headscale.ACLPolicy) Option {
func WithACLPolicy(acl *hscontrol.ACLPolicy) Option {
return func(hsic *HeadscaleInContainer) {
// TODO(kradalby): Move somewhere appropriate
hsic.env["HEADSCALE_ACL_POLICY_PATH"] = aclPolicyPath
Expand Down Expand Up @@ -132,7 +132,7 @@ func WithHostPortBindings(bindings map[string][]string) Option {
// in the Docker container name.
func WithTestName(testName string) Option {
return func(hsic *HeadscaleInContainer) {
hash, _ := headscale.GenerateRandomStringDNSSafe(hsicHashLength)
hash, _ := hscontrol.GenerateRandomStringDNSSafe(hsicHashLength)

hostname := fmt.Sprintf("hs-%s-%s", testName, hash)
hsic.hostname = hostname
Expand Down Expand Up @@ -167,7 +167,7 @@ func New(
network *dockertest.Network,
opts ...Option,
) (*HeadscaleInContainer, error) {
hash, err := headscale.GenerateRandomStringDNSSafe(hsicHashLength)
hash, err := hscontrol.GenerateRandomStringDNSSafe(hsicHashLength)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions integration/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"sync"
"time"

"github.com/juanfont/headscale"
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/juanfont/headscale/hscontrol"
"github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/hsic"
"github.com/juanfont/headscale/integration/tsic"
Expand Down Expand Up @@ -105,7 +105,7 @@ type Scenario struct {
// NewScenario creates a test Scenario which can be used to bootstraps a ControlServer with
// a set of Users and TailscaleClients.
func NewScenario() (*Scenario, error) {
hash, err := headscale.GenerateRandomStringDNSSafe(scenarioHashLength)
hash, err := hscontrol.GenerateRandomStringDNSSafe(scenarioHashLength)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 52ad138

Please sign in to comment.