first commit
This commit is contained in:
21
internal/webhook/signer_test.go
Normal file
21
internal/webhook/signer_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package webhook
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSign(t *testing.T) {
|
||||
if Sign("", []byte("hello")) != "" {
|
||||
t.Error("empty secret should return empty signature")
|
||||
}
|
||||
sig := Sign("supersecret", []byte("hello"))
|
||||
if len(sig) != 64 {
|
||||
t.Errorf("expected 64-char hex hmac, got %d: %q", len(sig), sig)
|
||||
}
|
||||
again := Sign("supersecret", []byte("hello"))
|
||||
if sig != again {
|
||||
t.Error("signature should be deterministic")
|
||||
}
|
||||
other := Sign("different", []byte("hello"))
|
||||
if sig == other {
|
||||
t.Error("different secret should produce different signature")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user