From e256add757e290777a5f995ed4954cb00f498b7b Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 25 Oct 2017 13:26:17 +0200 Subject: [PATCH] Polishing. Add author tags. Reformat code. Original pull request: gh-165. --- .../AppRoleAuthenticationOptions.java | 1 + ...AppRoleAuthenticationIntegrationTests.java | 4 +- .../AppRoleAuthenticationUnitTests.java | 42 +++++++++---------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/spring-vault-core/src/main/java/org/springframework/vault/authentication/AppRoleAuthenticationOptions.java b/spring-vault-core/src/main/java/org/springframework/vault/authentication/AppRoleAuthenticationOptions.java index c32d4afd..4b66f2e3 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/authentication/AppRoleAuthenticationOptions.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/authentication/AppRoleAuthenticationOptions.java @@ -29,6 +29,7 @@ import org.springframework.vault.support.VaultToken; * * @author Mark Paluch * @author Vincent Le Nair + * @author Christophe Tafani-Dereeper * @see AppRoleAuthentication * @see #builder() */ diff --git a/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationIntegrationTests.java b/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationIntegrationTests.java index 3b1201c5..3d8b9141 100644 --- a/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationIntegrationTests.java +++ b/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationIntegrationTests.java @@ -216,9 +216,9 @@ public class AppRoleAuthenticationIntegrationTests extends IntegrationTestSuppor public void shouldAuthenticatePushModeWithProvidedSecretId() { String roleId = getRoleId("with-secret-id"); - final String secretId = "hello_world"; + String secretId = "hello_world"; - final VaultResponse customSecretIdResponse = getVaultOperations().write( + VaultResponse customSecretIdResponse = getVaultOperations().write( "auth/approle/role/with-secret-id/custom-secret-id", Collections.singletonMap("secret_id", secretId)); diff --git a/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationUnitTests.java b/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationUnitTests.java index c816c63a..6e5e3044 100644 --- a/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationUnitTests.java +++ b/spring-vault-core/src/test/java/org/springframework/vault/authentication/AppRoleAuthenticationUnitTests.java @@ -27,7 +27,6 @@ import org.springframework.vault.VaultException; import org.springframework.vault.client.VaultClients; import org.springframework.vault.client.VaultClients.PrefixAwareUriTemplateHandler; import org.springframework.vault.support.VaultToken; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -179,9 +178,9 @@ public class AppRoleAuthenticationUnitTests { @Test public void loginShouldUnwrapSecretIdResponse() { + AppRoleAuthenticationOptions options = AppRoleAuthenticationOptions.builder() - .roleId("my_role_id") - .unwrappingToken(VaultToken.of("unwrapping_token")) + .roleId("my_role_id").unwrappingToken(VaultToken.of("unwrapping_token")) .build(); // Expect a first request to unwrap the response @@ -189,21 +188,19 @@ public class AppRoleAuthenticationUnitTests { .andExpect(header("X-Vault-Token", "unwrapping_token")) .andExpect(method(HttpMethod.POST)) .andRespond( - withSuccess().contentType(MediaType.APPLICATION_JSON).body("{" + - " \"request_id\": \"aad6a19b-a42b-b750-cafb-51087662f53e\"," + - " \"lease_id\": \"\"," + - " \"renewable\": false," + - " \"lease_duration\": 0," + - " \"data\": {" + - " \"secret_id\": \"my_secret_id\"," + - " \"secret_id_accessor\": \"my_secret_id_accessor\"" + - " }," + - " \"wrap_info\": null," + - " \"warnings\": null," + - " \"auth\": null" + - "}" - ) - ); + withSuccess() + .contentType(MediaType.APPLICATION_JSON) + .body("{" + + " \"request_id\": \"aad6a19b-a42b-b750-cafb-51087662f53e\"," + + " \"lease_id\": \"\"," + + " \"renewable\": false," + + " \"lease_duration\": 0," + + " \"data\": {" + + " \"secret_id\": \"my_secret_id\"," + + " \"secret_id_accessor\": \"my_secret_id_accessor\"" + + " }," + " \"wrap_info\": null," + + " \"warnings\": null," + " \"auth\": null" + + "}")); // Also expect a second request to retrieve a token mockRest.expect(requestTo("/auth/approle/login")) @@ -212,11 +209,10 @@ public class AppRoleAuthenticationUnitTests { .andExpect(jsonPath("$.secret_id").value("my_secret_id")) .andRespond( withSuccess() - .contentType(MediaType.APPLICATION_JSON) - .body("{" - + "\"auth\":{\"client_token\":\"my-token\", \"lease_duration\": 10, \"renewable\": true}" - + "}") - ); + .contentType(MediaType.APPLICATION_JSON) + .body("{" + + "\"auth\":{\"client_token\":\"my-token\", \"lease_duration\": 10, \"renewable\": true}" + + "}")); AppRoleAuthentication auth = new AppRoleAuthentication(options, restTemplate);