mirror of
https://github.com/hanzoai/kms-operator.git
synced 2026-10-30 18:32:57 +00:00
Three faults, found live in one incident (index-chat-env pending, a push
"succeeding" while every read missed):
1. The client addressed /v1/kms/orgs/{org}/... — the org-addressed shape both
servers removed (a URL that names a tenant is caller-selectable). Every
URL is /v1/kms/secrets/... now; the org rides the TOKEN minted at login,
and the org parameter still selects which credential logs in.
2. The push wrote the raw spec path while reads normalized it: a leading-slash
secretsPath was WRITTEN at "/x" and READ (never found) at "x", and the
reconciler honestly reported the write it had made — to an address nothing
reads. One normalization (NormaliseScopePath) now rides both directions.
3. resyncInterval "300" failed "invalid time unit" once a minute forever. A
bare integer is seconds; "5m" still works.
Each pinned by test, negatives included.
Co-authored-by: Hanzo Dev <[email protected]>
27 lines
694 B
Go
27 lines
694 B
Go
package util
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// "300" is 300 seconds — an operator writes bare seconds as naturally as "5m",
|
|
// and rejecting it looped "invalid time unit" once a minute forever.
|
|
func TestConvertIntervalToDuration_BareSeconds(t *testing.T) {
|
|
for in, want := range map[string]time.Duration{
|
|
"300": 300 * time.Second,
|
|
"5m": 5 * time.Minute,
|
|
"60": time.Minute,
|
|
} {
|
|
s := in
|
|
got, err := ConvertIntervalToDuration(&s)
|
|
if err != nil || got != want {
|
|
t.Fatalf("ConvertIntervalToDuration(%q) = %v, %v; want %v", in, got, err, want)
|
|
}
|
|
}
|
|
neg := "-5"
|
|
if _, err := ConvertIntervalToDuration(&neg); err == nil {
|
|
t.Fatal("a negative interval must be refused")
|
|
}
|
|
}
|