42 lines
1002 B
Go
42 lines
1002 B
Go
package handlers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLooksLikeSHA256_Valid(t *testing.T) {
|
|
validSHA256 := "550e8400e29b41d4a716446655440000550e8400e29b41d4a716446655440000"
|
|
|
|
result := looksLikeSHA256(validSHA256)
|
|
assert.True(t, result)
|
|
}
|
|
|
|
func TestLooksLikeSHA256_Lowercase(t *testing.T) {
|
|
sha256 := "550e8400e29b41d4a716446655440000550e8400e29b41d4a716446655440000"
|
|
|
|
result := looksLikeSHA256(sha256)
|
|
assert.True(t, result)
|
|
}
|
|
|
|
func TestLooksLikeSHA256_Invalid(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
}{
|
|
{"too short", "abc123"},
|
|
{"too long", "550e8400e29b41d4a716446655440000550e8400e29b41d4a71644665544000000"},
|
|
{"wrong characters", "550e8400e29b41d4a716446655440000550e8400e29b41d4a71644665544000gg"},
|
|
{"empty", ""},
|
|
{"with spaces", "550e8400 e29b 41d4 a716 446655440000"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
result := looksLikeSHA256(tt.input)
|
|
assert.False(t, result)
|
|
})
|
|
}
|
|
}
|