Skip to content

Commit

Permalink
Fixing Key Vault live tests. (#24142)
Browse files Browse the repository at this point in the history
* Updated platform-matrix.json and tests.yml to ensure Code Coverage for Key Vault Administration is only checked when running against an HSM endpoint.

* Applied PR feedback.

* Fixed matrix importing issue with platform-matrix.json

* Fixed path to platform-matrix.json

* Fixed failing Keys tests for Managed HSM.

* Removed unused imports.
  • Loading branch information
vcolin7 authored Sep 16, 2021
1 parent 932b715 commit 71c3575
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.azure.security.keyvault.keys;

import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.HttpClient;
Expand Down Expand Up @@ -89,21 +88,18 @@ public void createRsaKey(HttpClient httpClient, KeyServiceVersion serviceVersion
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("getTestParameters")
public void setKeyEmptyName(HttpClient httpClient, KeyServiceVersion serviceVersion) {
if (isManagedHsmTest && interceptorManager.isPlaybackMode()) {
// Setting a key with an empty name returns 500 in MHSM, we don't currently produce a recording for that the
// way things are set.
return;
createKeyAsyncClient(httpClient, serviceVersion);

final KeyType keyType;

if (isManagedHsmTest) {
keyType = KeyType.RSA_HSM;
} else {
keyType = KeyType.RSA;
}

createKeyAsyncClient(httpClient, serviceVersion);
StepVerifier.create(client.createKey("", KeyType.RSA))
.verifyErrorSatisfies(ex -> {
if (isManagedHsmTest) {
assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_SERVER_ERROR);
} else {
assertRestException(ex, ResourceModifiedException.class, HttpURLConnection.HTTP_BAD_REQUEST);
}
});
StepVerifier.create(client.createKey("", keyType)).verifyErrorSatisfies(ex ->
assertRestException(ex, ResourceModifiedException.class, HttpURLConnection.HTTP_BAD_REQUEST));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.azure.security.keyvault.keys;

import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.HttpClient;
Expand Down Expand Up @@ -90,13 +89,16 @@ public void createRsaKey(HttpClient httpClient, KeyServiceVersion serviceVersion
public void setKeyEmptyName(HttpClient httpClient, KeyServiceVersion serviceVersion) {
createKeyClient(httpClient, serviceVersion);

final KeyType keyType;

if (isManagedHsmTest) {
assertRestException(() -> client.createKey("", KeyType.RSA_HSM), HttpResponseException.class,
HttpURLConnection.HTTP_SERVER_ERROR);
keyType = KeyType.RSA_HSM;
} else {
assertRestException(() -> client.createKey("", KeyType.RSA), ResourceModifiedException.class,
HttpURLConnection.HTTP_BAD_REQUEST);
keyType = KeyType.RSA;
}

assertRestException(() -> client.createKey("", keyType), ResourceModifiedException.class,
HttpURLConnection.HTTP_BAD_REQUEST);
}

/**
Expand Down
31 changes: 25 additions & 6 deletions sdk/keyvault/platform-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@
"displayNames": {
"@{ enableHsm = $true }": "HSM"
},
"matrix": {
"$IMPORT": "eng/pipelines/templates/stages/platform-matrix.json"
},
"exclude": [
{
"TestFromSource": true
},
{
"TestGoals": "verify"
}
],
"include": [
{
"Agent": {
"ubuntu-20.04": {
"ubuntu-20.04_TestFromSource": {
"OSVmImage": "MMSUbuntu20.04",
"Pool": "azsdk-pool-mms-ubuntu-2004-general"
"Pool": "azsdk-pool-mms-ubuntu-2004-general",
"TestGoals": "surefire:test",
"TestFromSource": true
},
"JavaTestVersion": "1.11",
"AZURE_TEST_HTTP_CLIENTS": "netty",
"TestGoals": "surefire:test"
"windows-2019_am_verify": {
"OSVmImage": "MMS2019",
"Pool": "azsdk-pool-mms-win-2019-general",
"AdditionalOptions": "-am",
"TestGoals": "verify"
}
},
"ArmTemplateParameters": "@{ enableHsm = $true }"
"ArmTemplateParameters": "@{ enableHsm = $true }",
"AZURE_TEST_HTTP_CLIENTS": "netty",
"JavaTestVersion": "1.11",
"TestOptions": ""
}
]
}
4 changes: 2 additions & 2 deletions sdk/keyvault/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ stages:
SubscriptionConfiguration: $(sub-config-cn-test-resources)
MatrixFilters:
- ArmTemplateParameters=^(?!.*enableHsm.*true)
AdditionalMatrixConfigs:
- Name: keyvault_test_matrix_addons
MatrixConfigs:
- Name: Key_Vault_live_test
Path: sdk/keyvault/platform-matrix.json
Selection: sparse
GenerateVMJobs: true
Expand Down

0 comments on commit 71c3575

Please sign in to comment.