project_import_spec.rb 1.2 KB
Newer Older
1 2 3 4 5 6 7
require 'spec_helper'

describe API::ProjectImport do
  include ExternalAuthorizationServiceHelpers

  let(:export_path) { "#{Dir.tmpdir}/project_export_spec" }
  let(:user) { create(:user) }
Robert Speicher's avatar
Robert Speicher committed
8
  let(:file) { File.join('spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  let(:namespace) { create(:group) }
  before do
    allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)

    namespace.add_owner(user)
  end

  after do
    FileUtils.rm_rf(export_path, secure: true)
  end

  describe 'POST /projects/import' do
    it 'overrides the classification label when the service is enabled' do
      enable_external_authorization_service_check
      override_params = { 'external_authorization_classification_label' => 'Hello world' }

      Sidekiq::Testing.inline! do
        post api('/projects/import', user),
             path: 'test-import',
             file: fixture_file_upload(file),
             namespace: namespace.id,
             override_params: override_params
      end
      import_project = Project.find(json_response['id'])

      expect(import_project.external_authorization_classification_label).to eq('Hello world')
    end
  end
end