diff --git a/spring-vault-core/src/main/java/org/springframework/vault/authentication/AzureVmEnvironment.java b/spring-vault-core/src/main/java/org/springframework/vault/authentication/AzureVmEnvironment.java index ee83c74c..ab5d9d93 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/authentication/AzureVmEnvironment.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/authentication/AzureVmEnvironment.java @@ -22,6 +22,7 @@ import org.springframework.util.Assert; * resource group name and the VM name. * * @author Mark Paluch + * @author Willi Schönborn * @since 2.1 * @see AzureMsiAuthentication * @see AzureMsiAuthenticationOptions @@ -55,13 +56,14 @@ public class AzureVmEnvironment { * @param resourceGroupName must not be {@literal null}. * @param vmName must not be {@literal null}. * @param vmScaleSetName must not be {@literal null}. + * @since 2.3.1 */ public AzureVmEnvironment(String subscriptionId, String resourceGroupName, String vmName, String vmScaleSetName) { Assert.notNull(subscriptionId, "SubscriptionId must not be null"); Assert.notNull(resourceGroupName, "Resource group name must not be null"); Assert.notNull(vmName, "VM name must not be null"); - Assert.notNull(vmScaleSetName, "VMSS name must not be null"); + Assert.notNull(vmScaleSetName, "VM Scale Set name must not be null"); this.subscriptionId = subscriptionId; this.resourceGroupName = resourceGroupName; @@ -81,8 +83,11 @@ public class AzureVmEnvironment { return this.vmName; } + /** + * @since 2.3.1 + */ public String getVmScaleSetName() { - return vmScaleSetName; + return this.vmScaleSetName; } } diff --git a/spring-vault-core/src/test/java/org/springframework/vault/authentication/AzureMsiAuthenticationUnitTests.java b/spring-vault-core/src/test/java/org/springframework/vault/authentication/AzureMsiAuthenticationUnitTests.java index cf2cf924..52f78da1 100644 --- a/spring-vault-core/src/test/java/org/springframework/vault/authentication/AzureMsiAuthenticationUnitTests.java +++ b/spring-vault-core/src/test/java/org/springframework/vault/authentication/AzureMsiAuthenticationUnitTests.java @@ -37,6 +37,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * Unit tests for {@link AzureMsiAuthentication}. * * @author Mark Paluch + * @author Willi Schönborn */ class AzureMsiAuthenticationUnitTests { @@ -144,14 +145,9 @@ class AzureMsiAuthenticationUnitTests { this.mockRest.expect(requestTo(AzureMsiAuthenticationOptions.DEFAULT_INSTANCE_METADATA_SERVICE_URI)) .andExpect(method(HttpMethod.GET)).andExpect(header("Metadata", "true")) .andRespond(withSuccess().contentType(MediaType.APPLICATION_JSON) - .body("{\n" - + " \"compute\": {\n" - + " \"name\": \"vault-client\",\n" - + " \"vmScaleSetName\": \"\",\n" - + " \"resourceGroupName\": \"vault\",\n" - + " \"subscriptionId\": \"foobar-subscription\"\n" + - " }\n" + - "}")); + .body("{\n" + " \"compute\": {\n" + " \"name\": \"vault-client\",\n" + + " \"vmScaleSetName\": \"\",\n" + " \"resourceGroupName\": \"vault\",\n" + + " \"subscriptionId\": \"foobar-subscription\"\n" + " }\n" + "}")); } private void expectVmssMetadataRequest() { @@ -159,14 +155,10 @@ class AzureMsiAuthenticationUnitTests { this.mockRest.expect(requestTo(AzureMsiAuthenticationOptions.DEFAULT_INSTANCE_METADATA_SERVICE_URI)) .andExpect(method(HttpMethod.GET)).andExpect(header("Metadata", "true")) .andRespond(withSuccess().contentType(MediaType.APPLICATION_JSON) - .body("{\n" - + " \"compute\": {\n" - + " \"name\": \"vault-client-scale-set_0\",\n" + .body("{\n" + " \"compute\": {\n" + " \"name\": \"vault-client-scale-set_0\",\n" + " \"vmScaleSetName\": \"vault-client-scale-set\",\n" + " \"resourceGroupName\": \"vault\",\n" - + " \"subscriptionId\": \"foobar-subscription\"\n" + - " }\n" + - "}")); + + " \"subscriptionId\": \"foobar-subscription\"\n" + " }\n" + "}")); } private void expectIdentityTokenRequest() { @@ -183,8 +175,7 @@ class AzureMsiAuthenticationUnitTests { .andExpect(jsonPath("$.role").value("dev-role")).andExpect(jsonPath("$.jwt").value("my-token")) .andExpect(jsonPath("$.subscription_id").value("foobar-subscription")) .andExpect(jsonPath("$.resource_group_name").value("vault")) - .andExpect(jsonPath("$.vm_name").value("vault-client")) - .andExpect(jsonPath("$.vmss_name").value("")) + .andExpect(jsonPath("$.vm_name").value("vault-client")).andExpect(jsonPath("$.vmss_name").value("")) .andRespond(withSuccess().contentType(MediaType.APPLICATION_JSON) .body("{" + "\"auth\":{\"client_token\":\"my-token\"}" + "}")); }