From commits-return-6102-archive-asf-public=cust-asf.ponee.io@openwhisk.apache.org Thu Nov 1 15:54:23 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 256A4180652 for ; Thu, 1 Nov 2018 15:54:22 +0100 (CET) Received: (qmail 90310 invoked by uid 500); 1 Nov 2018 14:54:22 -0000 Mailing-List: contact commits-help@openwhisk.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwhisk.apache.org Delivered-To: mailing list commits@openwhisk.apache.org Received: (qmail 90297 invoked by uid 99); 1 Nov 2018 14:54:22 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2018 14:54:22 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 80D8E85BB9; Thu, 1 Nov 2018 14:54:21 +0000 (UTC) Date: Thu, 01 Nov 2018 14:54:21 +0000 To: "commits@openwhisk.apache.org" Subject: [incubator-openwhisk-runtime-ruby] branch master updated: Fixes #14 - Support zip files without dir entries (#15) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154108406148.22861.3227410898824027170@gitbox.apache.org> From: jamesthomas@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-openwhisk-runtime-ruby X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 033d29307a2e7fcf93c710807b35c6c456774e23 X-Git-Newrev: 99ceec8e14a66ba38b0b5451228170db37e1b338 X-Git-Rev: 99ceec8e14a66ba38b0b5451228170db37e1b338 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. jamesthomas pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-ruby.git The following commit(s) were added to refs/heads/master by this push: new 99ceec8 Fixes #14 - Support zip files without dir entries (#15) 99ceec8 is described below commit 99ceec8e14a66ba38b0b5451228170db37e1b338 Author: James Thomas AuthorDate: Thu Nov 1 15:54:16 2018 +0100 Fixes #14 - Support zip files without dir entries (#15) * Fixes #14 - Support zip files without dir entries Ensure directories exist before unzipping files. Add tests to validate this test case. * re-formating scala tests to pass ci bot --- .gitignore | 3 ++- core/ruby2.5Action/rackapp/init.rb | 4 +++- tests/dat/without_dir_entries.zip | Bin 0 -> 592 bytes .../actionContainers/Ruby25ActionContainerTests.scala | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ed2c749..0c3444f 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,5 @@ ansible/roles/nginx/files/*cert.pem !tests/dat/actions/python3_virtualenv.zip !tests/dat/actions/python_virtualenv_dir.zip !tests/dat/actions/python_virtualenv_name.zip -!tests/dat/actions/zippedaction.zip \ No newline at end of file +!tests/dat/actions/zippedaction.zip +!tests/dat/without_dir_entries.zip diff --git a/core/ruby2.5Action/rackapp/init.rb b/core/ruby2.5Action/rackapp/init.rb index eee1767..caefe52 100644 --- a/core/ruby2.5Action/rackapp/init.rb +++ b/core/ruby2.5Action/rackapp/init.rb @@ -84,7 +84,9 @@ class InitApp def unzip(zipfile_path, destination_folder) Zip::File.open(zipfile_path) do |zip| zip.each do |file| - zip.extract(file, destination_folder + file.name) + f_path = destination_folder + file.name + FileUtils.mkdir_p(File.dirname(f_path)) + zip.extract(file, f_path) end end true diff --git a/tests/dat/without_dir_entries.zip b/tests/dat/without_dir_entries.zip new file mode 100644 index 0000000..224a5f9 Binary files /dev/null and b/tests/dat/without_dir_entries.zip differ diff --git a/tests/src/test/scala/actionContainers/Ruby25ActionContainerTests.scala b/tests/src/test/scala/actionContainers/Ruby25ActionContainerTests.scala index 1090c14..68146bd 100644 --- a/tests/src/test/scala/actionContainers/Ruby25ActionContainerTests.scala +++ b/tests/src/test/scala/actionContainers/Ruby25ActionContainerTests.scala @@ -23,6 +23,8 @@ import common.WskActorSystem import actionContainers.{ActionContainer, BasicActionRunnerTests} import actionContainers.ActionContainer.withContainer import actionContainers.ResourceHelpers.ZipBuilder +import actionContainers.ResourceHelpers +import java.nio.file.FileSystems; import spray.json._ @RunWith(classOf[JUnitRunner]) @@ -329,6 +331,21 @@ class Ruby25ActionContainerTests extends BasicActionRunnerTests with WskActorSys } } + it should "support zip-encoded packages without directory entries" in { + val path = FileSystems.getDefault().getPath("dat", "without_dir_entries.zip"); + val code = ResourceHelpers.readAsBase64(path) + + val (out, err) = withRuby25Container { c => + c.init(initPayload(code))._1 should be(200) + + val (runCode, runRes) = c.run(runPayload(JsObject())) + + runCode should be(200) + runRes.get.fields.get("greeting") shouldBe defined + runRes.get.fields.get("greeting") shouldBe Some(JsString("Hello stranger!")) + } + } + it should "fail gracefully on invalid zip files" in { // Some text-file encoded to base64. val code = "Q2VjaSBuJ2VzdCBwYXMgdW4gemlwLgo="