22 lines
580 B
Go
22 lines
580 B
Go
package resend
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"log/slog"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCredentialRedactsItself(t *testing.T) {
|
|
const key = "re_credential-test-key"
|
|
value := credential{authorization: "Bearer " + key}
|
|
|
|
var logs bytes.Buffer
|
|
slog.New(slog.NewTextHandler(&logs, nil)).Info("credential", slog.Any("value", value), slog.Any("pointer", &value))
|
|
output := fmt.Sprintf("%v %+v %#v %s %q", value, value, value, value, value) + fmt.Sprint(&value) + logs.String()
|
|
if strings.Contains(output, key) {
|
|
t.Fatalf("printed credential exposes the API key: %s", output)
|
|
}
|
|
}
|