Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix method name typo #170

Merged
merged 1 commit into from
Oct 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/web_console/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(app)

def call(env)
request = create_regular_or_whiny_request(env)
return @app.call(env) unless request.from_whitelited_ip?
return @app.call(env) unless request.from_whitelisted_ip?

if id = id_for_repl_session_update(request)
return update_repl_session(id, request)
Expand Down
2 changes: 1 addition & 1 deletion lib/web_console/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Request < ActionDispatch::Request
#
# For a request to hit Web Console features, it needs to come from a white
# listed IP.
def from_whitelited_ip?
def from_whitelisted_ip?
whitelisted_ips.include?(strict_remote_ip)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/web_console/whiny_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module WebConsole
# If any calls to +from_whitelisted_ip?+ and +acceptable_content_type?+
# return false, an info log message will be displayed in users' logs.
class WhinyRequest < SimpleDelegator
def from_whitelited_ip?
whine_unless request.from_whitelited_ip? do
def from_whitelisted_ip?
whine_unless request.from_whitelisted_ip? do
"Cannot render console from #{request.remote_ip}! " \
"Allowed networks: #{request.whitelisted_ips}"
end
Expand Down
16 changes: 8 additions & 8 deletions test/web_console/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ class RequestTest < ActiveSupport::TestCase
Request.stubs(:whitelisted_ips).returns(IPAddr.new('127.0.0.1'))
end

test '#from_whitelited_ip? is falsy for blacklisted IPs' do
test '#from_whitelisted_ip? is falsy for blacklisted IPs' do
req = request('http://example.com', 'REMOTE_ADDR' => '0.0.0.0')

assert_not req.from_whitelited_ip?
assert_not req.from_whitelisted_ip?
end

test '#from_whitelited_ip? is truthy for whitelisted IPs' do
test '#from_whitelisted_ip? is truthy for whitelisted IPs' do
req = request('http://example.com', 'REMOTE_ADDR' => '127.0.0.1')

assert req.from_whitelited_ip?
assert req.from_whitelisted_ip?
end

test '#from_whitelisted_ip? is truthy for whitelisted IPs via whitelisted proxies' do
req = request('http://example.com', 'REMOTE_ADDR' => '127.0.0.1', 'HTTP_X_FORWARDED_FOR' => '127.0.0.0')

assert req.from_whitelited_ip?
assert req.from_whitelisted_ip?
end

test '#from_whitelisted_ip? is falsy for blacklisted IPs via whitelisted proxies' do
req = request('http://example.com', 'REMOTE_ADDR' => '127.0.0.1', 'HTTP_X_FORWARDED_FOR' => '0.0.0.0')

assert_not req.from_whitelited_ip?
assert_not req.from_whitelisted_ip?
end

test '#from_whitelisted_ip? is falsy for lying blacklisted IPs via whitelisted proxies' do
req = request('http://example.com', 'REMOTE_ADDR' => '127.0.0.1', 'HTTP_X_FORWARDED_FOR' => '10.0.0.0, 127.0.0.0')

assert_not req.from_whitelited_ip?
assert_not req.from_whitelisted_ip?
end

test '#from_whitelisted_ip? is falsy for whitelisted IPs via blacklisted proxies' do
req = request('http://example.com', 'REMOTE_ADDR' => '10.0.0.0', 'HTTP_X_FORWARDED_FOR' => '127.0.0.0')

assert_not req.from_whitelited_ip?
assert_not req.from_whitelisted_ip?
end

test '#acceptable? is truthy for current version' do
Expand Down
4 changes: 2 additions & 2 deletions test/web_console/whiny_request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

module WebConsole
class WhinyRequestTest < ActiveSupport::TestCase
test '#from_whitelited_ip? logs out to stderr' do
test '#from_whitelisted_ip? logs out to stderr' do
Request.stubs(:whitelisted_ips).returns(IPAddr.new('127.0.0.1'))
assert_output_to_stderr do
req = request('http://example.com', 'REMOTE_ADDR' => '0.0.0.0')
assert_not req.from_whitelited_ip?
assert_not req.from_whitelisted_ip?
end
end

Expand Down