captcher 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6486,6 +6486,181 @@ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
6486
6486
   (0.1ms) rollback transaction
6487
6487
   (0.1ms) begin transaction
6488
6488
  Started POST "/captcher/captcha/confirm" for 127.0.0.1 at 2019-03-26 01:04:52 +0300
6489
+ Processing by Captcher::CaptchasController#confirm as HTML
6490
+ Parameters: {"confirmation"=>"IIIII"}
6491
+ Completed 422 Unprocessable Entity in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
6492
+  (0.1ms) rollback transaction
6493
+  (0.1ms) begin transaction
6494
+  (0.1ms) rollback transaction
6495
+  (0.0ms) begin transaction
6496
+  (0.0ms) rollback transaction
6497
+  (0.0ms) begin transaction
6498
+  (0.0ms) rollback transaction
6499
+  (0.0ms) begin transaction
6500
+  (0.0ms) rollback transaction
6501
+  (0.0ms) begin transaction
6502
+  (0.1ms) rollback transaction
6503
+  (0.1ms) begin transaction
6504
+  (0.1ms) rollback transaction
6505
+  (0.1ms) begin transaction
6506
+  (0.1ms) rollback transaction
6507
+  (0.1ms) begin transaction
6508
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 22:15:35 +0300
6509
+ Processing by Captcher::CaptchasController#show as HTML
6510
+ Rendering text template
6511
+ Rendered text template (0.0ms)
6512
+ Sent data captcha.png (4.2ms)
6513
+ Completed 200 OK in 57ms (Views: 3.9ms | ActiveRecord: 0.0ms)
6514
+  (0.1ms) rollback transaction
6515
+  (0.0ms) begin transaction
6516
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 22:15:35 +0300
6517
+ Processing by Captcher::CaptchasController#show as HTML
6518
+ Rendering text template
6519
+ Rendered text template (0.0ms)
6520
+ Sent data captcha.png (0.5ms)
6521
+ Completed 200 OK in 48ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6522
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 22:15:35 +0300
6523
+ Processing by Captcher::CaptchasController#show as HTML
6524
+ Rendering text template
6525
+ Rendered text template (0.0ms)
6526
+ Sent data captcha.png (0.9ms)
6527
+ Completed 200 OK in 52ms (Views: 0.6ms | ActiveRecord: 0.0ms)
6528
+  (0.1ms) rollback transaction
6529
+  (0.1ms) begin transaction
6530
+ Started POST "/captcher/captcha/refresh" for 127.0.0.1 at 2019-03-26 22:15:35 +0300
6531
+ Processing by Captcher::CaptchasController#refresh as HTML
6532
+ Rendering text template
6533
+ Rendered text template (0.0ms)
6534
+ Sent data captcha.png (0.6ms)
6535
+ Completed 200 OK in 49ms (Views: 0.4ms | ActiveRecord: 0.0ms)
6536
+ Started POST "/captcher/captcha/refresh" for 127.0.0.1 at 2019-03-26 22:15:35 +0300
6537
+ Processing by Captcher::CaptchasController#refresh as HTML
6538
+ Rendering text template
6539
+ Rendered text template (0.0ms)
6540
+ Sent data captcha.png (0.4ms)
6541
+ Completed 200 OK in 45ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6542
+  (0.1ms) rollback transaction
6543
+  (0.1ms) begin transaction
6544
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 22:15:36 +0300
6545
+ Processing by Captcher::CaptchasController#show as HTML
6546
+ Rendering text template
6547
+ Rendered text template (0.0ms)
6548
+ Sent data captcha.png (0.4ms)
6549
+ Completed 200 OK in 67ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6550
+ Started POST "/captcher/captcha/confirm" for 127.0.0.1 at 2019-03-26 22:15:36 +0300
6551
+ Processing by Captcher::CaptchasController#confirm as HTML
6552
+ Parameters: {"confirmation"=>"SKOmi"}
6553
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
6554
+  (0.1ms) rollback transaction
6555
+  (0.1ms) begin transaction
6556
+ Started POST "/captcher/captcha/confirm" for 127.0.0.1 at 2019-03-26 22:15:36 +0300
6557
+ Processing by Captcher::CaptchasController#confirm as HTML
6558
+ Parameters: {"confirmation"=>"IIIII"}
6559
+ Completed 422 Unprocessable Entity in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
6560
+  (0.1ms) rollback transaction
6561
+  (0.1ms) begin transaction
6562
+  (0.1ms) rollback transaction
6563
+  (0.0ms) begin transaction
6564
+  (0.0ms) rollback transaction
6565
+  (0.1ms) begin transaction
6566
+  (0.0ms) rollback transaction
6567
+  (0.0ms) begin transaction
6568
+  (0.1ms) rollback transaction
6569
+  (0.1ms) begin transaction
6570
+  (0.1ms) begin transaction
6571
+  (0.2ms) rollback transaction
6572
+  (0.0ms) begin transaction
6573
+  (0.0ms) rollback transaction
6574
+  (0.1ms) begin transaction
6575
+  (0.1ms) rollback transaction
6576
+  (0.0ms) begin transaction
6577
+  (0.0ms) rollback transaction
6578
+  (0.0ms) begin transaction
6579
+  (0.1ms) rollback transaction
6580
+  (0.1ms) begin transaction
6581
+  (0.1ms) rollback transaction
6582
+  (0.0ms) begin transaction
6583
+  (0.0ms) rollback transaction
6584
+  (0.0ms) begin transaction
6585
+  (0.1ms) rollback transaction
6586
+  (0.0ms) begin transaction
6587
+  (0.0ms) rollback transaction
6588
+  (0.0ms) begin transaction
6589
+  (0.0ms) rollback transaction
6590
+  (0.1ms) begin transaction
6591
+  (0.0ms) rollback transaction
6592
+  (0.0ms) begin transaction
6593
+  (0.1ms) rollback transaction
6594
+  (0.0ms) begin transaction
6595
+  (0.1ms) rollback transaction
6596
+  (0.0ms) begin transaction
6597
+  (0.0ms) rollback transaction
6598
+  (0.0ms) begin transaction
6599
+  (0.0ms) rollback transaction
6600
+  (0.0ms) begin transaction
6601
+  (0.0ms) rollback transaction
6602
+  (0.0ms) begin transaction
6603
+  (0.0ms) rollback transaction
6604
+  (0.0ms) begin transaction
6605
+  (0.1ms) rollback transaction
6606
+  (0.0ms) begin transaction
6607
+  (0.0ms) rollback transaction
6608
+  (0.0ms) begin transaction
6609
+  (0.0ms) rollback transaction
6610
+  (0.0ms) begin transaction
6611
+  (0.0ms) rollback transaction
6612
+  (0.0ms) begin transaction
6613
+  (0.0ms) rollback transaction
6614
+  (0.1ms) begin transaction
6615
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6616
+ Processing by Captcher::CaptchasController#show as HTML
6617
+ Rendering text template
6618
+ Rendered text template (0.0ms)
6619
+ Sent data captcha.png (2.7ms)
6620
+ Completed 200 OK in 40ms (Views: 2.5ms | ActiveRecord: 0.0ms)
6621
+  (0.1ms) rollback transaction
6622
+  (0.0ms) begin transaction
6623
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6624
+ Processing by Captcher::CaptchasController#show as HTML
6625
+ Rendering text template
6626
+ Rendered text template (0.0ms)
6627
+ Sent data captcha.png (0.4ms)
6628
+ Completed 200 OK in 31ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6629
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6630
+ Processing by Captcher::CaptchasController#show as HTML
6631
+ Rendering text template
6632
+ Rendered text template (0.0ms)
6633
+ Sent data captcha.png (0.4ms)
6634
+ Completed 200 OK in 30ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6635
+  (0.1ms) rollback transaction
6636
+  (0.0ms) begin transaction
6637
+ Started POST "/captcher/captcha/refresh" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6638
+ Processing by Captcher::CaptchasController#refresh as HTML
6639
+ Rendering text template
6640
+ Rendered text template (0.0ms)
6641
+ Sent data captcha.png (0.4ms)
6642
+ Completed 200 OK in 31ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6643
+ Started POST "/captcher/captcha/refresh" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6644
+ Processing by Captcher::CaptchasController#refresh as HTML
6645
+ Rendering text template
6646
+ Rendered text template (0.0ms)
6647
+ Sent data captcha.png (0.4ms)
6648
+ Completed 200 OK in 32ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6649
+  (0.1ms) rollback transaction
6650
+  (0.0ms) begin transaction
6651
+ Started GET "/captcher/captcha" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6652
+ Processing by Captcher::CaptchasController#show as HTML
6653
+ Rendering text template
6654
+ Rendered text template (0.0ms)
6655
+ Sent data captcha.png (0.4ms)
6656
+ Completed 200 OK in 34ms (Views: 0.3ms | ActiveRecord: 0.0ms)
6657
+ Started POST "/captcher/captcha/confirm" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6658
+ Processing by Captcher::CaptchasController#confirm as HTML
6659
+ Parameters: {"confirmation"=>"aYDHX"}
6660
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
6661
+  (0.1ms) rollback transaction
6662
+  (0.1ms) begin transaction
6663
+ Started POST "/captcher/captcha/confirm" for 127.0.0.1 at 2019-03-26 23:25:48 +0300
6489
6664
  Processing by Captcher::CaptchasController#confirm as HTML
