remove deprecated SecretResponse#getValue() convenience method
All checks were successful
continuous-integration/drone/push Build is passing

This method was deprecated since 0.5 and is basically a wrapper for
the more generic get("value").
This commit is contained in:
Stefan Kalscheuer 2021-06-06 14:47:56 +02:00
parent df466a4dd2
commit 9346619237
3 changed files with 10 additions and 40 deletions

View File

@ -7,6 +7,7 @@
* Remove deprecated `VaultConnectorFactory` in favor of `VaultConnectorBuilder` with identical API
* Remove deprecated `AppRoleBuilder` and `TokenBuilder` in favor of `AppRole.Builder` and `Token.Builder`
* Remove deprecated `Period`, `Policy` and `Policies` methods from `AppRole` in favor of `Token`-prefixed versions
* Remove deprecated `SecretResponse#getValue()` method, use `get("value")` instead.
### Improvements
* Use pre-sized map objects for fixed-size payloads

View File

@ -95,37 +95,6 @@ public class SecretResponse extends VaultDataResponse {
return getData().get(key);
}
/**
* Get data element for key "value".
* Method for backwards compatibility in case of simple secrets.
*
* @return the value
* @deprecated Deprecated artifact, will be removed at latest at v1.0.0
*/
@Deprecated
public final String getValue() {
Object value = get("value");
if (value == null) {
return null;
}
return value.toString();
}
/**
* Get response parsed as JSON.
*
* @param type Class to parse response
* @param <T> Class to parse response
* @return Parsed object
* @throws InvalidResponseException on parsing error
* @since 0.3
* @deprecated Deprecated artifact, will be removed at latest at v1.0.0
*/
@Deprecated
public final <T> T getValue(final Class<T> type) throws InvalidResponseException {
return get("value", type);
}
/**
* Get response parsed as JSON.
*

View File

@ -159,17 +159,17 @@ class HTTPVaultConnectorTest {
() -> connector.readSecret(SECRET_PATH + "/" + SECRET_KEY),
"Valid secret path could not be read"
);
assertThat("Known secret returned invalid value.", res.getValue(), is(SECRET_VALUE));
assertThat("Known secret returned invalid value.", res.get("value"), is(SECRET_VALUE));
/* Try to read accessible path with JSON value */
res = assertDoesNotThrow(
() -> connector.readSecret(SECRET_PATH + "/" + SECRET_KEY_JSON),
"Valid secret path could not be read"
);
assertThat("Known secret returned null value.", res.getValue(), notNullValue());
assertThat("Known secret returned null value.", res.get("value"), notNullValue());
SecretResponse finalRes = res;
Credentials parsedRes = assertDoesNotThrow(() -> finalRes.getValue(Credentials.class), "JSON response could not be parsed");
Credentials parsedRes = assertDoesNotThrow(() -> finalRes.get("value", Credentials.class), "JSON response could not be parsed");
assertThat("JSON response was null", parsedRes, notNullValue());
assertThat("JSON response incorrect", parsedRes.getUsername(), is("user"));
assertThat("JSON response incorrect", parsedRes.getPassword(), is("password"));
@ -179,10 +179,10 @@ class HTTPVaultConnectorTest {
() -> connector.readSecret(SECRET_PATH + "/" + SECRET_KEY_JSON),
"Valid secret path could not be read"
);
assertThat("Known secret returned null value.", res.getValue(), notNullValue());
assertThat("Known secret returned null value.", res.get("value"), notNullValue());
SecretResponse finalRes1 = res;
parsedRes = assertDoesNotThrow(() -> finalRes1.getValue(Credentials.class), "JSON response could not be parsed");
parsedRes = assertDoesNotThrow(() -> finalRes1.get("value", Credentials.class), "JSON response could not be parsed");
assertThat("JSON response was null", parsedRes, notNullValue());
assertThat("JSON response incorrect", parsedRes.getUsername(), is("user"));
assertThat("JSON response incorrect", parsedRes.getPassword(), is("password"));
@ -257,7 +257,7 @@ class HTTPVaultConnectorTest {
() -> connector.readSecret(SECRET_PATH + "/temp"),
"Written secret could not be read."
);
assertThat(res.getValue(), is("Abc123äöü,!"));
assertThat(res.get("value"), is("Abc123äöü,!"));
}
/**
@ -354,7 +354,7 @@ class HTTPVaultConnectorTest {
);
assertThat("Metadata not populated for KV v2 secret", res.getMetadata(), is(notNullValue()));
assertThat("Unexpected secret version", res.getMetadata().getVersion(), is(2));
assertThat("Known secret returned invalid value.", res.getValue(), is(SECRET2_VALUE2));
assertThat("Known secret returned invalid value.", res.get("value"), is(SECRET2_VALUE2));
// Try to read different version of same secret.
res = assertDoesNotThrow(
@ -362,7 +362,7 @@ class HTTPVaultConnectorTest {
"Valid secret version could not be read."
);
assertThat("Unexpected secret version", res.getMetadata().getVersion(), is(1));
assertThat("Known secret returned invalid value.", res.getValue(), is(SECRET2_VALUE1));
assertThat("Known secret returned invalid value.", res.get("value"), is(SECRET2_VALUE1));
}
/**
@ -397,7 +397,7 @@ class HTTPVaultConnectorTest {
() -> connector.readSecretData(MOUNT_KV2, SECRET2_KEY),
"Reading secret from KV v2 store failed."
);
assertThat("Data not updated correctly", res3.getValue(), is(SECRET2_VALUE3));
assertThat("Data not updated correctly", res3.get("value"), is(SECRET2_VALUE3));
// Now try with explicit CAS value (invalid).
Map<String, Object> data4 = singletonMap("value", SECRET2_VALUE4);