diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/requests/api/internal | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/requests/api/internal')
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 95 |
1 files changed, 40 insertions, 55 deletions
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 93c2233e021..684f0329909 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -323,18 +323,6 @@ describe API::Internal::Base do end end - shared_examples 'snippets with disabled feature flag' do - context 'when feature flag :version_snippets is disabled' do - it 'returns 401' do - stub_feature_flags(version_snippets: false) - - subject - - expect(response).to have_gitlab_http_status(:unauthorized) - end - end - end - shared_examples 'snippet success' do it 'responds with success' do subject @@ -344,18 +332,6 @@ describe API::Internal::Base do end end - shared_examples 'snippets with web protocol' do - it_behaves_like 'snippet success' - - context 'with disabled version flag' do - before do - stub_feature_flags(version_snippets: false) - end - - it_behaves_like 'snippet success' - end - end - context 'git push with personal snippet' do subject { push(key, personal_snippet, env: env.to_json, changes: snippet_changes) } @@ -369,12 +345,6 @@ describe API::Internal::Base do expect(user.reload.last_activity_on).to be_nil end - it_behaves_like 'snippets with disabled feature flag' - - it_behaves_like 'snippets with web protocol' do - subject { push(key, personal_snippet, 'web', env: env.to_json, changes: snippet_changes) } - end - it_behaves_like 'sets hook env' do let(:gl_repository) { Gitlab::GlRepository::SNIPPET.identifier_for_container(personal_snippet) } end @@ -392,12 +362,6 @@ describe API::Internal::Base do expect(json_response["gl_repository"]).to eq("snippet-#{personal_snippet.id}") expect(user.reload.last_activity_on).to eql(Date.today) end - - it_behaves_like 'snippets with disabled feature flag' - - it_behaves_like 'snippets with web protocol' do - subject { pull(key, personal_snippet, 'web') } - end end context 'git push with project snippet' do @@ -413,12 +377,6 @@ describe API::Internal::Base do expect(user.reload.last_activity_on).to be_nil end - it_behaves_like 'snippets with disabled feature flag' - - it_behaves_like 'snippets with web protocol' do - subject { push(key, project_snippet, 'web', env: env.to_json, changes: snippet_changes) } - end - it_behaves_like 'sets hook env' do let(:gl_repository) { Gitlab::GlRepository::SNIPPET.identifier_for_container(project_snippet) } end @@ -434,14 +392,6 @@ describe API::Internal::Base do expect(json_response["gl_repository"]).to eq("snippet-#{project_snippet.id}") expect(user.reload.last_activity_on).to eql(Date.today) end - - it_behaves_like 'snippets with disabled feature flag' do - subject { pull(key, project_snippet) } - end - - it_behaves_like 'snippets with web protocol' do - subject { pull(key, project_snippet, 'web') } - end end context "git pull" do @@ -491,23 +441,25 @@ describe API::Internal::Base do allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { 1 } end - it 'returns custom git config' do + it 'returns maxInputSize and partial clone git config' do push(key, project) expect(json_response["git_config_options"]).to be_present + expect(json_response["git_config_options"]).to include("receive.maxInputSize=1048576") expect(json_response["git_config_options"]).to include("uploadpack.allowFilter=true") expect(json_response["git_config_options"]).to include("uploadpack.allowAnySHA1InWant=true") end context 'when gitaly_upload_pack_filter feature flag is disabled' do before do - stub_feature_flags(gitaly_upload_pack_filter: { enabled: false, thing: project }) + stub_feature_flags(gitaly_upload_pack_filter: false) end - it 'does not include allowFilter and allowAnySha1InWant in the git config options' do + it 'returns only maxInputSize and not partial clone git config' do push(key, project) expect(json_response["git_config_options"]).to be_present + expect(json_response["git_config_options"]).to include("receive.maxInputSize=1048576") expect(json_response["git_config_options"]).not_to include("uploadpack.allowFilter=true") expect(json_response["git_config_options"]).not_to include("uploadpack.allowAnySHA1InWant=true") end @@ -515,12 +467,28 @@ describe API::Internal::Base do end context 'when receive_max_input_size is empty' do - it 'returns an empty git config' do + before do allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { nil } + end + it 'returns partial clone git config' do push(key, project) - expect(json_response["git_config_options"]).to be_empty + expect(json_response["git_config_options"]).to be_present + expect(json_response["git_config_options"]).to include("uploadpack.allowFilter=true") + expect(json_response["git_config_options"]).to include("uploadpack.allowAnySHA1InWant=true") + end + + context 'when gitaly_upload_pack_filter feature flag is disabled' do + before do + stub_feature_flags(gitaly_upload_pack_filter: false) + end + + it 'returns an empty git config' do + push(key, project) + + expect(json_response["git_config_options"]).to be_empty + end end end end @@ -949,6 +917,23 @@ describe API::Internal::Base do expect(json_response['status']).to be_falsy end end + + context 'for design repositories' do + let(:gl_repository) { Gitlab::GlRepository::DESIGN.identifier_for_container(project) } + + it 'does not allow access' do + post(api('/internal/allowed'), + params: { + key_id: key.id, + project: project.full_path, + gl_repository: gl_repository, + secret_token: secret_token, + protocol: 'ssh' + }) + + expect(response).to have_gitlab_http_status(:unauthorized) + end + end end describe 'POST /internal/post_receive', :clean_gitlab_redis_shared_state do |