|
1 | | -package io.github.jopenlibs.vault.v1_11_4.api; |
| 1 | +package io.github.jopenlibs.vault.api; |
2 | 2 |
|
3 | 3 | import io.github.jopenlibs.vault.Vault; |
4 | 4 | import io.github.jopenlibs.vault.VaultException; |
5 | | -import io.github.jopenlibs.vault.v1_11_4.util.VaultContainer; |
| 5 | +import io.github.jopenlibs.vault.util.VaultContainer; |
| 6 | +import io.github.jopenlibs.vault.util.VaultVersion; |
6 | 7 | import java.io.IOException; |
| 8 | +import java.util.Optional; |
7 | 9 | import org.junit.BeforeClass; |
8 | 10 | import org.junit.ClassRule; |
9 | 11 | import org.junit.Test; |
10 | 12 |
|
11 | 13 | import static org.junit.Assert.assertNotNull; |
12 | 14 | import static org.junit.Assert.assertNotSame; |
| 15 | +import static org.junit.Assume.assumeTrue; |
13 | 16 |
|
14 | 17 | /** |
15 | | - * Integration tests for the AppId auth backend. |
| 18 | + * Integration tests for the AppId auth backend. According to the Vault documentation, this method |
| 19 | + * is deprecated. Also, from Vault 1.11.7 it fails the usage. For this reason, we skip this test if |
| 20 | + * Vault version is greater than 1.11.6 |
16 | 21 | */ |
17 | 22 | public class AuthBackendAppIdTests { |
18 | 23 |
|
19 | 24 | @ClassRule |
20 | 25 | public static final VaultContainer container = new VaultContainer(); |
21 | 26 |
|
| 27 | + private static boolean checkVersion() { |
| 28 | + VaultVersion accepted = new VaultVersion("1.11.6"); |
| 29 | + try { |
| 30 | + VaultVersion current = new VaultVersion( |
| 31 | + Optional.ofNullable(System.getenv("VAULT_VERSION")).orElse("latest")); |
| 32 | + if (current.compareTo(accepted) > 0) { |
| 33 | + return false; |
| 34 | + } |
| 35 | + } catch (NumberFormatException ignored) { |
| 36 | + return false; |
| 37 | + } |
| 38 | + |
| 39 | + return true; |
| 40 | + } |
| 41 | + |
22 | 42 | @BeforeClass |
23 | 43 | public static void setupClass() throws IOException, InterruptedException { |
| 44 | + assumeTrue(checkVersion()); |
| 45 | + |
24 | 46 | container.initAndUnsealVault(); |
25 | 47 | container.setupBackendAppId(); |
26 | 48 | } |
27 | 49 |
|
| 50 | + |
28 | 51 | /** |
29 | 52 | * Test Authentication with app-id auth backend |
30 | 53 | */ |
|
0 commit comments