diff --git a/src/api/app/models/package.rb b/src/api/app/models/package.rb index 19bd3cc381c..4102b523171 100644 --- a/src/api/app/models/package.rb +++ b/src/api/app/models/package.rb @@ -1283,6 +1283,13 @@ def save_file(opt = {}) path = self.source_path(opt[:filename], put_opt) ActiveXML.backend.http_do :put, path, data: content, timeout: 500 + # KIWI file + if opt[:filename] =~ /\.kiwi\.txz$/ + logger.debug 'Found a kiwi archive, creating kiwi_import source service' + services = self.services + services.addKiwiImport + end + # update package timestamp and reindex sources unless opt[:rev] == 'repository' || %w(_project _pattern).include?(self.name) self.sources_changed(wait_for_update: ['_aggregate', '_constraints', '_link', '_service', '_patchinfo', '_channel'].include?(opt[:filename])) diff --git a/src/api/app/models/service.rb b/src/api/app/models/service.rb index 5ee83e52471..26420ba8a98 100644 --- a/src/api/app/models/service.rb +++ b/src/api/app/models/service.rb @@ -60,6 +60,24 @@ def addDownloadURL(url, filename = nil) true end + def addKiwiImport + addService('kiwi_import') + if save + logger.debug 'Service successfully saved' + begin + logger.debug 'Executing waitservice command' + Suse::Backend.post("/source/#{URI.escape(init_options[:project])}/#{URI.escape(init_options[:package])}?cmd=waitservice", '') + logger.debug 'Executing mergeservice command' + cmd = "/source/#{URI.escape(init_options[:project])}/#{URI.escape(init_options[:package])}?cmd=mergeservice&user=#{User.current.login}" + Suse::Backend.post(cmd, '') + rescue ActiveXML::Transport::Error, Timeout::Error => e + logger.debug "Error while executing backend command: #{e.message}" + end + else + logger.debug 'Failed to save service' + end + end + def removeService(serviceid) each("/services/service") do |service| serviceid -= 1 diff --git a/src/api/spec/cassettes/FileUpload/uploading_a_kiwi_txz_file_creates_and_runs_kiwi_import_service.yml b/src/api/spec/cassettes/FileUpload/uploading_a_kiwi_txz_file_creates_and_runs_kiwi_import_service.yml new file mode 100644 index 00000000000..5eeef0bb36c --- /dev/null +++ b/src/api/spec/cassettes/FileUpload/uploading_a_kiwi_txz_file_creates_and_runs_kiwi_import_service.yml @@ -0,0 +1,1144 @@ +--- +http_interactions: +- request: + method: put + uri: http://localhost:3200/source/home:tom/test_package/_meta?user=_nobody_ + body: + encoding: UTF-8 + string: | + + + <description/> + </package> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '108' + body: + encoding: UTF-8 + string: | + <package name="test_package" project="home:tom"> + <title> + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:22 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package?nofilename=1&view=info&withchangesmd5=1 + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '240' + body: + encoding: UTF-8 + string: | + + 400 remote error: /vagrant/src/api/test/fixtures/backend/services/kiwi_import.service No such file or directory + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:26 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '522' + body: + encoding: UTF-8 + string: | + + + 400 remote error: /vagrant/src/api/test/fixtures/backend/services/kiwi_import.service No such file or directory + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:26 GMT +- request: + method: post + uri: http://localhost:3200/source/home:tom/test_package?cmd=diff&linkrev=base&onlyissues=1&orev=0&view=xml + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - application/octet-stream + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Content-Length: + - '305' + Cache-Control: + - no-cache + Connection: + - close + body: + encoding: UTF-8 + string: | + + + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:26 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '522' + body: + encoding: UTF-8 + string: | + + + 400 remote error: /vagrant/src/api/test/fixtures/backend/services/kiwi_import.service No such file or directory + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:26 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package?rev=3 + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '522' + body: + encoding: UTF-8 + string: | + + + 400 remote error: /vagrant/src/api/test/fixtures/backend/services/kiwi_import.service No such file or directory + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:26 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '522' + body: + encoding: UTF-8 + string: | + + + 400 remote error: /vagrant/src/api/test/fixtures/backend/services/kiwi_import.service No such file or directory + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:26 GMT +- request: + method: put + uri: http://localhost:3200/source/home:tom/test_package/foo.kiwi.txz?user=tom + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Content-Length: + - '0' + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '203' + body: + encoding: UTF-8 + string: | + + 388339c62bee54443b7c8bc152f7cf13 + unknown + + tom + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:27 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package/_service + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Content-Length: + - '54' + Cache-Control: + - no-cache + Connection: + - close + body: + encoding: UTF-8 + string: |- + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:27 GMT +- request: + method: put + uri: http://localhost:3200/source/home:tom/test_package/_service?user=tom + body: + encoding: UTF-8 + string: |- + + + + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Content-Length: + - '83' + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '203' + body: + encoding: UTF-8 + string: | + + 157142356f1671344a324466ecbc0dd2 + unknown + + tom + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:28 GMT +- request: + method: post + uri: http://localhost:3200/source/home:tom/test_package?cmd=runservice&user=tom + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - application/octet-stream + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '21' + body: + encoding: UTF-8 + string: ' + +' + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:28 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '332' + body: + encoding: UTF-8 + string: | + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:28 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package?nofilename=1&view=info&withchangesmd5=1 + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '146' + body: + encoding: UTF-8 + string: | + + service in progress + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:28 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '332' + body: + encoding: UTF-8 + string: | + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:29 GMT +- request: + method: post + uri: http://localhost:3200/source/home:tom/test_package?cmd=diff&linkrev=base&onlyissues=1&orev=0&view=xml + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - application/octet-stream + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '305' + body: + encoding: UTF-8 + string: | + + + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:29 GMT +- request: + method: post + uri: http://localhost:3200/source/home:tom/test_package?cmd=waitservice + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - application/octet-stream + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '21' + body: + encoding: UTF-8 + string: ' + +' + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: post + uri: http://localhost:3200/source/home:tom/test_package?cmd=mergeservice&user=tom + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - application/octet-stream + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '203' + body: + encoding: UTF-8 + string: | + + f619aceb9f94380f0b8272f79c9658ab + unknown + + tom + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '301' + body: + encoding: UTF-8 + string: | + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package?nofilename=1&view=info&withchangesmd5=1 + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '186' + body: + encoding: UTF-8 + string: | + + 1456847611 + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '301' + body: + encoding: UTF-8 + string: | + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: post + uri: http://localhost:3200/source/home:tom/test_package?cmd=diff&linkrev=base&onlyissues=1&orev=0&view=xml + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - application/octet-stream + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '305' + body: + encoding: UTF-8 + string: | + + + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/build/home:tom/_result?package=test_package&view=status + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '774' + body: + encoding: UTF-8 + string: | + + + + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '301' + body: + encoding: UTF-8 + string: | + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package?expand=1&rev=7 + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '301' + body: + encoding: UTF-8 + string: | + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '301' + body: + encoding: UTF-8 + string: | + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:31 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/test_package/_history + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '1363' + body: + encoding: UTF-8 + string: | + + + 5c6164d882258ac8ef8d0f3f065c7b68 + unknown + + tom + + + ab434c3ede01df02184bd59d8d8ce8d7 + unknown + + tom + + + 3157573ec64372c79644656206dae4c9 + unknown + + tom + trigger service run + + + 388339c62bee54443b7c8bc152f7cf13 + unknown + + tom + + + 157142356f1671344a324466ecbc0dd2 + unknown + + tom + + + d19172476892766215bcbc135ad664fc + unknown + + tom + trigger service run + + + f619aceb9f94380f0b8272f79c9658ab + unknown + + tom + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:32 GMT +- request: + method: get + uri: http://localhost:3200/build/home:tom/_result?package=test_package&view=status + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '774' + body: + encoding: UTF-8 + string: | + + + + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:32 GMT +- request: + method: get + uri: http://localhost:3200/build/home:tom/_result?package=test_package&view=status + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '774' + body: + encoding: UTF-8 + string: | + + + + + + + + + http_version: + recorded_at: Tue, 01 Mar 2016 15:53:32 GMT +- request: + method: get + uri: http://localhost:3200/build/home:tom/home_coolo_standard/i586/test_package/rpmlint.log + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - text/plain + Accept-Encoding: + - identity + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 404 + message: rpmlint.log No such file or directory + headers: + Content-Type: + - text/xml + Content-Length: + - '154' + Cache-Control: + - no-cache + Connection: + - close + body: + encoding: UTF-8 + string: | + + rpmlint.log: No such file or directory +
404 rpmlint.log: No such file or directory
+
+ http_version: + recorded_at: Tue, 01 Mar 2016 15:53:34 GMT +recorded_with: VCR 3.0.1 diff --git a/src/api/spec/features/webui/file_upload_spec.rb b/src/api/spec/features/webui/file_upload_spec.rb new file mode 100644 index 00000000000..2bf00587ffc --- /dev/null +++ b/src/api/spec/features/webui/file_upload_spec.rb @@ -0,0 +1,21 @@ +require 'browser_helper' + +RSpec.feature 'FileUpload', :type => :feature, :js => true do + let!(:user) { create(:confirmed_user, login: 'tom') } + let(:home_project) { Project.find_by(name: user.home_project_name) } + let!(:package) { create(:package, name: 'test_package', project: home_project) } + + scenario 'uploading a kiwi.txz file creates and runs kiwi_import service' do + login user + + visit "/package/add_file/#{home_project}/#{package}" + expect(page).to have_content("Add File to #{package} (Project #{home_project})") + + fill_in "filename", with: "foo.kiwi.txz", :match => :first + page.execute_script("$('#submit_button').attr('disabled', false)") + click_button('Save changes') + + expect(current_path).to eq(package_show_path(home_project, package)) + expect(page).to have_content('config.kiwi') + end +end