From 55aea8d880ea7c8466c203d95ab8a6f333c5b88d Mon Sep 17 00:00:00 2001 From: jiikko Date: Thu, 23 Jan 2020 14:58:02 +0900 Subject: [PATCH] =?UTF-8?q?targetSdkVersion=E3=81=A8sdkVersion=E3=81=8C?= =?UTF-8?q?=E9=87=8D=E8=A4=87=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=82=89?= =?UTF-8?q?=E4=BE=8B=E5=A4=96=E3=82=92=E6=8A=95=E3=81=92=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/android_apk.rb | 8 ++++++-- spec/android_apk_spec.rb | 7 +++++++ spec/fixture/other/duplicate_sdk_version.apk | Bin 0 -> 2203790 bytes 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 spec/fixture/other/duplicate_sdk_version.apk diff --git a/lib/android_apk.rb b/lib/android_apk.rb index 022f84f..3b54a7f 100644 --- a/lib/android_apk.rb +++ b/lib/android_apk.rb @@ -79,7 +79,11 @@ class AndroidApk # @return [String] Return a file path of this apk file attr_accessor :filepath - NOT_ALLOW_DUPLICATE_TAG_NAMES = %w(application).freeze + NOT_ALLOW_DUPLICATE_TAG_NAMES = %w( + application + sdkVersion + targetSdkVersion + ).freeze DPI_TO_NAME_MAP = { 120 => "ldpi", @@ -104,7 +108,7 @@ class AndroidManifestValidateError < StandardError # Do analyze the given apk file. Analyzed apk does not mean *valid*. # # @param [String] filepath a filepath of an apk to be analyzed - # @raise [AndroidManifestValidateError] if AndroidManifest.xml has multiple application tags. + # @raise [AndroidManifestValidateError] if AndroidManifest.xml has multiple application, sdkVersion tags. # @return [AndroidApk, nil] An instance of AndroidApk will be returned if no problem exists while analyzing. Otherwise nil. def self.analyze(filepath) return nil unless File.exist?(filepath) diff --git a/spec/android_apk_spec.rb b/spec/android_apk_spec.rb index 5e57fdf..17029db 100644 --- a/spec/android_apk_spec.rb +++ b/spec/android_apk_spec.rb @@ -25,6 +25,13 @@ end end + context "if duplicated sdk_version apk are given" do + let(:apk_filepath) { File.join(FIXTURE_DIR, "other", "duplicate_sdk_version.apk") } + it "should raise error" do + expect { subject }.to raise_error(AndroidApk::AndroidManifestValidateError, /Duplication of sdkVersion tag is not allowed/) + end + end + context "if invalid sample apk files are given" do context "no such apk file" do let(:apk_filepath) { File.join(FIXTURE_DIR, "other", "no_such_file") } diff --git a/spec/fixture/other/duplicate_sdk_version.apk b/spec/fixture/other/duplicate_sdk_version.apk new file mode 100644 index 0000000000000000000000000000000000000000..0071f182fbe505023ec6ef213616345c50cb6d79 GIT binary patch literal 2203790 zcmcG02|U#6_kX+Ff_qabg``pm6_LS+Le?p3mZ7esAxoJd!*IK<+&24?byBl5gvv4u zL**8i7-lfnGKOmzV=QH6Ookc%&uF=Ix9|7+dj0;rUdA(@&$FC!o^#IoJkL2gZM|~U zre({PeFOX~TNVq>f1g7D8W&b9+W`FXzI;9;#3$s4<^`W?a7K7eC%1laQ9EhZu1O!u ziV6QFJIro>OUGL$P4~dk>>rgmVA@P~r(I6lV`g>-)nZpMaiLip0luhI7Y$~HR6!GZ z8Twi+Hoh10Li|RBHCki3=WdH+L1k~dID(4(WZq&n-1Q$ihVZk)o5gK*=wKU&l$S=Hu=%_Z7RMS6ujsVYbq{z zD=v+FiKC})5{n<5{w+VyGT)@<=wwC~M%A7JcOK8%i>szNu&y(0+xkbMR`Tp{Hm#)*BGcSUIA!~`z} z_@$FDFJRvz!J=fV(0%(mEbr3T1mCRGEtpOiN~kqi<83+kUT0s6H5#wDeOQoUj<13R z6g+XTJTK_jZ)-)t*4a=vF^Pe?}c z%S`sTj+TbC7p|asbP}RSYlM3t4MbU?{Y9AI%j3yNyd}GxXChRetc+Yo!0P{k=Is}z3CFNuWXP#FXrRK~bc78h=(kTqpR!K3XN^)pYC zHSJQU57|SG@7~r-+f#J3$jM?`>4e6iY;%kSwVFUpnj_=vVAn{-G#5K|r{TXY_dXlrt*1rek}cdcac<%E}4!s~GL4tQX< zZPaOW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