Sha256: ad0d55c47ef7637898c700a882187c9a7d0b0816e9f4151dd1007aa6bdce3dc4

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

describe 'config server' do
  include_context :integration
  include_context :sitehub_json

  let(:config) do
    {
        proxies: [
            {
                sitehub_cookie_name: 'custom_name',
                sitehub_cookie_path: '/custom/path',
                path: '%r{/regex(.*)}',
                default: DOWNSTREAM_URL
            }
        ]
    }
  end

  let(:downstream_response) { 'downstream response' }

  before do
    stub_request(:get, CONFIG_SERVER_URL).and_return(body: config.to_json)
    stub_request(:get, DOWNSTREAM_URL).and_return(body: downstream_response)
  end

  let(:app) do
    sitehub = sitehub do
      config_server(CONFIG_SERVER_URL, caching_options: {expires_in: 1})
    end

    Async::Middleware.new(sitehub)
  end

  context 'from_json' do
    it 'reads cookie path from config' do
      get('/regex123')

      expect(app.last_response.cookies['custom_name'][:path]).to eq('/custom/path')
    end
  end

  it 'path as regex' do
    get('/regex123')

    expect(app.last_response.body).to eq([downstream_response])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sitehub-0.5.0.alpha11 spec/integration/config_server_spec.rb