Make path in WrappedMetadata optional.
Path is provided as of Vault 0.8.0 and we want to support also older Vault versions. See gh-208.
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.vault.support;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -41,35 +42,35 @@ public class WrappedMetadata {
|
||||
* @param token must not be {@literal null}.
|
||||
* @param ttl must not be {@literal null}.
|
||||
* @param creationTime must not be {@literal null}.
|
||||
* @param path must not be {@literal null}.
|
||||
* @param path can be {@literal null}.
|
||||
*/
|
||||
public WrappedMetadata(VaultToken token, Duration ttl, Instant creationTime,
|
||||
String path) {
|
||||
@Nullable String path) {
|
||||
|
||||
Assert.notNull(token, "VaultToken must not be null");
|
||||
Assert.notNull(ttl, "TTL duration must not be null");
|
||||
Assert.notNull(creationTime, "Creation time must not be null");
|
||||
Assert.notNull(path, "Path must not be null");
|
||||
|
||||
this.token = token;
|
||||
this.ttl = ttl;
|
||||
this.creationTime = creationTime;
|
||||
this.path = path;
|
||||
this.ttl = ttl;
|
||||
}
|
||||
|
||||
public VaultToken getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public Duration getTtl() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
public Instant getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Duration getTtl() {
|
||||
return ttl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ public class VaultWrappingTemplateIntegrationTests extends IntegrationTestSuppor
|
||||
|
||||
WrappedMetadata metadata = wrappingOperations.wrap(map, Duration.ofSeconds(100));
|
||||
|
||||
assertThat(metadata.getPath()).isEqualTo("sys/wrapping/wrap");
|
||||
assertThat(metadata.getTtl()).isEqualTo(Duration.ofSeconds(100));
|
||||
assertThat(metadata.getToken()).isNotNull();
|
||||
assertThat(metadata.getCreationTime()).isBefore(Instant.now().plusSeconds(60))
|
||||
@@ -94,7 +93,6 @@ public class VaultWrappingTemplateIntegrationTests extends IntegrationTestSuppor
|
||||
|
||||
WrappedMetadata lookup = wrappingOperations.lookup(metadata.getToken());
|
||||
|
||||
assertThat(lookup.getPath()).isEqualTo("sys/wrapping/wrap");
|
||||
assertThat(lookup.getTtl()).isEqualTo(Duration.ofSeconds(100));
|
||||
assertThat(lookup.getToken()).isNotNull();
|
||||
assertThat(lookup.getCreationTime()).isBefore(Instant.now().plusSeconds(60))
|
||||
@@ -149,7 +147,6 @@ public class VaultWrappingTemplateIntegrationTests extends IntegrationTestSuppor
|
||||
|
||||
WrappedMetadata rewrap = wrappingOperations.rewrap(metadata.getToken());
|
||||
|
||||
assertThat(rewrap.getPath()).isEqualTo("sys/wrapping/wrap");
|
||||
assertThat(rewrap.getTtl()).isEqualTo(Duration.ofSeconds(100));
|
||||
assertThat(rewrap.getToken()).isNotEqualTo(metadata.getToken());
|
||||
assertThat(rewrap.getCreationTime()).isBefore(Instant.now().plusSeconds(60))
|
||||
|
||||
Reference in New Issue
Block a user