From 3ae5bea99971ab1ea36189df7cba99ee6cbe7abc Mon Sep 17 00:00:00 2001 From: Robert Berry Date: Wed, 27 Dec 2017 10:58:03 +0000 Subject: [PATCH] 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 --- .../RecoverableKeyStoreManagerTest.java | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java index 419d7b4cf367..c2166e56107b 100644 --- a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java @@ -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( @@ -159,27 +160,6 @@ public class RecoverableKeyStoreManagerTest { } @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( TEST_SESSION_ID, -- 2.11.0