Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge 55a8adc into 44cb11c
Browse files Browse the repository at this point in the history
  • Loading branch information
iamthechad committed May 6, 2018
2 parents 44cb11c + 55a8adc commit c0765db
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,11 @@ public class ReCaptcha {
* @return
*/
public boolean checkAnswer(String remoteAddr, String response) {
def post = new Post(url: BASE_URL + VERIFY_URL, proxy: proxy)
def post = new Post(url: BASE_URL + VERIFY_URL, proxy: proxy, connectTimeout: timeoutConfig?.connectTimeout, readTimeout: timeoutConfig?.readTimeout)
post.queryParams.add("secret", privateKey)
post.queryParams.add("response", response)
post.queryParams.add("remoteip", remoteAddr)

post.connectTimeout = timeoutConfig?.connectTimeout ?: post.connectTimeout
post.readTimeout = timeoutConfig?.readTimeout ?: post.readTimeout

def responseObject = post.response

if (!responseObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Post {
RestBuilder rest = null

public Post(Map options) {
options.each { k,v -> if (this.hasProperty(k)) { this."$k" = v} }
options.each { k,v -> if (this.hasProperty(k) && v) { this."$k" = v} }
if (null == rest) {
if (proxy?.isConfigured()) {
rest = new RestBuilder(connectTimeout: connectTimeout, readTimeout: readTimeout, proxy: proxy.proxy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,10 @@ class ReCaptchaTests extends Specification {

private void buildAndCheckAnswer(String postText, boolean expectedValid) {
def stub = new StubFor(Post.class)
stub.demand.hasProperty(3..3) { true }
stub.demand.hasProperty(5..5) { true }
stub.demand.setUrl() {}
stub.demand.setProxy() {}
stub.demand.getQueryParams(3..3) { new QueryParams(null) }
stub.demand.setConnectTimeout() {}
stub.demand.getConnectTimeout() { 10000 }
stub.demand.setReadTimeout() {}
stub.demand.getReadTimeout() { 1000 }
stub.demand.getResponse() { postText == null ? null : new JsonSlurper().parseText(postText) }

stub.use {
Expand Down

0 comments on commit c0765db

Please sign in to comment.