Sha256: bd395d257f72eed6dadb5574f29f12b0dabbd8c8f4ce23d8fcfc8c0b424613c8

Contents?: true

Size: 972 Bytes

Versions: 7

Compression:

Stored size: 972 Bytes

Contents

class TestCurbCurlProtocols < Test::Unit::TestCase
  include TestServerMethods

  def setup
    @easy = Curl::Easy.new
    @easy.set :protocols, Curl::CURLPROTO_HTTP | Curl::CURLPROTO_HTTPS
    @easy.follow_location = true
    server_setup
  end

  def test_protocol_allowed
    @easy.set :url, "http://127.0.0.1:9129/this_file_does_not_exist.html"
    @easy.perform
    assert_equal 404, @easy.response_code
  end

  def test_protocol_denied
    @easy.set :url, "gopher://google.com/"
    assert_raises Curl::Err::UnsupportedProtocolError do
      @easy.perform
    end
  end

  def test_redir_protocol_allowed
    @easy.set :url, TestServlet.url + "/redirect"
    @easy.set :redir_protocols, Curl::CURLPROTO_HTTP
    @easy.perform
  end

  def test_redir_protocol_denied
    @easy.set :url, TestServlet.url + "/redirect"
    @easy.set :redir_protocols, Curl::CURLPROTO_HTTPS
    assert_raises Curl::Err::UnsupportedProtocolError do
      @easy.perform
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curb-1.0.6 tests/tc_curl_protocols.rb
curb-1.0.5 tests/tc_curl_protocols.rb
curb-1.0.4 tests/tc_curl_protocols.rb
curb-1.0.3 tests/tc_curl_protocols.rb
curb-1.0.2 tests/tc_curl_protocols.rb
curb-1.0.1 tests/tc_curl_protocols.rb
curb-1.0.0 tests/tc_curl_protocols.rb