Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/import/gitlab_groups_controller_spec.rb')
-rw-r--r--spec/requests/import/gitlab_groups_controller_spec.rb67
1 files changed, 5 insertions, 62 deletions
diff --git a/spec/requests/import/gitlab_groups_controller_spec.rb b/spec/requests/import/gitlab_groups_controller_spec.rb
index 4125c5c7c7a..51f1363cf1c 100644
--- a/spec/requests/import/gitlab_groups_controller_spec.rb
+++ b/spec/requests/import/gitlab_groups_controller_spec.rb
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Import::GitlabGroupsController do
include WorkhorseHelpers
+ let_it_be(:user) { create(:user) }
let(:import_path) { "#{Dir.tmpdir}/gitlab_groups_controller_spec" }
let(:workhorse_token) { JWT.encode({ 'iss' => 'gitlab-workhorse' }, Gitlab::Workhorse.secret, 'HS256') }
let(:workhorse_headers) do
@@ -28,8 +29,6 @@ RSpec.describe Import::GitlabGroupsController do
describe 'POST create' do
subject(:import_request) { upload_archive(file_upload, workhorse_headers, request_params) }
- let_it_be(:user) { create(:user) }
-
let(:file) { File.join('spec', %w[fixtures group_export.tar.gz]) }
let(:file_upload) { fixture_file_upload(file) }
@@ -194,67 +193,11 @@ RSpec.describe Import::GitlabGroupsController do
end
describe 'POST authorize' do
- let_it_be(:user) { create(:user) }
-
- before do
- login_as(user)
- end
-
- context 'when using a workhorse header' do
- subject(:authorize_request) { post authorize_import_gitlab_group_path, headers: workhorse_headers }
-
- it 'authorizes the request' do
- authorize_request
-
- expect(response).to have_gitlab_http_status :ok
- expect(response.media_type).to eq Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
- expect(json_response['TempPath']).to eq ImportExportUploader.workhorse_local_upload_path
- end
- end
-
- context 'when the request bypasses gitlab-workhorse' do
- subject(:authorize_request) { post authorize_import_gitlab_group_path }
-
- it 'rejects the request' do
- expect { authorize_request }.to raise_error(JWT::DecodeError)
- end
- end
-
- context 'when direct upload is enabled' do
- subject(:authorize_request) { post authorize_import_gitlab_group_path, headers: workhorse_headers }
+ it_behaves_like 'handle uploads authorize request' do
+ let(:uploader_class) { ImportExportUploader }
+ let(:maximum_size) { Gitlab::CurrentSettings.max_import_size.megabytes }
- before do
- stub_uploads_object_storage(ImportExportUploader, enabled: true, direct_upload: true)
- end
-
- it 'accepts the request and stores the files' do
- authorize_request
-
- expect(response).to have_gitlab_http_status :ok
- expect(response.media_type).to eq Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
- expect(json_response).not_to have_key 'TempPath'
-
- expect(json_response['RemoteObject'].keys)
- .to include('ID', 'GetURL', 'StoreURL', 'DeleteURL', 'MultipartUpload')
- end
- end
-
- context 'when direct upload is disabled' do
- subject(:authorize_request) { post authorize_import_gitlab_group_path, headers: workhorse_headers }
-
- before do
- stub_uploads_object_storage(ImportExportUploader, enabled: true, direct_upload: false)
- end
-
- it 'handles the local file' do
- authorize_request
-
- expect(response).to have_gitlab_http_status :ok
- expect(response.media_type).to eq Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
-
- expect(json_response['TempPath']).to eq ImportExportUploader.workhorse_local_upload_path
- expect(json_response['RemoteObject']).to be_nil
- end
+ subject { post authorize_import_gitlab_group_path, headers: workhorse_headers }
end
end
end