diff --git a/go/outward/outward_test.go b/go/outward/outward_test.go index fdc77a5..7a4a143 100644 --- a/go/outward/outward_test.go +++ b/go/outward/outward_test.go @@ -4,11 +4,8 @@ package outward import ( "encoding/base64" - "encoding/json" "fmt" "math/rand" - "os" - "path/filepath" "testing" ) @@ -166,33 +163,6 @@ func TestCheckSecretLetsACamelCaseNameThrough(t *testing.T) { } } -// 1439/AC1: a name written in lowercase words and digits between `-`, `_` or `/`, every piece short, is a -// name and not a secret: mesh-issues' owners list (the catalogue's 134 defaults plus okioki) was refused -// whole as "a long random-looking string" for modules/asus-zephyrus-g14, i3status-rust and powerlevel10k. -func TestCheckSecretLetsALowercaseNameWithDigitsThrough(t *testing.T) { - for _, text := range []string{ - "mesh-catalog modules/asus-zephyrus-g14", - "mesh-catalog modules/i3status-rust", - "mesh-catalog modules/powerlevel10k", - } { - if r, ok := CheckSecret(text); !ok { - t.Errorf("CheckSecret(%q) withheld it: %s", text, r) - } - } - raw, err := os.ReadFile(filepath.Join("testdata", "owners-1439.json")) - if err != nil { - t.Fatal(err) - } - var owners []string - if err := json.Unmarshal(raw, &owners); err != nil || len(owners) != 135 { - t.Fatalf("testdata holds %d owners (%v), want the 134 defaults plus okioki", len(owners), err) - } - compact, _ := json.Marshal(owners) - if r, ok := CheckSecret("+ owners: " + string(compact)); !ok { - t.Errorf("CheckSecret withheld the owners list: %s", r) - } -} - // 1439/AC2: what looks random is still refused: a mixed-case run, a base64url token with `-` and `_`, a // lowercase run of letters and digits with no separator, and a lowercase name with one long random piece. func TestCheckSecretStillRefusesRandomRunsBesideNames(t *testing.T) { diff --git a/go/outward/testdata/owners-1439.json b/go/outward/replay1439_owners.json similarity index 100% rename from go/outward/testdata/owners-1439.json rename to go/outward/replay1439_owners.json diff --git a/go/outward/replay1439_test.go b/go/outward/replay1439_test.go new file mode 100644 index 0000000..ac1390d --- /dev/null +++ b/go/outward/replay1439_test.go @@ -0,0 +1,37 @@ +package outward + +import ( + "encoding/json" + "os" + "testing" +) + +// TestReplay1439 is issue 1439, replayed (mesh-lab R1439, novox/hq ADR 0237 ยง5), written only with what the +// package had before its fix: it fails on the commit before mesh-sdk #52 and passes on it. +// +// 1439/AC1: a name written in lowercase words and digits between `-`, `_` or `/`, every piece short, is a +// name and not a secret: mesh-issues' owners list (the catalogue's 134 defaults plus okioki) was refused +// whole as "a long random-looking string" for modules/asus-zephyrus-g14, i3status-rust and powerlevel10k. +func TestReplay1439(t *testing.T) { + for _, text := range []string{ + "mesh-catalog modules/asus-zephyrus-g14", + "mesh-catalog modules/i3status-rust", + "mesh-catalog modules/powerlevel10k", + } { + if r, ok := CheckSecret(text); !ok { + t.Errorf("CheckSecret(%q) withheld it: %s", text, r) + } + } + raw, err := os.ReadFile("replay1439_owners.json") + if err != nil { + t.Fatal(err) + } + var owners []string + if err := json.Unmarshal(raw, &owners); err != nil || len(owners) != 135 { + t.Fatalf("testdata holds %d owners (%v), want the 134 defaults plus okioki", len(owners), err) + } + compact, _ := json.Marshal(owners) + if r, ok := CheckSecret("+ owners: " + string(compact)); !ok { + t.Errorf("CheckSecret withheld the owners list: %s", r) + } +}