Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkValidatorTest.java

Issue 2896273005: Fix bug in one conditional. Add more apk test files. (Closed)
Patch Set: Check for gaps between files in zip. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVerifySignature.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVerifySignature.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698