Skip to content

Commit

Permalink
Merge pull request #170 from wazery/fix_method_name_type
Browse files Browse the repository at this point in the history
Fix method name typo
  • Loading branch information
gsamokovarov committed Oct 24, 2015
2 parents ca5fa48 + 3dd2e6a commit c8b7fc8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
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

0 comments on commit c8b7fc8

Please sign in to comment.