6490
6665
  Parameters: {"confirmation"=>"IIIII"}
6491
6666
  Completed 422 Unprocessable Entity in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
@@ -0,0 +1,3 @@
1
+ o: ActiveSupport::Cache::Entry : @valueI"
2
+ LtFPF:EF:
3
+ 3.6e3
@@ -0,0 +1,3 @@
1
+ o: ActiveSupport::Cache::Entry : @valueI"
2
+ fHluA:EF:
3
+ 3.6e3
@@ -0,0 +1,3 @@
1
+ o: ActiveSupport::Cache::Entry : @valueI"
2
+ yHHmS:EF:
3
+ 3.6e3
@@ -0,0 +1,3 @@
1
+ o: ActiveSupport::Cache::Entry : @valueI"
2
+ AwOuL:EF:
3
+ 3.6e3
@@ -0,0 +1,3 @@
1
+ o: ActiveSupport::Cache::Entry : @valueI"
2
+ MMSLO:EF:
3
+ 3.6e3
@@ -0,0 +1,49 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe Captcher::Captchas::CachedCaptcha do
4
+ let(:config) do
5
+ config = Captcher.config
6
+ config[:mode] = :cached_captcha
7
+ config
8
+ end
9
+ let(:own_config) { config[:cached_captcha] }
10
+ let(:captcha) { described_class.new(config: config) }
11
+
12
+ describe "#initialize" do
13
+ it "receives config for code_captcha" do
14
+ expect(captcha.own_config).to eq(own_config.with_indifferent_access)
15
+ end
16
+
17
+ it "generates a text when initialized" do
18
+ expect(captcha.payload.size).to eq(5)
19
+ end
20
+ end
21
+
22
+ describe "#represent" do
23
+ let(:raw_image) { captcha.represent(:html) }
24
+ let(:image_path) { "#{tmp_dir}/test.png" }
25
+ let(:validate_img) { system("convert #{image_path} -", out: "/dev/null") }
26
+
27
+ it "produces a valid png image" do
28
+ save_image(raw_image, image_path)
29
+ expect(File).to exist(image_path)
30
+ expect(validate_img).to eq(true)
31
+ end
32
+ end
33
+
34
+ describe "#validate" do
35
+ let(:payload) { "LVsll" }
36
+ let(:captcha) { described_class.new(config: config, payload: payload) }
37
+
38
+ it "accepts a valid confirmation code" do
39
+ expect(captcha.validate(" LVsll ")).to eq(true)
40
+ expect(captcha.validate("lvsll")).to eq(true)
41
+ expect(captcha.validate("LVSLL")).to eq(true)
42
+ end
43
+
44
+ it "declines invalid confirmation code" do
45
+ expect(captcha.validate("IIIII")).to eq(false)
46
+ expect(captcha.validate("")).to eq(false)
47
+ end
48
+ end
49
+ end
@@ -39,7 +39,7 @@ RSpec.configure do |config|
39
39
  end
