Skip to content

Commit

Permalink
Supress known warnings during test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshi Nakamura committed Apr 19, 2012
1 parent c041811 commit 285cf2f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ def default_redirect_uri_callback(uri, res)
newuri = URI.parse(res.header['location'][0])
unless newuri.is_a?(URI::HTTP)
newuri = uri + newuri
STDERR.puts("could be a relative URI in location header which is not recommended")
STDERR.puts("'The field value consists of a single absolute URI' in HTTP spec")
warn("could be a relative URI in location header which is not recommended")
warn("'The field value consists of a single absolute URI' in HTTP spec")
end
if https?(uri) && !https?(newuri)
raise BadResponseError.new("redirecting to non-https resource")
Expand Down
3 changes: 3 additions & 0 deletions test/test_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ def setup_server
htdigest = File.join(File.dirname(__FILE__), 'htdigest')
htdigest_userdb = WEBrick::HTTPAuth::Htdigest.new(htdigest)
@basic_auth = WEBrick::HTTPAuth::BasicAuth.new(
:Logger => @logger,
:Realm => 'auth',
:UserDB => htpasswd_userdb
)
@digest_auth = WEBrick::HTTPAuth::DigestAuth.new(
:Logger => @logger,
:Algorithm => 'MD5',
:Realm => 'auth',
:UserDB => htdigest_userdb
)
@digest_sess_auth = WEBrick::HTTPAuth::DigestAuth.new(
:Logger => @logger,
:Algorithm => 'MD5-sess',
:Realm => 'auth',
:UserDB => htdigest_userdb
Expand Down
17 changes: 15 additions & 2 deletions test/test_httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@ def test_redirect_non_https

def test_redirect_relative
@client.test_loopback_http_response << "HTTP/1.0 302 OK\nLocation: hello\n\n"
assert_equal('hello', @client.get_content(serverurl + 'redirect1'))
silent do
assert_equal('hello', @client.get_content(serverurl + 'redirect1'))
end
#
@client.reset_all
@client.redirect_uri_callback = @client.method(:strict_redirect_uri_callback)
Expand All @@ -437,7 +439,9 @@ def test_redirect_https_relative
https_url.scheme = 'https'
@client.test_loopback_http_response << "HTTP/1.0 302 OK\nLocation: /foo\n\n"
@client.test_loopback_http_response << "HTTP/1.0 200 OK\n\nhello"
assert_equal('hello', @client.get_content(https_url))
silent do
assert_equal('hello', @client.get_content(https_url))
end
end

def test_no_content
Expand Down Expand Up @@ -1415,6 +1419,15 @@ def test_charset

private

def silent
begin
back, $VERBOSE = $VERBOSE, nil
yield
ensure
$VERBOSE = back
end
end

def check_query_get(query)
WEBrick::HTTPUtils.parse_query(
@client.get(serverurl + 'servlet', query).header["x-query"][0]
Expand Down

0 comments on commit 285cf2f

Please sign in to comment.