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

Commit b599ff6a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix a test in AppIntegrityManagerServiceImpl."

parents 1570829f 7a9c4c20
Loading
Loading
Loading
Loading
+27 −14
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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();
@@ -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()))