init
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package secret
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseEE_UserExample(t *testing.T) {
|
||||
s := "ee5ba9cf5cf84698032e5300c864544dd0632e6170692e73746570612e6f6e65"
|
||||
p, err := Parse(s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Kind != KindEE {
|
||||
t.Fatalf("kind %v", p.Kind)
|
||||
}
|
||||
raw, err := hex.DecodeString(s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if raw[0] != 0xee {
|
||||
t.Fatal("marker")
|
||||
}
|
||||
if !bytes.Equal(p.Key, raw[1:17]) {
|
||||
t.Fatalf("key: got %x want %x", p.Key, raw[1:17])
|
||||
}
|
||||
if !bytes.Equal(p.Domain, raw[17:]) {
|
||||
t.Fatalf("domain: got %x want %x", p.Domain, raw[17:])
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseDD(t *testing.T) {
|
||||
s := "dd00000000000000000000000000000000"
|
||||
p, err := Parse(s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Kind != KindDD {
|
||||
t.Fatalf("kind %v", p.Kind)
|
||||
}
|
||||
for _, b := range p.Key {
|
||||
if b != 0 {
|
||||
t.Fatal("expected zero key")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user