Skip to content

Commit 37ef83a

Browse files
committed
Remove LabConfig and related code, use constant for tenant info
1 parent 0408c7c commit 37ef83a

7 files changed

Lines changed: 4 additions & 191 deletions

File tree

msal4j-sdk/src/integrationtest/java/com.microsoft.aad.msal4j/AcquireTokenInteractiveIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ void acquireTokenWithAuthorizationCode_B2C_LegacyFormat() {
8282
void acquireTokenInteractive_ManagedUser_InstanceAware() {
8383
AppConfig app = LabResponseHelper.getAppConfig(APP_ARLINGTON);
8484
UserConfig user = LabResponseHelper.getUserConfig(USER_ARLINGTON);
85-
LabConfig lab = LabResponseHelper.getLabConfig(LAB_ARLMSIDLAB1);
8685

87-
assertAcquireTokenInstanceAware(user, app.getAppId(), lab.getTenantId());
86+
assertAcquireTokenInstanceAware(user, app.getAppId(), TestConstants.ARLINGTON_TENANT_ID);
8887
}
8988

9089
@Test

msal4j-sdk/src/integrationtest/java/com.microsoft.aad.msal4j/TestConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ public class TestConstants {
3838
public static final String ADFS_SCOPE = USER_READ_SCOPE;
3939

4040
public static final String AUTHORITY_PUBLIC_TENANT_SPECIFIC = "https://login.microsoftonline.com/" + MICROSOFT_AUTHORITY_TENANT;
41+
42+
public static final String ARLINGTON_TENANT_ID = "45ff0c17-f8b5-489b-b7fd-2fedebbec0c4";
4143
}

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/labapi/KeyVaultSecrets.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,5 @@ private KeyVaultSecrets() {
3030
public static final String APP_B2C = "MSAL-App-B2C-JSON";
3131
public static final String APP_ARLINGTON = "MSAL-App-Arlington-JSON";
3232
public static final String APP_CIAM = "MSAL-App-CIAM-JSON";
33-
34-
// Lab Configuration Secrets
35-
public static final String LAB_ID4SLAB1 = "ID4SLAB1";
36-
public static final String LAB_ARLMSIDLAB1 = "ARLMSIDLAB1";
3733
}
3834

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/labapi/KeyVaultSecretsProvider.java

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class KeyVaultSecretsProvider implements AutoCloseable {
3838
public static final String CERTIFICATE_ALIAS = "LabAuth.MSIDLab.com";
3939

4040
// The app ID for the application used to access Key Vault
41-
private final String MSIDLAB_APP_ID = "f62c5ae3-bf3a-4af5-afa8-a68b800396e9";
41+
private static final String MSIDLAB_APP_ID = "f62c5ae3-bf3a-4af5-afa8-a68b800396e9";
4242

4343
static class KeyVaultInstance {
4444
/**
@@ -213,62 +213,6 @@ public Object getLabData(String secretName) {
213213
}
214214
}
215215

216-
/**
217-
* Merge multiple Key Vault secrets into a single LabResponse.
218-
* Each secret should contain a LabResponse JSON object.
219-
* Fields from later secrets override fields from earlier ones.
220-
*
221-
* @param secretNames Array of Key Vault secret names to merge
222-
* @return Merged LabResponse
223-
*/
224-
public LabResponse mergeLabResponses(String... secretNames) {
225-
if (secretNames == null || secretNames.length == 0) {
226-
throw new IllegalArgumentException(
227-
"At least one secret name must be provided.");
228-
}
229-
230-
try {
231-
LabResponse mergedResponse = new LabResponse();
232-
boolean hasValidResponse = false;
233-
234-
for (String secretName : secretNames) {
235-
Object data = getLabData(secretName);
236-
237-
if (data instanceof LabResponse) {
238-
LabResponse response = (LabResponse) data;
239-
hasValidResponse = true;
240-
241-
// Merge user, app, and lab fields (later values override earlier ones)
242-
if (response.getUser() != null) {
243-
mergedResponse.setUser(response.getUser());
244-
}
245-
if (response.getApp() != null) {
246-
mergedResponse.setApp(response.getApp());
247-
}
248-
if (response.getLab() != null) {
249-
mergedResponse.setLab(response.getLab());
250-
}
251-
}
252-
}
253-
254-
if (!hasValidResponse) {
255-
log.error("Failed to merge secrets - no valid LabResponse found: {}",
256-
String.join(", ", secretNames));
257-
throw new RuntimeException("Failed to create merged LabResponse from secrets: " +
258-
String.join(", ", secretNames));
259-
}
260-
261-
log.info("Merged secrets [{}]: {}", String.join(", ", secretNames),
262-
mergedResponse.getUser() != null ? mergedResponse.getUser().getUpn() : "N/A");
263-
264-
return mergedResponse;
265-
} catch (Exception e) {
266-
log.error("Failed to merge secrets [{}]: {}", String.join(", ", secretNames), e.getMessage());
267-
throw new RuntimeException(
268-
"Failed to merge Key Vault secrets: " + String.join(", ", secretNames), e);
269-
}
270-
}
271-
272216
/**
273217
* Fetch user password from Key Vault.
274218
* Note: This should only be called on instances configured for the MSID LabConfig vault.

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/labapi/LabConfig.java

Lines changed: 0 additions & 79 deletions
This file was deleted.

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/labapi/LabResponse.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,15 @@ public class LabResponse implements JsonSerializable<LabResponse> {
1717

1818
private UserConfig user;
1919
private AppConfig app;
20-
private LabConfig labConfig;
2120

2221
public UserConfig getUser() {
2322
return user;
2423
}
2524

26-
void setUser(UserConfig user) {
27-
this.user = user;
28-
}
29-
3025
public AppConfig getApp() {
3126
return app;
3227
}
3328

34-
void setApp(AppConfig app) {
35-
this.app = app;
36-
}
37-
38-
public LabConfig getLab() {
39-
return labConfig;
40-
}
41-
42-
void setLab(LabConfig labConfig) {
43-
this.labConfig = labConfig;
44-
}
45-
4629
/**
4730
* Deserialize a LabResponse from JSON.
4831
*/
@@ -61,9 +44,6 @@ static LabResponse fromJson(JsonReader jsonReader) throws IOException {
6144
case "app":
6245
response.app = AppConfig.fromJson(reader);
6346
break;
64-
case "lab":
65-
response.labConfig = LabConfig.fromJson(reader);
66-
break;
6747
default:
6848
reader.skipChildren();
6949
break;
@@ -83,19 +63,8 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
8363
if (app != null) {
8464
jsonWriter.writeJsonField("app", app);
8565
}
86-
if (labConfig != null) {
87-
jsonWriter.writeJsonField("labConfig", labConfig);
88-
}
8966

9067
jsonWriter.writeEndObject();
9168
return jsonWriter;
9269
}
93-
94-
@Override
95-
public String toString() {
96-
return String.format("LabResponse{user=%s, app=%s, labConfig=%s}",
97-
user != null ? user.getUpn() : "null",
98-
app != null ? app.getAppId() : "null",
99-
labConfig != null ? labConfig.getTenantId() : "null");
100-
}
10170
}

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/labapi/LabResponseHelper.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class LabResponseHelper {
1515
// Static caches for configuration instances
1616
private static final ConcurrentHashMap<String, AppConfig> appConfigCache = new ConcurrentHashMap<>();
1717
private static final ConcurrentHashMap<String, UserConfig> userConfigCache = new ConcurrentHashMap<>();
18-
private static final ConcurrentHashMap<String, LabConfig> labConfigCache = new ConcurrentHashMap<>();
1918

2019
/**
2120
* Retrieves an AppConfig from Key Vault by secret name.
@@ -50,21 +49,4 @@ public static UserConfig getUserConfig(String userConfigName) {
5049
throw new RuntimeException("Expected LabResponse with UserConfig for secret: " + key);
5150
});
5251
}
53-
54-
/**
55-
* Retrieves a LabConfig from Key Vault by secret name.
56-
* Results are cached to avoid redundant Key Vault calls.
57-
*
58-
* @param labConfigName The Key Vault secret name for the lab configuration (use KeyVaultSecrets constants)
59-
* @return LabConfig instance
60-
*/
61-
public static LabConfig getLabConfig(String labConfigName) {
62-
return labConfigCache.computeIfAbsent(labConfigName, key -> {
63-
Object data = KeyVaultRegistry.getMsalTeamProvider().getLabData(key);
64-
if (data instanceof LabResponse) {
65-
return ((LabResponse) data).getLab();
66-
}
67-
throw new RuntimeException("Expected LabResponse with LabConfig for secret: " + key);
68-
});
69-
}
7052
}

0 commit comments

Comments
 (0)