|
33 | 33 | package org.opensearch.repositories.azure;
|
34 | 34 |
|
35 | 35 | import com.azure.core.http.policy.HttpPipelinePolicy;
|
36 |
| -import com.azure.identity.CredentialUnavailableException; |
37 | 36 | import com.azure.storage.blob.BlobServiceClient;
|
38 | 37 | import com.azure.storage.common.policy.RequestRetryPolicy;
|
| 38 | +import com.microsoft.aad.msal4j.MsalServiceException; |
39 | 39 | import org.opensearch.common.settings.MockSecureSettings;
|
40 | 40 | import org.opensearch.common.settings.Settings;
|
41 | 41 | import org.opensearch.common.settings.SettingsException;
|
|
61 | 61 | import reactor.netty.http.HttpResources;
|
62 | 62 |
|
63 | 63 | import static org.hamcrest.Matchers.containsInAnyOrder;
|
| 64 | +import static org.hamcrest.Matchers.containsString; |
64 | 65 | import static org.hamcrest.Matchers.emptyString;
|
65 | 66 | import static org.hamcrest.Matchers.equalTo;
|
66 | 67 | import static org.hamcrest.Matchers.is;
|
@@ -202,10 +203,9 @@ public void testClientUsingManagedIdentity() throws IOException {
|
202 | 203 | final BlobServiceClient client1 = azureStorageService.client("azure1").v1();
|
203 | 204 |
|
204 | 205 | // Expect the client to use managed identity for authentication, and it should fail because managed identity environment is
|
205 |
| - // not |
206 |
| - // setup in the test |
207 |
| - final CredentialUnavailableException e = expectThrows(CredentialUnavailableException.class, () -> client1.getAccountInfo()); |
208 |
| - assertThat(e.getMessage(), is("Managed Identity authentication is not available.")); |
| 206 | + // not setup in the test |
| 207 | + final MsalServiceException e = expectThrows(MsalServiceException.class, () -> client1.getAccountInfo()); |
| 208 | + assertThat(e.getMessage(), containsString("HttpStatusCode: 401")); |
209 | 209 | }
|
210 | 210 | }
|
211 | 211 | }
|
|
0 commit comments