mirror of
https://github.com/juanfont/headscale.git
synced 2025-06-19 01:18:37 +02:00
integration: ensure last_seen is set
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
109e412692
commit
4414dfcbdc
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
"github.com/juanfont/headscale/integration/hsic"
|
"github.com/juanfont/headscale/integration/hsic"
|
||||||
"github.com/juanfont/headscale/integration/tsic"
|
"github.com/juanfont/headscale/integration/tsic"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
@ -44,6 +45,9 @@ func TestAuthKeyLogoutAndReloginSameUser(t *testing.T) {
|
|||||||
allClients, err := scenario.ListTailscaleClients()
|
allClients, err := scenario.ListTailscaleClients()
|
||||||
assertNoErrListClients(t, err)
|
assertNoErrListClients(t, err)
|
||||||
|
|
||||||
|
allIps, err := scenario.ListTailscaleClientsIPs()
|
||||||
|
assertNoErrListClientIPs(t, err)
|
||||||
|
|
||||||
err = scenario.WaitForTailscaleSync()
|
err = scenario.WaitForTailscaleSync()
|
||||||
assertNoErrSync(t, err)
|
assertNoErrSync(t, err)
|
||||||
|
|
||||||
@ -66,6 +70,10 @@ func TestAuthKeyLogoutAndReloginSameUser(t *testing.T) {
|
|||||||
nodeCountBeforeLogout := len(listNodes)
|
nodeCountBeforeLogout := len(listNodes)
|
||||||
t.Logf("node count before logout: %d", nodeCountBeforeLogout)
|
t.Logf("node count before logout: %d", nodeCountBeforeLogout)
|
||||||
|
|
||||||
|
for _, node := range listNodes {
|
||||||
|
assertLastSeenSet(t, node)
|
||||||
|
}
|
||||||
|
|
||||||
for _, client := range allClients {
|
for _, client := range allClients {
|
||||||
err := client.Logout()
|
err := client.Logout()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -78,6 +86,13 @@ func TestAuthKeyLogoutAndReloginSameUser(t *testing.T) {
|
|||||||
|
|
||||||
t.Logf("all clients logged out")
|
t.Logf("all clients logged out")
|
||||||
|
|
||||||
|
listNodes, err = headscale.ListNodes()
|
||||||
|
require.Equal(t, nodeCountBeforeLogout, len(listNodes))
|
||||||
|
|
||||||
|
for _, node := range listNodes {
|
||||||
|
assertLastSeenSet(t, node)
|
||||||
|
}
|
||||||
|
|
||||||
// if the server is not running with HTTPS, we have to wait a bit before
|
// if the server is not running with HTTPS, we have to wait a bit before
|
||||||
// reconnection as the newest Tailscale client has a measure that will only
|
// reconnection as the newest Tailscale client has a measure that will only
|
||||||
// reconnect over HTTPS if they saw a noise connection previously.
|
// reconnect over HTTPS if they saw a noise connection previously.
|
||||||
@ -105,8 +120,9 @@ func TestAuthKeyLogoutAndReloginSameUser(t *testing.T) {
|
|||||||
listNodes, err = headscale.ListNodes()
|
listNodes, err = headscale.ListNodes()
|
||||||
require.Equal(t, nodeCountBeforeLogout, len(listNodes))
|
require.Equal(t, nodeCountBeforeLogout, len(listNodes))
|
||||||
|
|
||||||
allIps, err := scenario.ListTailscaleClientsIPs()
|
for _, node := range listNodes {
|
||||||
assertNoErrListClientIPs(t, err)
|
assertLastSeenSet(t, node)
|
||||||
|
}
|
||||||
|
|
||||||
allAddrs := lo.Map(allIps, func(x netip.Addr, index int) string {
|
allAddrs := lo.Map(allIps, func(x netip.Addr, index int) string {
|
||||||
return x.String()
|
return x.String()
|
||||||
@ -137,8 +153,20 @@ func TestAuthKeyLogoutAndReloginSameUser(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listNodes, err = headscale.ListNodes()
|
||||||
|
require.Equal(t, nodeCountBeforeLogout, len(listNodes))
|
||||||
|
for _, node := range listNodes {
|
||||||
|
assertLastSeenSet(t, node)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func assertLastSeenSet(t *testing.T, node *v1.Node) {
|
||||||
|
assert.NotNil(t, node)
|
||||||
|
assert.NotNil(t, node.LastSeen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test will first log in two sets of nodes to two sets of users, then
|
// This test will first log in two sets of nodes to two sets of users, then
|
||||||
|
Loading…
Reference in New Issue
Block a user