feat: add mount_type attribute to common response model

This commit is contained in:
Stefan Kalscheuer 2024-06-22 13:53:57 +02:00
parent 69da6b9f14
commit 8ec160a436
Signed by: stefan
GPG Key ID: 3887EC2A53B55430
3 changed files with 19 additions and 4 deletions

View File

@ -8,6 +8,7 @@
* `replication_primary_canary_age_ms` * `replication_primary_canary_age_ms`
* `enterprise` * `enterprise`
* Add missing `num_uses` field to `AuthData` * Add missing `num_uses` field to `AuthData`
* Add `mount_type` attribute to common response model
### Dependencies ### Dependencies
* Updated Jackson to 2.17.1 * Updated Jackson to 2.17.1

View File

@ -29,7 +29,7 @@ import java.util.Objects;
* @since 0.1 * @since 0.1
*/ */
public abstract class VaultDataResponse implements VaultResponse { public abstract class VaultDataResponse implements VaultResponse {
private static final long serialVersionUID = 7486270767477652184L; private static final long serialVersionUID = -6396903229092254181L;
@JsonProperty("request_id") @JsonProperty("request_id")
private String requestId; private String requestId;
@ -49,6 +49,9 @@ public abstract class VaultDataResponse implements VaultResponse {
@JsonProperty("wrap_info") @JsonProperty("wrap_info")
private WrapInfo wrapInfo; private WrapInfo wrapInfo;
@JsonProperty("mount_type")
private String mountType;
/** /**
* @return Request ID * @return Request ID
* @since 1.1 * @since 1.1
@ -93,6 +96,13 @@ public abstract class VaultDataResponse implements VaultResponse {
return wrapInfo; return wrapInfo;
} }
/**
* @return Information about the type of mount this secret is from (since Vault 1.17)
* @since 1.3
*/
public final String getMountType() {
return mountType;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
@ -106,11 +116,12 @@ public abstract class VaultDataResponse implements VaultResponse {
Objects.equals(leaseId, that.leaseId) && Objects.equals(leaseId, that.leaseId) &&
Objects.equals(leaseDuration, that.leaseDuration) && Objects.equals(leaseDuration, that.leaseDuration) &&
Objects.equals(warnings, that.warnings) && Objects.equals(warnings, that.warnings) &&
Objects.equals(wrapInfo, that.wrapInfo); Objects.equals(wrapInfo, that.wrapInfo) &&
Objects.equals(mountType, that.mountType);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(requestId, leaseId, renewable, leaseDuration, warnings, wrapInfo); return Objects.hash(requestId, leaseId, renewable, leaseDuration, warnings, wrapInfo, mountType);
} }
} }

View File

@ -55,6 +55,7 @@ class TokenResponseTest extends AbstractModelTest<TokenResponse> {
private static final String TOKEN_ID = "my-token"; private static final String TOKEN_ID = "my-token";
private static final String TOKEN_ISSUE_TIME = "2018-04-17T11:35:54.466476078-04:00"; private static final String TOKEN_ISSUE_TIME = "2018-04-17T11:35:54.466476078-04:00";
private static final String TOKEN_TYPE = "service"; private static final String TOKEN_TYPE = "service";
private static final String MOUNT_TYPE = "token";
private static final String RES_JSON = "{\n" + private static final String RES_JSON = "{\n" +
" \"lease_id\": \"\",\n" + " \"lease_id\": \"\",\n" +
@ -85,7 +86,8 @@ class TokenResponseTest extends AbstractModelTest<TokenResponse> {
" \"type\": \"" + TOKEN_TYPE + "\"\n" + " \"type\": \"" + TOKEN_TYPE + "\"\n" +
" },\n" + " },\n" +
" \"warnings\": null,\n" + " \"warnings\": null,\n" +
" \"auth\": null\n" + " \"auth\": null,\n" +
" \"mount_type\": \"" + MOUNT_TYPE + "\"\n" +
"}"; "}";
TokenResponseTest() { TokenResponseTest() {
@ -125,6 +127,7 @@ class TokenResponseTest extends AbstractModelTest<TokenResponse> {
assertEquals(RES_LEASE_DURATION, res.getLeaseDuration(), "Incorrect lease duration"); assertEquals(RES_LEASE_DURATION, res.getLeaseDuration(), "Incorrect lease duration");
assertEquals(RES_RENEWABLE, res.isRenewable(), "Incorrect response renewable flag"); assertEquals(RES_RENEWABLE, res.isRenewable(), "Incorrect response renewable flag");
assertEquals(RES_LEASE_DURATION, res.getLeaseDuration(), "Incorrect response lease duration"); assertEquals(RES_LEASE_DURATION, res.getLeaseDuration(), "Incorrect response lease duration");
assertEquals(MOUNT_TYPE, res.getMountType(), "Incorrect mount type");
// Extract token data. // Extract token data.
TokenData data = res.getData(); TokenData data = res.getData();
assertNotNull(data, "Token data is NULL"); assertNotNull(data, "Token data is NULL");