Skip to content

Commit

Permalink
Removed commented out code (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzarghili authored Apr 17, 2020
1 parent 8759a62 commit d91ea9e
Showing 1 changed file with 0 additions and 142 deletions.
142 changes: 0 additions & 142 deletions recaptcha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,145 +430,3 @@ func (s *ReCaptchaSuite) TestV2VerifyWithV3IgnoreOptions(c *C) {
err := captcha.VerifyWithOptions("mycode", VerifyOption{Action: "homepage", Threshold: 0.5})
c.Assert(err, IsNil)
}

/*
func (*mockSuccessClient) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
resp = &http.Response{
Status: "200 OK",
StatusCode: 200,
}
resp.Body = ioutil.NopCloser(strings.NewReader(`
{
"success": true,
"challenge_ts": "2018-03-06T03:41:29+00:00",
"hostname": "test.com"
}
`))
return
}
func (*mockSuccessClientHostnameOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
resp = &http.Response{
Status: "200 OK",
StatusCode: 200,
}
resp.Body = ioutil.NopCloser(strings.NewReader(`
{
"success": true,
"challenge_ts": "2018-03-06T03:41:29+00:00",
"hostname": "valid.com"
}
`))
return
}
func (*mockFailedClientHostnameOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
resp = &http.Response{
Status: "200 OK",
StatusCode: 200,
}
resp.Body = ioutil.NopCloser(strings.NewReader(`
{
"success": true,
"challenge_ts": "2018-03-06T03:41:29+00:00",
"hostname": "invalid.com"
}
`))
return
}
func (*mockFailedClient) PostForm(url string, formValues url.Values) (resp *http.Response, err error) {
resp = &http.Response{
Status: "200 OK",
StatusCode: 200,
}
resp.Body = ioutil.NopCloser(strings.NewReader(`
{
"success": false,
"challenge_ts": "2018-03-06T03:41:29+00:00",
"hostname": "test.com",
"error-codes": ["bad-request"]
}
`))
return
}
// bad json body
func (s *ReCaptchaSuite) TestNewReCAPTCHA(c *C) {
captcha, err := NewReCAPTCHA("my secret", V2, 10)
c.Assert(err, IsNil)
c.Check(captcha.Secret, Equals, "my secret")
c.Check(captcha.Version, Equals, V2)
c.Check(captcha.Timeout, Equals, (uint)(10))
c.Check(captcha.ReCAPTCHALink, Equals, reCAPTCHALink)
captcha, err = NewReCAPTCHA("", V2, 10)
c.Assert(err, NotNil)
}
func (s *ReCaptchaSuite) TestVerifyV2WithoutClientIP(c *C) {
captcha := ReCAPTCHA{
client: &mockSuccessClient{},
Version: V2,
}
success, err := captcha.Verify("mycode")
c.Assert(err, IsNil)
c.Check(success, Equals, true)
captcha.client = &mockFailedClient{}
success, err = captcha.Verify("mycode")
c.Assert(err, IsNil)
c.Check(success, Equals, false)
}
func (s *ReCaptchaSuite) TestV3VerifyWithCHostnameOption(c *C) {
captcha := ReCAPTCHA{
client: &mockSuccessClientHostnameOption{},
Version: V3,
}
success, err := captcha.VerifyWithOptions("mycode", VerifyOption{Hostname: "valid.com"})
c.Assert(err, IsNil)
c.Check(success, Equals, true)
captcha.client = &mockFailedClientHostnameOption{}
success, err = captcha.VerifyWithOptions("mycode", VerifyOption{Hostname: "valid.com"})
c.Assert(err, NotNil)
c.Check(success, Equals, false)
}
/*
func (s *ReCaptchaSuite) TestVerifyWithClientIP(c *C) {
captcha := ReCAPTCHA{
client: &mockSuccessClient{},
}
success, err := captcha.Verify("mycode", "127.0.0.1")
c.Assert(err, IsNil)
c.Check(success, Equals, true)
captcha.client = &mockFailedClient{}
success, err = captcha.Verify("mycode", "127.0.0.1")
c.Assert(err, IsNil)
c.Check(success, Equals, false)
}
func (s *ReCaptchaSuite) TestConfirm(c *C) {
// check that an invalid json body errors
captcha := ReCAPTCHA{
client: &mockInvalidClient{},
}
body := reCHAPTCHARequest{Secret: "", Response: ""}
success, err := captcha.confirm(body)
c.Assert(err, NotNil)
c.Check(success, Equals, false)
captcha.client = &mockUnavailableClient{}
success, err = captcha.confirm(body)
c.Assert(err, NotNil)
c.Check(success, Equals, false)
}
*/

0 comments on commit d91ea9e

Please sign in to comment.