model: implement Serializable with model classes
implement equals() and hashCode()
This commit is contained in:
parent
18cb89ace4
commit
021421a54c
@ -7,6 +7,7 @@
|
|||||||
* Add `migration`, `recovery_seal` and `storage_type` fields to `SealReponse` model
|
* Add `migration`, `recovery_seal` and `storage_type` fields to `SealReponse` model
|
||||||
* Add support for `wrap_info` in data response models
|
* Add support for `wrap_info` in data response models
|
||||||
* Dependency updates
|
* Dependency updates
|
||||||
|
* model and response classes implement `Serializable` (#57)
|
||||||
|
|
||||||
### Test
|
### Test
|
||||||
* Tested against Vault 1.10.0
|
* Tested against Vault 1.10.0
|
||||||
|
6
pom.xml
6
pom.xml
@ -149,6 +149,12 @@
|
|||||||
<version>2.11.0</version>
|
<version>2.11.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.jqno.equalsverifier</groupId>
|
||||||
|
<artifactId>equalsverifier</artifactId>
|
||||||
|
<version>3.9</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -18,17 +18,22 @@ package de.stklcode.jvault.connector.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault AppRole role metamodel.
|
* Vault AppRole role metamodel.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AppRole {
|
public final class AppRole implements Serializable {
|
||||||
|
private static final long serialVersionUID = -6248529625864573990L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get {@link Builder} instance.
|
* Get {@link Builder} instance.
|
||||||
*
|
*
|
||||||
@ -316,6 +321,39 @@ public final class AppRole {
|
|||||||
return tokenType;
|
return tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AppRole appRole = (AppRole) o;
|
||||||
|
return Objects.equals(name, appRole.name) &&
|
||||||
|
Objects.equals(id, appRole.id) &&
|
||||||
|
Objects.equals(bindSecretId, appRole.bindSecretId) &&
|
||||||
|
Objects.equals(secretIdBoundCidrs, appRole.secretIdBoundCidrs) &&
|
||||||
|
Objects.equals(secretIdNumUses, appRole.secretIdNumUses) &&
|
||||||
|
Objects.equals(secretIdTtl, appRole.secretIdTtl) &&
|
||||||
|
Objects.equals(enableLocalSecretIds, appRole.enableLocalSecretIds) &&
|
||||||
|
Objects.equals(tokenTtl, appRole.tokenTtl) &&
|
||||||
|
Objects.equals(tokenMaxTtl, appRole.tokenMaxTtl) &&
|
||||||
|
Objects.equals(tokenPolicies, appRole.tokenPolicies) &&
|
||||||
|
Objects.equals(tokenBoundCidrs, appRole.tokenBoundCidrs) &&
|
||||||
|
Objects.equals(tokenExplicitMaxTtl, appRole.tokenExplicitMaxTtl) &&
|
||||||
|
Objects.equals(tokenNoDefaultPolicy, appRole.tokenNoDefaultPolicy) &&
|
||||||
|
Objects.equals(tokenNumUses, appRole.tokenNumUses) &&
|
||||||
|
Objects.equals(tokenPeriod, appRole.tokenPeriod) &&
|
||||||
|
Objects.equals(tokenType, appRole.tokenType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(name, id, bindSecretId, secretIdBoundCidrs, secretIdNumUses, secretIdTtl,
|
||||||
|
enableLocalSecretIds, tokenTtl, tokenMaxTtl, tokenPolicies, tokenBoundCidrs, tokenExplicitMaxTtl,
|
||||||
|
tokenNoDefaultPolicy, tokenNumUses, tokenPeriod, tokenType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A builder for vault AppRole roles..
|
* A builder for vault AppRole roles..
|
||||||
|
@ -18,17 +18,22 @@ package de.stklcode.jvault.connector.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault AppRole role metamodel.
|
* Vault AppRole role metamodel.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AppRoleSecret {
|
public final class AppRoleSecret implements Serializable {
|
||||||
|
private static final long serialVersionUID = -3401074170145792641L;
|
||||||
|
|
||||||
@JsonProperty("secret_id")
|
@JsonProperty("secret_id")
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
private String id;
|
private String id;
|
||||||
@ -166,4 +171,29 @@ public final class AppRoleSecret {
|
|||||||
public Integer getTtl() {
|
public Integer getTtl() {
|
||||||
return ttl;
|
return ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AppRoleSecret that = (AppRoleSecret) o;
|
||||||
|
return Objects.equals(id, that.id) &&
|
||||||
|
Objects.equals(accessor, that.accessor) &&
|
||||||
|
Objects.equals(metadata, that.metadata) &&
|
||||||
|
Objects.equals(cidrList, that.cidrList) &&
|
||||||
|
Objects.equals(creationTime, that.creationTime) &&
|
||||||
|
Objects.equals(expirationTime, that.expirationTime) &&
|
||||||
|
Objects.equals(lastUpdatedTime, that.lastUpdatedTime) &&
|
||||||
|
Objects.equals(numUses, that.numUses) &&
|
||||||
|
Objects.equals(ttl, that.ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, accessor, metadata, cidrList, creationTime, expirationTime, lastUpdatedTime, numUses,
|
||||||
|
ttl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,9 +28,12 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class Token {
|
public final class Token implements Serializable {
|
||||||
|
private static final long serialVersionUID = 5208508683665365287L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get {@link Builder} instance.
|
* Get {@link Builder} instance.
|
||||||
*
|
*
|
||||||
@ -214,6 +218,35 @@ public final class Token {
|
|||||||
return entityAlias;
|
return entityAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Token token = (Token) o;
|
||||||
|
return Objects.equals(id, token.id) &&
|
||||||
|
Objects.equals(type, token.type) &&
|
||||||
|
Objects.equals(displayName, token.displayName) &&
|
||||||
|
Objects.equals(noParent, token.noParent) &&
|
||||||
|
Objects.equals(noDefaultPolicy, token.noDefaultPolicy) &&
|
||||||
|
Objects.equals(ttl, token.ttl) &&
|
||||||
|
Objects.equals(explicitMaxTtl, token.explicitMaxTtl) &&
|
||||||
|
Objects.equals(numUses, token.numUses) &&
|
||||||
|
Objects.equals(policies, token.policies) &&
|
||||||
|
Objects.equals(meta, token.meta) &&
|
||||||
|
Objects.equals(renewable, token.renewable) &&
|
||||||
|
Objects.equals(period, token.period) &&
|
||||||
|
Objects.equals(entityAlias, token.entityAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, type, displayName, noParent, noDefaultPolicy, ttl, explicitMaxTtl, numUses, policies,
|
||||||
|
meta, renewable, period, entityAlias);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for token types.
|
* Constants for token types.
|
||||||
*/
|
*/
|
||||||
|
@ -20,17 +20,22 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault Token Role metamodel.
|
* Vault Token Role metamodel.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.9
|
* @since 0.9
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class TokenRole {
|
public final class TokenRole implements Serializable {
|
||||||
|
private static final long serialVersionUID = -6159563751115867561L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get {@link Builder} instance.
|
* Get {@link Builder} instance.
|
||||||
*
|
*
|
||||||
@ -205,6 +210,36 @@ public final class TokenRole {
|
|||||||
return tokenType;
|
return tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TokenRole tokenRole = (TokenRole) o;
|
||||||
|
return Objects.equals(name, tokenRole.name) &&
|
||||||
|
Objects.equals(allowedPolicies, tokenRole.allowedPolicies) &&
|
||||||
|
Objects.equals(disallowedPolicies, tokenRole.disallowedPolicies) &&
|
||||||
|
Objects.equals(orphan, tokenRole.orphan) &&
|
||||||
|
Objects.equals(renewable, tokenRole.renewable) &&
|
||||||
|
Objects.equals(pathSuffix, tokenRole.pathSuffix) &&
|
||||||
|
Objects.equals(allowedEntityAliases, tokenRole.allowedEntityAliases) &&
|
||||||
|
Objects.equals(tokenBoundCidrs, tokenRole.tokenBoundCidrs) &&
|
||||||
|
Objects.equals(tokenExplicitMaxTtl, tokenRole.tokenExplicitMaxTtl) &&
|
||||||
|
Objects.equals(tokenNoDefaultPolicy, tokenRole.tokenNoDefaultPolicy) &&
|
||||||
|
Objects.equals(tokenNumUses, tokenRole.tokenNumUses) &&
|
||||||
|
Objects.equals(tokenPeriod, tokenRole.tokenPeriod) &&
|
||||||
|
Objects.equals(tokenType, tokenRole.tokenType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(name, allowedPolicies, disallowedPolicies, orphan, renewable, pathSuffix,
|
||||||
|
allowedEntityAliases, tokenBoundCidrs, tokenExplicitMaxTtl, tokenNoDefaultPolicy, tokenNumUses,
|
||||||
|
tokenPeriod, tokenType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A builder for vault token roles.
|
* A builder for vault token roles.
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,7 @@ import de.stklcode.jvault.connector.model.AppRole;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for AppRole lookup.
|
* Vault response for AppRole lookup.
|
||||||
@ -33,6 +34,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AppRoleResponse extends VaultDataResponse {
|
public final class AppRoleResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = -7817890935652200399L;
|
||||||
|
|
||||||
private AppRole role;
|
private AppRole role;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,4 +61,20 @@ public final class AppRoleResponse extends VaultDataResponse {
|
|||||||
public AppRole getRole() {
|
public AppRole getRole() {
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AppRoleResponse that = (AppRoleResponse) o;
|
||||||
|
return Objects.equals(role, that.role);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), role);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.stklcode.jvault.connector.model.AppRoleSecret;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for AppRole lookup.
|
* Vault response for AppRole lookup.
|
||||||
@ -33,6 +34,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AppRoleSecretResponse extends VaultDataResponse {
|
public final class AppRoleSecretResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = 7511563325431032667L;
|
||||||
|
|
||||||
private AppRoleSecret secret;
|
private AppRoleSecret secret;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,4 +61,20 @@ public final class AppRoleSecretResponse extends VaultDataResponse {
|
|||||||
public AppRoleSecret getSecret() {
|
public AppRoleSecret getSecret() {
|
||||||
return secret;
|
return secret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AppRoleSecretResponse that = (AppRoleSecretResponse) o;
|
||||||
|
return Objects.equals(secret, that.secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), secret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.stklcode.jvault.connector.model.response.embedded.AuthMethod;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authentication method response.
|
* Authentication method response.
|
||||||
@ -33,6 +34,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AuthMethodsResponse extends VaultDataResponse {
|
public final class AuthMethodsResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = 5521702564857621352L;
|
||||||
|
|
||||||
private Map<String, AuthMethod> supportedMethods;
|
private Map<String, AuthMethod> supportedMethods;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,4 +64,20 @@ public final class AuthMethodsResponse extends VaultDataResponse {
|
|||||||
public Map<String, AuthMethod> getSupportedMethods() {
|
public Map<String, AuthMethod> getSupportedMethods() {
|
||||||
return supportedMethods;
|
return supportedMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AuthMethodsResponse that = (AuthMethodsResponse) o;
|
||||||
|
return Objects.equals(supportedMethods, that.supportedMethods);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), supportedMethods);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.stklcode.jvault.connector.model.response.embedded.AuthData;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for authentication providing auth info in {@link AuthData} field.
|
* Vault response for authentication providing auth info in {@link AuthData} field.
|
||||||
@ -33,6 +34,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AuthResponse extends VaultDataResponse {
|
public final class AuthResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = -6728387061352164781L;
|
||||||
|
|
||||||
private Map<String, Object> data;
|
private Map<String, Object> data;
|
||||||
|
|
||||||
private AuthData auth;
|
private AuthData auth;
|
||||||
@ -71,4 +74,20 @@ public final class AuthResponse extends VaultDataResponse {
|
|||||||
public AuthData getAuth() {
|
public AuthData getAuth() {
|
||||||
return auth;
|
return auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AuthResponse that = (AuthResponse) o;
|
||||||
|
return Objects.equals(data, that.data) && Objects.equals(auth, that.auth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), data, auth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class CredentialsResponse extends SecretResponse {
|
public final class CredentialsResponse extends SecretResponse {
|
||||||
|
private static final long serialVersionUID = -1439692963299045425L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Username
|
* @return Username
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response in case of errors.
|
* Vault response in case of errors.
|
||||||
@ -29,6 +30,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class ErrorResponse implements VaultResponse {
|
public final class ErrorResponse implements VaultResponse {
|
||||||
|
private static final long serialVersionUID = -6227368087842549149L;
|
||||||
|
|
||||||
@JsonProperty("errors")
|
@JsonProperty("errors")
|
||||||
private List<String> errors;
|
private List<String> errors;
|
||||||
|
|
||||||
@ -47,4 +50,20 @@ public final class ErrorResponse implements VaultResponse {
|
|||||||
return errors.get(0);
|
return errors.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ErrorResponse that = (ErrorResponse) o;
|
||||||
|
return Objects.equals(errors, that.errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(errors);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for health query.
|
* Vault response for health query.
|
||||||
*
|
*
|
||||||
@ -27,6 +29,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class HealthResponse implements VaultResponse {
|
public final class HealthResponse implements VaultResponse {
|
||||||
|
private static final long serialVersionUID = 6483840078694294401L;
|
||||||
|
|
||||||
@JsonProperty("cluster_id")
|
@JsonProperty("cluster_id")
|
||||||
private String clusterID;
|
private String clusterID;
|
||||||
|
|
||||||
@ -129,4 +133,30 @@ public final class HealthResponse implements VaultResponse {
|
|||||||
public Boolean isPerformanceStandby() {
|
public Boolean isPerformanceStandby() {
|
||||||
return performanceStandby;
|
return performanceStandby;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
HealthResponse that = (HealthResponse) o;
|
||||||
|
return Objects.equals(clusterID, that.clusterID) &&
|
||||||
|
Objects.equals(clusterName, that.clusterName) &&
|
||||||
|
Objects.equals(version, that.version) &&
|
||||||
|
Objects.equals(serverTimeUTC, that.serverTimeUTC) &&
|
||||||
|
Objects.equals(standby, that.standby) &&
|
||||||
|
Objects.equals(sealed, that.sealed) &&
|
||||||
|
Objects.equals(initialized, that.initialized) &&
|
||||||
|
Objects.equals(replicationPerfMode, that.replicationPerfMode) &&
|
||||||
|
Objects.equals(replicationDrMode, that.replicationDrMode) &&
|
||||||
|
Objects.equals(performanceStandby, that.performanceStandby);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(clusterID, clusterName, version, serverTimeUTC, standby, sealed, initialized,
|
||||||
|
replicationPerfMode, replicationDrMode, performanceStandby);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for help request.
|
* Vault response for help request.
|
||||||
*
|
*
|
||||||
@ -27,6 +29,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class HelpResponse implements VaultResponse {
|
public final class HelpResponse implements VaultResponse {
|
||||||
|
private static final long serialVersionUID = -1152070966642848490L;
|
||||||
|
|
||||||
@JsonProperty("help")
|
@JsonProperty("help")
|
||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
@ -36,4 +40,20 @@ public final class HelpResponse implements VaultResponse {
|
|||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return help;
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
HelpResponse that = (HelpResponse) o;
|
||||||
|
return Objects.equals(help, that.help);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(help);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.stklcode.jvault.connector.model.response.embedded.SecretMetadata;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for secret metadata (KV v2).
|
* Vault response for secret metadata (KV v2).
|
||||||
@ -32,6 +33,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class MetadataResponse extends VaultDataResponse {
|
public class MetadataResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = 3407081728744500975L;
|
||||||
|
|
||||||
private SecretMetadata metadata;
|
private SecretMetadata metadata;
|
||||||
|
|
||||||
@ -53,4 +55,20 @@ public class MetadataResponse extends VaultDataResponse {
|
|||||||
public SecretMetadata getMetadata() {
|
public SecretMetadata getMetadata() {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MetadataResponse that = (MetadataResponse) o;
|
||||||
|
return Objects.equals(metadata, that.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple Vault data response.
|
* Simple Vault data response.
|
||||||
@ -28,6 +29,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class RawDataResponse extends VaultDataResponse {
|
public final class RawDataResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = -5494734676257709074L;
|
||||||
|
|
||||||
private Map<String, Object> data;
|
private Map<String, Object> data;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,4 +44,20 @@ public final class RawDataResponse extends VaultDataResponse {
|
|||||||
public Map<String, Object> getData() {
|
public Map<String, Object> getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
RawDataResponse that = (RawDataResponse) o;
|
||||||
|
return Objects.equals(data, that.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for seal status or unseal request.
|
* Vault response for seal status or unseal request.
|
||||||
*
|
*
|
||||||
@ -27,6 +29,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class SealResponse implements VaultResponse {
|
public final class SealResponse implements VaultResponse {
|
||||||
|
private static final long serialVersionUID = -3661916639367542617L;
|
||||||
|
|
||||||
@JsonProperty("type")
|
@JsonProperty("type")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@ -165,4 +169,33 @@ public final class SealResponse implements VaultResponse {
|
|||||||
public String getStorageType() {
|
public String getStorageType() {
|
||||||
return storageType;
|
return storageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SealResponse that = (SealResponse) o;
|
||||||
|
return sealed == that.sealed &&
|
||||||
|
initialized == that.initialized &&
|
||||||
|
Objects.equals(type, that.type) &&
|
||||||
|
Objects.equals(threshold, that.threshold) &&
|
||||||
|
Objects.equals(numberOfShares, that.numberOfShares) &&
|
||||||
|
Objects.equals(progress, that.progress) &&
|
||||||
|
Objects.equals(version, that.version) &&
|
||||||
|
Objects.equals(nonce, that.nonce) &&
|
||||||
|
Objects.equals(clusterName, that.clusterName) &&
|
||||||
|
Objects.equals(clusterId, that.clusterId) &&
|
||||||
|
Objects.equals(migration, that.migration) &&
|
||||||
|
Objects.equals(recoverySeal, that.recoverySeal) &&
|
||||||
|
Objects.equals(storageType, that.storageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(type, sealed, initialized, threshold, numberOfShares, progress, version, nonce,
|
||||||
|
clusterName, clusterId, migration, recoverySeal, storageType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for secret list request.
|
* Vault response for secret list request.
|
||||||
@ -31,13 +32,14 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class SecretListResponse extends VaultDataResponse {
|
public final class SecretListResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = -5279146643326713976L;
|
||||||
|
|
||||||
private List<String> keys;
|
private List<String> keys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set data. Extracts list of keys from raw response data.
|
* Set data. Extracts list of keys from raw response data.
|
||||||
*
|
*
|
||||||
* @param data Raw data
|
* @param data Raw data
|
||||||
* @throws InvalidResponseException on parsing errors
|
|
||||||
*/
|
*/
|
||||||
@JsonProperty("data")
|
@JsonProperty("data")
|
||||||
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
public void setData(final Map<String, Object> data) throws InvalidResponseException {
|
||||||
@ -54,4 +56,20 @@ public final class SecretListResponse extends VaultDataResponse {
|
|||||||
public List<String> getKeys() {
|
public List<String> getKeys() {
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SecretListResponse that = (SecretListResponse) o;
|
||||||
|
return Objects.equals(keys, that.keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), keys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.stklcode.jvault.connector.model.response.embedded.VersionMetadata;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for secret request.
|
* Vault response for secret request.
|
||||||
@ -33,6 +34,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class SecretResponse extends VaultDataResponse {
|
public class SecretResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = -8215178956885015265L;
|
||||||
|
|
||||||
private static final String KEY_DATA = "data";
|
private static final String KEY_DATA = "data";
|
||||||
private static final String KEY_METADATA = "metadata";
|
private static final String KEY_METADATA = "metadata";
|
||||||
|
|
||||||
@ -116,4 +119,20 @@ public class SecretResponse extends VaultDataResponse {
|
|||||||
throw new InvalidResponseException("Unable to parse response payload: " + e.getMessage());
|
throw new InvalidResponseException("Unable to parse response payload: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SecretResponse that = (SecretResponse) o;
|
||||||
|
return Objects.equals(data, that.data) && Objects.equals(metadata, that.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), data, metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.stklcode.jvault.connector.model.response.embedded.VersionMetadata;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response for a single secret version metadata, i.e. after update (KV v2).
|
* Vault response for a single secret version metadata, i.e. after update (KV v2).
|
||||||
@ -32,6 +33,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class SecretVersionResponse extends VaultDataResponse {
|
public class SecretVersionResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = -6681638207727120184L;
|
||||||
|
|
||||||
private VersionMetadata metadata;
|
private VersionMetadata metadata;
|
||||||
|
|
||||||
@ -53,4 +55,20 @@ public class SecretVersionResponse extends VaultDataResponse {
|
|||||||
public VersionMetadata getMetadata() {
|
public VersionMetadata getMetadata() {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SecretVersionResponse that = (SecretVersionResponse) o;
|
||||||
|
return Objects.equals(metadata, that.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.stklcode.jvault.connector.model.response.embedded.TokenData;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response from token lookup providing Token information in {@link TokenData} field.
|
* Vault response from token lookup providing Token information in {@link TokenData} field.
|
||||||
@ -33,6 +34,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class TokenResponse extends VaultDataResponse {
|
public final class TokenResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = 2248288114849229479L;
|
||||||
|
|
||||||
private TokenData data;
|
private TokenData data;
|
||||||
|
|
||||||
@JsonProperty("auth")
|
@JsonProperty("auth")
|
||||||
@ -60,4 +63,20 @@ public final class TokenResponse extends VaultDataResponse {
|
|||||||
public TokenData getData() {
|
public TokenData getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TokenResponse that = (TokenResponse) o;
|
||||||
|
return Objects.equals(data, that.data) && Objects.equals(auth, that.auth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), data, auth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.stklcode.jvault.connector.model.response.embedded.TokenData;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault response from token role lookup providing Token information in {@link TokenData} field.
|
* Vault response from token role lookup providing Token information in {@link TokenData} field.
|
||||||
@ -33,6 +34,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class TokenRoleResponse extends VaultDataResponse {
|
public final class TokenRoleResponse extends VaultDataResponse {
|
||||||
|
private static final long serialVersionUID = -6622498881812517596L;
|
||||||
|
|
||||||
private TokenRole data;
|
private TokenRole data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,4 +60,20 @@ public final class TokenRoleResponse extends VaultDataResponse {
|
|||||||
public TokenRole getData() {
|
public TokenRole getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass() || !super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TokenRoleResponse that = (TokenRoleResponse) o;
|
||||||
|
return Objects.equals(data, that.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import de.stklcode.jvault.connector.model.response.embedded.WrapInfo;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract Vault response with default payload fields.
|
* Abstract Vault response with default payload fields.
|
||||||
@ -30,6 +31,8 @@ import java.util.Map;
|
|||||||
* @since 0.1
|
* @since 0.1
|
||||||
*/
|
*/
|
||||||
public abstract class VaultDataResponse implements VaultResponse {
|
public abstract class VaultDataResponse implements VaultResponse {
|
||||||
|
private static final long serialVersionUID = 2507925101227179499L;
|
||||||
|
|
||||||
@JsonProperty("lease_id")
|
@JsonProperty("lease_id")
|
||||||
private String leaseId;
|
private String leaseId;
|
||||||
|
|
||||||
@ -89,4 +92,24 @@ public abstract class VaultDataResponse implements VaultResponse {
|
|||||||
public final WrapInfo getWrapInfo() {
|
public final WrapInfo getWrapInfo() {
|
||||||
return wrapInfo;
|
return wrapInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
VaultDataResponse that = (VaultDataResponse) o;
|
||||||
|
return renewable == that.renewable &&
|
||||||
|
Objects.equals(leaseId, that.leaseId) &&
|
||||||
|
Objects.equals(leaseDuration, that.leaseDuration) &&
|
||||||
|
Objects.equals(warnings, that.warnings) &&
|
||||||
|
Objects.equals(wrapInfo, that.wrapInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(leaseId, renewable, leaseDuration, warnings, wrapInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,14 @@
|
|||||||
|
|
||||||
package de.stklcode.jvault.connector.model.response;
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marker interface for responses from Vault backend.
|
* Marker interface for responses from Vault backend.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.1
|
* @since 0.1
|
||||||
|
* @since 1.1 extends {@link Serializable}
|
||||||
*/
|
*/
|
||||||
public interface VaultResponse {
|
public interface VaultResponse extends Serializable {
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,22 @@ package de.stklcode.jvault.connector.model.response.embedded;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Embedded authorization information inside Vault response.
|
* Embedded authorization information inside Vault response.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.1
|
* @since 0.1
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AuthData {
|
public final class AuthData implements Serializable {
|
||||||
|
private static final long serialVersionUID = -6962244199229885869L;
|
||||||
|
|
||||||
@JsonProperty("client_token")
|
@JsonProperty("client_token")
|
||||||
private String clientToken;
|
private String clientToken;
|
||||||
|
|
||||||
@ -133,4 +138,31 @@ public final class AuthData {
|
|||||||
public boolean isOrphan() {
|
public boolean isOrphan() {
|
||||||
return orphan;
|
return orphan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AuthData authData = (AuthData) o;
|
||||||
|
return renewable == authData.renewable &&
|
||||||
|
orphan == authData.orphan &&
|
||||||
|
Objects.equals(clientToken, authData.clientToken) &&
|
||||||
|
Objects.equals(accessor, authData.accessor) &&
|
||||||
|
Objects.equals(policies, authData.policies) &&
|
||||||
|
Objects.equals(tokenPolicies, authData.tokenPolicies) &&
|
||||||
|
Objects.equals(metadata, authData.metadata) &&
|
||||||
|
Objects.equals(leaseDuration, authData.leaseDuration) &&
|
||||||
|
Objects.equals(entityId, authData.entityId) &&
|
||||||
|
Objects.equals(tokenType, authData.tokenType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(clientToken, accessor, policies, tokenPolicies, metadata, leaseDuration, renewable,
|
||||||
|
entityId, tokenType, orphan);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||||
import de.stklcode.jvault.connector.model.AuthBackend;
|
import de.stklcode.jvault.connector.model.AuthBackend;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Embedded authentication method response.
|
* Embedded authentication method response.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.1
|
* @since 0.1
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AuthMethod {
|
public final class AuthMethod implements Serializable {
|
||||||
|
private static final long serialVersionUID = -5241997986380823391L;
|
||||||
|
|
||||||
private AuthBackend type;
|
private AuthBackend type;
|
||||||
private String rawType;
|
private String rawType;
|
||||||
|
|
||||||
@ -86,4 +91,24 @@ public final class AuthMethod {
|
|||||||
public boolean isLocal() {
|
public boolean isLocal() {
|
||||||
return local;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AuthMethod that = (AuthMethod) o;
|
||||||
|
return local == that.local &&
|
||||||
|
type == that.type &&
|
||||||
|
Objects.equals(rawType, that.rawType) &&
|
||||||
|
Objects.equals(description, that.description) &&
|
||||||
|
Objects.equals(config, that.config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(type, rawType, description, config, local);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,19 +19,24 @@ package de.stklcode.jvault.connector.model.response.embedded;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Embedded metadata for Key-Value v2 secrets.
|
* Embedded metadata for Key-Value v2 secrets.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8
|
* @since 0.8
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class SecretMetadata {
|
public final class SecretMetadata implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1684891108903409038L;
|
||||||
|
|
||||||
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX");
|
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX");
|
||||||
|
|
||||||
@JsonProperty("created_time")
|
@JsonProperty("created_time")
|
||||||
@ -124,4 +129,24 @@ public final class SecretMetadata {
|
|||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SecretMetadata that = (SecretMetadata) o;
|
||||||
|
return Objects.equals(createdTimeString, that.createdTimeString) &&
|
||||||
|
Objects.equals(currentVersion, that.currentVersion) &&
|
||||||
|
Objects.equals(maxVersions, that.maxVersions) &&
|
||||||
|
Objects.equals(oldestVersion, that.oldestVersion) &&
|
||||||
|
Objects.equals(updatedTime, that.updatedTime) &&
|
||||||
|
Objects.equals(versions, that.versions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(createdTimeString, currentVersion, maxVersions, oldestVersion, updatedTime, versions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,23 @@ package de.stklcode.jvault.connector.model.response.embedded;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Embedded token information inside Vault response.
|
* Embedded token information inside Vault response.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.1
|
* @since 0.1
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class TokenData {
|
public final class TokenData implements Serializable {
|
||||||
|
private static final long serialVersionUID = 2915180734313753649L;
|
||||||
|
|
||||||
@JsonProperty("accessor")
|
@JsonProperty("accessor")
|
||||||
private String accessor;
|
private String accessor;
|
||||||
|
|
||||||
@ -231,4 +236,37 @@ public final class TokenData {
|
|||||||
public Map<String, Object> getMeta() {
|
public Map<String, Object> getMeta() {
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TokenData tokenData = (TokenData) o;
|
||||||
|
return orphan == tokenData.orphan &&
|
||||||
|
renewable == tokenData.renewable &&
|
||||||
|
Objects.equals(accessor, tokenData.accessor) &&
|
||||||
|
Objects.equals(creationTime, tokenData.creationTime) &&
|
||||||
|
Objects.equals(creationTtl, tokenData.creationTtl) &&
|
||||||
|
Objects.equals(name, tokenData.name) &&
|
||||||
|
Objects.equals(entityId, tokenData.entityId) &&
|
||||||
|
Objects.equals(expireTime, tokenData.expireTime) &&
|
||||||
|
Objects.equals(explicitMaxTtl, tokenData.explicitMaxTtl) &&
|
||||||
|
Objects.equals(id, tokenData.id) &&
|
||||||
|
Objects.equals(issueTime, tokenData.issueTime) &&
|
||||||
|
Objects.equals(meta, tokenData.meta) &&
|
||||||
|
Objects.equals(numUses, tokenData.numUses) &&
|
||||||
|
Objects.equals(path, tokenData.path) &&
|
||||||
|
Objects.equals(policies, tokenData.policies) &&
|
||||||
|
Objects.equals(ttl, tokenData.ttl) &&
|
||||||
|
Objects.equals(type, tokenData.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(accessor, creationTime, creationTtl, name, entityId, expireTime, explicitMaxTtl, id,
|
||||||
|
issueTime, meta, numUses, orphan, path, policies, renewable, ttl, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,23 @@ package de.stklcode.jvault.connector.model.response.embedded;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Embedded metadata for a single Key-Value v2 version.
|
* Embedded metadata for a single Key-Value v2 version.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.8
|
* @since 0.8
|
||||||
|
* @since 1.1 implements {@link Serializable}
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class VersionMetadata {
|
public final class VersionMetadata implements Serializable {
|
||||||
|
private static final long serialVersionUID = -5286693953873839611L;
|
||||||
|
|
||||||
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX");
|
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX");
|
||||||
|
|
||||||
@JsonProperty("created_time")
|
@JsonProperty("created_time")
|
||||||
@ -103,4 +108,22 @@ public final class VersionMetadata {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
VersionMetadata that = (VersionMetadata) o;
|
||||||
|
return destroyed == that.destroyed &&
|
||||||
|
Objects.equals(createdTimeString, that.createdTimeString) &&
|
||||||
|
Objects.equals(deletionTimeString, that.deletionTimeString) &&
|
||||||
|
Objects.equals(version, that.version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(createdTimeString, deletionTimeString, destroyed, version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,17 @@ package de.stklcode.jvault.connector.model.response.embedded;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping information object.
|
* Wrapping information object.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public class WrapInfo {
|
public class WrapInfo implements Serializable {
|
||||||
|
private static final long serialVersionUID = -7764500642913116581L;
|
||||||
|
|
||||||
@JsonProperty("token")
|
@JsonProperty("token")
|
||||||
private String token;
|
private String token;
|
||||||
@ -65,4 +69,23 @@ public class WrapInfo {
|
|||||||
public String getCreationPath() {
|
public String getCreationPath() {
|
||||||
return creationPath;
|
return creationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
} else if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
WrapInfo that = (WrapInfo) o;
|
||||||
|
return Objects.equals(token, that.token) &&
|
||||||
|
Objects.equals(ttl, that.ttl) &&
|
||||||
|
Objects.equals(creationTime, that.creationTime) &&
|
||||||
|
Objects.equals(creationPath, that.creationPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(token, ttl, creationTime, creationPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,10 @@
|
|||||||
package de.stklcode.jvault.connector.model;
|
package de.stklcode.jvault.connector.model;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -37,13 +36,11 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|||||||
*/
|
*/
|
||||||
class AppRoleSecretTest {
|
class AppRoleSecretTest {
|
||||||
private static final String TEST_ID = "abc123";
|
private static final String TEST_ID = "abc123";
|
||||||
private static final Map<String, Object> TEST_META = new HashMap<>();
|
private static final Map<String, Object> TEST_META = Map.of(
|
||||||
private static final List<String> TEST_CIDR = Arrays.asList("203.0.113.0/24", "198.51.100.0/24");
|
"foo", "bar",
|
||||||
|
"number", 1337
|
||||||
static {
|
);
|
||||||
TEST_META.put("foo", "bar");
|
private static final List<String> TEST_CIDR = List.of("203.0.113.0/24", "198.51.100.0/24");
|
||||||
TEST_META.put("number", 1337);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test constructors.
|
* Test constructors.
|
||||||
@ -167,7 +164,11 @@ class AppRoleSecretTest {
|
|||||||
assertEquals("TEST_LASTUPDATE", secret2.getLastUpdatedTime());
|
assertEquals("TEST_LASTUPDATE", secret2.getLastUpdatedTime());
|
||||||
assertEquals(678, secret2.getNumUses());
|
assertEquals(678, secret2.getNumUses());
|
||||||
assertEquals(12345, secret2.getTtl());
|
assertEquals(12345, secret2.getTtl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(AppRoleSecret.class).verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setPrivateField(Object object, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
|
private static void setPrivateField(Object object, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
|
||||||
@ -182,5 +183,4 @@ class AppRoleSecretTest {
|
|||||||
return json.replaceAll("\"cidr_list\":\"([^\"]*)\"", "\"cidr_list\":\\[$1\\]")
|
return json.replaceAll("\"cidr_list\":\"([^\"]*)\"", "\"cidr_list\":\\[$1\\]")
|
||||||
.replaceAll("(\\d+\\.\\d+\\.\\d+\\.\\d+/\\d+)", "\"$1\"");
|
.replaceAll("(\\d+\\.\\d+\\.\\d+\\.\\d+/\\d+)", "\"$1\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package de.stklcode.jvault.connector.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -172,4 +173,9 @@ class AppRoleTest {
|
|||||||
assertEquals(2, role.getTokenPolicies().size());
|
assertEquals(2, role.getTokenPolicies().size());
|
||||||
assertTrue(role.getTokenPolicies().containsAll(List.of(POLICY, POLICY_2)));
|
assertTrue(role.getTokenPolicies().containsAll(List.of(POLICY, POLICY_2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(AppRole.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package de.stklcode.jvault.connector.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -26,12 +27,12 @@ import java.util.List;
|
|||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit Test for {@link Token.Builder}
|
* Unit Test for {@link TokenRole} and {@link TokenRole.Builder}.
|
||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.9
|
* @since 0.9
|
||||||
*/
|
*/
|
||||||
class TokenRoleBuilderTest {
|
class TokenRoleTest {
|
||||||
private static final String NAME = "test-role";
|
private static final String NAME = "test-role";
|
||||||
private static final String ALLOWED_POLICY_1 = "apol-1";
|
private static final String ALLOWED_POLICY_1 = "apol-1";
|
||||||
private static final String ALLOWED_POLICY_2 = "apol-2";
|
private static final String ALLOWED_POLICY_2 = "apol-2";
|
||||||
@ -132,6 +133,9 @@ class TokenRoleBuilderTest {
|
|||||||
assertNull(role.getTokenPeriod());
|
assertNull(role.getTokenPeriod());
|
||||||
assertNull(role.getTokenType());
|
assertNull(role.getTokenType());
|
||||||
|
|
||||||
|
// Empty builder should be equal to no-arg construction.
|
||||||
|
assertEquals(role, new TokenRole());
|
||||||
|
|
||||||
// Optional fields should be ignored, so JSON string should be empty.
|
// Optional fields should be ignored, so JSON string should be empty.
|
||||||
assertEquals("{}", new ObjectMapper().writeValueAsString(role));
|
assertEquals("{}", new ObjectMapper().writeValueAsString(role));
|
||||||
}
|
}
|
||||||
@ -180,4 +184,9 @@ class TokenRoleBuilderTest {
|
|||||||
// Verify that all parameters are included in JSON string.
|
// Verify that all parameters are included in JSON string.
|
||||||
assertEquals(JSON_FULL, new ObjectMapper().writeValueAsString(role));
|
assertEquals(JSON_FULL, new ObjectMapper().writeValueAsString(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(TokenRole.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ package de.stklcode.jvault.connector.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -81,6 +82,9 @@ class TokenTest {
|
|||||||
|
|
||||||
// Optional fields should be ignored, so JSON string should be empty.
|
// Optional fields should be ignored, so JSON string should be empty.
|
||||||
assertEquals("{}", new ObjectMapper().writeValueAsString(token));
|
assertEquals("{}", new ObjectMapper().writeValueAsString(token));
|
||||||
|
|
||||||
|
// Empty builder should be equal to no-arg construction.
|
||||||
|
assertEquals(token, new Token());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,4 +171,9 @@ class TokenTest {
|
|||||||
assertEquals(META_VALUE, token.getMeta().get(META_KEY));
|
assertEquals(META_VALUE, token.getMeta().get(META_KEY));
|
||||||
assertEquals(META_VALUE_2, token.getMeta().get(META_KEY_2));
|
assertEquals(META_VALUE_2, token.getMeta().get(META_KEY_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(Token.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
import de.stklcode.jvault.connector.model.AppRole;
|
import de.stklcode.jvault.connector.model.AppRole;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -63,11 +63,7 @@ class AppRoleResponseTest {
|
|||||||
" \"lease_id\": \"\"\n" +
|
" \"lease_id\": \"\"\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
private static final Map<String, Object> INVALID_DATA = new HashMap<>();
|
private static final Map<String, Object> INVALID_DATA = Map.of("token_policies", "fancy-policy");
|
||||||
|
|
||||||
static {
|
|
||||||
INVALID_DATA.put("token_policies", "fancy-policy");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
@ -109,4 +105,9 @@ class AppRoleResponseTest {
|
|||||||
assertNull(role.getTokenBoundCidrs(), "Incorrect bound CIDR list");
|
assertNull(role.getTokenBoundCidrs(), "Incorrect bound CIDR list");
|
||||||
assertEquals("", role.getTokenBoundCidrsString(), "Incorrect bound CIDR list string");
|
assertEquals("", role.getTokenBoundCidrsString(), "Incorrect bound CIDR list string");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(AppRoleResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
import de.stklcode.jvault.connector.model.AuthBackend;
|
import de.stklcode.jvault.connector.model.AuthBackend;
|
||||||
import de.stklcode.jvault.connector.model.response.embedded.AuthMethod;
|
import de.stklcode.jvault.connector.model.response.embedded.AuthMethod;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -62,11 +63,7 @@ class AuthMethodsResponseTest {
|
|||||||
" }\n" +
|
" }\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
private static final Map<String, Object> INVALID_DATA = new HashMap<>();
|
private static final Map<String, Object> INVALID_DATA = Map.of("dummy/", new Dummy());
|
||||||
|
|
||||||
static {
|
|
||||||
INVALID_DATA.put("dummy/", new Dummy());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
@ -119,7 +116,12 @@ class AuthMethodsResponseTest {
|
|||||||
assertEquals(TK_MAX_LEASE_TTL.toString(), method.getConfig().get("max_lease_ttl"), "Incorrect max lease TTL config");
|
assertEquals(TK_MAX_LEASE_TTL.toString(), method.getConfig().get("max_lease_ttl"), "Incorrect max lease TTL config");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Dummy {
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(AuthMethodsResponse.class).verify();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Dummy implements Serializable {
|
||||||
|
private static final long serialVersionUID = 9075949348402246139L;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
import de.stklcode.jvault.connector.model.response.embedded.AuthData;
|
import de.stklcode.jvault.connector.model.response.embedded.AuthData;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -69,11 +69,7 @@ class AuthResponseTest {
|
|||||||
" }\n" +
|
" }\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
private static final Map<String, Object> INVALID_AUTH_DATA = new HashMap<>();
|
private static final Map<String, Object> INVALID_AUTH_DATA = Map.of("policies", "fancy-policy");
|
||||||
|
|
||||||
static {
|
|
||||||
INVALID_AUTH_DATA.put("policies", "fancy-policy");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
@ -122,4 +118,9 @@ class AuthResponseTest {
|
|||||||
assertTrue(data.getTokenPolicies().containsAll(Set.of(AUTH_POLICY_2, AUTH_POLICY_1)), "Incorrect token policies");
|
assertTrue(data.getTokenPolicies().containsAll(Set.of(AUTH_POLICY_2, AUTH_POLICY_1)), "Incorrect token policies");
|
||||||
assertEquals(Map.of(AUTH_META_KEY, AUTH_META_VALUE), data.getMetadata(), "Incorrect auth metadata");
|
assertEquals(Map.of(AUTH_META_KEY, AUTH_META_VALUE), data.getMetadata(), "Incorrect auth metadata");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(AuthResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
package de.stklcode.jvault.connector.model.response;
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -32,14 +32,12 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||||||
* @since 0.8
|
* @since 0.8
|
||||||
*/
|
*/
|
||||||
class CredentialsResponseTest {
|
class CredentialsResponseTest {
|
||||||
private static final Map<String, Object> DATA = new HashMap<>();
|
|
||||||
private static final String VAL_USER = "testUserName";
|
private static final String VAL_USER = "testUserName";
|
||||||
private static final String VAL_PASS = "5up3r5ecr3tP455";
|
private static final String VAL_PASS = "5up3r5ecr3tP455";
|
||||||
|
private static final Map<String, Object> DATA = Map.of(
|
||||||
static {
|
"username", VAL_USER,
|
||||||
DATA.put("username", VAL_USER);
|
"password", VAL_PASS
|
||||||
DATA.put("password", VAL_PASS);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
@ -47,7 +45,6 @@ class CredentialsResponseTest {
|
|||||||
* @throws InvalidResponseException Should not occur
|
* @throws InvalidResponseException Should not occur
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
void getCredentialsTest() throws InvalidResponseException {
|
void getCredentialsTest() throws InvalidResponseException {
|
||||||
// Create empty Object.
|
// Create empty Object.
|
||||||
CredentialsResponse res = new CredentialsResponse();
|
CredentialsResponse res = new CredentialsResponse();
|
||||||
@ -59,4 +56,9 @@ class CredentialsResponseTest {
|
|||||||
assertEquals(VAL_USER, res.getUsername(), "Incorrect username");
|
assertEquals(VAL_USER, res.getUsername(), "Incorrect username");
|
||||||
assertEquals(VAL_PASS, res.getPassword(), "Incorrect password");
|
assertEquals(VAL_PASS, res.getPassword(), "Incorrect password");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(CredentialsResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016-2021 Stefan Kalscheuer
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit Test for {@link ErrorResponse} model.
|
||||||
|
*
|
||||||
|
* @author Stefan Kalscheuer
|
||||||
|
*/
|
||||||
|
class ErrorResponseTest {
|
||||||
|
private static final String ERROR_1 = "Error #1";
|
||||||
|
private static final String ERROR_2 = "Error #2";
|
||||||
|
|
||||||
|
private static final String JSON = "{\"errors\":[\"" + ERROR_1 + "\",\"" + ERROR_2 + "\"]}";
|
||||||
|
private static final String JSON_EMPTY = "{\"errors\":[]}";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test creation from JSON value as returned by Vault.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void jsonRoundtrip() {
|
||||||
|
ObjectMapper om = new ObjectMapper();
|
||||||
|
ErrorResponse res = assertDoesNotThrow(
|
||||||
|
() -> om.readValue(JSON, ErrorResponse.class),
|
||||||
|
"ErrorResponse deserialization failed"
|
||||||
|
);
|
||||||
|
assertNotNull(res, "Parsed response is NULL");
|
||||||
|
assertEquals(List.of(ERROR_1, ERROR_2), res.getErrors(), "Unexpected error messages");
|
||||||
|
assertEquals(
|
||||||
|
JSON,
|
||||||
|
assertDoesNotThrow(() -> om.writeValueAsString(res), "ErrorResponse serialization failed"),
|
||||||
|
"Unexpected JSON string after serialization"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testToString() {
|
||||||
|
ErrorResponse res = assertDoesNotThrow(
|
||||||
|
() -> new ObjectMapper().readValue(JSON, ErrorResponse.class),
|
||||||
|
"ErrorResponse deserialization failed"
|
||||||
|
);
|
||||||
|
assertEquals(ERROR_1, res.toString());
|
||||||
|
|
||||||
|
res = assertDoesNotThrow(
|
||||||
|
() -> new ObjectMapper().readValue(JSON_EMPTY, ErrorResponse.class),
|
||||||
|
"ErrorResponse deserialization failed with empty list"
|
||||||
|
);
|
||||||
|
assertEquals("error response", res.toString());
|
||||||
|
|
||||||
|
assertEquals("error response", new ErrorResponse().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(ErrorResponse.class).verify();
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
package de.stklcode.jvault.connector.model.response;
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@ -73,4 +74,9 @@ class HealthResponseTest {
|
|||||||
assertEquals(REPL_PERF_MODE, res.getReplicationPerfMode(), "Incorrect replication perf mode");
|
assertEquals(REPL_PERF_MODE, res.getReplicationPerfMode(), "Incorrect replication perf mode");
|
||||||
assertEquals(REPL_DR_MODE, res.getReplicationDrMode(), "Incorrect replication DR mode");
|
assertEquals(REPL_DR_MODE, res.getReplicationDrMode(), "Incorrect replication DR mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(HealthResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016-2021 Stefan Kalscheuer
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit Test for {@link HelpResponse} model.
|
||||||
|
*
|
||||||
|
* @author Stefan Kalscheuer
|
||||||
|
*/
|
||||||
|
class HelpResponseTest {
|
||||||
|
private static final String HELP = "Help Text.";
|
||||||
|
|
||||||
|
private static final String JSON = "{\"help\":\"" + HELP + "\"}";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test creation from JSON value as returned by Vault.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void jsonRoundtrip() {
|
||||||
|
ObjectMapper om = new ObjectMapper();
|
||||||
|
HelpResponse res = assertDoesNotThrow(
|
||||||
|
() -> om.readValue(JSON, HelpResponse.class),
|
||||||
|
"HelpResponse deserialization failed"
|
||||||
|
);
|
||||||
|
assertNotNull(res, "Parsed response is NULL");
|
||||||
|
assertEquals(HELP, res.getHelp(), "Unexpected help text");
|
||||||
|
assertEquals(
|
||||||
|
JSON,
|
||||||
|
assertDoesNotThrow(() -> om.writeValueAsString(res), "HelpResponse serialization failed"),
|
||||||
|
"Unexpected JSON string after serialization"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(HelpResponse.class).verify();
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
package de.stklcode.jvault.connector.model.response;
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@ -88,4 +89,9 @@ class MetadataResponseTest {
|
|||||||
assertNotNull(res.getMetadata().getVersions().get(2).getCreatedTime(), "Parsing version created failed");
|
assertNotNull(res.getMetadata().getVersions().get(2).getCreatedTime(), "Parsing version created failed");
|
||||||
assertFalse(res.getMetadata().getVersions().get(3).isDestroyed(), "Incorrect version 3 destroyed state");
|
assertFalse(res.getMetadata().getVersions().get(3).isDestroyed(), "Incorrect version 3 destroyed state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(MetadataResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package de.stklcode.jvault.connector.model.response;
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@ -79,7 +80,7 @@ class SealResponseTest {
|
|||||||
// First test sealed Vault's response.
|
// First test sealed Vault's response.
|
||||||
SealResponse res = assertDoesNotThrow(
|
SealResponse res = assertDoesNotThrow(
|
||||||
() -> new ObjectMapper().readValue(RES_SEALED, SealResponse.class),
|
() -> new ObjectMapper().readValue(RES_SEALED, SealResponse.class),
|
||||||
"TokenResponse deserialization failed"
|
"SealResponse deserialization failed"
|
||||||
);
|
);
|
||||||
assertNotNull(res, "Parsed response is NULL");
|
assertNotNull(res, "Parsed response is NULL");
|
||||||
assertEquals(TYPE, res.getType(), "Incorrect seal type");
|
assertEquals(TYPE, res.getType(), "Incorrect seal type");
|
||||||
@ -101,7 +102,7 @@ class SealResponseTest {
|
|||||||
// Not test unsealed Vault's response.
|
// Not test unsealed Vault's response.
|
||||||
res = assertDoesNotThrow(
|
res = assertDoesNotThrow(
|
||||||
() -> new ObjectMapper().readValue(RES_UNSEALED, SealResponse.class),
|
() -> new ObjectMapper().readValue(RES_UNSEALED, SealResponse.class),
|
||||||
"TokenResponse deserialization failed"
|
"SealResponse deserialization failed"
|
||||||
);
|
);
|
||||||
assertNotNull(res, "Parsed response is NULL");
|
assertNotNull(res, "Parsed response is NULL");
|
||||||
assertEquals(TYPE, res.getType(), "Incorrect seal type");
|
assertEquals(TYPE, res.getType(), "Incorrect seal type");
|
||||||
@ -118,4 +119,9 @@ class SealResponseTest {
|
|||||||
assertEquals(RECOVERY_SEAL, res.getRecoverySeal(), "Incorrect recovery seal");
|
assertEquals(RECOVERY_SEAL, res.getRecoverySeal(), "Incorrect recovery seal");
|
||||||
assertEquals(STORAGE_TYPE, res.getStorageType(), "Incorrect storage type");
|
assertEquals(STORAGE_TYPE, res.getStorageType(), "Incorrect storage type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(SealResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,13 @@
|
|||||||
package de.stklcode.jvault.connector.model.response;
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
@ -30,14 +34,10 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
* @since 0.8
|
* @since 0.8
|
||||||
*/
|
*/
|
||||||
class SecretListResponseTest {
|
class SecretListResponseTest {
|
||||||
private static final Map<String, Object> DATA = new HashMap<>();
|
|
||||||
private static final String KEY1 = "key1";
|
private static final String KEY1 = "key1";
|
||||||
private static final String KEY2 = "key-2";
|
private static final String KEY2 = "key-2";
|
||||||
private static final List<String> KEYS = Arrays.asList(KEY1, KEY2);
|
private static final List<String> KEYS = Arrays.asList(KEY1, KEY2);
|
||||||
|
private static final Map<String, Object> DATA = Map.of("keys", KEYS);
|
||||||
static {
|
|
||||||
DATA.put("keys", KEYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
@ -51,8 +51,7 @@ class SecretListResponseTest {
|
|||||||
assertNull(res.getKeys(), "Keys should be null without initialization");
|
assertNull(res.getKeys(), "Keys should be null without initialization");
|
||||||
|
|
||||||
// Provoke internal ClassCastException.
|
// Provoke internal ClassCastException.
|
||||||
Map<String, Object> invalidData = new HashMap<>();
|
Map<String, Object> invalidData = Map.of("keys", "some string");
|
||||||
invalidData.put("keys", "some string");
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> res.setData(invalidData),
|
() -> res.setData(invalidData),
|
||||||
@ -65,4 +64,9 @@ class SecretListResponseTest {
|
|||||||
assertEquals(2, res.getKeys().size(), "Unexpected number of keys");
|
assertEquals(2, res.getKeys().size(), "Unexpected number of keys");
|
||||||
assertTrue(res.getKeys().containsAll(Set.of(KEY1, KEY2)), "Unexpected keys");
|
assertTrue(res.getKeys().containsAll(Set.of(KEY1, KEY2)), "Unexpected keys");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(SecretListResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -34,7 +34,6 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
class SecretResponseTest {
|
class SecretResponseTest {
|
||||||
private static final Map<String, Object> DATA = new HashMap<>();
|
|
||||||
private static final String KEY_UNKNOWN = "unknown";
|
private static final String KEY_UNKNOWN = "unknown";
|
||||||
private static final String KEY_STRING = "test1";
|
private static final String KEY_STRING = "test1";
|
||||||
private static final String VAL_STRING = "testvalue";
|
private static final String VAL_STRING = "testvalue";
|
||||||
@ -43,6 +42,12 @@ class SecretResponseTest {
|
|||||||
private static final String KEY_LIST = "list";
|
private static final String KEY_LIST = "list";
|
||||||
private static final String VAL_LIST = "[\"first\",\"second\"]";
|
private static final String VAL_LIST = "[\"first\",\"second\"]";
|
||||||
|
|
||||||
|
private static final Map<String, Object> DATA = Map.of(
|
||||||
|
KEY_STRING, VAL_STRING,
|
||||||
|
KEY_INTEGER, VAL_INTEGER,
|
||||||
|
KEY_LIST, VAL_LIST
|
||||||
|
);
|
||||||
|
|
||||||
private static final String SECRET_REQUEST_ID = "68315073-6658-e3ff-2da7-67939fb91bbd";
|
private static final String SECRET_REQUEST_ID = "68315073-6658-e3ff-2da7-67939fb91bbd";
|
||||||
private static final String SECRET_LEASE_ID = "";
|
private static final String SECRET_LEASE_ID = "";
|
||||||
private static final Integer SECRET_LEASE_DURATION = 2764800;
|
private static final Integer SECRET_LEASE_DURATION = 2764800;
|
||||||
@ -104,13 +109,6 @@ class SecretResponseTest {
|
|||||||
" \"warnings\": " + SECRET_WARNINGS + "\n" +
|
" \"warnings\": " + SECRET_WARNINGS + "\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
|
||||||
static {
|
|
||||||
DATA.put(KEY_STRING, VAL_STRING);
|
|
||||||
DATA.put(KEY_INTEGER, VAL_INTEGER);
|
|
||||||
DATA.put(KEY_LIST, VAL_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
*
|
*
|
||||||
@ -171,7 +169,7 @@ class SecretResponseTest {
|
|||||||
assertNotNull(res.getMetadata().getCreatedTime(), "Creation date parsing failed");
|
assertNotNull(res.getMetadata().getCreatedTime(), "Creation date parsing failed");
|
||||||
assertEquals("", res.getMetadata().getDeletionTimeString(), "Incorrect deletion date string");
|
assertEquals("", res.getMetadata().getDeletionTimeString(), "Incorrect deletion date string");
|
||||||
assertNull(res.getMetadata().getDeletionTime(), "Incorrect deletion date");
|
assertNull(res.getMetadata().getDeletionTime(), "Incorrect deletion date");
|
||||||
assertEquals(false, res.getMetadata().isDestroyed(), "Secret destroyed when not expected");
|
assertFalse(res.getMetadata().isDestroyed(), "Secret destroyed when not expected");
|
||||||
assertEquals(1, res.getMetadata().getVersion(), "Incorrect secret version");
|
assertEquals(1, res.getMetadata().getVersion(), "Incorrect secret version");
|
||||||
|
|
||||||
// Deleted KV v2 secret.
|
// Deleted KV v2 secret.
|
||||||
@ -185,10 +183,15 @@ class SecretResponseTest {
|
|||||||
assertNotNull(res.getMetadata().getCreatedTime(), "Creation date parsing failed");
|
assertNotNull(res.getMetadata().getCreatedTime(), "Creation date parsing failed");
|
||||||
assertEquals(SECRET_META_DELETED, res.getMetadata().getDeletionTimeString(), "Incorrect deletion date string");
|
assertEquals(SECRET_META_DELETED, res.getMetadata().getDeletionTimeString(), "Incorrect deletion date string");
|
||||||
assertNotNull(res.getMetadata().getDeletionTime(), "Incorrect deletion date");
|
assertNotNull(res.getMetadata().getDeletionTime(), "Incorrect deletion date");
|
||||||
assertEquals(true, res.getMetadata().isDestroyed(), "Secret destroyed when not expected");
|
assertTrue(res.getMetadata().isDestroyed(), "Secret destroyed when not expected");
|
||||||
assertEquals(2, res.getMetadata().getVersion(), "Incorrect secret version");
|
assertEquals(2, res.getMetadata().getVersion(), "Incorrect secret version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(SecretResponse.class).verify();
|
||||||
|
}
|
||||||
|
|
||||||
private void assertSecretData(SecretResponse res) {
|
private void assertSecretData(SecretResponse res) {
|
||||||
assertNotNull(res, "Parsed response is NULL");
|
assertNotNull(res, "Parsed response is NULL");
|
||||||
assertEquals(SECRET_LEASE_ID, res.getLeaseId(), "Incorrect lease ID");
|
assertEquals(SECRET_LEASE_ID, res.getLeaseId(), "Incorrect lease ID");
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package de.stklcode.jvault.connector.model.response;
|
package de.stklcode.jvault.connector.model.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@ -54,7 +55,12 @@ class SecretVersionResponseTest {
|
|||||||
assertNotNull(res.getMetadata(), "Parsed metadata is NULL");
|
assertNotNull(res.getMetadata(), "Parsed metadata is NULL");
|
||||||
assertEquals(CREATION_TIME, res.getMetadata().getCreatedTimeString(), "Incorrect created time");
|
assertEquals(CREATION_TIME, res.getMetadata().getCreatedTimeString(), "Incorrect created time");
|
||||||
assertEquals(DELETION_TIME, res.getMetadata().getDeletionTimeString(), "Incorrect deletion time");
|
assertEquals(DELETION_TIME, res.getMetadata().getDeletionTimeString(), "Incorrect deletion time");
|
||||||
assertEquals(false, res.getMetadata().isDestroyed(), "Incorrect destroyed state");
|
assertFalse(res.getMetadata().isDestroyed(), "Incorrect destroyed state");
|
||||||
assertEquals(VERSION, res.getMetadata().getVersion(), "Incorrect version");
|
assertEquals(VERSION, res.getMetadata().getVersion(), "Incorrect version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(SecretVersionResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ package de.stklcode.jvault.connector.model.response;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
import de.stklcode.jvault.connector.model.response.embedded.TokenData;
|
import de.stklcode.jvault.connector.model.response.embedded.TokenData;
|
||||||
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -89,11 +89,7 @@ class TokenResponseTest {
|
|||||||
" \"auth\": null\n" +
|
" \"auth\": null\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
private static final Map<String, Object> INVALID_TOKEN_DATA = new HashMap<>();
|
private static final Map<String, Object> INVALID_TOKEN_DATA = Map.of("num_uses", "fourtytwo");
|
||||||
|
|
||||||
static {
|
|
||||||
INVALID_TOKEN_DATA.put("num_uses", "fourtytwo");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getter, setter and get-methods for response data.
|
* Test getter, setter and get-methods for response data.
|
||||||
@ -149,4 +145,9 @@ class TokenResponseTest {
|
|||||||
assertEquals(RES_TTL, data.getTtl(), "Incorrect token TTL");
|
assertEquals(RES_TTL, data.getTtl(), "Incorrect token TTL");
|
||||||
assertEquals(TOKEN_TYPE, data.getType(), "Incorrect token type");
|
assertEquals(TOKEN_TYPE, data.getType(), "Incorrect token type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testEqualsHashcode() {
|
||||||
|
EqualsVerifier.simple().forClass(TokenResponse.class).verify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user