mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-29 16:18:40 +08:00
24 lines
480 B
Go
24 lines
480 B
Go
package captcha
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateTokenRespectsEnabled(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
if NewCaptcha().ValidateToken(ctx, "") {
|
|
t.Fatal("enabled captcha accepted an empty token")
|
|
}
|
|
if !NewCaptcha(false).ValidateToken(ctx, "") {
|
|
t.Fatal("disabled captcha rejected an empty token")
|
|
}
|
|
|
|
cap := NewCaptcha()
|
|
cap.SetEnabled(false)
|
|
if !cap.ValidateToken(ctx, "") {
|
|
t.Fatal("SetEnabled(false) did not disable validation")
|
|
}
|
|
}
|