summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorBen Gruver <bgruv@google.com>2012-09-28 10:58:18 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-28 10:58:19 -0700
commit9dbbfcda81f251f23aded866f7f9d49d8a744c75 (patch)
treed76ac568a3da95b39987c611aaa4d27ba26c7465 /core/tests
parentf80ad90f0b269e31d9450b9fa33f4dc3e4a507c7 (diff)
parent37d83a3caf138e35fa1a355787d20c351f6b37a6 (diff)
downloadframeworks_base-9dbbfcda81f251f23aded866f7f9d49d8a744c75.zip
frameworks_base-9dbbfcda81f251f23aded866f7f9d49d8a744c75.tar.gz
frameworks_base-9dbbfcda81f251f23aded866f7f9d49d8a744c75.tar.bz2
Merge "Pass the originating uid to the package verifier" into jb-mr1-dev
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/coretests/src/android/content/pm/VerificationParamsTest.java80
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());