Skip to content

Commit 54d28ea

Browse files
fix: clear cache before testCachePurged to prevent stale entry interference
AzureAppConfigurationProviderTest#testCachePurged was failing on CI because the static OracleConfigurationCache could hold valid credentials from a previous test run, causing the first connection to succeed from cache instead of fetching the (intentionally wrong) credentials from Azure App Config. Added @BeforeAll to obtain the cache reference and a CACHE.remove() call at the start of the test, mirroring the pattern already used in AzureAppConfigurationProviderURLParserTest.
1 parent 2292e23 commit 54d28ea

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

ojdbc-provider-azure/src/test/java/oracle/jdbc/provider/azure/configuration/AzureAppConfigurationProviderTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
import oracle.jdbc.provider.TestProperties;
99
import oracle.jdbc.provider.azure.AzureTestProperty;
1010
import oracle.jdbc.provider.azure.authentication.AzureAuthenticationMethod;
11+
import oracle.jdbc.spi.OracleConfigurationProvider;
12+
import oracle.jdbc.util.OracleConfigurationCache;
1113
import org.junit.jupiter.api.Assertions;
14+
import org.junit.jupiter.api.BeforeAll;
1215
import org.junit.jupiter.api.Nested;
1316
import org.junit.jupiter.api.Test;
1417

@@ -21,6 +24,16 @@
2124

2225
class AzureAppConfigurationProviderTest {
2326

27+
private static OracleConfigurationCache CACHE;
28+
29+
@BeforeAll
30+
static void init() {
31+
OracleConfigurationProvider.allowedProviders.add("azure");
32+
CACHE = ((AzureAppConfigurationProvider) OracleConfigurationProvider
33+
.find("azure"))
34+
.getCache();
35+
}
36+
2437
/**
2538
* Label-related tests
2639
*/
@@ -113,6 +126,9 @@ public void testCachePurged() throws SQLException {
113126

114127
String url = composeUrlWithServicePrincipleAuthentication(originalUrl);
115128

129+
// Clear cache to ensure we fetch fresh credentials from Azure App Config
130+
CACHE.remove(APP_CONFIG_NAME + "?key=" + APP_CONFIG_KEY + "&label=" + APP_CONFIG_LABEL);
131+
116132
// Retrieve original value of 'user'
117133
String originalKeyValue =
118134
client.getConfigurationSetting(APP_CONFIG_KEY + username,

0 commit comments

Comments
 (0)