2019-07-23 21:53:06 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe 'git_http routing' do
|
2020-12-01 07:09:17 -05:00
|
|
|
describe 'code repositories' do
|
|
|
|
it_behaves_like 'git repository routes' do
|
|
|
|
let(:path) { '/gitlab-org/gitlab-test.git' }
|
|
|
|
end
|
2021-02-01 19:09:14 -05:00
|
|
|
|
|
|
|
it_behaves_like 'git repository routes with fallback for git-upload-pack' do
|
|
|
|
let(:path) { '/gitlab-org/gitlab-test.git' }
|
|
|
|
end
|
2020-12-01 07:09:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'wiki repositories' do
|
|
|
|
context 'in project' do
|
|
|
|
let(:path) { '/gitlab-org/gitlab-test.wiki.git' }
|
|
|
|
|
|
|
|
it_behaves_like 'git repository routes'
|
2021-02-01 19:09:14 -05:00
|
|
|
it_behaves_like 'git repository routes with fallback for git-upload-pack'
|
2020-12-01 07:09:17 -05:00
|
|
|
|
|
|
|
describe 'redirects', type: :request do
|
|
|
|
let(:web_path) { '/gitlab-org/gitlab-test/-/wikis' }
|
|
|
|
|
|
|
|
it 'redirects namespace/project.wiki.git to the project wiki' do
|
|
|
|
expect(get(path)).to redirect_to(web_path)
|
|
|
|
end
|
2019-07-23 21:53:06 -04:00
|
|
|
|
2020-12-01 07:09:17 -05:00
|
|
|
it 'preserves query parameters' do
|
|
|
|
expect(get("#{path}?foo=bar&baz=qux")).to redirect_to("#{web_path}?foo=bar&baz=qux")
|
|
|
|
end
|
2019-07-23 21:53:06 -04:00
|
|
|
|
2020-12-01 07:09:17 -05:00
|
|
|
it 'only redirects when the format is .git' do
|
|
|
|
expect(get(path.delete_suffix('.git'))).not_to redirect_to(web_path)
|
|
|
|
expect(get(path.delete_suffix('.git') + '.json')).not_to redirect_to(web_path)
|
|
|
|
end
|
|
|
|
end
|
2019-07-23 21:53:06 -04:00
|
|
|
end
|
|
|
|
|
2020-12-01 07:09:17 -05:00
|
|
|
context 'in toplevel group' do
|
|
|
|
it_behaves_like 'git repository routes' do
|
|
|
|
let(:path) { '/gitlab-org.wiki.git' }
|
|
|
|
end
|
2021-02-01 19:09:14 -05:00
|
|
|
|
|
|
|
it_behaves_like 'git repository routes with fallback for git-upload-pack' do
|
|
|
|
let(:path) { '/gitlab-org.wiki.git' }
|
|
|
|
end
|
2020-12-01 07:09:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'in child group' do
|
|
|
|
it_behaves_like 'git repository routes' do
|
|
|
|
let(:path) { '/gitlab-org/child.wiki.git' }
|
|
|
|
end
|
2021-02-01 19:09:14 -05:00
|
|
|
|
|
|
|
it_behaves_like 'git repository routes with fallback for git-upload-pack' do
|
|
|
|
let(:path) { '/gitlab-org/child.wiki.git' }
|
|
|
|
end
|
2020-12-01 07:09:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'snippet repositories' do
|
|
|
|
context 'personal snippet' do
|
|
|
|
it_behaves_like 'git repository routes' do
|
|
|
|
let(:path) { '/snippets/123.git' }
|
|
|
|
end
|
2021-02-01 19:09:14 -05:00
|
|
|
|
|
|
|
it_behaves_like 'git repository routes without fallback' do
|
|
|
|
let(:path) { '/snippets/123.git' }
|
|
|
|
end
|
2019-07-23 21:53:06 -04:00
|
|
|
end
|
|
|
|
|
2020-12-01 07:09:17 -05:00
|
|
|
context 'project snippet' do
|
|
|
|
it_behaves_like 'git repository routes' do
|
|
|
|
let(:path) { '/gitlab-org/gitlab-test/snippets/123.git' }
|
|
|
|
end
|
2021-02-01 19:09:14 -05:00
|
|
|
|
|
|
|
it_behaves_like 'git repository routes with fallback' do
|
|
|
|
let(:path) { '/gitlab-org/gitlab-test/snippets/123.git' }
|
|
|
|
end
|
2019-07-23 21:53:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|