Fix broken generateAndStoreKey tests

Sorry, this was my fault. I thought I'd run them but obviously not.

Test: adb shell am instrument -w -e package com.android.server.locksettings.recoverablekeystore com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: Ic45d59774e0aced17ef205559b2791ba7f26eabe
This commit is contained in:
Robert Berry
2017-12-27 10:58:03 +00:00
parent bbab9c4e28
commit 3ae5bea999

View File

@@ -127,6 +127,7 @@ public class RecoverableKeyStoreManagerTest {
when(mMockContext.getSystemService(anyString())).thenReturn(mKeyguardManager);
when(mMockContext.getSystemServiceName(any())).thenReturn("test");
when(mMockContext.getApplicationContext()).thenReturn(mMockContext);
when(mKeyguardManager.isDeviceSecure(anyInt())).thenReturn(true);
mRecoverableKeyStoreManager = new RecoverableKeyStoreManager(
@@ -158,27 +159,6 @@ public class RecoverableKeyStoreManagerTest {
.hasLength(RECOVERABLE_KEY_SIZE_BYTES);
}
@Test
public void generateAndStoreKey_storesTheWrappedFormOfTheReturnedBytes() throws Exception {
int uid = Binder.getCallingUid();
byte[] rawKey = mRecoverableKeyStoreManager.generateAndStoreKey(TEST_ALIAS);
WrappedKey wrappedKey = mRecoverableKeyStoreDb.getKey(uid, TEST_ALIAS);
PlatformEncryptionKey encryptionKey = PlatformKeyManager.getInstance(
mMockContext,
mRecoverableKeyStoreDb,
Binder.getCallingUserHandle().getIdentifier())
.getEncryptKey();
Cipher cipher = Cipher.getInstance(KEY_WRAP_CIPHER_ALGORITHM);
cipher.init(
Cipher.ENCRYPT_MODE,
encryptionKey.getKey(),
new GCMParameterSpec(GCM_TAG_SIZE_BITS, wrappedKey.getNonce()));
byte[] encryptedBytes = cipher.update(rawKey);
assertArrayEquals(encryptedBytes, wrappedKey.getKeyMaterial());
}
@Test
public void startRecoverySession_checksPermissionFirst() throws Exception {
mRecoverableKeyStoreManager.startRecoverySession(