summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-07 12:11:05 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-07 12:11:05 +0000
commit515e623c2dc37d6742435c458d188dc717c5a8d6 (patch)
tree05f75e98ae002918c617f301a6598dd4b907ba01
parentabce252087ed055b4c9d84a472fdd8103e17af71 (diff)
parentb7a5d0973ffc4bb3feb8cd6896199f5aa93ac7cd (diff)
downloadRemoteKeyProvisioning-android14-mainline-conscrypt-release.tar.gz
Snap for 11190379 from b7a5d0973ffc4bb3feb8cd6896199f5aa93ac7cd to mainline-conscrypt-releaseaml_con_341410300android14-mainline-conscrypt-release
Change-Id: I22269343f541bd71f563e5875b928d0b8dc71c07
-rw-r--r--app/tests/e2e/src/com/android/rkpdapp/e2etest/KeystoreIntegrationTest.java25
-rw-r--r--app/tests/hosttest/src/com/android/rkpdapp/hosttest/RkpdStatsTests.java5
2 files changed, 18 insertions, 12 deletions
diff --git a/app/tests/e2e/src/com/android/rkpdapp/e2etest/KeystoreIntegrationTest.java b/app/tests/e2e/src/com/android/rkpdapp/e2etest/KeystoreIntegrationTest.java
index 1d58033..6f46896 100644
--- a/app/tests/e2e/src/com/android/rkpdapp/e2etest/KeystoreIntegrationTest.java
+++ b/app/tests/e2e/src/com/android/rkpdapp/e2etest/KeystoreIntegrationTest.java
@@ -230,9 +230,10 @@ public class KeystoreIntegrationTest {
// Verify that if the system is set to rkp only, key creation fails when RKP is unable
// to get keys.
- try {
+ try (FakeRkpServer server = new FakeRkpServer(FakeRkpServer.Response.INTERNAL_ERROR,
+ FakeRkpServer.Response.INTERNAL_ERROR)) {
Settings.setDeviceConfig(sContext, Settings.EXTRA_SIGNED_KEYS_AVAILABLE_DEFAULT,
- Duration.ofDays(1), "bad url");
+ Duration.ofDays(1), server.getUrl());
Settings.setMaxRequestTime(sContext, 100);
createKeystoreKeyBackedByRkp();
assertWithMessage("Should have gotten a KeyStoreException").fail();
@@ -251,14 +252,17 @@ public class KeystoreIntegrationTest {
.that(SystemProperties.getBoolean(getRkpOnlyProp(), false))
.isFalse();
- Settings.setDeviceConfig(sContext, Settings.EXTRA_SIGNED_KEYS_AVAILABLE_DEFAULT,
- Duration.ofDays(1), "bad url");
+ try (FakeRkpServer server = new FakeRkpServer(FakeRkpServer.Response.INTERNAL_ERROR,
+ FakeRkpServer.Response.INTERNAL_ERROR)) {
+ Settings.setDeviceConfig(sContext, Settings.EXTRA_SIGNED_KEYS_AVAILABLE_DEFAULT,
+ Duration.ofDays(1), server.getUrl());
- createKeystoreKey();
+ createKeystoreKey();
- // Ensure the key has a cert, but it didn't come from rkpd.
- assertThat(mKeyStore.getCertificateChain(getTestKeyAlias())).isNotEmpty();
- assertThat(mKeyDao.getTotalKeysForIrpc(mServiceName)).isEqualTo(0);
+ // Ensure the key has a cert, but it didn't come from rkpd.
+ assertThat(mKeyStore.getCertificateChain(getTestKeyAlias())).isNotEmpty();
+ assertThat(mKeyDao.getTotalKeysForIrpc(mServiceName)).isEqualTo(0);
+ }
}
@Test
@@ -279,8 +283,9 @@ public class KeystoreIntegrationTest {
@Test
public void testRetryableRkpError() throws Exception {
- try {
- Settings.setDeviceConfig(sContext, 1, Duration.ofDays(1), "bad url");
+ try (FakeRkpServer server = new FakeRkpServer(FakeRkpServer.Response.INTERNAL_ERROR,
+ FakeRkpServer.Response.INTERNAL_ERROR)) {
+ Settings.setDeviceConfig(sContext, 1, Duration.ofDays(1), server.getUrl());
Settings.setMaxRequestTime(sContext, 100);
createKeystoreKeyBackedByRkp();
Assert.fail("Expected a keystore exception");
diff --git a/app/tests/hosttest/src/com/android/rkpdapp/hosttest/RkpdStatsTests.java b/app/tests/hosttest/src/com/android/rkpdapp/hosttest/RkpdStatsTests.java
index 823179d..e7bf7cc 100644
--- a/app/tests/hosttest/src/com/android/rkpdapp/hosttest/RkpdStatsTests.java
+++ b/app/tests/hosttest/src/com/android/rkpdapp/hosttest/RkpdStatsTests.java
@@ -40,6 +40,7 @@ import java.util.List;
@RunWith(DeviceJUnit4ClassRunner.class)
public final class RkpdStatsTests extends AtomsHostTest {
private static final int NO_HTTP_STATUS_ERROR = 0;
+ private static final int HTTP_STATUS_SERVER_ERROR = 500;
private static final int HTTPS_OK = 200;
private static final String RPC_DEFAULT =
"android.hardware.security.keymint.IRemotelyProvisionedComponent/default";
@@ -107,7 +108,7 @@ public final class RkpdStatsTests extends AtomsHostTest {
assertThat(attempt.getUptime()).isNotEqualTo(UpTime.UPTIME_UNKNOWN);
assertThat(attempt.getEnablement()).isEqualTo(Enablement.ENABLED_RKP_ONLY);
assertThat(attempt.getStatus()).isEqualTo(
- RemoteKeyProvisioningStatus.FETCH_GEEK_IO_EXCEPTION);
+ RemoteKeyProvisioningStatus.FETCH_GEEK_HTTP_ERROR);
final RemoteKeyProvisioningTiming timing = getTimingMetric(data);
assertThat(timing).isNotNull();
@@ -125,7 +126,7 @@ public final class RkpdStatsTests extends AtomsHostTest {
assertThat(network).isNotNull();
assertThat(network.getTransportType()).isEqualTo(timing.getTransportType());
assertThat(network.getStatus()).isEqualTo(attempt.getStatus());
- assertThat(network.getHttpStatusError()).isEqualTo(NO_HTTP_STATUS_ERROR);
+ assertThat(network.getHttpStatusError()).isEqualTo(HTTP_STATUS_SERVER_ERROR);
}
@Test