Sha256: 4fa8aeaeab8b4bc1d7b86b5486bf3a266b5151261a4bb1542d87a10cb35a9698

Contents?: true

Size: 804 Bytes

Versions: 2

Compression:

Stored size: 804 Bytes

Contents

require 'rack/test'
require 'rack/logs'

describe 'accessing an individual log', type: :integration do
  include Rack::Test::Methods

  let(:app) do
    log_dir = support_path('fixtures/log')
    Rack::Builder.app do
      logs = Rack::Logs.configure do |config|
        config.log_dir = log_dir
      end
      run logs
    end
  end

  before do
    get '/my_log_file.log'
  end

  example 'returns a 200 response code' do
    expect(last_response).to be_ok
  end

  example 'accessing the log returns only the specific log contents' do
    expect(last_response.body).to     match 'LOG ENTRY 1234'
    expect(last_response.body).to_not match 'LOG ENTRY 5678'
  end

  example 'cross path traversal is prevented' do
    get "/../tmp/secret_file.txt"
    expect(last_response.status).to be 404
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-logs-0.1.0 spec/integration/accessing_an_individual_log_spec.rb
rack-logs-0.0.6 spec/integration/accessing_an_individual_log_spec.rb