40
40
 
41
41
  config.after(:suite) do
42
- # Helpers.remove_tmp_dir
42
+ Helpers.remove_tmp_dir
43
43
  end
44
44
 
45
45
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: captcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Zinovyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -126,6 +126,7 @@ files:
126
126
  - lib/captcher.rb
127
127
  - lib/captcher/base_captcha.rb
128
128
  - lib/captcher/captchas/awesome_captcha.rb
129
+ - lib/captcher/captchas/cached_captcha.rb
129
130
  - lib/captcher/captchas/code_captcha.rb
130
131
  - lib/captcher/captchas/math_captcha.rb
131
132
  - lib/captcher/config.rb
@@ -194,14 +195,22 @@ files:
194
195
  - spec/dummy/public/apple-touch-icon-precomposed.png
195
196
  - spec/dummy/public/apple-touch-icon.png
196
197
  - spec/dummy/public/favicon.ico
198
+ - spec/dummy/tmp/cache/043/151/captcher__cached__%3A7a99210142fee43c006bfe2ff927701b
199
+ - spec/dummy/tmp/cache/111/E31/captcher__cached__%3A5688ef242c39cd01f3bf4f2c7c6ebb5f
200
+ - spec/dummy/tmp/cache/D50/E10/captcher__cached__%3Acode_captcha%3A1
201
+ - spec/dummy/tmp/cache/D51/E20/captcher__cached__%3Acode_captcha%3A2
202
+ - spec/dummy/tmp/cache/D52/E30/captcher__cached__%3Acode_captcha%3A3
203
+ - spec/dummy/tmp/cache/D54/E50/captcher__cached__%3Acode_captcha%3A5
204
+ - spec/dummy/tmp/cache/D56/E70/captcher__cached__%3Acode_captcha%3A7
205
+ - spec/dummy/tmp/cache/FB2/D60/captcher__cached__%3A542081068251d2ec3b7f3e453b29750c
197
206
  - spec/dummy/tmp/development_secret.txt
