diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-03 21:08:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-03 21:08:16 +0300 |
commit | e9c2bf267862e22c0770cc7b3a1ed97a8b87a7fd (patch) | |
tree | 7b778e44f210132af1233ceb8801b388ac3519f5 /spec/requests/api/remote_mirrors_spec.rb | |
parent | 946771d0b016ae92b15a60bc3290a33b94191ffe (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/remote_mirrors_spec.rb')
-rw-r--r-- | spec/requests/api/remote_mirrors_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/requests/api/remote_mirrors_spec.rb b/spec/requests/api/remote_mirrors_spec.rb index 065d9c7ca5b..2186fe375ac 100644 --- a/spec/requests/api/remote_mirrors_spec.rb +++ b/spec/requests/api/remote_mirrors_spec.rb @@ -39,6 +39,54 @@ describe API::RemoteMirrors do end end + describe 'POST /projects/:id/remote_mirrors' do + let(:route) { "/projects/#{project.id}/remote_mirrors" } + + shared_examples 'creates a remote mirror' do + it 'creates a remote mirror and returns reponse' do + project.add_maintainer(user) + + post api(route, user), params: params + + enabled = params.fetch(:enabled, false) + expect(response).to have_gitlab_http_status(:success) + expect(response).to match_response_schema('remote_mirror') + expect(json_response['enabled']).to eq(enabled) + end + end + + it 'requires `admin_remote_mirror` permission' do + post api(route, developer) + + expect(response).to have_gitlab_http_status(:unauthorized) + end + + context 'creates a remote mirror' do + context 'disabled by default' do + let(:params) { { url: 'https://foo:bar@test.com' } } + + it_behaves_like 'creates a remote mirror' + end + + context 'enabled' do + let(:params) { { url: 'https://foo:bar@test.com', enabled: true } } + + it_behaves_like 'creates a remote mirror' + end + end + + it 'returns error if url is invalid' do + project.add_maintainer(user) + + post api(route, user), params: { + url: 'ftp://foo:bar@test.com' + } + + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['message']['url']).to eq(["is blocked: Only allowed schemes are ssh, git, http, https"]) + end + end + describe 'PUT /projects/:id/remote_mirrors/:mirror_id' do let(:route) { ->(id) { "/projects/#{project.id}/remote_mirrors/#{id}" } } let(:mirror) { project.remote_mirrors.first } |