Sha256: 4e0ed0b2fae5a2dddd98b4581581accf3711941307cda9a7bee595bd61d465bf

Contents?: true

Size: 1.97 KB

Versions: 42

Compression:

Stored size: 1.97 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
require 'new_relic/agent/http_clients/uri_util'

class URIUtilTest < Minitest::Test

  def test_filter_uri
    assert_filtered("http://foo.com/bar/baz",
                    "http://foo.com/bar/baz")
  end

  def test_filter_uri_custom_port
    assert_filtered("http://foo.com:1234/bar/baz",
                    "http://foo.com:1234/bar/baz")
  end

  def test_filtered_uri_omits_query_params
    assert_filtered("http://foo.com/bar/baz?a=1&b=2",
                    "http://foo.com/bar/baz")
  end

  def test_filtered_uri_omits_fragment
    assert_filtered("http://foo.com/bar/baz#fragment",
                    "http://foo.com/bar/baz")
  end

  def test_filtered_uri_omits_query_params_and_fragment
    assert_filtered("http://foo.com/bar/baz?a=1&b=2#fragment",
                    "http://foo.com/bar/baz")
  end

  def test_filtered_uri_reflects_use_of_ssl
    assert_filtered('https://foo.com/bar/baz',
                    "https://foo.com/bar/baz")
  end

  def test_filtered_uri_reflects_use_of_ssl_with_custom_port
    assert_filtered('https://foo.com:9999/bar/baz',
                    "https://foo.com:9999/bar/baz")
  end

  def test_filter_uri_with_full_uri_request_path
    assert_filtered("http://foo.com/bar/baz?a=1&b=2#fragment",
                    "http://foo.com/bar/baz")
  end

  def test_filter_uri_with_full_uri_request_path_https
    assert_filtered("https://foo.com/bar/baz?a=1&b=2#fragment",
                    "https://foo.com/bar/baz")
  end

  def test_strips_credentials_embedded_in_uri
    assert_filtered("http://user:pass@foo.com/bar/baz",
                    "http://foo.com/bar/baz")
  end

  def assert_filtered(original, expected)
    assert_equal(expected, NewRelic::Agent::HTTPClients::URIUtil.filter_uri(URI(original)))
  end

end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
newrelic_rpm-4.1.0.333 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-4.0.0.332 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.18.1.330 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.18.0.329 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.17.2.327 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.17.1.326 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.17.0.325 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.16.3.323 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.16.2.321 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.16.1.320 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.16.0.318 test/new_relic/agent/http_clients/uri_util_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.15.2.317 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.15.1.316 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.15.0.314 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.14.3.313 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.14.2.312 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.14.1.311 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.14.0.305 test/new_relic/agent/http_clients/uri_util_test.rb
newrelic_rpm-3.13.2.302 test/new_relic/agent/http_clients/uri_util_test.rb