198
207
  - spec/helpers.rb
208
+ - spec/lib/captcher/captchas/cached_captcha_spec.rb
209
+ - spec/lib/captcher/captchas/code_captcha_spec.rb
199
210
  - spec/lib/captcher/config_spec.rb
200
- - spec/models/captchas/code_captcha_spec.rb
201
211
  - spec/rails_helper.rb
202
212
  - spec/requests/captcha_management_spec.rb
203
213
  - spec/spec_helper.rb
204
- - spec/tmp/test.png
205
214
  homepage: https://github.com/zinovyev/captcher
206
215
  licenses:
207
216
  - MIT
@@ -281,11 +290,19 @@ test_files:
281
290
  - spec/dummy/public/apple-touch-icon-precomposed.png
282
291
  - spec/dummy/public/apple-touch-icon.png
283
292
  - spec/dummy/public/favicon.ico
293
+ - spec/dummy/tmp/cache/D56/E70/captcher__cached__%3Acode_captcha%3A7
294
+ - spec/dummy/tmp/cache/D54/E50/captcher__cached__%3Acode_captcha%3A5
295
+ - spec/dummy/tmp/cache/043/151/captcher__cached__%3A7a99210142fee43c006bfe2ff927701b
296
+ - spec/dummy/tmp/cache/D50/E10/captcher__cached__%3Acode_captcha%3A1
297
+ - spec/dummy/tmp/cache/D52/E30/captcher__cached__%3Acode_captcha%3A3
298
+ - spec/dummy/tmp/cache/D51/E20/captcher__cached__%3Acode_captcha%3A2
299
+ - spec/dummy/tmp/cache/FB2/D60/captcher__cached__%3A542081068251d2ec3b7f3e453b29750c
300
+ - spec/dummy/tmp/cache/111/E31/captcher__cached__%3A5688ef242c39cd01f3bf4f2c7c6ebb5f
284
301
  - spec/dummy/tmp/development_secret.txt
285
302
  - spec/spec_helper.rb
286
303
  - spec/requests/captcha_management_spec.rb
287
- - spec/models/captchas/code_captcha_spec.rb
288
304
  - spec/helpers.rb
289
- - spec/rails_helper.rb
290
305
  - spec/lib/captcher/config_spec.rb
291
- - spec/tmp/test.png
306
+ - spec/lib/captcher/captchas/code_captcha_spec.rb
307
+ - spec/lib/captcher/captchas/cached_captcha_spec.rb
308
+ - spec/rails_helper.rb
Binary file