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

Commit c98fd71a authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "NIAP: Ignore BluetoothKeystoreServiceTest when the User is not...

Merge "NIAP: Ignore BluetoothKeystoreServiceTest when the User is not primary." am: b4851b1c am: 81487fed am: eb32c2bc am: 4588e5f6

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/1343418

Change-Id: Ie61543ce6e0d9b36fb5f4ca25235fbf6b31778a2
parents 2a1d10a3 4588e5f6
Loading
Loading
Loading
Loading
+5 −18
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import java.util.Map;


import org.junit.After;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
@@ -118,6 +119,7 @@ public final class BluetoothKeystoreServiceTest {


    @Before
    @Before
    public void setUp() {
    public void setUp() {
        Assume.assumeTrue("Ignore test when the user is not primary.", isPrimaryUser());
        mBluetoothKeystoreService = new BluetoothKeystoreService(true);
        mBluetoothKeystoreService = new BluetoothKeystoreService(true);
        Assert.assertNotNull(mBluetoothKeystoreService);
        Assert.assertNotNull(mBluetoothKeystoreService);
        // backup origin config data.
        // backup origin config data.
@@ -132,6 +134,9 @@ public final class BluetoothKeystoreServiceTest {


    @After
    @After
    public void tearDown() {
    public void tearDown() {
        if (!isPrimaryUser()) {
            return;
        }
        try {
        try {
            if (!mConfigData.isEmpty()) {
            if (!mConfigData.isEmpty()) {
                Files.write(Paths.get(CONFIG_FILE_PATH), mConfigData);
                Files.write(Paths.get(CONFIG_FILE_PATH), mConfigData);
@@ -216,9 +221,6 @@ public final class BluetoothKeystoreServiceTest {


    @Test
    @Test
    public void testParserFile() {
    public void testParserFile() {
        if (!isPrimaryUser()) {
            return;
        }
        // over write config
        // over write config
        overwriteConfigFile(mConfigTestData);
        overwriteConfigFile(mConfigTestData);
        // load config file.
        // load config file.
@@ -230,9 +232,6 @@ public final class BluetoothKeystoreServiceTest {


    @Test
    @Test
    public void testEncrypt() {
    public void testEncrypt() {
        if (!isPrimaryUser()) {
            return;
        }
        // load config file and put the unencrypted key in to queue.
        // load config file and put the unencrypted key in to queue.
        testParserFile();
        testParserFile();
        // Wait for encryption to complete
        // Wait for encryption to complete
@@ -244,9 +243,6 @@ public final class BluetoothKeystoreServiceTest {


    @Test
    @Test
    public void testDecrypt() {
    public void testDecrypt() {
        if (!isPrimaryUser()) {
            return;
        }
        // create an encrypted key list and save it.
        // create an encrypted key list and save it.
        testEncrypt();
        testEncrypt();
        mBluetoothKeystoreService.saveEncryptedKey();
        mBluetoothKeystoreService.saveEncryptedKey();
@@ -263,9 +259,6 @@ public final class BluetoothKeystoreServiceTest {


    @Test
    @Test
    public void testCompareHashFile() {
    public void testCompareHashFile() {
        if (!isPrimaryUser()) {
            return;
        }
        // save config checksum.
        // save config checksum.
        Assert.assertTrue(setEncryptKeyOrRemoveKey(CONFIG_FILE_PREFIX, CONFIG_FILE_HASH));
        Assert.assertTrue(setEncryptKeyOrRemoveKey(CONFIG_FILE_PREFIX, CONFIG_FILE_HASH));
        // clean up memory
        // clean up memory
@@ -278,9 +271,6 @@ public final class BluetoothKeystoreServiceTest {


    @Test
    @Test
    public void testParserFileAfterDisableNiapMode() {
    public void testParserFileAfterDisableNiapMode() {
        if (!isPrimaryUser()) {
            return;
        }
        // preconfiguration.
        // preconfiguration.
        // need to creat encrypted file.
        // need to creat encrypted file.
        testParserFile();
        testParserFile();
@@ -310,9 +300,6 @@ public final class BluetoothKeystoreServiceTest {


    @Test
    @Test
    public void testParserFileAfterDisableNiapModeWhenEnableNiapMode() {
    public void testParserFileAfterDisableNiapModeWhenEnableNiapMode() {
        if (!isPrimaryUser()) {
            return;
        }
        testParserFileAfterDisableNiapMode();
        testParserFileAfterDisableNiapMode();
        mBluetoothKeystoreService.cleanupForNiapModeDisable();
        mBluetoothKeystoreService.cleanupForNiapModeDisable();