Remove tests (2/n)

Remove tests that have been migrated to CTS.

Bug: 194971428
Test: m RollbackTest
Change-Id: Ib880b067b93396e097b3bbe6aca004b524d8833f
This commit is contained in:
JW Wang
2021-07-30 10:32:34 +08:00
parent 14c899c8d7
commit 2f582b9d4a

View File

@@ -31,7 +31,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.rollback.RollbackInfo;
import android.content.rollback.RollbackManager;
import android.os.UserManager;
@@ -1160,109 +1159,4 @@ public class RollbackTest {
InstallUtils.dropShellPermissionIdentity();
}
}
/**
* Test we can't enable rollback for non-whitelisted app without
* TEST_MANAGE_ROLLBACKS permission
*/
@Test
public void testNonRollbackWhitelistedApp() throws Exception {
try {
InstallUtils.adoptShellPermissionIdentity(
Manifest.permission.INSTALL_PACKAGES,
Manifest.permission.DELETE_PACKAGES,
Manifest.permission.MANAGE_ROLLBACKS);
Uninstall.packages(TestApp.A);
Install.single(TestApp.A1).commit();
assertThat(RollbackUtils.getAvailableRollback(TestApp.A)).isNull();
Install.single(TestApp.A2).setEnableRollback().commit();
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
assertThat(RollbackUtils.getAvailableRollback(TestApp.A)).isNull();
} finally {
InstallUtils.dropShellPermissionIdentity();
}
}
@Test
public void testRollbackDataPolicy() throws Exception {
try {
InstallUtils.adoptShellPermissionIdentity(
Manifest.permission.INSTALL_PACKAGES,
Manifest.permission.DELETE_PACKAGES,
Manifest.permission.TEST_MANAGE_ROLLBACKS);
Uninstall.packages(TestApp.A, TestApp.B, TestApp.C);
Install.multi(TestApp.A1, TestApp.B1, TestApp.C1).commit();
// Write user data version = 1
InstallUtils.processUserData(TestApp.A);
InstallUtils.processUserData(TestApp.B);
InstallUtils.processUserData(TestApp.C);
Install a2 = Install.single(TestApp.A2)
.setEnableRollback(PackageManager.RollbackDataPolicy.WIPE);
Install b2 = Install.single(TestApp.B2)
.setEnableRollback(PackageManager.RollbackDataPolicy.RESTORE);
// The rollback data policy of C2 is specified in the manifest
Install c2 = Install.single(TestApp.C2).setEnableRollback();
Install.multi(a2, b2, c2).setEnableRollback().commit();
// Write user data version = 2
InstallUtils.processUserData(TestApp.A);
InstallUtils.processUserData(TestApp.B);
InstallUtils.processUserData(TestApp.C);
RollbackInfo info = RollbackUtils.getAvailableRollback(TestApp.A);
RollbackUtils.rollback(info.getRollbackId());
// Read user data version from userdata.txt
// A's user data version is -1 for user data is wiped.
// B's user data version is 1 as rollback committed.
// C's user data version is -1 for user data is wiped.
assertThat(InstallUtils.getUserDataVersion(TestApp.A)).isEqualTo(-1);
assertThat(InstallUtils.getUserDataVersion(TestApp.B)).isEqualTo(1);
assertThat(InstallUtils.getUserDataVersion(TestApp.C)).isEqualTo(-1);
} finally {
InstallUtils.dropShellPermissionIdentity();
}
}
/**
* Tests an app can be rolled back to the previous signing key.
*
* <p>The rollback capability in the signing lineage allows an app to be updated to an APK
* signed with a previous signing key in the lineage; however this often defeats the purpose
* of key rotation as a compromised key could then be used to roll an app back to the previous
* key. To avoid requiring the rollback capability to support app rollbacks the PackageManager
* allows an app to be rolled back to the previous signing key if the rollback install reason
* is set.
*/
@Test
public void testRollbackAfterKeyRotation() throws Exception {
try {
InstallUtils.adoptShellPermissionIdentity(
Manifest.permission.INSTALL_PACKAGES,
Manifest.permission.DELETE_PACKAGES,
Manifest.permission.TEST_MANAGE_ROLLBACKS,
Manifest.permission.MANAGE_ROLLBACKS);
// Uninstall TestApp.A
Uninstall.packages(TestApp.A);
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(-1);
// Install v1 of the app with the original signing key (without rollbacks enabled).
Install.single(TestApp.AOriginal1).commit();
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1);
// Upgrade from v1 to v2 with the rotated signing key, with rollbacks enabled.
Install.single(TestApp.ARotated2).setEnableRollback().commit();
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2);
// Roll back the app.
RollbackInfo available = waitForAvailableRollback(TestApp.A);
RollbackUtils.rollback(available.getRollbackId());
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1);
} finally {
InstallUtils.dropShellPermissionIdentity();
}
}
}