Loading services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java +27 −14 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; Loading Loading @@ -109,14 +110,21 @@ public class AppIntegrityManagerServiceImplTest { private static final String PLAY_STORE_CERT = "play_store_cert"; private static final String ADB_CERT = ""; @org.junit.Rule public MockitoRule mMockitoRule = MockitoJUnit.rule(); @Mock PackageManagerInternal mPackageManagerInternal; @Mock Context mMockContext; @Mock Resources mMockResources; @Mock RuleEvaluationEngine mRuleEvaluationEngine; @Mock IntegrityFileManager mIntegrityFileManager; @Mock Handler mHandler; @org.junit.Rule public MockitoRule mMockitoRule = MockitoJUnit.rule(); @Mock PackageManagerInternal mPackageManagerInternal; @Mock Context mMockContext; @Mock Resources mMockResources; @Mock RuleEvaluationEngine mRuleEvaluationEngine; @Mock IntegrityFileManager mIntegrityFileManager; @Mock Handler mHandler; private PackageManager mSpyPackageManager; private File mTestApk; Loading Loading @@ -146,9 +154,6 @@ public class AppIntegrityManagerServiceImplTest { when(mIntegrityFileManager.initialized()).thenReturn(true); } // TODO(b/148370598): Implement a test to validate that allow response is retuned when the test // request times out. @Test public void updateRuleSet_notAuthorized() throws Exception { makeUsSystemApp(); Loading Loading @@ -357,9 +362,17 @@ public class AppIntegrityManagerServiceImplTest { public void verifierAsInstaller_skipIntegrityVerification() throws Exception { whitelistUsAsRuleProvider(); makeUsSystemApp(); mService = new AppIntegrityManagerServiceImpl( mMockContext, mPackageManagerInternal, mRuleEvaluationEngine, mIntegrityFileManager, mHandler, /* checkIntegrityForRuleProviders= */ false); ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor = ArgumentCaptor.forClass(BroadcastReceiver.class); verify(mMockContext) verify(mMockContext, atLeastOnce()) .registerReceiver(broadcastReceiverCaptor.capture(), any(), any(), any()); Intent intent = makeVerificationIntent(TEST_FRAMEWORK_PACKAGE); when(mRuleEvaluationEngine.evaluate(any(), any())) Loading Loading
services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java +27 −14 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; Loading Loading @@ -109,14 +110,21 @@ public class AppIntegrityManagerServiceImplTest { private static final String PLAY_STORE_CERT = "play_store_cert"; private static final String ADB_CERT = ""; @org.junit.Rule public MockitoRule mMockitoRule = MockitoJUnit.rule(); @Mock PackageManagerInternal mPackageManagerInternal; @Mock Context mMockContext; @Mock Resources mMockResources; @Mock RuleEvaluationEngine mRuleEvaluationEngine; @Mock IntegrityFileManager mIntegrityFileManager; @Mock Handler mHandler; @org.junit.Rule public MockitoRule mMockitoRule = MockitoJUnit.rule(); @Mock PackageManagerInternal mPackageManagerInternal; @Mock Context mMockContext; @Mock Resources mMockResources; @Mock RuleEvaluationEngine mRuleEvaluationEngine; @Mock IntegrityFileManager mIntegrityFileManager; @Mock Handler mHandler; private PackageManager mSpyPackageManager; private File mTestApk; Loading Loading @@ -146,9 +154,6 @@ public class AppIntegrityManagerServiceImplTest { when(mIntegrityFileManager.initialized()).thenReturn(true); } // TODO(b/148370598): Implement a test to validate that allow response is retuned when the test // request times out. @Test public void updateRuleSet_notAuthorized() throws Exception { makeUsSystemApp(); Loading Loading @@ -357,9 +362,17 @@ public class AppIntegrityManagerServiceImplTest { public void verifierAsInstaller_skipIntegrityVerification() throws Exception { whitelistUsAsRuleProvider(); makeUsSystemApp(); mService = new AppIntegrityManagerServiceImpl( mMockContext, mPackageManagerInternal, mRuleEvaluationEngine, mIntegrityFileManager, mHandler, /* checkIntegrityForRuleProviders= */ false); ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor = ArgumentCaptor.forClass(BroadcastReceiver.class); verify(mMockContext) verify(mMockContext, atLeastOnce()) .registerReceiver(broadcastReceiverCaptor.capture(), any(), any(), any()); Intent intent = makeVerificationIntent(TEST_FRAMEWORK_PACKAGE); when(mRuleEvaluationEngine.evaluate(any(), any())) Loading