oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipotest
2
3import (
4 "context"
5 "testing"
6 "time"
7
8 "amadan.net/oficina/equipo/internal/equipo"
9)
10
11func TestRotationRecoveryWindow(t *testing.T) {
12 for _, age := range []time.Duration{4 * time.Minute, 5 * time.Minute} {
13 t.Run(age.String(), func(t *testing.T) {
14 f := runnerFixtureNew(t, true)
15 f.x.SetRunnerValidators(equipo.RunnerValidators{Containment: func(context.Context, equipo.Assignment, equipo.RunnerRequest) error { return nil }})
16 q := f.request()
17 q.RequestID = "rotation"
18 q.Proof = []byte(`{}`)
19 _, err := f.x.Mutate(connectionContext, f.principal, "contained", q)
20 executionMust(t, err)
21 f.clock.Advance(age)
22 value, err := f.x.Cleanup(connectionContext, f.claim.CleanupToken, "contained", q)
23 executionMust(t, err)
24 rotation := value.(equipo.CredentialRotation)
25 if (rotation.Bearer.Token != "") != (age < 5*time.Minute) {
26 t.Fatal("rotation recovered live authority outside window", age)
27 }
28 if len(rotation.CleanupTokens) == 0 {
29 t.Fatal("expired rotation lost cleanup")
30 }
31 })
32 }
33}
34