Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4d372f6 authored by dcashman's avatar dcashman Committed by Daniel Cashman
Browse files

Fix getKeySetByAlias PackageMgr test.

commit 42aed1b8ecf591009f9e2df8eaca4f41074c37c8 changed the hidden
KeySet API to allow packages to retrieve keysets of other packages.
Change the PackageManagerTests to not expect a SecurityExeption
anymore and also make sure that this is supported.

Bug: 25935839
Change-Id: I18c00997a627c9df1eb3826650c1aa71f563a2bd
parent 9f3a78cb
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -17,4 +17,11 @@
        package="com.android.frameworks.coretests.keysets_api">
    <application android:hasCode="false">
    </application>
    <key-sets>
        <key-set android:name="A" >
          <public-key android:name="keyA"
                      android:value="MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJoN1Nsgqf0V4C/bbN8wo8O2X/S5D76+5Mb9mlIsHkUTUTbHCNk+LxHIUYLm89YbP9zImrV0bUHLUAZUyoMUCiMCAwEAAQ=="/>
        </key-set>
    </key-sets>

</manifest>
+7 −5
Original line number Diff line number Diff line
@@ -3278,7 +3278,6 @@ public class PackageManagerTests extends AndroidTestCase {
     * testGetKeySetByAlias - same as getSigningKeySet, but for keysets defined
     * by this package.
     */
    @Suppress
    public void testGetKeySetByAlias() throws Exception {
        PackageManager pm = getPm();
        String mPkgName = mContext.getPackageName();
@@ -3309,17 +3308,20 @@ public class PackageManagerTests extends AndroidTestCase {
            assertTrue(false); // should have thrown
        } catch(IllegalArgumentException e) {
        }

        // make sure we can get a KeySet from our pkg
        ks = pm.getKeySetByAlias(mPkgName, "A");
        assertNotNull(ks);

        // and another
        final InstallParams ip = installFromRawResource("keysetApi.apk", R.raw.keyset_splat_api,
                0, false, false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
        try {
            ks = pm.getKeySetByAlias(otherPkgName, "A");
            assertTrue(false); // should have thrown
        } catch (SecurityException e) {
            assertNotNull(ks);
        } finally {
            cleanUpInstall(ip);
        }
        ks = pm.getKeySetByAlias(mPkgName, "A");
        assertNotNull(ks);
    }

    public void testIsSignedBy() throws Exception {