Commit dbd7c89f authored by charlie ablett's avatar charlie ablett

Merge branch 'add_tests_projects_with_dots' into 'master'

Add tests for archive API for projects with dots in path

Closes #224669

See merge request gitlab-org/gitlab!36038
parents f4a310ef 2e1f9eb0
......@@ -227,7 +227,8 @@ RSpec.describe API::Repositories do
end
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
allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(false)
......@@ -246,7 +247,7 @@ RSpec.describe API::Repositories do
end
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)
......@@ -257,7 +258,7 @@ RSpec.describe API::Repositories do
end
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)
......@@ -277,7 +278,7 @@ RSpec.describe API::Repositories do
it 'rate limits user when thresholds hit' do
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)
end
......@@ -302,6 +303,13 @@ RSpec.describe API::Repositories do
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
it_behaves_like '404 response' do
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