servertest: replay the expire-key-expiry capture

This commit is contained in:
Kristoffer Dalby committed 2026-11-20 23:02:54 +01:00
1 parent ff356662da
commit 23a637290c
4 files changed
+33145 -7

No files matched your search

+12 -4
View File
@@ -55,6 +55,12 @@ func TestNodeExpiryCompat(t *testing.T) {
runNodeExpiryCompat(t, "expiry", "observer")
})
t.Run("expire-key-expiry", func(t *testing.T) {
t.Parallel()
runNodeExpiryCompat(t, "expire-key-expiry", "observer")
})
}
func runNodeExpiryCompat(t *testing.T, id, observer string) {
@@ -168,9 +174,9 @@ func runNodeExpiryCompat(t *testing.T, id, observer string) {
prevCaps = step.Captures
}
// The map serves this capture alone, so every entry must name a check.
// Every entry for this capture must name a check.
for k := range expirySkipReasons {
if !evaluated[k] {
if strings.HasPrefix(k, id+"/") && !evaluated[k] {
t.Errorf("skip entry %q names no check", k)
}
}
@@ -392,7 +398,8 @@ func (e *expiryStep) apiChecks(t *testing.T, saasPrev, hsPrev map[string]deviceV
return fmt.Sprintf("devices %d", len(views))
}
return renderKeyExpiry(views[0], prevGot, hadGot)
// Judged against an earlier reading only where SaaS has one.
return renderKeyExpiry(views[0], prevGot, hadGot && hadWant)
}})
}
@@ -478,7 +485,8 @@ func captureKeyDuration(t *testing.T, c *testcapture.Capture) time.Duration {
KeyExpiryDisabled bool `json:"keyExpiryDisabled"`
Tags []string `json:"tags"`
}
if json.Unmarshal(a.Response, &d) == nil && !d.KeyExpiryDisabled && len(d.Tags) == 0 {
// A device list decodes to all zero fields.
if json.Unmarshal(a.Response, &d) == nil && !d.Created.IsZero() && !d.KeyExpiryDisabled && len(d.Tags) == 0 {
return d.Expires.Sub(d.Created)
}
}
+3 -3
View File
@@ -649,11 +649,11 @@ func (r *stepReplay) hsViews(alias string) []deviceView {
v.owner = "user " + nv.User().Name()
}
if exp := nv.Expiry(); exp.Valid() && !exp.Get().IsZero() {
v.expires = exp.Get().String()
if exp, ok := nv.KeyExpiry(); ok && !exp.IsZero() {
v.expires = exp.String()
v.expiry = "future"
if exp.Get().Before(time.Now()) {
if exp.Before(time.Now()) {
v.expiry = "past"
}
}
File diff suppressed because it is too large. Load diff
@@ -961,6 +961,10 @@ func (r *stepReplay) daemon(ctx context.Context, t *testing.T, stepName string,
r.hostinfo[a.Node].Hostname = strings.TrimPrefix(args, "set --hostname=")
r.sendHostinfo(ctx, t, a.Node)
case a.Kind == "cli" && strings.HasPrefix(args, "ping "):
// A reachability probe changes nothing; the harness has no data
// plane, and the peer's netmap checks judge what it showed.
case a.Kind == "down", a.Kind == "cli" && args == "down":
cl.Disconnect(t)