ruby-recaptcha 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/History.txt +4 -291
- data/README.txt +1 -1
- data/lib/recaptcha.rb +8 -9
- data/lib/ruby-recaptcha.rb +1 -1
- data/test/test_recaptcha.rb +16 -17
- metadata +41 -14
data/.gemtest
ADDED
File without changes
|
data/History.txt
CHANGED
@@ -1,291 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
[31a822ec2421] [tip]
|
6
|
-
|
7
|
-
2009-02-15 m <m@loonsoft.com>
|
8
|
-
|
9
|
-
* .hgtags:
|
10
|
-
Added tag 1.0.0 release for changeset 19f9c037e388
|
11
|
-
[d4de467a907f]
|
12
|
-
|
13
|
-
* lib/ruby-recaptcha.rb:
|
14
|
-
fixed require line
|
15
|
-
[19f9c037e388] [1.0.0 release]
|
16
|
-
|
17
|
-
2009-02-13 m <m@loonsoft.com>
|
18
|
-
|
19
|
-
* Manifest.txt, README.txt, Rakefile, lib/recaptcha.rb,
|
20
|
-
lib/recaptcha/version.rb, lib/ruby-recaptcha.rb, script/console,
|
21
|
-
script/destroy, script/generate, test/test_helper.rb,
|
22
|
-
website/index.txt, website/javascripts/rounded_corners_lite.inc.js,
|
23
|
-
website/stylesheets/screen.css, website/template.rhtml:
|
24
|
-
updated to new version of newgem
|
25
|
-
[de8078de5372]
|
26
|
-
|
27
|
-
2008-12-08 m <m@loonsoft.com>
|
28
|
-
|
29
|
-
* website/index.txt, website/template.rhtml:
|
30
|
-
fixed js
|
31
|
-
[3cb43baa75ef]
|
32
|
-
|
33
|
-
* website/index.txt:
|
34
|
-
updated site
|
35
|
-
[353af929586d]
|
36
|
-
|
37
|
-
* Rakefile:
|
38
|
-
fix uploaded perms
|
39
|
-
[1bfdbd7dbf58]
|
40
|
-
|
41
|
-
* Rakefile, website/index.txt:
|
42
|
-
updated deploy script & site template
|
43
|
-
[0ed40a3c44bc]
|
44
|
-
|
45
|
-
2008-12-05 m <m@loonsoft.com>
|
46
|
-
|
47
|
-
* website/index.txt, website/template.rhtml:
|
48
|
-
updated website
|
49
|
-
[cb2384317947]
|
50
|
-
|
51
|
-
2008-09-02 m <m@loonsoft.com>
|
52
|
-
|
53
|
-
* README.txt, lib/recaptcha.rb, test/test_recaptcha.rb:
|
54
|
-
removed test code which seems to cause trouble with the masses
|
55
|
-
[201f032ce586]
|
56
|
-
|
57
|
-
2008-05-30 m <m@loonsoft.com>
|
58
|
-
|
59
|
-
* README.txt, lib/recaptcha.rb:
|
60
|
-
fix for loopback addr requests
|
61
|
-
[297ed7ad0790]
|
62
|
-
|
63
|
-
2008-04-07 m <m@loonsoft.com>
|
64
|
-
|
65
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
66
|
-
fix for kim griggs
|
67
|
-
[143671e3abb0]
|
68
|
-
|
69
|
-
2008-03-05 m <m@loonsoft.com>
|
70
|
-
|
71
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb:
|
72
|
-
fixed bug when nil challenge string
|
73
|
-
[52e0ff173f56]
|
74
|
-
|
75
|
-
2008-03-01 m <m@loonsoft.com>
|
76
|
-
|
77
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
78
|
-
integrated more patches from pv
|
79
|
-
[f63d820d97f9]
|
80
|
-
|
81
|
-
2008-02-24 m <m@loonsoft.com>
|
82
|
-
|
83
|
-
* lib/recaptcha.rb, website/index.txt:
|
84
|
-
reapplied missing patch
|
85
|
-
[4964962ea7be]
|
86
|
-
|
87
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
88
|
-
patch from peter vandenberk
|
89
|
-
[299402495d48]
|
90
|
-
|
91
|
-
2008-01-12 m <m@loonsoft.com>
|
92
|
-
|
93
|
-
* website/index.txt:
|
94
|
-
website formatting
|
95
|
-
[0c065e76a6a8]
|
96
|
-
|
97
|
-
* website/index.txt:
|
98
|
-
website formatting
|
99
|
-
[79fe86cded6a]
|
100
|
-
|
101
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
102
|
-
proxy support
|
103
|
-
[e55d02f563e4]
|
104
|
-
|
105
|
-
2007-12-30 m <m@loonsoft.com>
|
106
|
-
|
107
|
-
* scripts/txt2html, website/index.txt:
|
108
|
-
updated website
|
109
|
-
[aa2897a0b6fd]
|
110
|
-
|
111
|
-
* website/index.txt:
|
112
|
-
Backed out changeset 0cc68aefef09
|
113
|
-
[770296229d47]
|
114
|
-
|
115
|
-
* website/index.txt:
|
116
|
-
fixed uri
|
117
|
-
[0cc68aefef09]
|
118
|
-
|
119
|
-
2007-12-26 m <m@loonsoft.com>
|
120
|
-
|
121
|
-
* Rakefile, website/index.txt:
|
122
|
-
bleh
|
123
|
-
[62edd6a24d72]
|
124
|
-
|
125
|
-
2007-10-08 m <m@loonsoft.com>
|
126
|
-
|
127
|
-
* website/template.rhtml:
|
128
|
-
modified coda
|
129
|
-
[d0102db1ece1]
|
130
|
-
|
131
|
-
2007-08-23 m <m@loonsoft.com>
|
132
|
-
|
133
|
-
* lib/recaptcha.rb:
|
134
|
-
fix from joey geiger
|
135
|
-
[24e4ed5017bc]
|
136
|
-
|
137
|
-
2007-06-09 m <m@loonsoft.com>
|
138
|
-
|
139
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb:
|
140
|
-
error parameter no longer included when the error is blank or nil
|
141
|
-
[310e75fbd650]
|
142
|
-
|
143
|
-
2007-06-06 m <m@loonsoft.com>
|
144
|
-
|
145
|
-
* website/index.txt:
|
146
|
-
merge
|
147
|
-
[13de70beb380]
|
148
|
-
|
149
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
150
|
-
Backed out changeset 5a6746ce03f73d0dd02db155816500870088bf6e
|
151
|
-
backout of the backout, cosby patch back in
|
152
|
-
[ed21f08b6331]
|
153
|
-
|
154
|
-
* website/index.txt:
|
155
|
-
further clarification
|
156
|
-
[db3308cd9f2b]
|
157
|
-
|
158
|
-
* lib/recaptcha/version.rb, website/index.txt:
|
159
|
-
clarification to doc
|
160
|
-
[0ce238b954ed]
|
161
|
-
|
162
|
-
* website/index.txt:
|
163
|
-
updated site
|
164
|
-
[b798dbd756f5]
|
165
|
-
|
166
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
167
|
-
Backed out changeset d614a6a28630eb4dba913739518dbdc6d3aaa410
|
168
|
-
|
169
|
-
seems to be causing issues
|
170
|
-
[5a6746ce03f7]
|
171
|
-
|
172
|
-
* website/index.txt:
|
173
|
-
clarification
|
174
|
-
[9d2ff1293a4e]
|
175
|
-
|
176
|
-
2007-05-30 m <m@loonsoft.com>
|
177
|
-
|
178
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
179
|
-
patch from victor cosby
|
180
|
-
[d614a6a28630]
|
181
|
-
|
182
|
-
2007-05-29 m <m@loonsoft.com>
|
183
|
-
|
184
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
185
|
-
Backed out changeset 1086e6e6217f85433cc539e6d687880adc421c2f
|
186
|
-
[d1dc394b249b]
|
187
|
-
|
188
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb, website/index.txt:
|
189
|
-
reworked error handling
|
190
|
-
[1086e6e6217f]
|
191
|
-
|
192
|
-
2007-05-27 m <m@loonsoft.com>
|
193
|
-
|
194
|
-
* lib/recaptcha.rb:
|
195
|
-
removed bogon method stub
|
196
|
-
[5497521e6a01]
|
197
|
-
|
198
|
-
* website/index.txt:
|
199
|
-
fixup page
|
200
|
-
[99665cb4b9a1]
|
201
|
-
|
202
|
-
* website/index.txt:
|
203
|
-
mailhide supported
|
204
|
-
[4a0b9f72eede]
|
205
|
-
|
206
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb:
|
207
|
-
mailhide supported
|
208
|
-
[943383442ab0]
|
209
|
-
|
210
|
-
2007-05-25 m <m@loonsoft.com>
|
211
|
-
|
212
|
-
* website/index.txt:
|
213
|
-
pointer to code
|
214
|
-
[848e1a4c0b17]
|
215
|
-
|
216
|
-
* website/template.rhtml:
|
217
|
-
urchin
|
218
|
-
[e2b1d5e77f97]
|
219
|
-
|
220
|
-
* lib/recaptcha.rb, test/test_recaptcha.rb:
|
221
|
-
added cgi module, some tests
|
222
|
-
[a9f834ef0ffb]
|
223
|
-
|
224
|
-
* Rakefile, website/index.txt:
|
225
|
-
updates
|
226
|
-
[5f41c4ec54b2]
|
227
|
-
|
228
|
-
* Rakefile, lib/recaptcha/version.rb, scripts/txt2html:
|
229
|
-
updates
|
230
|
-
[ef9516789992]
|
231
|
-
|
232
|
-
* .hgignore, History.txt, Rakefile:
|
233
|
-
updates
|
234
|
-
[976727776d37]
|
235
|
-
|
236
|
-
* website/index.txt:
|
237
|
-
changed license
|
238
|
-
[63e4d638cbea]
|
239
|
-
|
240
|
-
* lib/recaptcha.rb, website/index.txt:
|
241
|
-
changed license
|
242
|
-
[d7dcf24bb808]
|
243
|
-
|
244
|
-
* lib/recaptcha/version.rb:
|
245
|
-
turned off ssl
|
246
|
-
[5ae4c8024402]
|
247
|
-
|
248
|
-
* lib/recaptcha.rb:
|
249
|
-
turned off ssl
|
250
|
-
[8047f6e7eceb]
|
251
|
-
|
252
|
-
* .hgtags:
|
253
|
-
Added tag release 1.1.2 for changeset cd3bd3392418
|
254
|
-
[844ac63dfb5a]
|
255
|
-
|
256
|
-
* Rakefile, scripts/txt2html:
|
257
|
-
update
|
258
|
-
[cd3bd3392418] [release 1.1.2]
|
259
|
-
|
260
|
-
* .hgignore, Rakefile, website/index.txt:
|
261
|
-
update
|
262
|
-
[3d15d7d8ff91]
|
263
|
-
|
264
|
-
* Rakefile, website/index.html, website/index.txt:
|
265
|
-
update
|
266
|
-
[6af50b34c9fa]
|
267
|
-
|
268
|
-
* lib/recaptcha.rb, lib/recaptcha/version.rb:
|
269
|
-
updated
|
270
|
-
[d28f38ac7cde]
|
271
|
-
|
272
|
-
* .hgignore:
|
273
|
-
ignore packages
|
274
|
-
[1c4ea4c672d2]
|
275
|
-
|
276
|
-
* .hgignore:
|
277
|
-
hgignore
|
278
|
-
[57e762617a54]
|
279
|
-
|
280
|
-
* lib/recaptcha.rb:
|
281
|
-
fixed license
|
282
|
-
[146d97cc2e51]
|
283
|
-
|
284
|
-
* History.txt, Manifest.txt, README.txt, Rakefile, lib/recaptcha.rb,
|
285
|
-
lib/recaptcha/version.rb, scripts/txt2html, setup.rb,
|
286
|
-
test/test_helper.rb, test/test_recaptcha.rb, website/index.html,
|
287
|
-
website/index.txt, website/javascripts/rounded_corners_lite.inc.js,
|
288
|
-
website/stylesheets/screen.css, website/template.rhtml:
|
289
|
-
initial
|
290
|
-
[1f1ba6ed3ef1]
|
291
|
-
|
1
|
+
=== 1.0.3
|
2
|
+
New history file, new Google urls
|
3
|
+
=== 1.0.1
|
4
|
+
Lost History file
|
data/README.txt
CHANGED
@@ -62,7 +62,7 @@ To customize theme and tabindex of the widget, you can include an options hash:
|
|
62
62
|
|
63
63
|
<pre>get_captcha(:options => {:theme => 'white', :tabindex => 10})</pre>
|
64
64
|
|
65
|
-
See the "reCAPTCHA API Documentation":
|
65
|
+
See the "reCAPTCHA API Documentation": under "Look and Feel Customization" for more information.
|
66
66
|
|
67
67
|
=== Proxy support
|
68
68
|
|
data/lib/recaptcha.rb
CHANGED
@@ -55,7 +55,7 @@ module ReCaptcha
|
|
55
55
|
contents = truncate(address,10) if contents.nil?
|
56
56
|
k = ReCaptcha::MHClient.new(MH_PUB, MH_PRIV, address)
|
57
57
|
enciphered = k.crypted_address
|
58
|
-
uri = "http://
|
58
|
+
uri = "http://www.google.com/recaptcha/mailhide/d?k=#{MH_PUB}&c=#{enciphered}"
|
59
59
|
t =<<-EOF
|
60
60
|
<a href="#{uri}"
|
61
61
|
onclick="window.open('#{uri}', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="Reveal this e-mail address">#{contents}</a>
|
@@ -87,10 +87,9 @@ module ReCaptcha
|
|
87
87
|
# [privkey] MailHide private key
|
88
88
|
# [address] the address you want to hide.
|
89
89
|
def initialize(pubkey, privkey, address)
|
90
|
-
@pubkey=pubkey
|
91
|
-
@privkey=privkey
|
90
|
+
@pubkey = pubkey
|
91
|
+
@privkey = privkey
|
92
92
|
@address = address
|
93
|
-
@host='mailhide.recaptcha.net'
|
94
93
|
end
|
95
94
|
#The encrypted address
|
96
95
|
def crypted_address
|
@@ -132,8 +131,8 @@ module ReCaptcha
|
|
132
131
|
def initialize(pubkey, privkey, ssl=false)
|
133
132
|
@pubkey = pubkey
|
134
133
|
@privkey=privkey
|
135
|
-
@host = ssl ? '
|
136
|
-
@vhost = '
|
134
|
+
@host = ssl ? 'www.google.com':'www.google.com'
|
135
|
+
@vhost = 'www.google.com'
|
137
136
|
@proto = ssl ? 'https' : 'http'
|
138
137
|
@ssl = ssl
|
139
138
|
@last_error=nil
|
@@ -156,9 +155,9 @@ module ReCaptcha
|
|
156
155
|
end
|
157
156
|
errslug = (error.empty?||error==nil||error=="success") ? '' : "&error=#{CGI.escape(error)}"
|
158
157
|
s <<<<-EOF
|
159
|
-
<script type="text/javascript" src="#{@proto}://#{@host}/challenge?k=#{CGI.escape(@pubkey)}#{errslug}"> </script>
|
158
|
+
<script type="text/javascript" src="#{@proto}://#{@host}/recaptcha/api/challenge?k=#{CGI.escape(@pubkey)}#{errslug}"> </script>
|
160
159
|
<noscript>
|
161
|
-
<iframe src="#{@proto}://#{@host}/noscript?k=#{CGI.escape(@pubkey)}#{errslug}"
|
160
|
+
<iframe src="#{@proto}://#{@host}/recaptcha/api/noscript?k=#{CGI.escape(@pubkey)}#{errslug}"
|
162
161
|
height="300" width="500" frameborder="0"></iframe><br>
|
163
162
|
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
|
164
163
|
</textarea>
|
@@ -182,7 +181,7 @@ module ReCaptcha
|
|
182
181
|
proxy_host, proxy_port = nil, nil
|
183
182
|
proxy_host, proxy_port = ENV['proxy_host'].split(':') if ENV.has_key?('proxy_host')
|
184
183
|
http = Net::HTTP::Proxy(proxy_host, proxy_port).start(@vhost)
|
185
|
-
path='/verify'
|
184
|
+
path='/recaptcha/api/verify'
|
186
185
|
data = "privatekey=#{CGI.escape(@privkey)}&remoteip=#{CGI.escape(remoteip)}&challenge=#{CGI.escape(challenge)}&response=#{CGI.escape(response)}"
|
187
186
|
resp, data = http.post(path, data, {'Content-Type'=>'application/x-www-form-urlencoded'})
|
188
187
|
response = data.split
|
data/lib/ruby-recaptcha.rb
CHANGED
data/test/test_recaptcha.rb
CHANGED
@@ -2,7 +2,6 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
2
|
require 'rubygems'
|
3
3
|
gem 'mocha'
|
4
4
|
require 'mocha'
|
5
|
-
gem 'rails'
|
6
5
|
|
7
6
|
module ReCaptcha
|
8
7
|
module ViewHelper
|
@@ -58,7 +57,7 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
58
57
|
@request.stubs(:remote_ip).returns('0.0.0.0') # this will skip the actual captcha validation...
|
59
58
|
@request
|
60
59
|
end
|
61
|
-
include Mocha::
|
60
|
+
include Mocha::API
|
62
61
|
end
|
63
62
|
|
64
63
|
def setup
|
@@ -90,17 +89,17 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
90
89
|
def test_constructor
|
91
90
|
client = new_client('abc', 'def', true)
|
92
91
|
expected= <<-EOF
|
93
|
-
<script type=\"text/javascript\" src=\"https://
|
92
|
+
<script type=\"text/javascript\" src=\"https://www.google.com/recaptcha/api/challenge?k=abc\"> </script>\n <noscript>\n <iframe src=\"https://www.google.com/recaptcha/api/noscript?k=abc\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\" \n value=\"manual_challenge\">\n </noscript>
|
94
93
|
EOF
|
95
94
|
assert_equal expected.strip, client.get_challenge.strip
|
96
95
|
client = new_client
|
97
96
|
expected= <<-EOF
|
98
|
-
<script type=\"text/javascript\" src=\"http://
|
97
|
+
<script type=\"text/javascript\" src=\"http://www.google.com/recaptcha/api/challenge?k=abc\"> </script>\n <noscript>\n <iframe src=\"http://www.google.com/recaptcha/api/noscript?k=abc\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\" \n value=\"manual_challenge\">\n </noscript>
|
99
98
|
EOF
|
100
99
|
assert_equal expected.strip, client.get_challenge.strip
|
101
100
|
client = new_client
|
102
101
|
expected= <<-EOF
|
103
|
-
<script type=\"text/javascript\" src=\"http://
|
102
|
+
<script type=\"text/javascript\" src=\"http://www.google.com/recaptcha/api/challenge?k=abc\"> </script>\n <noscript>\n <iframe src=\"http://www.google.com/recaptcha/api/noscript?k=abc\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\" \n value=\"manual_challenge\">\n </noscript>
|
104
103
|
EOF
|
105
104
|
assert_equal expected.strip, client.get_challenge.strip
|
106
105
|
end
|
@@ -117,8 +116,8 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
117
116
|
err_stub.expects(:add_to_base).with("Captcha failed.")
|
118
117
|
stub_proxy=mock('proxy')
|
119
118
|
stub_http = mock('http mock')
|
120
|
-
stub_proxy.expects(:start).with('
|
121
|
-
stub_http.expects(:post).with('/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', badwords_resp])
|
119
|
+
stub_proxy.expects(:start).with('www.google.com').returns(stub_http)
|
120
|
+
stub_http.expects(:post).with('/recaptcha/api/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', badwords_resp])
|
122
121
|
Net::HTTP.expects(:Proxy).returns(stub_proxy)
|
123
122
|
client = new_client
|
124
123
|
assert !client.validate('localhost', 'abc', 'def', err_stub)
|
@@ -128,8 +127,8 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
128
127
|
err_stub=mock()
|
129
128
|
stub_proxy=mock('proxy')
|
130
129
|
stub_http = mock('http mock')
|
131
|
-
stub_proxy.expects(:start).with('
|
132
|
-
stub_http.expects(:post).with('/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', goodwords_resp])
|
130
|
+
stub_proxy.expects(:start).with('www.google.com').returns(stub_http)
|
131
|
+
stub_http.expects(:post).with('/recaptcha/api/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', goodwords_resp])
|
133
132
|
Net::HTTP.expects(:Proxy).with(nil, nil).returns(stub_proxy)
|
134
133
|
client = new_client
|
135
134
|
assert client.validate('localhost', 'abc', 'def', err_stub)
|
@@ -140,8 +139,8 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
140
139
|
err_stub=mock()
|
141
140
|
stub_proxy=mock('proxy')
|
142
141
|
stub_http = mock('http mock')
|
143
|
-
stub_proxy.expects(:start).with('
|
144
|
-
stub_http.expects(:post).with('/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', goodwords_resp])
|
142
|
+
stub_proxy.expects(:start).with('www.google.com').returns(stub_http)
|
143
|
+
stub_http.expects(:post).with('/recaptcha/api/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', goodwords_resp])
|
145
144
|
Net::HTTP.expects(:Proxy).with('fubar', '8080').returns(stub_proxy)
|
146
145
|
client = new_client
|
147
146
|
assert client.validate('localhost', 'abc', 'def', err_stub)
|
@@ -149,8 +148,8 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
149
148
|
err_stub=mock()
|
150
149
|
stub_proxy=mock('proxy')
|
151
150
|
stub_http = mock('http mock')
|
152
|
-
stub_proxy.expects(:start).with('
|
153
|
-
stub_http.expects(:post).with('/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', goodwords_resp])
|
151
|
+
stub_proxy.expects(:start).with('www.google.com').returns(stub_http)
|
152
|
+
stub_http.expects(:post).with('/recaptcha/api/verify', 'privatekey=def&remoteip=localhost&challenge=abc&response=def', {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(['foo', goodwords_resp])
|
154
153
|
Net::HTTP.expects(:Proxy).with('fubar', nil).returns(stub_proxy)
|
155
154
|
client = new_client
|
156
155
|
assert client.validate('localhost', 'abc', 'def', err_stub)
|
@@ -212,7 +211,7 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
212
211
|
end
|
213
212
|
def test_get_captcha_is_correct_with_constants_and_with_options
|
214
213
|
expected= <<-EOF
|
215
|
-
<script type=\"text/javascript\" src=\"http://
|
214
|
+
<script type=\"text/javascript\" src=\"http://www.google.com/recaptcha/api/challenge?k=%s\"> </script>\n <noscript>\n <iframe src=\"http://www.google.com/recaptcha/api/noscript?k=%s\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\" \n value=\"manual_challenge\">\n </noscript>
|
216
215
|
EOF
|
217
216
|
# first, with constants
|
218
217
|
ReCaptcha::ViewHelper.define_public_key # 'foo'
|
@@ -305,21 +304,21 @@ class TestRecaptcha < Test::Unit::TestCase
|
|
305
304
|
|
306
305
|
def test_get_captcha_uses_http_without_options
|
307
306
|
expected= <<-EOF
|
308
|
-
<script type=\"text/javascript\" src=\"http://
|
307
|
+
<script type=\"text/javascript\" src=\"http://www.google.com/recaptcha/api/challenge?k=%s\"> </script>\n <noscript>\n <iframe src=\"http://www.google.com/recaptcha/api/noscript?k=%s\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\" \n value=\"manual_challenge\">\n </noscript>
|
309
308
|
EOF
|
310
309
|
actual = @vf.get_captcha(:rcc_pub => 'foobar', :rcc_priv => 'blegga')
|
311
310
|
assert_equal(((expected % ['foobar', 'foobar']).strip), actual.strip)
|
312
311
|
end
|
313
312
|
def test_get_captcha_uses_https_with_options_true
|
314
313
|
expected= <<-EOF
|
315
|
-
<script type=\"text/javascript\" src=\"https://
|
314
|
+
<script type=\"text/javascript\" src=\"https://www.google.com/recaptcha/api/challenge?k=%s\"> </script>\n <noscript>\n <iframe src=\"https://www.google.com/recaptcha/api/noscript?k=%s\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\" \n value=\"manual_challenge\">\n </noscript>
|
316
315
|
EOF
|
317
316
|
actual = @vf.get_captcha(:rcc_pub => 'foobar', :rcc_priv => 'blegga', :ssl => true)
|
318
317
|
assert_equal(((expected % ['foobar', 'foobar']).strip), actual.strip)
|
319
318
|
end
|
320
319
|
def test_get_captcha_uses_http_with_options_false
|
321
320
|
expected= <<-EOF
|
322
|
-
<script type=\"text/javascript\" src=\"http://
|
321
|
+
<script type=\"text/javascript\" src=\"http://www.google.com/recaptcha/api/challenge?k=%s\"> </script>\n <noscript>\n <iframe src=\"http://www.google.com/recaptcha/api/noscript?k=%s\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\" \n value=\"manual_challenge\">\n </noscript>
|
323
322
|
EOF
|
324
323
|
actual = @vf.get_captcha(:rcc_pub => 'foobar', :rcc_priv => 'blegga', :ssl => false)
|
325
324
|
assert_equal(((expected % ['foobar', 'foobar']).strip), actual.strip)
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-recaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- McClain Looney
|
@@ -9,29 +15,41 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2011-04-27 00:00:00 -05:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: hoe
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 5
|
33
|
+
- 0
|
23
34
|
version: 2.5.0
|
24
|
-
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
25
37
|
- !ruby/object:Gem::Dependency
|
26
38
|
name: hoe
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
30
42
|
requirements:
|
31
43
|
- - ">="
|
32
44
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
45
|
+
hash: 35
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 9
|
49
|
+
- 4
|
50
|
+
version: 2.9.4
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
35
53
|
description: ""
|
36
54
|
email:
|
37
55
|
- m@loonsoft.com
|
@@ -47,6 +65,9 @@ files:
|
|
47
65
|
- README.txt
|
48
66
|
- lib/recaptcha.rb
|
49
67
|
- lib/ruby-recaptcha.rb
|
68
|
+
- test/test_helper.rb
|
69
|
+
- test/test_recaptcha.rb
|
70
|
+
- .gemtest
|
50
71
|
has_rdoc: true
|
51
72
|
homepage: http://www.bitbucket.org/mml/ruby-recaptcha
|
52
73
|
licenses: []
|
@@ -58,21 +79,27 @@ rdoc_options:
|
|
58
79
|
require_paths:
|
59
80
|
- lib
|
60
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
61
83
|
requirements:
|
62
84
|
- - ">="
|
63
85
|
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
64
89
|
version: "0"
|
65
|
-
version:
|
66
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
67
92
|
requirements:
|
68
93
|
- - ">="
|
69
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
70
98
|
version: "0"
|
71
|
-
version:
|
72
99
|
requirements: []
|
73
100
|
|
74
101
|
rubyforge_project: ruby-recaptcha
|
75
|
-
rubygems_version: 1.
|
102
|
+
rubygems_version: 1.4.2
|
76
103
|
signing_key:
|
77
104
|
specification_version: 3
|
78
105
|
summary: ""
|