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 f233f30779
commit 873e33764e
2 changed files with 24 additions and 26 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.4
*/
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.4
*/
public String getVmScaleSetName() {
return vmScaleSetName;
return this.vmScaleSetName;
}
}

View File

@@ -26,17 +26,15 @@ import org.springframework.vault.client.VaultClients.PrefixAwareUriTemplateHandl
import org.springframework.vault.support.VaultToken;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.header;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
import static org.springframework.test.web.client.response.MockRestResponseCreators.*;
/**
* Unit tests for {@link AzureMsiAuthentication}.
*
* @author Mark Paluch
* @author Willi Schönborn
*/
class AzureMsiAuthenticationUnitTests {
@@ -141,32 +139,25 @@ class AzureMsiAuthenticationUnitTests {
private void expectVmMetadataRequest() {
this.mockRest.expect(requestTo(AzureMsiAuthenticationOptions.DEFAULT_INSTANCE_METADATA_SERVICE_URI))
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() {
this.mockRest.expect(requestTo(AzureMsiAuthenticationOptions.DEFAULT_INSTANCE_METADATA_SERVICE_URI))
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() {
@@ -179,8 +170,10 @@ class AzureMsiAuthenticationUnitTests {
private void expectVmLoginRequest() {
this.mockRest.expect(requestTo("/auth/azure/login")).andExpect(method(HttpMethod.POST))
.andExpect(jsonPath("$.role").value("dev-role")).andExpect(jsonPath("$.jwt").value("my-token"))
this.mockRest.expect(requestTo("/auth/azure/login"))
.andExpect(method(HttpMethod.POST))
.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"))