29 lines
648 B
Go
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)
|
|
}
|