initial upload
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDeploymentCodeFormatAndNormalization(t *testing.T) {
|
||||
code, err := deploymentCode()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.HasPrefix(code, "TAPM-") || len(code) != 16 {
|
||||
t.Fatalf("unexpected code format: %q", code)
|
||||
}
|
||||
if got := normalizeCode(strings.ToLower(code)); got != code {
|
||||
t.Fatalf("normalizeCode() = %q, want %q", got, code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignature(t *testing.T) {
|
||||
secret := []byte("01234567890123456789012345678901")
|
||||
signature := signValue(secret, "state")
|
||||
if !verifySignature(secret, "state", signature) {
|
||||
t.Fatal("valid signature was rejected")
|
||||
}
|
||||
if verifySignature(secret, "different", signature) {
|
||||
t.Fatal("invalid signature was accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user