Polishing.
Add since tags, increment license header years, add javadoc. See gh-726 Original pull request: gh-792
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
* Copyright 2016-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,15 @@
|
||||
*/
|
||||
package org.springframework.vault.support;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Transit backend encryption/decryption/rewrapping context.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Nanne Baars
|
||||
*/
|
||||
public class VaultTransitContext {
|
||||
|
||||
@@ -93,9 +94,10 @@ public class VaultTransitContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the version of the key to use for the operation. If not set, uses the
|
||||
* latest version. Must be greater than or equal to the key's min_encryption_version,
|
||||
* @return the version of the key to use for the operation. Uses the latest version if
|
||||
* not set. Must be greater than or equal to the key's {@code min_encryption_version},
|
||||
* if set.
|
||||
* @since 3.0.3
|
||||
*/
|
||||
public int getKeyVersion() {
|
||||
return this.keyVersion;
|
||||
@@ -164,7 +166,16 @@ public class VaultTransitContext {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the key version to use. Must be greater than or equal to the key's
|
||||
* {@code min_encryption_version}. The key version is not used if not set.
|
||||
* @param keyVersion the key version to be used, must be greater than or equal to
|
||||
* the key's {@code min_encryption_version}
|
||||
* @return {@code this} {@link VaultTransitRequestBuilder}.
|
||||
* @since 3.0.3
|
||||
*/
|
||||
public VaultTransitRequestBuilder keyVersion(int keyVersion) {
|
||||
|
||||
Assert.isTrue(keyVersion >= 0, "Key version must have a positive value");
|
||||
|
||||
this.keyVersion = keyVersion;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
* Copyright 2016-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,12 @@
|
||||
*/
|
||||
package org.springframework.vault.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -23,6 +29,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@@ -48,12 +55,6 @@ import org.springframework.vault.util.IntegrationTestSupport;
|
||||
import org.springframework.vault.util.RequiresVaultVersion;
|
||||
import org.springframework.vault.util.Version;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
@@ -36,7 +36,7 @@ class VaultVersionExtension implements ExecutionCondition {
|
||||
private static final ExtensionContext.Namespace VAULT = ExtensionContext.Namespace.create("vault.version");
|
||||
|
||||
private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = ConditionEvaluationResult
|
||||
.enabled("@VaultVersion is not present");
|
||||
.enabled("@VaultVersion is not present");
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
@@ -66,13 +66,13 @@ class VaultVersionExtension implements ExecutionCondition {
|
||||
|
||||
if (runningVersion.isGreaterThanOrEqualTo(requiredVersion)) {
|
||||
return ConditionEvaluationResult
|
||||
.enabled(String.format("Test is enabled, @VaultVersion(%s) is met with Vault running version %s",
|
||||
requiredVersion, runningVersion));
|
||||
.enabled(String.format("Test is enabled, @VaultVersion(%s) is met with Vault running version %s",
|
||||
requiredVersion, runningVersion));
|
||||
}
|
||||
|
||||
return ConditionEvaluationResult
|
||||
.disabled(String.format("Test is disabled, @VaultVersion(%s) is not met with Vault running version %s",
|
||||
requiredVersion, runningVersion));
|
||||
.disabled(String.format("Test is disabled, @VaultVersion(%s) is not met with Vault running version %s",
|
||||
requiredVersion, runningVersion));
|
||||
}
|
||||
|
||||
if (disabled.isPresent()) {
|
||||
|
||||
Reference in New Issue
Block a user