Sha256: 697b9e1767fa671ae2dada39ed0959cafbcf1747df8e06a0e98997cd0619bf4f

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe 'Fetch proxy pac' do
  context '/v1/pac' do
    let(:valid_pac_file) do <<-EOS.strip_heredoc.chomp
                           function FindProxyForURL(url, host) {
                             return "DIRECT";
                           }
                           EOS
    end

    let(:git_repo) { 'git_repo' }

    before(:each) do
      git_init(git_repo)
      create_file(File.join(git_repo, 'file.pac'), valid_pac_file)
      git_add(git_repo, 'file.pac')
      git_commit(git_repo)
    end

    def app
      config = Class.new do
        include FeduxOrg::Stdlib::Filesystem

        def root_directory
          File.expand_path('../../../', __FILE__)
        end

        def local_storage
          File.join(working_directory, 'git_repo', '.git')
        end
      end.new

      LocalPac.config(config)
      LocalPac::FileServer
    end

    it 'finds an existing proxy pac' do
      response = get('/v1/pac/file.pac')
      expect(response.body).to eq(valid_pac_file)
    end

    it 'exits with 404 if file does not exist' do
      response = get('/v1/pac/does_not_exist.pac')
      expect(response.body).to include('does_not_exist.pac')
    end

    it 'compresses data for transit if requested' do
      ['deflate','gzip', 'deflate,gzip','gzip,deflate'].each do|compression_method|
        response = get('/v1/pac/file.pac', {}, { 'HTTP_ACCEPT_ENCODING' => compression_method })
        expect(response.headers['Content-Encoding']).to be
      end
    end

    it 'does not compresses data for transit if not requested' do
      ['deflate','gzip', 'deflate,gzip','gzip,deflate'].each do|compression_method|
        response = get('/v1/pac/does_not_exist.pac')
        expect(response.headers['Content-Encoding']).not_to be
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
local_pac-0.1.6 spec/features/fetch_proxy_pac_spec.rb
local_pac-0.1.5 spec/features/fetch_proxy_pac_spec.rb
local_pac-0.1.4 spec/features/fetch_proxy_pac_spec.rb
local_pac-0.1.3 spec/features/fetch_proxy_pac_spec.rb
local_pac-0.1.2 spec/features/fetch_proxy_pac_spec.rb
local_pac-0.1.1 spec/features/fetch_proxy_pac_spec.rb
local_pac-0.1.0 spec/features/fetch_proxy_pac_spec.rb