Skip to content

Commit cc4e8a8

Browse files
Merge pull request #358 from skyflowapi/SK-2967-java-sdk-add-flow-db-vault-api-support-using-modular-build-approach
SK-2967 fix compile errors
2 parents 5e7d83c + 1b6f88c commit cc4e8a8

2 files changed

Lines changed: 29 additions & 13 deletions

File tree

common/src/test/java/com/skyflow/BaseSkyflowTests.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,12 @@ public void testMergeVaultConfigWithNullClusterIdFallsBackToPreviousClusterId()
260260
Assert.assertEquals(clusterID, result.getClusterId());
261261
}
262262

263-
private static class TestSkyflow extends BaseSkyflow<TestSkyflow, BaseVaultConfig, Object> {
263+
private static class TestSkyflow extends BaseSkyflow<TestSkyflow, BaseVaultConfig> {
264+
private final TestSkyflowClientBuilder builder;
265+
264266
private TestSkyflow(TestSkyflowClientBuilder builder) {
265267
super(builder);
268+
this.builder = builder;
266269
}
267270

268271
static TestSkyflowClientBuilder builder() {
@@ -274,12 +277,19 @@ protected TestSkyflow self() {
274277
return this;
275278
}
276279

280+
Object vault() throws SkyflowException {
281+
return resolveOrThrow(this.builder.vaultClientsMap, null,
282+
ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST, ErrorMessage.VaultIdNotInConfigList);
283+
}
284+
277285
Object vault(String vaultId) throws SkyflowException {
278286
return resolveOrThrow(this.builder.vaultClientsMap, vaultId,
279287
ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST, ErrorMessage.VaultIdNotInConfigList);
280288
}
281289

282-
private static class TestSkyflowClientBuilder extends BaseSkyflowClientBuilder<BaseVaultConfig, Object> {
290+
private static class TestSkyflowClientBuilder extends BaseSkyflowClientBuilder<BaseVaultConfig> {
291+
private final java.util.LinkedHashMap<String, Object> vaultClientsMap = new java.util.LinkedHashMap<>();
292+
283293
@Override
284294
protected void validateVaultConfig(BaseVaultConfig vaultConfig) throws SkyflowException {
285295
if (vaultConfig.getVaultId() == null || vaultConfig.getVaultId().trim().isEmpty()) {
@@ -297,6 +307,11 @@ protected void onVaultConfigUpdated(BaseVaultConfig updatedConfig) {
297307
this.vaultClientsMap.put(updatedConfig.getVaultId(), new Object());
298308
}
299309

310+
@Override
311+
protected void onVaultConfigRemoved(String vaultId) {
312+
this.vaultClientsMap.remove(vaultId);
313+
}
314+
300315
@Override
301316
protected void onCredentialsUpdated(Credentials credentials) {
302317
// no-op: this test double only exercises template orchestration, not propagation

common/src/test/java/com/skyflow/BaseVaultClientTests.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.skyflow;
22

33
import com.skyflow.config.BaseCredentials;
4+
import com.skyflow.config.BaseVaultConfig;
45
import com.skyflow.errors.ErrorMessage;
56
import com.skyflow.errors.SkyflowException;
67
import com.skyflow.utils.BaseConstants;
@@ -35,15 +36,15 @@ public void restoreEnvFile() throws IOException {
3536
}
3637
}
3738

38-
private BaseVaultClient<Object> newClient(BaseCredentials commonCredentials) {
39-
return new BaseVaultClient<>(new Object(), commonCredentials);
39+
private BaseVaultClient<BaseVaultConfig> newClient(BaseCredentials commonCredentials) {
40+
return new BaseVaultClient<>(new BaseVaultConfig(), commonCredentials);
4041
}
4142

4243
@Test
4344
public void testPrioritiseCredentials_prefersVaultSpecificCredentials() throws SkyflowException {
4445
BaseCredentials vaultSpecific = new BaseCredentials();
4546
vaultSpecific.setApiKey("test_api_key");
46-
BaseVaultClient<Object> client = newClient(null);
47+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
4748

4849
client.prioritiseCredentials(vaultSpecific);
4950

@@ -54,7 +55,7 @@ public void testPrioritiseCredentials_prefersVaultSpecificCredentials() throws S
5455
public void testPrioritiseCredentials_fallsBackToCommonCredentials() throws SkyflowException {
5556
BaseCredentials common = new BaseCredentials();
5657
common.setApiKey("common_api_key");
57-
BaseVaultClient<Object> client = newClient(common);
58+
BaseVaultClient<BaseVaultConfig> client = newClient(common);
5859

5960
client.prioritiseCredentials(null);
6061

@@ -65,7 +66,7 @@ public void testPrioritiseCredentials_fallsBackToCommonCredentials() throws Skyf
6566
public void testPrioritiseCredentials_credentialChange_resetsTokenAndApiKey() throws SkyflowException {
6667
BaseCredentials credentialsA = new BaseCredentials();
6768
credentialsA.setToken("x.eyJleHAiOjk5OTk5OTk5OTl9.y");
68-
BaseVaultClient<Object> client = newClient(null);
69+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
6970

7071
client.prioritiseCredentials(credentialsA);
7172
client.token = "cached-token";
@@ -83,7 +84,7 @@ public void testPrioritiseCredentials_credentialChange_resetsTokenAndApiKey() th
8384
public void testSetBearerToken_withApiKey() throws SkyflowException {
8485
BaseCredentials creds = new BaseCredentials();
8586
creds.setApiKey("sky-ab123-abcd1234cdef1234abcd4321cdef4321");
86-
BaseVaultClient<Object> client = newClient(null);
87+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
8788

8889
client.setBearerToken(creds);
8990

@@ -94,7 +95,7 @@ public void testSetBearerToken_withApiKey() throws SkyflowException {
9495
public void testSetBearerToken_generatesTokenWhenNull() throws SkyflowException {
9596
BaseCredentials creds = new BaseCredentials();
9697
creds.setToken("x.eyJleHAiOjk5OTk5OTk5OTl9.y");
97-
BaseVaultClient<Object> client = newClient(null);
98+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
9899

99100
client.setBearerToken(creds);
100101

@@ -105,7 +106,7 @@ public void testSetBearerToken_generatesTokenWhenNull() throws SkyflowException
105106
public void testSetBearerToken_reusesValidNonExpiredToken() throws SkyflowException {
106107
BaseCredentials creds = new BaseCredentials();
107108
creds.setToken("x.eyJleHAiOjk5OTk5OTk5OTl9.y");
108-
BaseVaultClient<Object> client = newClient(null);
109+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
109110

110111
// First call: token=null → generates from creds.getToken()
111112
client.setBearerToken(creds);
@@ -118,7 +119,7 @@ public void testSetBearerToken_reusesValidNonExpiredToken() throws SkyflowExcept
118119

119120
@Test
120121
public void testSetBearerToken_noCredentials_throwsEmptyCredentials() {
121-
BaseVaultClient<Object> client = newClient(null);
122+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
122123
try {
123124
client.setBearerToken(null);
124125
Assert.fail("Should have thrown SkyflowException");
@@ -137,7 +138,7 @@ public void testPrioritiseCredentials_dotenvReturnsCredentials_setsCredentials()
137138
fw.write(BaseConstants.ENV_CREDENTIALS_KEY_NAME + "={\"token\":\"env-token-value\"}\n");
138139
}
139140

140-
BaseVaultClient<Object> client = newClient(null);
141+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
141142
client.prioritiseCredentials(null);
142143

143144
Assert.assertNotNull(client.finalCredentials);
@@ -154,7 +155,7 @@ public void testPrioritiseCredentials_dotenvKeyMissing_throwsSkyflowException()
154155
fw.write("SOME_OTHER_KEY=some_value\n");
155156
}
156157

157-
BaseVaultClient<Object> client = newClient(null);
158+
BaseVaultClient<BaseVaultConfig> client = newClient(null);
158159
try {
159160
client.prioritiseCredentials(null);
160161
Assert.fail("Should have thrown SkyflowException");

0 commit comments

Comments
 (0)