Skip to content

Commit

Permalink
Fix typos. (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzarghili authored Jun 13, 2020
1 parent 14b5e4c commit d227bbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions recaptcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const (
V2 VERSION = iota
// V3 recaptcha api v3, more details can be found here : https://developers.google.com/recaptcha/docs/v3
V3
// DefaultTreshold Default minimin score when using V3 api
DefaultTreshold float32 = 0.5
// DefaultThreshold Default minimin score when using V3 api
DefaultThreshold float32 = 0.5
)

type reCHAPTCHARequest struct {
Expand Down Expand Up @@ -100,7 +100,7 @@ type VerifyOption struct {
RemoteIP string
}

// VerifyWithOptions returns `nil` if no error and the client solved the challenge correctly and all options are natching
// VerifyWithOptions returns `nil` if no error and the client solved the challenge correctly and all options are matching
// `Threshold` and `Action` are ignored when using V2 version
func (r *ReCAPTCHA) VerifyWithOptions(challengeResponse string, options VerifyOption) error {
var body reCHAPTCHARequest
Expand Down Expand Up @@ -164,8 +164,8 @@ func (r *ReCAPTCHA) confirm(recaptcha reCHAPTCHARequest, options VerifyOption) (
Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, options.Threshold)
return
}
if options.Threshold == 0 && DefaultTreshold > result.Score {
Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, DefaultTreshold)
if options.Threshold == 0 && DefaultThreshold > result.Score {
Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, DefaultThreshold)
return
}
}
Expand Down
16 changes: 8 additions & 8 deletions recaptcha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ func (s *ReCaptchaSuite) TestV3VerifyWithActionOption(c *C) {

}

type mockV3SuccessClientWithTresholdOption struct{}
type mockV3FailClientWithTresholdOption struct{}
type mockV3SuccessClientWithThresholdOption struct{}
type mockV3FailClientWithThresholdOption struct{}

func (*mockV3SuccessClientWithTresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
func (*mockV3SuccessClientWithThresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
resp = &http.Response{
Status: "200 OK",
StatusCode: 200,
Expand All @@ -375,7 +375,7 @@ func (*mockV3SuccessClientWithTresholdOption) PostForm(url string, formValues ur
`))
return
}
func (*mockV3FailClientWithTresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
func (*mockV3FailClientWithThresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
resp = &http.Response{
Status: "200 OK",
StatusCode: 200,
Expand All @@ -389,16 +389,16 @@ func (*mockV3FailClientWithTresholdOption) PostForm(url string, formValues url.V
`))
return
}
func (s *ReCaptchaSuite) TestV3VerifyWithTresholdOption(c *C) {
func (s *ReCaptchaSuite) TestV3VerifyWithThresholdOption(c *C) {
captcha := ReCAPTCHA{
client: &mockV3SuccessClientWithTresholdOption{},
client: &mockV3SuccessClientWithThresholdOption{},
Version: V3,
}

err := captcha.VerifyWithOptions("mycode", VerifyOption{Threshold: 0.6})
c.Assert(err, IsNil)

captcha.client = &mockV3FailClientWithTresholdOption{}
captcha.client = &mockV3FailClientWithThresholdOption{}
err = captcha.VerifyWithOptions("mycode", VerifyOption{Threshold: 0.6})
c.Assert(err, NotNil)
c.Check(err, ErrorMatches, "received score '0.230000', while expecting minimum '0.600000'")
Expand Down Expand Up @@ -426,7 +426,7 @@ func (*mockV2SuccessClientWithV3IgnoreOptions) PostForm(url string, formValues u
}
func (s *ReCaptchaSuite) TestV2VerifyWithV3IgnoreOptions(c *C) {
captcha := ReCAPTCHA{
client: &mockV3SuccessClientWithTresholdOption{},
client: &mockV3SuccessClientWithThresholdOption{},
Version: V2,
}
err := captcha.VerifyWithOptions("mycode", VerifyOption{Action: "homepage", Threshold: 0.5})
Expand Down

0 comments on commit d227bbb

Please sign in to comment.