Commit e809d9ff authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'sh-fix-500-error-renaming-project-with-underscores' into 'master'

Fix 500 errors when renaming projects with underscores

See merge request gitlab-org/gitlab!77485
parents 6fbd11e4 4a70f4ef
...@@ -145,6 +145,9 @@ module Auth ...@@ -145,6 +145,9 @@ module Auth
# we'll remove them manually from this deny list, and their new repositories will become eligible. # we'll remove them manually from this deny list, and their new repositories will become eligible.
Feature.disabled?(:container_registry_migration_phase1_deny, project.root_ancestor) && Feature.disabled?(:container_registry_migration_phase1_deny, project.root_ancestor) &&
Feature.enabled?(:container_registry_migration_phase1_allow, project) Feature.enabled?(:container_registry_migration_phase1_allow, project)
rescue ContainerRegistry::Path::InvalidRegistryPathError => ex
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(ex, **Gitlab::ApplicationContext.current)
false
end end
## ##
......
...@@ -92,6 +92,35 @@ RSpec.describe Auth::ContainerRegistryAuthenticationService do ...@@ -92,6 +92,35 @@ RSpec.describe Auth::ContainerRegistryAuthenticationService do
it_behaves_like 'a modified token' it_behaves_like 'a modified token'
end end
context 'with a project with a path with trailing underscore' do
let(:bad_project) { create(:project) }
before do
bad_project.update!(path: bad_project.path + '_')
bad_project.add_developer(current_user)
end
describe '#full_access_token' do
let(:token) { described_class.full_access_token(bad_project.full_path) }
let(:access) do
[{ 'type' => 'repository',
'name' => bad_project.full_path,
'actions' => ['*'],
'migration_eligible' => false }]
end
subject { { token: token } }
it 'logs an exception and returns a valid access token' do
expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
expect(token).to be_present
expect(payload).to be_a(Hash)
expect(payload).to include('access' => access)
end
end
end
end end
context 'when not in migration mode' do context 'when not in migration mode' 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