diff options
author | Pavel Grafov <pgrafov@google.com> | 2020-11-30 12:51:52 +0000 |
---|---|---|
committer | Pavel Grafov <pgrafov@google.com> | 2020-12-03 00:24:00 +0000 |
commit | d280b114285976ac805757c8356be09461cabe11 (patch) | |
tree | 1236fa35356c104b86027a901b7fef726887023c /tests | |
parent | b0ecf45484bafbe6fc92f3b27a28e4dffeb71a75 (diff) | |
download | KeyChain-d280b114285976ac805757c8356be09461cabe11.tar.gz |
Add DPM.getKeyPairGrants()
This CL adds the underlying method to KeyChain. The method
returns UIDs of the grantee packages.
Bug: 160457441
Test: atest com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testKeyManagement
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegatedCertInstallerDirectly
Test: atest android.admin.cts.DevicePolicyManagerTest
Test: atest KeyChainTests
Test: m RunKeyChainRoboTests
Change-Id: I73529e8871fd35ddff29f4cfddae97ed47587407
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/keychain/tests/BasicKeyChainServiceTest.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/src/com/android/keychain/tests/BasicKeyChainServiceTest.java b/tests/src/com/android/keychain/tests/BasicKeyChainServiceTest.java index ff7fc2d..0315a51 100644 --- a/tests/src/com/android/keychain/tests/BasicKeyChainServiceTest.java +++ b/tests/src/com/android/keychain/tests/BasicKeyChainServiceTest.java @@ -416,6 +416,29 @@ public class BasicKeyChainServiceTest { assertThat(mKeyChainService.containsKeyPair(ALIAS_IMPORTED)).isFalse(); } + @Test + public void testGetGrants_NonExisting() { + assertThrows(IllegalArgumentException.class, + () -> mKeyChainService.getGrants(ALIAS_NON_EXISTING)); + } + + @Test + public void testGetGrants_Empty() throws Exception { + installTestRsaKey(); + + assertThat(mKeyChainService.getGrants(ALIAS_IMPORTED)).isEmpty(); + } + + @Test + public void testGetGrants_NonEmpty() throws Exception { + final int uid = Process.myUid(); + + installTestRsaKey(); + mTestSupportService.grantAppPermission(uid, ALIAS_IMPORTED); + + assertThat(mKeyChainService.getGrants(ALIAS_IMPORTED)).isEqualTo(new int[] {uid}); + } + private void installTestRsaKey() throws Exception { final PrivateKeyEntry privateKeyEntry = TestKeyStore.getClientCertificate().getPrivateKey("RSA", "RSA"); |