diff options
author | Ben Gruver <bgruv@google.com> | 2012-09-27 13:02:06 -0700 |
---|---|---|
committer | Ben Gruver <bgruv@google.com> | 2012-09-27 13:02:06 -0700 |
commit | 37d83a3caf138e35fa1a355787d20c351f6b37a6 (patch) | |
tree | a4fe753ce045a1fc0eb7edc17641425981a6079f /core/tests/coretests | |
parent | 0b1711582ff07d6d1e8e4de6c057eaf6a3473ac3 (diff) | |
download | frameworks_base-37d83a3caf138e35fa1a355787d20c351f6b37a6.zip frameworks_base-37d83a3caf138e35fa1a355787d20c351f6b37a6.tar.gz frameworks_base-37d83a3caf138e35fa1a355787d20c351f6b37a6.tar.bz2 |
Pass the originating uid to the package verifier
Bug: 6923241
Change-Id: I85a3e0d53b469543cb0551d3a440d2663b5d0697
Diffstat (limited to 'core/tests/coretests')
-rw-r--r-- | core/tests/coretests/src/android/content/pm/VerificationParamsTest.java | 80 |
1 files changed, 55 insertions, 25 deletions
diff --git a/core/tests/coretests/src/android/content/pm/VerificationParamsTest.java b/core/tests/coretests/src/android/content/pm/VerificationParamsTest.java index 105bcba..9b216cb 100644 --- a/core/tests/coretests/src/android/content/pm/VerificationParamsTest.java +++ b/core/tests/coretests/src/android/content/pm/VerificationParamsTest.java @@ -40,11 +40,13 @@ public class VerificationParamsTest extends AndroidTestCase { private final static Uri ORIGINATING_URI = Uri.parse(ORIGINATING_URI_STRING); private final static Uri REFERRER = Uri.parse(REFERRER_STRING); + private final static int ORIGINATING_UID = 10042; + private final static ManifestDigest MANIFEST_DIGEST = new ManifestDigest(DIGEST_BYTES); public void testParcel() throws Exception { VerificationParams expected = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); Parcel parcel = Parcel.obtain(); expected.writeToParcel(parcel, 0); @@ -58,71 +60,86 @@ public class VerificationParamsTest extends AndroidTestCase { assertEquals(REFERRER, actual.getReferrer()); + assertEquals(ORIGINATING_UID, actual.getOriginatingUid()); + assertEquals(MANIFEST_DIGEST, actual.getManifestDigest()); } public void testEquals_Success() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); assertEquals(params1, params2); } public void testEquals_VerificationUri_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse("http://a.different.uri/"), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); assertFalse(params1.equals(params2)); } public void testEquals_OriginatingUri_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse("http://a.different.uri/"), - Uri.parse(REFERRER_STRING), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); assertFalse(params1.equals(params2)); } public void testEquals_Referrer_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); + + VerificationParams params2 = new VerificationParams( + Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), + Uri.parse("http://a.different.uri/"), ORIGINATING_UID, + new ManifestDigest(DIGEST_BYTES)); + + assertFalse(params1.equals(params2)); + } + + public void testEquals_Originating_Uid_Failure() throws Exception { + VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse("http://a.different.uri/"), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), 12345, new ManifestDigest(DIGEST_BYTES)); assertFalse(params1.equals(params2)); } public void testEquals_ManifestDigest_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest("a different digest".getBytes())); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, + new ManifestDigest("a different digest".getBytes())); assertFalse(params1.equals(params2)); } public void testEquals_InstallerUid_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); params2.setInstallerUid(INSTALLER_UID); assertFalse(params1.equals(params2)); @@ -130,65 +147,78 @@ public class VerificationParamsTest extends AndroidTestCase { public void testHashCode_Success() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); assertEquals(params1.hashCode(), params2.hashCode()); } public void testHashCode_VerificationUri_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams(null, Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); assertFalse(params1.hashCode() == params2.hashCode()); } public void testHashCode_OriginatingUri_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse("http://a.different.uri/"), - Uri.parse(REFERRER_STRING), new ManifestDigest(DIGEST_BYTES)); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); assertFalse(params1.hashCode() == params2.hashCode()); } public void testHashCode_Referrer_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), null, - new ManifestDigest(DIGEST_BYTES)); + ORIGINATING_UID, new ManifestDigest(DIGEST_BYTES)); + + assertFalse(params1.hashCode() == params2.hashCode()); + } + + public void testHashCode_Originating_Uid_Failure() throws Exception { + VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); + + VerificationParams params2 = new VerificationParams( + Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), + Uri.parse(REFERRER_STRING), 12345, new ManifestDigest(DIGEST_BYTES)); assertFalse(params1.hashCode() == params2.hashCode()); } public void testHashCode_ManifestDigest_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest("a different digest".getBytes())); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, + new ManifestDigest("a different digest".getBytes())); assertFalse(params1.hashCode() == params2.hashCode()); } public void testHashCode_InstallerUid_Failure() throws Exception { VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI, - REFERRER, MANIFEST_DIGEST); + REFERRER, ORIGINATING_UID, MANIFEST_DIGEST); VerificationParams params2 = new VerificationParams( Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), - Uri.parse(REFERRER_STRING), new ManifestDigest("a different digest".getBytes())); + Uri.parse(REFERRER_STRING), ORIGINATING_UID, + new ManifestDigest("a different digest".getBytes())); params2.setInstallerUid(INSTALLER_UID); assertFalse(params1.hashCode() == params2.hashCode()); |