Skip to content

Commit

Permalink
Merge pull request #1255 from travis-ci/bugfix_cycle_12
Browse files Browse the repository at this point in the history
Bugfix cycle 12
  • Loading branch information
murtaza-swati authored Nov 7, 2022
2 parents cfcd61a + bbea94b commit 85cbe96
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/travis/api/v3/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def initialize(routes = Routes)

def call(env)
::Metriks.meter("api.v3.total_requests").mark
metrics = @metrics_processor.create

return service_index(env) if env['PATH_INFO'.freeze] == ?/.freeze

process_txt_extension!(env)

metrics = @metrics_processor.create
access_control = AccessControl.new(env)
env_params = params(env)
factory, params = routes.factory_for(env['REQUEST_METHOD'.freeze], env['PATH_INFO'.freeze])
Expand Down
26 changes: 26 additions & 0 deletions spec/v3/router_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
describe Travis::API::V3::Router, set_app: true do
describe '#call' do
let(:env) do
{
'PATH_INFO' => '/',
'rack.request.query_hash' => {},
}
end

context 'when user has no perms' do
before { env['HTTP_AUTHORIZATION'] = 'Token 123' }

it 'returns a 403 error' do
expect(subject.call(env).first).to eq(403)
end
end

context 'when user has perms' do
before { env['rack.request.query_hash']['log.token'] = '123' }

it 'returns a 200 response' do
expect(subject.call(env).first).to eq(200)
end
end
end
end

0 comments on commit 85cbe96

Please sign in to comment.