mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-12 04:07:35 +00:00
Refactored integration tests
This commit is contained in:
@@ -219,7 +219,7 @@ func TestACLHostsInNetMapTable(t *testing.T) {
|
||||
// Test to confirm that we can use user:80 from one user
|
||||
// This should make the node appear in the peer list, but
|
||||
// disallow ping.
|
||||
// This ACL will not allow user1 access its own machines.
|
||||
// This ACL will not allow user1 access its own nodes.
|
||||
// Reported: https://github.com/juanfont/headscale/issues/699
|
||||
func TestACLAllowUser80Dst(t *testing.T) {
|
||||
IntegrationSkip(t)
|
||||
@@ -324,7 +324,7 @@ func TestACLDenyAllPort80(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test to confirm that we can use user:* from one user.
|
||||
// This ACL will not allow user1 access its own machines.
|
||||
// This ACL will not allow user1 access its own nodes.
|
||||
// Reported: https://github.com/juanfont/headscale/issues/699
|
||||
func TestACLAllowUserDst(t *testing.T) {
|
||||
IntegrationSkip(t)
|
||||
|
@@ -16,7 +16,7 @@ type ControlServer interface {
|
||||
WaitForReady() error
|
||||
CreateUser(user string) error
|
||||
CreateAuthKey(user string, reusable bool, ephemeral bool) (*v1.PreAuthKey, error)
|
||||
ListMachinesInUser(user string) ([]*v1.Machine, error)
|
||||
ListNodesInUser(user string) ([]*v1.Node, error)
|
||||
GetCert() []byte
|
||||
GetHostname() string
|
||||
GetIP() string
|
||||
|
@@ -266,18 +266,18 @@ func TestEphemeral(t *testing.T) {
|
||||
t.Logf("all clients logged out")
|
||||
|
||||
for userName := range spec {
|
||||
machines, err := headscale.ListMachinesInUser(userName)
|
||||
nodes, err := headscale.ListNodesInUser(userName)
|
||||
if err != nil {
|
||||
log.Error().
|
||||
Err(err).
|
||||
Str("user", userName).
|
||||
Msg("Error listing machines in user")
|
||||
Msg("Error listing nodes in user")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if len(machines) != 0 {
|
||||
t.Errorf("expected no machines, got %d in user %s", len(machines), userName)
|
||||
if len(nodes) != 0 {
|
||||
t.Errorf("expected no nodes, got %d in user %s", len(nodes), userName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,8 +617,8 @@ func TestExpireNode(t *testing.T) {
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
var machine v1.Machine
|
||||
err = json.Unmarshal([]byte(result), &machine)
|
||||
var node v1.Node
|
||||
err = json.Unmarshal([]byte(result), &node)
|
||||
assert.NoError(t, err)
|
||||
|
||||
time.Sleep(30 * time.Second)
|
||||
@@ -634,10 +634,10 @@ func TestExpireNode(t *testing.T) {
|
||||
|
||||
peerPublicKey := strings.TrimPrefix(peerStatus.PublicKey.String(), "nodekey:")
|
||||
|
||||
assert.NotEqual(t, machine.NodeKey, peerPublicKey)
|
||||
assert.NotEqual(t, node.NodeKey, peerPublicKey)
|
||||
}
|
||||
|
||||
if client.Hostname() != machine.Name {
|
||||
if client.Hostname() != node.Name {
|
||||
// Assert that we have the original count - self - expired node
|
||||
assert.Len(t, status.Peers(), len(TailscaleVersions)-2)
|
||||
}
|
||||
|
@@ -519,11 +519,11 @@ func (t *HeadscaleInContainer) CreateAuthKey(
|
||||
return &preAuthKey, nil
|
||||
}
|
||||
|
||||
// ListMachinesInUser list the TailscaleClients (Machine, Headscale internal representation)
|
||||
// ListNodesInUser list the TailscaleClients (Machine, Headscale internal representation)
|
||||
// associated with a user.
|
||||
func (t *HeadscaleInContainer) ListMachinesInUser(
|
||||
func (t *HeadscaleInContainer) ListNodesInUser(
|
||||
user string,
|
||||
) ([]*v1.Machine, error) {
|
||||
) ([]*v1.Node, error) {
|
||||
command := []string{"headscale", "--user", user, "nodes", "list", "--output", "json"}
|
||||
|
||||
result, _, err := dockertestutil.ExecuteCommand(
|
||||
@@ -535,7 +535,7 @@ func (t *HeadscaleInContainer) ListMachinesInUser(
|
||||
return nil, fmt.Errorf("failed to execute list node command: %w", err)
|
||||
}
|
||||
|
||||
var nodes []*v1.Machine
|
||||
var nodes []*v1.Node
|
||||
err = json.Unmarshal([]byte(result), &nodes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal nodes: %w", err)
|
||||
|
Reference in New Issue
Block a user