Polishing

Add author and since tags.

Related ticket: gh-614
Original pull request: gh-615
This commit is contained in:
Mark Paluch
2021-01-15 09:27:18 +01:00
parent 3e505f4b33
commit 196352a640
2 changed files with 14 additions and 18 deletions

View File

@@ -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;
}
}

View File

@@ -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\"}" + "}"));
}