OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.webapk.lib.client; | 5 package org.chromium.webapk.lib.client; |
6 | 6 |
7 import static org.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
8 import static org.junit.Assert.assertFalse; | 8 import static org.junit.Assert.assertFalse; |
9 import static org.junit.Assert.assertNull; | 9 import static org.junit.Assert.assertNull; |
10 import static org.junit.Assert.assertTrue; | 10 import static org.junit.Assert.assertTrue; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 * Tests {@link WebApkValidator#isValidWebApk()} for failing comment signed
webapks. | 222 * Tests {@link WebApkValidator#isValidWebApk()} for failing comment signed
webapks. |
223 * These WebAPKs were modified to fail in specific ways. | 223 * These WebAPKs were modified to fail in specific ways. |
224 */ | 224 */ |
225 @Test | 225 @Test |
226 public void testIsValidWebApkCommentSignedFailures() { | 226 public void testIsValidWebApkCommentSignedFailures() { |
227 String[] filenames = { | 227 String[] filenames = { |
228 "bad-sig.apk", "bad-utf8-fname.apk", "empty.apk", "extra-field-t
oo-large.apk", | 228 "bad-sig.apk", "bad-utf8-fname.apk", "empty.apk", "extra-field-t
oo-large.apk", |
229 "extra-len-too-large.apk", "fcomment-too-large.apk", "no-cd.apk"
, "no-comment.apk", | 229 "extra-len-too-large.apk", "fcomment-too-large.apk", "no-cd.apk"
, "no-comment.apk", |
230 "no-eocd.apk", "no-lfh.apk", "not-an.apk", "too-many-metainf.apk
", "truncated.apk", | 230 "no-eocd.apk", "no-lfh.apk", "not-an.apk", "too-many-metainf.apk
", "truncated.apk", |
231 "zeros.apk", "zeros-at-end.apk", "block-before-first.apk", "bloc
k-at-end.apk", | 231 "zeros.apk", "zeros-at-end.apk", "block-before-first.apk", "bloc
k-at-end.apk", |
232 "block-before-eocd.apk", "block-before-cd.apk", "v2-signed-too-l
arge.apk", | 232 "block-before-eocd.apk", "block-before-cd.apk", "block-middle.ap
k", |
| 233 "v2-signed-too-large.apk", |
233 }; | 234 }; |
234 String packageName = "com.webapk.a9c419502bb98fcb7"; | 235 String packageName = "com.webapk.a9c419502bb98fcb7"; |
235 Signature[] signature = new Signature[] {new Signature(SIGNATURE_1)}; | 236 Signature[] signature = new Signature[] {new Signature(SIGNATURE_1)}; |
236 | 237 |
237 for (String filename : filenames) { | 238 for (String filename : filenames) { |
238 mPackageManager.removePackage(packageName); | 239 mPackageManager.removePackage(packageName); |
239 mPackageManager.addPackage( | 240 mPackageManager.addPackage( |
240 newPackageInfo(packageName, signature, testFilePath(filename
))); | 241 newPackageInfo(packageName, signature, testFilePath(filename
))); |
241 assertFalse(filename, | 242 assertFalse(filename, |
242 WebApkValidator.isValidWebApk(RuntimeEnvironment.application
, packageName)); | 243 WebApkValidator.isValidWebApk(RuntimeEnvironment.application
, packageName)); |
(...skipping 25 matching lines...) Expand all Loading... |
268 return packageInfo; | 269 return packageInfo; |
269 } | 270 } |
270 | 271 |
271 // The browser signature is expected to always be the second signature - the
first (and any | 272 // The browser signature is expected to always be the second signature - the
first (and any |
272 // additional ones after the second) are ignored. | 273 // additional ones after the second) are ignored. |
273 private static PackageInfo newPackageInfoWithBrowserSignature( | 274 private static PackageInfo newPackageInfoWithBrowserSignature( |
274 String packageName, Signature signature) { | 275 String packageName, Signature signature) { |
275 return newPackageInfo(packageName, new Signature[] {new Signature(""), s
ignature}, null); | 276 return newPackageInfo(packageName, new Signature[] {new Signature(""), s
ignature}, null); |
276 } | 277 } |
277 } | 278 } |
OLD | NEW |