rastrillo / aviso Public

Clone
git clone https://amadan.net/rastrillo/aviso

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3import (
4 "bytes"
5 "encoding/base64"
6 "strings"
7 "testing"
8)
9
10// One line, one key, nothing else: a shell substitution captures it
11// without parsing.
12func TestRunPrintsOnePrivateKey(t *testing.T) {
13 var out bytes.Buffer
14 if err := run(&out); err != nil {
15 t.Fatal(err)
16 }
17 if !strings.HasSuffix(out.String(), "\n") || strings.Count(out.String(), "\n") != 1 {
18 t.Fatalf("want exactly one newline-terminated line, got %q", out.String())
19 }
20 s := strings.TrimSpace(out.String())
21 raw, err := base64.RawURLEncoding.DecodeString(s)
22 if err != nil || len(raw) != 32 {
23 t.Fatalf("not a 32-byte base64url key: %q", s)
24 }
25 if strings.ContainsAny(s, "=+/") {
26 t.Fatalf("not unpadded base64url: %q", s)
27 }
28}
29