request_recorder 0.3.0 → 0.3.1
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/Gemfile.lock +1 -1
- data/Readme.md +1 -1
- data/gemfiles/rails2.gemfile.lock +2 -2
- data/gemfiles/rails3.gemfile.lock +1 -1
- data/lib/request_recorder/middleware.rb +11 -5
- data/lib/request_recorder/version.rb +1 -1
- data/spec/request_recorder_spec.rb +11 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -12,7 +12,7 @@ Add to your middleware stack:
|
|
12
12
|
require "request_recorder/cache_logger"
|
13
13
|
use RequestRecorder::Middleware,
|
14
14
|
:store => RequestRecorder::CacheLogger.new(Rails.cache),
|
15
|
-
:frontend_auth => lambda { |env| Rails.env.development? } # TODO use something like `env.warden.user.is_admin?` in production
|
15
|
+
:frontend_auth => lambda { |env| Rails.env.development? } # TODO use something like `env.warden.user.is_admin?` in production, or return a [status, headers, body] array for custom failure message
|
16
16
|
# if you get 502's because of too large headers, you can reduce them: everything in :remove will be removed when above :max
|
17
17
|
# :headers => {:max => 10_000, :remove => [/Identity Map/, /Cache local read/, /Cache read/, /SELECT count(\*)/, /SELECT \* FROM/] }
|
18
18
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/mgrosser/code/tools/request_recorder
|
3
3
|
specs:
|
4
|
-
request_recorder (0.
|
4
|
+
request_recorder (0.3.0)
|
5
5
|
activerecord
|
6
6
|
logcast (>= 0.1.4)
|
7
7
|
multi_json
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
redis (~> 3.0.0)
|
23
23
|
json (1.7.7)
|
24
24
|
logcast (0.1.4)
|
25
|
-
multi_json (1.7.
|
25
|
+
multi_json (1.7.3)
|
26
26
|
rack (1.1.6)
|
27
27
|
rake (10.0.4)
|
28
28
|
redis (3.0.3)
|
@@ -48,7 +48,9 @@ module RequestRecorder
|
|
48
48
|
raise result # Do not mess up the apps normal exception behavior
|
49
49
|
else
|
50
50
|
path = [env["PATH_INFO"], env["QUERY_STRING"]].compact.join("?")
|
51
|
-
|
51
|
+
if @auth && auth = @auth.call(env)
|
52
|
+
extra_headers = chrome_logger_headers(log, path) unless auth.is_a?(Array)
|
53
|
+
end
|
52
54
|
response_with_data_in_cookie(result, steps_left, id, extra_headers)
|
53
55
|
end
|
54
56
|
end
|
@@ -58,11 +60,15 @@ module RequestRecorder
|
|
58
60
|
|
59
61
|
def render_frontend(env, key)
|
60
62
|
if @auth
|
61
|
-
if @auth.call(env)
|
62
|
-
if
|
63
|
-
|
63
|
+
if response = @auth.call(env)
|
64
|
+
if response.is_a?(Array)
|
65
|
+
response
|
64
66
|
else
|
65
|
-
|
67
|
+
if log = @store.read(key)
|
68
|
+
[200, {}, Frontend.render(log)]
|
69
|
+
else
|
70
|
+
[404, {}, "Did not find a log for key #{key}"]
|
71
|
+
end
|
66
72
|
end
|
67
73
|
else
|
68
74
|
[401, {}, "Unauthorized"]
|
@@ -141,6 +141,12 @@ describe RequestRecorder do
|
|
141
141
|
body.should_not include("yyy")
|
142
142
|
end
|
143
143
|
|
144
|
+
it "returns custom auth failure response" do
|
145
|
+
status, headers, body = middleware.call("PATH_INFO" => "/request_recorder/xxx", "success" => [422, {}, "Barfoo"])
|
146
|
+
status.should == 422
|
147
|
+
body.should include("Barfoo")
|
148
|
+
end
|
149
|
+
|
144
150
|
it "cannot view a missing log" do
|
145
151
|
status, headers, body = middleware.call("PATH_INFO" => "/request_recorder/missing-key", "success" => true)
|
146
152
|
status.should == 404
|
@@ -179,6 +185,11 @@ describe RequestRecorder do
|
|
179
185
|
status, headers, body = middleware.call("QUERY_STRING" => "request_recorder=10-xxx")
|
180
186
|
headers["X-ChromeLogger-Data"].should == nil
|
181
187
|
end
|
188
|
+
|
189
|
+
it "does not log with array response from frontend_auth" do
|
190
|
+
status, headers, body = middleware.call("QUERY_STRING" => "request_recorder=10-xxx", "success" => [302, {}, "asdas"])
|
191
|
+
headers["X-ChromeLogger-Data"].should == nil
|
192
|
+
end
|
182
193
|
end
|
183
194
|
end
|
184
195
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request_recorder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: 480702955277085282
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
none: false
|
125
125
|
requirements:
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
segments:
|
130
130
|
- 0
|
131
|
-
hash:
|
131
|
+
hash: 480702955277085282
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
134
|
rubygems_version: 1.8.25
|