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

Commit 7cd217b3 authored by Robert Berry's avatar Robert Berry
Browse files

Fix broken test RecoverySnapshotStorageTest

This throws an NPE now.

Bug: 75952916
Test: runtest frameworks-services -p \
      com.android.server.locksettings.recoverablekeystore
Change-Id: I094036dbe7e0c149b234a60729aa7fec8db3e2d9
parent af13eeb1
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -7,23 +7,19 @@ import android.security.keystore.recovery.KeyChainSnapshot;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;

import com.android.server.locksettings.recoverablekeystore.TestData;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.security.cert.CertificateException;
import java.util.ArrayList;

@SmallTest
@RunWith(AndroidJUnit4.class)
public class RecoverySnapshotStorageTest {
    private static final KeyChainSnapshot MINIMAL_KEYCHAIN_SNAPSHOT = new KeyChainSnapshot.Builder()
            .setCounterId(1)
            .setSnapshotVersion(1)
            .setServerParams(new byte[0])
            .setMaxAttempts(10)
            .setEncryptedRecoveryKeyBlob(new byte[0])
            .setKeyChainProtectionParams(new ArrayList<>())
            .setWrappedApplicationKeys(new ArrayList<>())
            .build();
    private static final KeyChainSnapshot MINIMAL_KEYCHAIN_SNAPSHOT =
            createMinimalKeyChainSnapshot();

    private final RecoverySnapshotStorage mRecoverySnapshotStorage = new RecoverySnapshotStorage();

@@ -50,4 +46,21 @@ public class RecoverySnapshotStorageTest {

        assertNull(mRecoverySnapshotStorage.get(1000));
    }

    private static KeyChainSnapshot createMinimalKeyChainSnapshot() {
        try {
            return new KeyChainSnapshot.Builder()
                    .setCounterId(1)
                    .setSnapshotVersion(1)
                    .setServerParams(new byte[0])
                    .setMaxAttempts(10)
                    .setEncryptedRecoveryKeyBlob(new byte[0])
                    .setKeyChainProtectionParams(new ArrayList<>())
                    .setWrappedApplicationKeys(new ArrayList<>())
                    .setTrustedHardwareCertPath(TestData.CERT_PATH_1)
                    .build();
        } catch (CertificateException e) {
            throw new RuntimeException(e);
        }
    }
}