diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/routing | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/routing')
-rw-r--r-- | spec/routing/git_http_routing_spec.rb | 58 | ||||
-rw-r--r-- | spec/routing/group_routing_spec.rb | 4 | ||||
-rw-r--r-- | spec/routing/import_routing_spec.rb | 26 | ||||
-rw-r--r-- | spec/routing/routing_spec.rb | 39 |
4 files changed, 83 insertions, 44 deletions
diff --git a/spec/routing/git_http_routing_spec.rb b/spec/routing/git_http_routing_spec.rb index e5216d99eb9..e3cc1440a9e 100644 --- a/spec/routing/git_http_routing_spec.rb +++ b/spec/routing/git_http_routing_spec.rb @@ -3,22 +3,60 @@ require 'spec_helper' RSpec.describe 'git_http routing' do - include RSpec::Rails::RequestExampleGroup + describe 'code repositories' do + it_behaves_like 'git repository routes' do + let(:path) { '/gitlab-org/gitlab-test.git' } + end + end + + describe 'wiki repositories' do + context 'in project' do + let(:path) { '/gitlab-org/gitlab-test.wiki.git' } + + it_behaves_like 'git repository routes' + + 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 - describe 'wiki.git routing', 'routing' do - let(:wiki_path) { '/gitlab/gitlabhq/wikis' } + it 'preserves query parameters' do + expect(get("#{path}?foo=bar&baz=qux")).to redirect_to("#{web_path}?foo=bar&baz=qux") + end - it 'redirects namespace/project.wiki.git to the project wiki' do - expect(get('/gitlab/gitlabhq.wiki.git')).to redirect_to(wiki_path) + 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 end - it 'preserves query parameters' do - expect(get('/gitlab/gitlabhq.wiki.git?foo=bar&baz=qux')).to redirect_to("#{wiki_path}?foo=bar&baz=qux") + context 'in toplevel group' do + it_behaves_like 'git repository routes' do + let(:path) { '/gitlab-org.wiki.git' } + end + end + + context 'in child group' do + it_behaves_like 'git repository routes' do + let(:path) { '/gitlab-org/child.wiki.git' } + end + end + end + + describe 'snippet repositories' do + context 'personal snippet' do + it_behaves_like 'git repository routes' do + let(:path) { '/snippets/123.git' } + end end - it 'only redirects when the format is .git' do - expect(get('/gitlab/gitlabhq.wiki')).not_to redirect_to(wiki_path) - expect(get('/gitlab/gitlabhq.wiki.json')).not_to redirect_to(wiki_path) + context 'project snippet' do + it_behaves_like 'git repository routes' do + let(:path) { '/gitlab-org/gitlab-test/snippets/123.git' } + end end end end diff --git a/spec/routing/group_routing_spec.rb b/spec/routing/group_routing_spec.rb index f4d5ccc81b6..f171c2faf5e 100644 --- a/spec/routing/group_routing_spec.rb +++ b/spec/routing/group_routing_spec.rb @@ -81,6 +81,10 @@ RSpec.describe "Groups", "routing" do end describe 'dependency proxy for containers' do + it 'routes to #authenticate' do + expect(get('/v2')).to route_to('groups/dependency_proxy_auth#authenticate') + end + context 'image name without namespace' do it 'routes to #manifest' do expect(get('/v2/gitlabhq/dependency_proxy/containers/ruby/manifests/2.3.6')) diff --git a/spec/routing/import_routing_spec.rb b/spec/routing/import_routing_spec.rb index 15d2f32de78..b1da2eaa33b 100644 --- a/spec/routing/import_routing_spec.rb +++ b/spec/routing/import_routing_spec.rb @@ -126,32 +126,6 @@ RSpec.describe Import::BitbucketServerController, 'routing' do end end -# status_import_google_code GET /import/google_code/status(.:format) import/google_code#status -# callback_import_google_code POST /import/google_code/callback(.:format) import/google_code#callback -# jobs_import_google_code GET /import/google_code/jobs(.:format) import/google_code#jobs -# new_user_map_import_google_code GET /import/google_code/user_map(.:format) import/google_code#new_user_map -# create_user_map_import_google_code POST /import/google_code/user_map(.:format) import/google_code#create_user_map -# import_google_code POST /import/google_code(.:format) import/google_code#create -# new_import_google_code GET /import/google_code/new(.:format) import/google_code#new -RSpec.describe Import::GoogleCodeController, 'routing' do - it_behaves_like 'importer routing' do - let(:except_actions) { [:callback] } - let(:provider) { 'google_code' } - end - - it 'to #callback' do - expect(post("/import/google_code/callback")).to route_to("import/google_code#callback") - end - - it 'to #new_user_map' do - expect(get('/import/google_code/user_map')).to route_to('import/google_code#new_user_map') - end - - it 'to #create_user_map' do - expect(post('/import/google_code/user_map')).to route_to('import/google_code#create_user_map') - end -end - # status_import_fogbugz GET /import/fogbugz/status(.:format) import/fogbugz#status # callback_import_fogbugz POST /import/fogbugz/callback(.:format) import/fogbugz#callback # realtime_changes_import_fogbugz GET /import/fogbugz/realtime_changes(.:format) import/fogbugz#realtime_changes diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 76ccdf3237c..26ad1f14786 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -2,7 +2,9 @@ require 'spec_helper' -# user GET /users/:username/ +# user GET /:username +# user_ssh_keys GET /:username.keys +# user_gpg_keys GET /:username.gpg # user_groups GET /users/:username/groups(.:format) # user_projects GET /users/:username/projects(.:format) # user_contributed_projects GET /users/:username/contributed(.:format) @@ -16,6 +18,12 @@ RSpec.describe UsersController, "routing" do expect(get("/User")).to route_to('users#show', username: 'User') end + it "to #gpg_keys" do + allow_any_instance_of(::Constraints::UserUrlConstrainer).to receive(:matches?).and_return(true) + + expect(get("/User.gpg")).to route_to('users#gpg_keys', username: 'User') + end + it "to #groups" do expect(get("/users/User/groups")).to route_to('users#groups', username: 'User') end @@ -32,6 +40,13 @@ RSpec.describe UsersController, "routing" do expect(get("/users/User/snippets")).to route_to('users#snippets', username: 'User') end + # get all the ssh-keys of a user + it "to #ssh_keys" do + allow_any_instance_of(::Constraints::UserUrlConstrainer).to receive(:matches?).and_return(true) + + expect(get("/User.keys")).to route_to('users#ssh_keys', username: 'User') + end + it "to #calendar" do expect(get("/users/User/calendar")).to route_to('users#calendar', username: 'User') end @@ -54,10 +69,6 @@ RSpec.describe "Mounted Apps", "routing" do it "to API" do expect(get("/api/issues")).to be_routable end - - it "to Grack" do - expect(get("/gitlab/gitlabhq.git")).to be_routable - end end # snippets GET /snippets(.:format) snippets#index @@ -175,11 +186,23 @@ RSpec.describe Profiles::KeysController, "routing" do it "to #destroy" do expect(delete("/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1') end +end - it "to #get_keys" do - allow_any_instance_of(::Constraints::UserUrlConstrainer).to receive(:matches?).and_return(true) +# keys GET /gpg_keys gpg_keys#index +# key POST /gpg_keys gpg_keys#create +# PUT /gpg_keys/:id gpg_keys#revoke +# DELETE /gpg_keys/:id gpg_keys#desroy +RSpec.describe Profiles::GpgKeysController, "routing" do + it "to #index" do + expect(get("/profile/gpg_keys")).to route_to('profiles/gpg_keys#index') + end - expect(get("/foo.keys")).to route_to('profiles/keys#get_keys', username: 'foo') + it "to #create" do + expect(post("/profile/gpg_keys")).to route_to('profiles/gpg_keys#create') + end + + it "to #destroy" do + expect(delete("/profile/gpg_keys/1")).to route_to('profiles/gpg_keys#destroy', id: '1') end end |