Skip to content
Browse files

Merge remote-tracking branch 'jmoses/master' into development

  • Loading branch information...
2 parents b4a68e0 + b7467c8 commit 46d9d468d7b161b0763aaccfcc13ec881f07834d @bhb committed Dec 12, 2011
View
4 lib/rack/perftools_profiler/action.rb
@@ -17,7 +17,9 @@ def act
def self.for_env(env, profiler, middleware)
request = Rack::Request.new(env)
klass =
- if !profiler.password_valid?(request.GET['profile'])
+ if profiler.should_check_password? && ! request.GET.key?('profile')
+ CallAppDirectly
+ elsif !profiler.password_valid?(request.GET['profile'])
ReturnPasswordError
else
case request.path_info
View
6 lib/rack/perftools_profiler/profiler.rb
@@ -58,7 +58,11 @@ def self.clear_data
def password_valid?(password)
@password.nil? || password == @password
end
-
+
+ def should_check_password?
+ ! @password.nil?
+ end
+
def start(mode = nil)
ensure_mode_is_changeable(mode) if mode
PerfTools::CpuProfiler.stop
View
12 test/single_request_profiling_test.rb
@@ -330,6 +330,18 @@ def setup
end
context "when a profile password is required" do
+ should "call the app directly when 'profile' is not a request parameter" do
+ env = Rack::MockRequest.env_for('/', :params => {})
+ app = lambda do |env|
+ request = Rack::Request.new(env)
+ assert_equal( {}, request.GET)
+ [200, {}, ["HI"]]
+ end
+ status, headers, body = Rack::PerftoolsProfiler.new(app, :default_printer => 'pdf', :password => "secret_password").call(env)
+ assert_equal 200, status
+ assert_equal ["HI"], body
+ end
+
should "error if password does not match" do
app = @app.clone
env = Rack::MockRequest.env_for('/', :params => {'profile' => 'true'})

0 comments on commit 46d9d46

Please sign in to comment.
Something went wrong with that request. Please try again.