feat(assessment): find the attempt behind a leaked task text
This commit is contained in:
1 parent
bb917bf62e
commit
5a731c25b7
26 files changed
+2500
No files matched your search
@@ -135,3 +135,26 @@ func TestLoadFromEnvRejectsThePlaceholderSecret(t *testing.T) {
|
||||
t.Fatalf("LoadFromEnv() error = %v, want a refusal that does not quote the value", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIdentityKeySecretFromEnvRefusesWhatTheServerCouldNotUseAndNeverEchoesIt(t *testing.T) {
|
||||
secret := strings.Repeat("s", MinIdentityKeySecretBytes)
|
||||
got, err := IdentityKeySecretFromEnv(func(key string) (string, bool) { return " " + secret + " ", key == "IDENTITY_KEY_SECRET" })
|
||||
if err != nil || string(got) != secret {
|
||||
t.Fatalf("IdentityKeySecretFromEnv(valid) = %q, %v, want the trimmed secret", got, err)
|
||||
}
|
||||
for name, value := range map[string]string{
|
||||
"unset": "",
|
||||
"placeholder": "replace-this-with-a-generated-secret-of-enough-length",
|
||||
"too short": "short-secret",
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
_, err := IdentityKeySecretFromEnv(func(key string) (string, bool) { return value, key == "IDENTITY_KEY_SECRET" && value != "" })
|
||||
if err == nil {
|
||||
t.Fatal("IdentityKeySecretFromEnv() succeeded, want an error")
|
||||
}
|
||||
if value != "" && strings.Contains(err.Error(), value) {
|
||||
t.Fatalf("the error contains the secret: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user