Commit 127bae43 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-fix-empty-namespace-git-access' into 'master'

Eliminate statement timeouts when namespace is blank

Closes #199207

See merge request gitlab-org/gitlab!23839
parents d862cf00 104e5196
---
title: Eliminate statement timeouts when namespace is blank
merge_request: 23839
author:
type: fixed
......@@ -50,8 +50,8 @@ module Gitlab
@project = project
@protocol = protocol
@authentication_abilities = authentication_abilities
@namespace_path = namespace_path
@project_path = project_path
@namespace_path = namespace_path || project&.namespace&.full_path
@project_path = project_path || project&.path
@redirected_path = redirected_path
@auth_result_type = auth_result_type
end
......@@ -60,6 +60,7 @@ module Gitlab
@logger = Checks::TimedLogger.new(timeout: INTERNAL_TIMEOUT, header: LOG_HEADER)
@changes = changes
check_namespace!
check_protocol!
check_valid_actor!
check_active_user!
......@@ -136,6 +137,12 @@ module Gitlab
end
end
def check_namespace!
return if namespace_path.present?
raise NotFoundError, ERROR_MESSAGES[:project_not_found]
end
def check_active_user!
return unless user
......
......@@ -75,6 +75,32 @@ describe Gitlab::GitAccess do
end
end
describe '#check_namespace!' do
context 'when namespace exists' do
before do
project.add_maintainer(user)
end
it 'allows push and pull access' do
aggregate_failures do
expect { push_access_check }.not_to raise_error
expect { pull_access_check }.not_to raise_error
end
end
end
context 'when namespace does not exist' do
let(:namespace_path) { nil }
it 'does not allow push and pull access' do
aggregate_failures do
expect { push_access_check }.to raise_not_found
expect { pull_access_check }.to raise_not_found
end
end
end
end
describe '#check_project_accessibility!' do
context 'when the project exists' do
context 'when actor exists' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment