Skip to content

Commit d7817f1

Browse files
authored
Added the ability to deploy a Managed HSM in our CI pipelines. (Azure#22319)
* Added the ability to provision a Managed HSM for CI runs. * Updated Key Vault Administration tests. * Added HSM tests for Key Vault Keys. * Removed unused imports. * Fixed test issues. Added missing recordings. * Applied PR feedback. * Applied PR feedback and fixed backup/restore tests. * Fixed tests playback issue. * Applied ARM template fixes for MSHM.
1 parent 264c384 commit d7817f1

File tree

59 files changed

+1502
-937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1502
-937
lines changed

sdk/keyvault/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
*.class
2+
*.cer
3+
*.key
4+
*.pfx
25

36
#External libs
47
extlib/

sdk/keyvault/azure-security-keyvault-administration/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@
8686
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-core-http-okhttp;dependency} -->
8787
<scope>test</scope>
8888
</dependency>
89+
<dependency>
90+
<groupId>com.azure</groupId>
91+
<artifactId>azure-security-keyvault-keys</artifactId>
92+
<version>4.2.8</version> <!-- {x-version-update;com.azure:azure-security-keyvault-keys;dependency} -->
93+
<scope>test</scope>
94+
</dependency>
95+
<dependency>
96+
<groupId>com.azure</groupId>
97+
<artifactId>azure-storage-blob</artifactId>
98+
<version>12.12.0</version> <!-- {x-version-update;com.azure:azure-storage-blob;dependency} -->
99+
<scope>test</scope>
100+
</dependency>
89101
<dependency>
90102
<groupId>com.azure</groupId>
91103
<artifactId>azure-identity</artifactId>

sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlAsyncClient.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.azure.security.keyvault.administration.implementation.KeyVaultAdministrationUtils;
2525
import com.azure.security.keyvault.administration.implementation.KeyVaultErrorCodeStrings;
2626
import com.azure.security.keyvault.administration.implementation.models.DataAction;
27-
import com.azure.security.keyvault.administration.implementation.models.KeyVaultErrorException;
2827
import com.azure.security.keyvault.administration.implementation.models.Permission;
2928
import com.azure.security.keyvault.administration.implementation.models.RoleAssignment;
3029
import com.azure.security.keyvault.administration.implementation.models.RoleAssignmentCreateParameters;
@@ -34,8 +33,8 @@
3433
import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionCreateParameters;
3534
import com.azure.security.keyvault.administration.implementation.models.RoleDefinitionProperties;
3635
import com.azure.security.keyvault.administration.implementation.models.RoleScope;
37-
import com.azure.security.keyvault.administration.models.KeyVaultDataAction;
3836
import com.azure.security.keyvault.administration.models.KeyVaultAdministrationException;
37+
import com.azure.security.keyvault.administration.models.KeyVaultDataAction;
3938
import com.azure.security.keyvault.administration.models.KeyVaultPermission;
4039
import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignment;
4140
import com.azure.security.keyvault.administration.models.KeyVaultRoleAssignmentProperties;
@@ -254,7 +253,7 @@ public Mono<KeyVaultRoleDefinition> setRoleDefinition(KeyVaultRoleScope roleScop
254253
}
255254

