summaryrefslogtreecommitdiff
path: root/services/robotests/backup
diff options
context:
space:
mode:
author Piyush Mehrotra <piee@google.com> 2022-08-16 17:02:39 +0000
committer Piyush Mehrotra <piee@google.com> 2022-08-19 14:46:52 +0000
commit5c7fc70ed73aaf31a04ff50d058849f8a1fba464 (patch)
treef5a8fb1f93eb0d13fee1a9df2472243bda4c8707 /services/robotests/backup
parent10a0a4a61bc9bae6311d9f3754692620f1805cb4 (diff)
Validate transport before selecting in UserBackupManagerService.
Make sure transport is registered before changing current transport in UserBackupManagerService. If the input transport is not registered, throw an error to user. Fixes: 163539637 Test: 1. atest -v BackupFrameworksServicesRoboTests 2. Manual test on device. - bmgr list transports # which lists registered transports - Verify selecting transport succeeds on registered transports - Verify selecting transport throws an error on non-registered transports Change-Id: I7e3572a13df07b2dee34e295ea07f1ccff5ca505
Diffstat (limited to 'services/robotests/backup')
-rw-r--r--services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java b/services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java
index 297538ad7b4b..159285a5ce5e 100644
--- a/services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java
+++ b/services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java
@@ -61,8 +61,8 @@ import com.android.server.backup.testing.BackupManagerServiceTestUtils;
import com.android.server.backup.testing.TransportData;
import com.android.server.backup.testing.TransportTestUtils.TransportMock;
import com.android.server.backup.transport.TransportNotRegisteredException;
-import com.android.server.testing.shadows.ShadowBackupEligibilityRules;
import com.android.server.testing.shadows.ShadowApplicationPackageManager;
+import com.android.server.testing.shadows.ShadowBackupEligibilityRules;
import com.android.server.testing.shadows.ShadowBinder;
import com.android.server.testing.shadows.ShadowKeyValueBackupJob;
import com.android.server.testing.shadows.ShadowKeyValueBackupTask;
@@ -361,6 +361,26 @@ public class UserBackupManagerServiceTest {
}
/**
+ * Test verifying that {@link UserBackupManagerService#selectBackupTransport(String)} does not
+ * switch the current transport to the inputted transport, when the inputted transport is not
+ * registered.
+ */
+ @Test
+ public void testSelectBackupTransport_nonRegisteredTransport() throws Exception {
+ setUpForSelectTransport();
+ mShadowContext.grantPermissions(android.Manifest.permission.BACKUP);
+ when(mTransportManager.isTransportRegistered(eq(mNewTransport.transportName)))
+ .thenReturn(false);
+ UserBackupManagerService backupManagerService = createUserBackupManagerServiceAndRunTasks();
+
+ String oldTransport = backupManagerService.selectBackupTransport(
+ mNewTransport.transportName);
+
+ assertThat(getSettingsTransport()).isNotEqualTo(mNewTransport.transportName);
+ assertThat(oldTransport).isEqualTo(null);
+ }
+
+ /**
* Test verifying that {@link UserBackupManagerService#selectBackupTransport(String)} throws a
* {@link SecurityException} if the caller does not have backup permission.
*/