Device ID attestation for profile owner: tests

Test that the profile owner can generate a key that includes the device
identifiers in the key attestation record if and only if the profile
owner was granted access to the identifiers explicitly.

Also test that when a delegated certificate installer is trying to
generate keys with attestation record, the same properties hold as for
the profile owner.

Testing matrix: Due to the different combinations, the table below
should help figuring out which state is tested by which test.

States: Device Owner (DO), Profile Owner (PO)
Delegated cert installer being tested? YES, NO
Has device id access been granted? Y, N, N/A
Is key generation including device id attestation expected to succeed? YES, NO

+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| MODE | DEL | ID ACC | SUC | HOST-SIDE TEST CLASS                                                       | DEVICE-SIDE TEST CLASS                                                                      |
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
| DO   | NO  | N/A    | YES | DeviceAndProfileOwnerTest#testKeyManagement                                | KeyManagementTest#assertAllVariantsOfDeviceIdAttestation                                    |
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
| DO   | YES | N/A    | YES | MixedDeviceOwnerTest#testDelegatedCertInstallerDeviceIdAttestation         | DelegatedDeviceIdAttestationTest#testGenerateKeyPairWithDeviceIdAttestationExpectingSuccess |
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
| PO   | NO  | NO     | NO  | MixedManagedProfileOwnerTest#testDeviceIdAttestationForProfileOwner        | DeviceIdAttestationTest#testFailsWithoutProfileOwnerIdsGrant                                |
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
| PO   | NO  | NO     | NO  | DeviceAndProfileOwnerTest#testKeyManagement                                | KeyManagementTest testProfileOwnerCannotAttestDeviceUniqueIds                               | * REDUNDANT TEST
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
| PO   | YES | NO     | NO  | MixedManagedProfileOwnerTest#testDelegatedCertInstallerDeviceIdAttestation | DelegatedDeviceIdAttestationTest#testGenerateKeyPairWithDeviceIdAttestationExpectingFailure |
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
| PO   | NO  | YES    | YES | MixedManagedProfileOwnerTest#testDeviceIdAttestationForProfileOwner        | DeviceIdAttestationTest#testSucceedsWithProfileOwnerIdsGrant                                |
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
| PO   | YES | YES    | YES | MixedManagedProfileOwnerTest#testDelegatedCertInstallerDeviceIdAttestation | DelegatedDeviceIdAttestationTest testGenerateKeyPairWithDeviceIdAttestationExpectingSuccess |
+------+-----+--------+-----+----------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+

Bug: 111335970
Bug: 71421376
Test: atest com.android.cts.devicepolicy.MixedProfileOwnerTest#testKeyManagement
Test: atest com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testKeyManagement
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testDeviceIdAttestationForProfileOwner
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testDelegatedCertInstallerDeviceIdAttestation
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegatedCertInstallerDeviceIdAttestation
Change-Id: I2758020cb573b6e17d7d520e59ed8d4a5ca17f0c
12 files changed