Skip to content

Commit dd69b98

Browse files
committed
fix testcontext
1 parent 47b39e6 commit dd69b98

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

entraid/src/test/java/redis/clients/authentication/TestContext.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424

2525
public class TestContext {
2626

27+
private static final String AZURE_CLIENT_ID = "AZURE_CLIENT_ID";
28+
private static final String AZURE_AUTHORITY = "AZURE_AUTHORITY";
29+
private static final String AZURE_CLIENT_SECRET = "AZURE_CLIENT_SECRET";
30+
private static final String AZURE_PRIVATE_KEY = "AZURE_PRIVATE_KEY";
31+
private static final String AZURE_CERT = "AZURE_CERT";
32+
private static final String AZURE_REDIS_SCOPES = "AZURE_REDIS_SCOPES";
2733
private static final String localContext = "./src/test/resources/local.context";
2834
private String clientId;
2935
private String authority;
@@ -39,23 +45,25 @@ private TestContext() {
3945
try {
4046
Properties properties = new Properties();
4147
properties.load(Files.newBufferedReader(Paths.get(localContext)));
42-
this.clientId = properties.getProperty("CLIENT_ID");
43-
this.authority = properties.getProperty("AUTHORITY");
44-
this.clientSecret = properties.getProperty("CLIENT_SECRET");
45-
this.privateKey = getPrivateKey(properties.getProperty("PRIVATE_KEY"));
46-
this.cert = getCert(properties.getProperty("CERT"));
47-
String redisScopesProp = properties.getProperty("REDIS_SCOPES");
48+
this.clientId = properties.getProperty(AZURE_CLIENT_ID);
49+
this.authority = properties.getProperty(AZURE_AUTHORITY);
50+
this.clientSecret = properties.getProperty(AZURE_CLIENT_SECRET);
51+
this.privateKey = getPrivateKey(properties.getProperty(AZURE_PRIVATE_KEY));
52+
this.cert = getCert(properties.getProperty(AZURE_CERT));
53+
String redisScopesProp = properties.getProperty(AZURE_REDIS_SCOPES);
4854
if (redisScopesProp != null && !redisScopesProp.isEmpty()) {
4955
this.redisScopes = new HashSet<>(Arrays.asList(redisScopesProp.split(";")));
5056
}
5157
} catch (IOException e) {
5258
throw new RuntimeException("Failed to load local.context", e);
5359
}
5460
} else {
55-
this.clientId = System.getenv("CLIENT_ID");
56-
this.authority = System.getenv("AUTHORITY");
57-
this.clientSecret = System.getenv("CLIENT_SECRET");
58-
String redisScopesEnv = System.getenv("REDIS_SCOPES");
61+
this.clientId = System.getenv(AZURE_CLIENT_ID);
62+
this.authority = System.getenv(AZURE_AUTHORITY);
63+
this.clientSecret = System.getenv(AZURE_CLIENT_SECRET);
64+
this.privateKey = getPrivateKey(System.getenv(AZURE_PRIVATE_KEY));
65+
this.cert = getCert(System.getenv(AZURE_CERT));
66+
String redisScopesEnv = System.getenv(AZURE_REDIS_SCOPES);
5967
if (redisScopesEnv != null && !redisScopesEnv.isEmpty()) {
6068
this.redisScopes = new HashSet<>(Arrays.asList(redisScopesEnv.split(";")));
6169
}

0 commit comments

Comments
 (0)