generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e497be0
commit 65111b9
Showing
4 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...c/provider/hashicorp/dedicated/configuration/DedicatedVaultConfigurationProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package oracle.jdbc.provider.hashicorp.dedicated.configuration; | ||
|
||
import oracle.jdbc.provider.TestProperties; | ||
import oracle.jdbc.provider.hashicorp.dedicated.configuration.DedicatedVaultTestProperty; | ||
import oracle.jdbc.spi.OracleConfigurationJsonSecretProvider; | ||
import oracle.jdbc.spi.OracleConfigurationProvider; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.sql.SQLException; | ||
import java.util.Properties; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
/** | ||
* Test class for the Dedicated Vault Configuration Provider. | ||
*/ | ||
public class DedicatedVaultConfigurationProviderTest { | ||
|
||
static { | ||
OracleConfigurationProvider.allowedProviders.add("hashicorpvault"); | ||
} | ||
|
||
|
||
private static final OracleConfigurationProvider PROVIDER = | ||
OracleConfigurationProvider.find("hashicorpvault"); | ||
|
||
|
||
/** | ||
* Verifies if Dedicated Vault Configuration Provider works with TOKEN-based authentication and a specific secret name. | ||
* | ||
* @throws SQLException if the provider encounters an error | ||
*/ | ||
@Test | ||
public void testTokenAuthentication() throws SQLException { | ||
|
||
String location = | ||
composeUrl(TestProperties.getOrAbort(DedicatedVaultTestProperty.DEDICATED_VAULT_SECRET_PATH), | ||
"KEY="+TestProperties.getOrAbort(DedicatedVaultTestProperty.KEY), | ||
"VAULT_ADDR="+TestProperties.getOrAbort(DedicatedVaultTestProperty.VAULT_ADDR), | ||
"VAULT_TOKEN="+TestProperties.getOrAbort(DedicatedVaultTestProperty.VAULT_TOKEN)); | ||
|
||
|
||
Properties properties = PROVIDER.getConnectionProperties(location); | ||
|
||
assertTrue(properties.containsKey("URL"), "Contains property URL"); | ||
assertTrue(properties.containsKey("user"), "Contains property user"); | ||
assertTrue(properties.containsKey("password"), "Contains property password"); | ||
} | ||
|
||
/** | ||
* Composes a full URL from a base URL and query options. | ||
*/ | ||
private static String composeUrl(String baseUrl, String... options) { | ||
return String.format("%s?%s", baseUrl, String.join("&", options)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...va/oracle/jdbc/provider/hashicorp/dedicated/configuration/DedicatedVaultTestProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package oracle.jdbc.provider.hashicorp.dedicated.configuration; | ||
|
||
/** | ||
* Enumeration of test properties for Dedicated Vault. | ||
*/ | ||
public enum DedicatedVaultTestProperty { | ||
DEDICATED_VAULT_SECRET_PATH, | ||
KEY, | ||
VAULT_TOKEN, | ||
VAULT_ADDR | ||
} |