rack-pooledthrottle 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f17681ae19c501bb8f4194f2d7e9389f3aae51ee
4
- data.tar.gz: 6349f697567a2cbc6f3a04248e710dbd36c253eb
3
+ metadata.gz: 93f678ed4ba1803eb76022038615a86360dcf110
4
+ data.tar.gz: 487c6c5332cc4469e6bba491a2233210d0db9468
5
5
  SHA512:
6
- metadata.gz: 2431de24d6e9c40b2f5e0b2b0f5bfdca57d5ae38b5b99e3c3cec3698c258f3cb56d52efbd30472071ca568046b5c5dcbc1784fff2208880ec31eb080eb8ecf1d
7
- data.tar.gz: 68eec81e9a722fc99bcbdc66a3cec630ed20500188854bea77ca48f77c83b46a950958b2756a0061f97569ccb4908e5ddbb5cf8e57f3307ad9772552251309f7
6
+ metadata.gz: 8c4f7308d1fa6628ce4fbfee90a68719de280646f5a47d4a79056cdd95d3835f906489a21c75f74213ceea3b1c6eb7eb49527b5d2fbdfaa80746964f57cf4328
7
+ data.tar.gz: 4d39db54a3c1a065ad50ece2638705639281fdedb982087ae1ecd8d334feaef1f20bb9228a0f5bd0f6af349a2e5edbd4b3affb32e548a7f7a78544083acac04a
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ rack-pooled*.gem
@@ -28,11 +28,19 @@ module Rack
28
28
  end
29
29
 
30
30
  def whitelisted?(request)
31
- false
31
+ if wl = options[:whitelisted]
32
+ wl.call(request)
33
+ else
34
+ false
35
+ end
32
36
  end
33
37
 
34
38
  def blacklisted?(request)
35
- false
39
+ if bl = options[:blacklisted]
40
+ bl.call(request)
41
+ else
42
+ false
43
+ end
36
44
  end
37
45
 
38
46
  def cache_key(request)
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Pooledthrottle
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -45,8 +45,30 @@ describe Rack::PooledThrottle::MemcachedThrottle do
45
45
  expect(last_response.body).to show_throttled_response
46
46
  end
47
47
 
48
+ it "should allow blacklisted? to be overridden" do
49
+ @options[:blacklisted] = ->(request){true}
50
+ get "/foo"
51
+ expect(last_response.body).to show_throttled_response
52
+ end
53
+
54
+ it "should allow whitelisted? to be overridden" do
55
+ @options[:whitelisted] = ->(request){true}
56
+ 4.times {get "/foo"}
57
+ expect(last_response.body).to show_allowed_response
58
+ end
59
+
60
+ it 'should execute the rate_limit_exceeded_callback if it is defined' do
61
+ callback = Object.new
62
+ expect(callback).to receive(:call)
63
+ @options[:rate_limit_exceeded_callback] = callback
64
+ @options[:max] = 0
65
+ get '/foo'
66
+ expect(last_response.body).to show_throttled_response
67
+
68
+ end
69
+
48
70
 
49
- it 'should allow the client_identifier to be overriden and pass' do
71
+ it 'should allow the client_identifier to be overridden and pass' do
50
72
  @options[:max] = 2
51
73
  @options[:client_identifier] = ->(request){request.params['email']}
52
74
  2.times {get('/foo', email: 'scottwater@gmail.com')}
@@ -54,7 +76,7 @@ describe Rack::PooledThrottle::MemcachedThrottle do
54
76
  expect(last_response.body).to show_allowed_response
55
77
  end
56
78
 
57
- it 'should allow the client_identifier to be overriden and fail' do
79
+ it 'should allow the client_identifier to be overridden and fail' do
58
80
  @options[:max] = 2
59
81
  @options[:client_identifier] = ->(request){request.params['email']}
60
82
  2.times {get('/foo', email: 'scottwater@gmail.com')}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-pooledthrottle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Watermasysk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-08 00:00:00.000000000 Z
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack