Replay issue 1439 as TestReplay1439 (mesh-lab R1439)
The test that proved the fix is now the issue's replay, as ADR 0237 asks of a core issue: it uses only what the package had before mesh-sdk #52, fails on the commit before it and passes on it.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package outward
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"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(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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user