summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-10-29 09:15:31 -0700
committerRoshan Pius <rpius@google.com>2019-11-07 10:02:21 -0800
commit49f71c82844c2ff633a232b2e73e1a1661867875 (patch)
treee4f740a85078184a6aa3935e99945bd10f0f8c77 /tests
parent91aa4c8bb78771f25ae28df220ed8d41a3830e05 (diff)
WifiConfigStore: Encrypt credentials for networks (4/4)
Add a setting to turn on/off encryption. This global setting will be turned on for devices which require encrypted credentials. We don't need to support flipping the global settings back n forth. Only needs to support the one way toggle from off to on once for the lifetime of the device. Bug: 140485110 Test: atest com.android.server.wifi Test: Manual verification - Store a PSK network config on older build - Upgrade to build with this CL - adb shell settings put global niap_mode 1 - Ensured that the psk was read correctly on upgrade - Ensured that the psk was encrypted when stored on disk after upgrade Change-Id: Ibabe0814bfc42a7bf610d18e89a7b82bacfdfeed
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java6
2 files changed, 4 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 74f102652..839b007cb 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -237,7 +237,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
.mockStatic(WifiConfigStore.class, withSettings().lenient())
.strictness(Strictness.LENIENT)
.startMocking();
- when(WifiConfigStore.createUserFiles(anyInt())).thenReturn(mock(List.class));
+ when(WifiConfigStore.createUserFiles(anyInt(), anyBoolean())).thenReturn(mock(List.class));
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mDataTelephonyManager);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java
index 64a6a8bcb..d4cdeb0cd 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java
@@ -39,8 +39,6 @@ import com.android.server.wifi.util.XmlUtil.WifiEnterpriseConfigXmlUtil;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -79,7 +77,7 @@ public class XmlUtilTest extends WifiBaseTest {
private static final int TEST_PHASE2_METHOD = WifiEnterpriseConfig.Phase2.MSCHAPV2;
private final String mXmlDocHeader = "XmlUtilTest";
- @Mock private WifiConfigStoreEncryptionUtil mWifiConfigStoreEncryptionUtil;
+ private WifiConfigStoreEncryptionUtil mWifiConfigStoreEncryptionUtil = null;
@Before
public void setUp() throws Exception {
@@ -119,6 +117,7 @@ public class XmlUtilTest extends WifiBaseTest {
@Test
public void testPskWifiConfigurationSerializeDeserializeWithEncryption()
throws IOException, XmlPullParserException {
+ mWifiConfigStoreEncryptionUtil = mock(WifiConfigStoreEncryptionUtil.class);
WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork();
EncryptedData encryptedData = new EncryptedData(new byte[0], new byte[0]);
when(mWifiConfigStoreEncryptionUtil.encrypt(pskNetwork.preSharedKey.getBytes()))
@@ -431,6 +430,7 @@ public class XmlUtilTest extends WifiBaseTest {
config.setEapMethod(TEST_EAP_METHOD);
config.setPhase2Method(TEST_PHASE2_METHOD);
+ mWifiConfigStoreEncryptionUtil = mock(WifiConfigStoreEncryptionUtil.class);
EncryptedData encryptedData = new EncryptedData(new byte[0], new byte[0]);
when(mWifiConfigStoreEncryptionUtil.encrypt(TEST_PASSWORD.getBytes()))
.thenReturn(encryptedData);