Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/lib/events/category_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions server/lib/events/category_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ func TestCategoryMapsAgreeOnAPICallSplit(t *testing.T) {
assert.Equal(t, Platform, cat)
}

func TestCaptchaCategories(t *testing.T) {
for _, eventType := range []string{"captcha_solve_started", "captcha_challenge_result"} {
t.Run(eventType, func(t *testing.T) {
cat, ok := CategoryForType(eventType)
require.True(t, ok)
assert.Equal(t, Captcha, cat)
})
}
}

func TestCategoryForOperation(t *testing.T) {
require.NotEmpty(t, categoryByOperationID, "generator produced no operations")

Expand Down
48 changes: 48 additions & 0 deletions server/lib/oapi/captcha_compat_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package oapi

import "testing"

func TestCaptchaGeneratedNamesRemainCompatible(t *testing.T) {
var captchaType BrowserCaptchaSolveResultEventDataCaptchaType = BrowserCaptchaSolveResultEventDataCaptchaTypeHcaptcha
var sharedType BrowserCaptchaType = captchaType
if sharedType != captchaType {
t.Fatalf("shared captcha type = %q, want %q", sharedType, captchaType)
}

statuses := []BrowserCaptchaSolveResultEventDataStatus{
Success,
Failure,
Timeout,
Abandoned,
}
for _, status := range statuses {
if !status.Valid() {
t.Fatalf("solve status %q is invalid", status)
}
}
for _, status := range []BrowserCaptchaChallengeResultEventDataStatus{
ChallengeSolved,
ChallengeFailure,
ChallengeTimeout,
ChallengeAbandoned,
} {
if !status.Valid() {
t.Fatalf("challenge status %q is invalid", status)
}
}

started := BrowserCaptchaSolveStartedEvent{
Data: BrowserCaptchaSolveStartedEventData{CaptchaType: captchaType},
}
challenge := BrowserCaptchaChallengeResultEvent{
Data: BrowserCaptchaChallengeResultEventData{
CaptchaType: captchaType,
ChallengeId: "challenge-id",
DurationMs: 1,
Status: ChallengeFailure,
},
}
if started.Data.CaptchaType != challenge.Data.CaptchaType {
t.Fatal("captcha event types are inconsistent")
}
}
Loading
Loading