mirror of
https://github.com/PrivateCaptcha/PrivateCaptcha.git
synced 2026-02-11 00:08:47 -06:00
Cosmetic improvements
This commit is contained in:
@@ -72,7 +72,15 @@ func puzzleSuiteWithBackfillWait(t *testing.T, ctx context.Context, sitekey, dom
|
||||
t.Errorf("Unexpected status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
time.Sleep(3 * authBackfillDelay)
|
||||
for i := 0; i < 10; i++ {
|
||||
time.Sleep(authBackfillDelay)
|
||||
|
||||
if _, err := store.Impl().GetCachedPropertyBySitekey(ctx, sitekey, nil); err != db.ErrCacheMiss {
|
||||
break
|
||||
} else {
|
||||
slog.DebugContext(ctx, "Waiting for property to be cached", "attempt", i, common.ErrAttr(err))
|
||||
}
|
||||
}
|
||||
|
||||
resp, err = puzzleSuite(ctx, sitekey, domain)
|
||||
if err != nil {
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestMain(m *testing.M) {
|
||||
timeSeries = db.NewTimeSeries(clickhouse)
|
||||
|
||||
var err error
|
||||
cache, err = db.NewMemoryCache[db.CacheKey, any]("default", 100, &struct{}{}, 1*time.Minute, 3*time.Minute, 30*time.Second)
|
||||
cache, err = db.NewMemoryCache[db.CacheKey, any]("default", 1000, &struct{}{}, 1*time.Minute, 3*time.Minute, 30*time.Second)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -22,15 +22,6 @@ import (
|
||||
"github.com/PrivateCaptcha/PrivateCaptcha/pkg/puzzle"
|
||||
)
|
||||
|
||||
func reverse(s string) string {
|
||||
rune := []rune(s)
|
||||
n := len(s)
|
||||
for i := 0; i < n/2; i++ {
|
||||
rune[i], rune[n-1-i] = rune[n-1-i], rune[i]
|
||||
}
|
||||
return string(rune)
|
||||
}
|
||||
|
||||
func TestSerializeResponse(t *testing.T) {
|
||||
v := VerifyResponseRecaptchaV3{
|
||||
VerifyResponseRecaptchaV2: VerifyResponseRecaptchaV2{
|
||||
@@ -185,12 +176,12 @@ func TestVerifyPuzzleWrongExpectedSitekey(t *testing.T) {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
payload, apiKey, sitekey, err := setupVerifySuite(t.Name())
|
||||
payload, apiKey, _, err := setupVerifySuite(t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := verifySuite(payload, apiKey, reverse(sitekey))
|
||||
resp, err := verifySuite(payload, apiKey, db.UUIDToSiteKey(*randomUUID()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -225,12 +216,12 @@ func TestSiteVerifyWrongExpectedSitekey(t *testing.T) {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
payload, apiKey, sitekey, err := setupVerifySuite(t.Name())
|
||||
payload, apiKey, _, err := setupVerifySuite(t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := siteVerifySuite(payload, apiKey, reverse(sitekey))
|
||||
resp, err := siteVerifySuite(payload, apiKey, db.UUIDToSiteKey(*randomUUID()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestMain(m *testing.M) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cache, err = db.NewMemoryCache[db.CacheKey, any]("default", 100, &struct{}{}, 1*time.Minute, 3*time.Minute, 30*time.Second)
|
||||
cache, err = db.NewMemoryCache[db.CacheKey, any]("default", 1000, &struct{}{}, 1*time.Minute, 3*time.Minute, 30*time.Second)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user