Sha256: ba7cda552f96f1adacf209ddef46b5ef98856afb60336348cbcfee8c615f3278

Contents?: true

Size: 1010 Bytes

Versions: 4

Compression:

Stored size: 1010 Bytes

Contents

with_rackup('basic_auth.ru') do
  Shindo.tests('Excon basics (Authorization data redacted)') do
    cases = [
             ['user & pass', 'http://user1:pass1@foo.com/', 'Basic dXNlcjE6cGFzczE='],
             ['user no pass', 'http://three_user@foo.com/', 'Basic dGhyZWVfdXNlcjo='],
             ['pass no user', 'http://:derppass@foo.com/', 'Basic OmRlcnBwYXNz']
            ]
    cases.each do |desc,url,auth_header|
      conn = Excon.new(url)

      test("authorization header concealed for #{desc}") do
        !conn.inspect.include?(auth_header)
      end

      test("authorization header remains correct for #{desc}") do
        conn.data[:headers]['Authorization'] == auth_header
      end

      if conn.data[:password]
        test("password param concealed for #{desc}") do
          !conn.inspect.include?(conn.data[:password])
        end
      end

      test("password param remains correct for #{desc}") do
        conn.data[:password] == URI.parse(url).password
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrant-shell-0.2.6 vendor/bundle/gems/excon-0.20.1/tests/authorization_header_tests.rb
vagrant-shell-0.2.5 vendor/bundle/gems/excon-0.20.1/tests/authorization_header_tests.rb
excon-0.20.1 tests/authorization_header_tests.rb
excon-0.20.0 tests/authorization_header_tests.rb