Skip to content

Commit 485350c

Browse files
committed
Various fixes for automated tests
1 parent e1813c4 commit 485350c

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void init() throws CertificateException, UnrecoverableKeyException, NoSuchAlgori
4040

4141
@Test
4242
void acquireTokenClientCredentials_ClientCertificate() throws Exception {
43-
String clientId = "2afb0add-2f32-4946-ac90-81a02aa4550e";
43+
String clientId = TestConstants.MSIDLAB_CLIENT_ID;
4444
assertAcquireTokenCommon(clientId, certificate, TestConstants.MICROSOFT_AUTHORITY);
4545
}
4646

@@ -49,7 +49,7 @@ void acquireTokenClientCredentials_ClientSecret() throws Exception {
4949
AppCredentialProvider appProvider = new AppCredentialProvider(AzureEnvironment.AZURE);
5050
final String clientId = appProvider.getLabVaultAppId();
5151
final String password = appProvider.getLabVaultPassword();
52-
IClientCredential credential = ClientCredentialFactory.createFromSecret(password);
52+
IClientCredential credential = CertificateHelper.getClientCertificate();
5353

5454
assertAcquireTokenCommon(clientId, credential, TestConstants.MICROSOFT_AUTHORITY);
5555
}
@@ -90,7 +90,7 @@ void acquireTokenClientCredentials_ClientSecret_Ciam() throws Exception {
9090

9191
@Test
9292
void acquireTokenClientCredentials_Callback() throws Exception {
93-
String clientId = "2afb0add-2f32-4946-ac90-81a02aa4550e";
93+
String clientId = TestConstants.MSIDLAB_CLIENT_ID;
9494

9595
// Creates a valid client assertion using a callback, and uses it to build the client app and make a request
9696
Callable<String> callable = () -> {
@@ -116,11 +116,9 @@ void acquireTokenClientCredentials_Callback() throws Exception {
116116
void acquireTokenClientCredentials_DefaultCacheLookup() throws Exception {
117117
AppCredentialProvider appProvider = new AppCredentialProvider(AzureEnvironment.AZURE);
118118
final String clientId = appProvider.getLabVaultAppId();
119-
final String password = appProvider.getLabVaultPassword();
120-
IClientCredential credential = ClientCredentialFactory.createFromSecret(password);
121119

122120
ConfidentialClientApplication cca = ConfidentialClientApplication.builder(
123-
clientId, credential).
121+
clientId, CertificateHelper.getClientCertificate()).
124122
authority(TestConstants.MICROSOFT_AUTHORITY).
125123
build();
126124

@@ -152,7 +150,7 @@ void acquireTokenClientCredentials_DefaultCacheLookup() throws Exception {
152150

153151
@Test
154152
void acquireTokenClientCredentials_Regional() throws Exception {
155-
String clientId = "2afb0add-2f32-4946-ac90-81a02aa4550e";
153+
String clientId = TestConstants.MSIDLAB_CLIENT_ID;
156154

157155
assertAcquireTokenCommon_withRegion(clientId, certificate, "westus", TestConstants.REGIONAL_MICROSOFT_AUTHORITY_BASIC_HOST_WESTUS);
158156
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
public class TestConstants {
1111
public final static String KEYVAULT_DEFAULT_SCOPE = "https://vault.azure.net/.default";
12-
public final static String MSIDLAB_DEFAULT_SCOPE = "https://msidlab.com/.default";
12+
public final static String MSIDLAB_DEFAULT_SCOPE = "https://request.msidlab.com/.default";
1313
public final static String MSIDLAB_VAULT_URL = "https://msidlabs.vault.azure.net/";
14+
public final static String MSIDLAB_CLIENT_ID = "f62c5ae3-bf3a-4af5-afa8-a68b800396e9";
1415
public final static String GRAPH_DEFAULT_SCOPE = "https://graph.windows.net/.default";
1516
public final static String USER_READ_SCOPE = "user.read";
1617
public final static String DEFAULT_SCOPE = ".default";

msal4j-sdk/src/integrationtest/java/labapi/KeyVaultSecretsProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class KeyVaultSecretsProvider {
2121

2222
private final SecretClient secretClient;
2323

24-
private static final String CLIENT_ID = "2afb0add-2f32-4946-ac90-81a02aa4550e";
25-
public static String CERTIFICATE_ALIAS = "MsalJavaAutomationRunner";
24+
private static final String CLIENT_ID = TestConstants.MSIDLAB_CLIENT_ID;
25+
public static String CERTIFICATE_ALIAS = "LabVaultAccessCert";
2626

2727
private static final String WIN_KEYSTORE = "Windows-MY";
2828
private static final String KEYSTORE_PROVIDER = "SunMSCAPI";
@@ -82,7 +82,7 @@ CLIENT_ID, getClientCredentialFromKeyStore()).
8282
}
8383
}
8484

85-
private IClientCredential getClientCredentialFromKeyStore() {
85+
IClientCredential getClientCredentialFromKeyStore() {
8686
PrivateKey key;
8787
X509Certificate publicCertificate;
8888
try {

msal4j-sdk/src/integrationtest/java/labapi/LabService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ static void initLabApp() throws MalformedURLException {
3333
KeyVaultSecretsProvider keyVaultSecretsProvider = new KeyVaultSecretsProvider();
3434

3535
String appID = keyVaultSecretsProvider.getSecret(LabConstants.APP_ID_KEY_VAULT_SECRET);
36-
String appSecret = keyVaultSecretsProvider.getSecret(LabConstants.APP_PASSWORD_KEY_VAULT_SECRET);
3736

3837
labApp = ConfidentialClientApplication.builder(
39-
appID, ClientCredentialFactory.createFromSecret(appSecret)).
38+
appID, keyVaultSecretsProvider.getClientCredentialFromKeyStore()).
4039
authority(TestConstants.MICROSOFT_AUTHORITY).
4140
build();
4241
}

0 commit comments

Comments
 (0)