Commit 2e1f9eb0 authored by Thong Kuah's avatar Thong Kuah

Add tests for archive API for projects with dots in path

The issue is that the requirement: for the route was clobbering the
requirement: for the containing namespace. This was since fixed in
https://github.com/ruby-grape/grape/pull/1788, and pulled in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33450.
parent 7318445e
...@@ -227,7 +227,8 @@ RSpec.describe API::Repositories do ...@@ -227,7 +227,8 @@ RSpec.describe API::Repositories do
end end
describe "GET /projects/:id/repository/archive(.:format)?:sha" do describe "GET /projects/:id/repository/archive(.:format)?:sha" do
let(:route) { "/projects/#{project.id}/repository/archive" } let(:project_id) { CGI.escape(project.full_path) }
let(:route) { "/projects/#{project_id}/repository/archive" }
before do before do
allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(false) allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(false)
...@@ -246,7 +247,7 @@ RSpec.describe API::Repositories do ...@@ -246,7 +247,7 @@ RSpec.describe API::Repositories do
end end
it 'returns the repository archive archive.zip' do it 'returns the repository archive archive.zip' do
get api("/projects/#{project.id}/repository/archive.zip", user) get api("/projects/#{project_id}/repository/archive.zip", user)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
...@@ -257,7 +258,7 @@ RSpec.describe API::Repositories do ...@@ -257,7 +258,7 @@ RSpec.describe API::Repositories do
end end
it 'returns the repository archive archive.tar.bz2' do it 'returns the repository archive archive.tar.bz2' do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user) get api("/projects/#{project_id}/repository/archive.tar.bz2", user)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
...@@ -277,7 +278,7 @@ RSpec.describe API::Repositories do ...@@ -277,7 +278,7 @@ RSpec.describe API::Repositories do
it 'rate limits user when thresholds hit' do it 'rate limits user when thresholds hit' do
allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true) allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true)
get api("/projects/#{project.id}/repository/archive.tar.bz2", user) get api("/projects/#{project_id}/repository/archive.tar.bz2", user)
expect(response).to have_gitlab_http_status(:too_many_requests) expect(response).to have_gitlab_http_status(:too_many_requests)
end end
...@@ -302,6 +303,13 @@ RSpec.describe API::Repositories do ...@@ -302,6 +303,13 @@ RSpec.describe API::Repositories do
end end
end end
context 'when unauthenticated and project path has dots' do
it_behaves_like 'repository archive' do
let(:project) { create(:project, :public, :repository, path: 'path.with.dot') }
let(:current_user) { nil }
end
end
context 'when unauthenticated', 'and project is private' do context 'when unauthenticated', 'and project is private' do
it_behaves_like '404 response' do it_behaves_like '404 response' do
let(:request) { get api(route) } let(:request) { get api(route) }
......
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