Files
upaas/internal/database/hash_test.go
user f4a407dda3
All checks were successful
Check / check (pull_request) Successful in 2m33s
fix: change module path to sneak.berlin/go/upaas (fixes #143)
2026-02-26 05:58:19 -08:00

29 lines
648 B
Go

package database_test
import (
"testing"
"github.com/stretchr/testify/assert"
"sneak.berlin/go/upaas/internal/database"
)
func TestHashWebhookSecret(t *testing.T) {
t.Parallel()
// Known SHA-256 of "test-secret"
hash := database.HashWebhookSecret("test-secret")
assert.Equal(t,
"9caf06bb4436cdbfa20af9121a626bc1093c4f54b31c0fa937957856135345b6",
hash,
)
// Different secrets produce different hashes
hash2 := database.HashWebhookSecret("other-secret")
assert.NotEqual(t, hash, hash2)
// Same secret always produces same hash (deterministic)
hash3 := database.HashWebhookSecret("test-secret")
assert.Equal(t, hash, hash3)
}