256255
/**
257-
* Creates or updates a {@link KeyVaultRoleDefinition}. If no name is provided, then a
256+
* Creates or updates a {@link KeyVaultRoleDefinition}. If no name is provided, then a
258257
* {@link KeyVaultRoleDefinition} will be created with a randomly generated name.
259258
*
260259
* @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition}. Managed HSM only
@@ -456,8 +455,7 @@ Mono<Response<KeyVaultRoleDefinition>> getRoleDefinitionWithResponse(KeyVaultRol
456455
*
457456
* @return A {@link Mono} of a {@link Void}.
458457
*
459-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleDefinition role definition} with the given name
460-
* cannot be found or if the given {@code roleScope} is invalid.
458+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
461459
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleDefinitionName} are
462460
* {@code null}.
463461
*/
@@ -474,8 +472,7 @@ public Mono<Void> deleteRoleDefinition(KeyVaultRoleScope roleScope, String roleD
474472
*
475473
* @return A {@link Mono} containing a {@link Response} with a {@link Void} value.
476474
*
477-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleDefinition role definition} with the given name
478-
* cannot be found or if the given {@code roleScope} is invalid.
475+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
479476
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleDefinitionName} are
480477
* {@code null}.
481478
*/
@@ -494,8 +491,7 @@ public Mono<Response<Void>> deleteRoleDefinitionWithResponse(KeyVaultRoleScope r
494491
*
495492
* @return A {@link Mono} containing a {@link Response} with a {@link Void} value.
496493
*
497-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleDefinition role definition} with the given name
498-
* cannot be found or if the given {@code roleScope} is invalid.
494+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
499495
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleDefinitionName} are
500496
* {@code null}.
501497
*/
@@ -518,7 +514,8 @@ Mono<Response<Void>> deleteRoleDefinitionWithResponse(KeyVaultRoleScope roleScop
518514
.doOnError(error -> logger.warning("Failed to delete role assignment - {}", roleDefinitionName, error))
519515
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
520516
.map(response -> (Response<Void>) new SimpleResponse<Void>(response, null))
521-
.onErrorResume(KeyVaultErrorException.class, e -> swallowExceptionForStatusCode(404, e, logger));
517+
.onErrorResume(KeyVaultAdministrationException.class, e ->
518+
swallowExceptionForStatusCode(404, e, logger));
522519
} catch (RuntimeException e) {
523520
return monoError(logger, e);
524521
}
@@ -839,8 +836,7 @@ Mono<Response<KeyVaultRoleAssignment>> getRoleAssignmentWithResponse(KeyVaultRol
839836
*
840837
* @return A {@link Mono} of a {@link Void}.
841838
*
842-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleAssignment role assignment} with the given name
843-
* cannot be found or if the given {@code roleScope} is invalid.
839+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
844840
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are
845841
* {@code null}.
846842
*/
@@ -857,8 +853,7 @@ public Mono<Void> deleteRoleAssignment(KeyVaultRoleScope roleScope, String roleA
857853
*
858854
* @return A {@link Mono} containing a {@link Response} with a {@link Void} value.
859855
*
860-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleAssignment role assignment} with the given name
861-
* cannot be found or if the given {@code roleScope} is invalid.
856+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
862857
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are
863858
* {@code null}.
864859
*/
@@ -877,8 +872,7 @@ public Mono<Response<Void>> deleteRoleAssignmentWithResponse(KeyVaultRoleScope r
877872
*
878873
* @return A {@link Mono} containing a {@link Response} with a {@link Void} value.
879874
*
880-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleAssignment role assignment} with the given name
881-
* cannot be found or if the given {@code roleScope} is invalid.
875+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
882876
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleAssignmentName} are
883877
* {@code null}.
884878
*/
@@ -900,7 +894,8 @@ Mono<Response<Void>> deleteRoleAssignmentWithResponse(KeyVaultRoleScope roleScop
900894
.doOnError(error -> logger.warning("Failed to delete role assignment - {}", roleAssignmentName, error))
901895
.onErrorMap(KeyVaultAdministrationUtils::mapThrowableToKeyVaultAdministrationException)
902896
.map(response -> (Response<Void>) new SimpleResponse<Void>(response, null))
903-
.onErrorResume(KeyVaultErrorException.class, e -> swallowExceptionForStatusCode(404, e, logger));
897+
.onErrorResume(KeyVaultAdministrationException.class, e ->
898+
swallowExceptionForStatusCode(404, e, logger));
904899
} catch (RuntimeException e) {
905900
return monoError(logger, e);
906901
}

sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/KeyVaultAccessControlClient.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public KeyVaultRoleDefinition setRoleDefinition(KeyVaultRoleScope roleScope) {
9999
}
100100

101101
/**
102-
* Creates or updates a {@link KeyVaultRoleDefinition} with a given name. If no name is provided, then a
102+
* Creates or updates a {@link KeyVaultRoleDefinition} with a given name. If no name is provided, then a
103103
* {@link KeyVaultRoleDefinition} will be created with a randomly generated name.
104104
*
105105
* @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleDefinition}. Managed HSM
@@ -184,8 +184,7 @@ public Response<KeyVaultRoleDefinition> getRoleDefinitionWithResponse(KeyVaultRo
184184
* only supports '/'.
185185
* @param roleDefinitionName The name of the {@link KeyVaultRoleDefinition}.
186186
*
187-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleDefinition role definition} with the given name
188-
* cannot be found or if the given {@code roleScope} is invalid.
187+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
189188
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleDefinitionName} are
190189
* {@code null}.
191190
*/
@@ -203,8 +202,7 @@ public void deleteRoleDefinition(KeyVaultRoleScope roleScope, String roleDefinit
203202
*
204203
* @return A {@link Response} with a {@link Void} value.
205204
*
206-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleDefinition role definition} with the given name
207-
* cannot be found or if the given {@code roleScope} is invalid.
205+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
208206
* @throws NullPointerException If the {@link KeyVaultRoleScope role scope} or {@link String roleDefinitionName} are
209207
* {@code null}.
210208
*/
@@ -365,8 +363,7 @@ public Response<KeyVaultRoleAssignment> getRoleAssignmentWithResponse(KeyVaultRo
365363
* @param roleScope The {@link KeyVaultRoleScope role scope} of the {@link KeyVaultRoleAssignment}.
366364
* @param roleAssignmentName The name of the {@link KeyVaultRoleAssignment}.
367365
*
368-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleAssignment role assignment} with the given name
369-
* cannot be found or if the given {@code roleScope} is invalid.
366+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
370367
* @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are
371368
* {@code null}.
372369
*/
@@ -384,8 +381,7 @@ public void deleteRoleAssignment(KeyVaultRoleScope roleScope, String roleAssignm
384381
*
385382
* @return A {@link Response} with a {@link Void} value.
386383
*
387-
* @throws KeyVaultAdministrationException If a {@link KeyVaultRoleAssignment role assignment} with the given name
388-
* cannot be found or if the given {@code roleScope} is invalid.
384+
* @throws KeyVaultAdministrationException If the given {@code roleScope} is invalid.
389385
* @throws NullPointerException if the {@link KeyVaultRoleScope roleScope} or {@link String roleAssignmentName} are
390386
* {@code null}.
391387
*/

0 commit comments

Comments
 (0)