Skip to content

Commit 9ec8181

Browse files
committed
Change exception type for null credential error
Signed-off-by: Daniel Widdis <widdis@gmail.com>
1 parent 1707bac commit 9ec8181

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

plugins/repository-azure/src/test/java/org/opensearch/repositories/azure/AzureStorageServiceTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
package org.opensearch.repositories.azure;
3434

3535
import com.azure.core.http.policy.HttpPipelinePolicy;
36-
import com.azure.identity.CredentialUnavailableException;
3736
import com.azure.storage.blob.BlobServiceClient;
3837
import com.azure.storage.common.policy.RequestRetryPolicy;
38+
import com.microsoft.aad.msal4j.MsalServiceException;
3939
import org.opensearch.common.settings.MockSecureSettings;
4040
import org.opensearch.common.settings.Settings;
4141
import org.opensearch.common.settings.SettingsException;
@@ -61,6 +61,7 @@
6161
import reactor.netty.http.HttpResources;
6262

6363
import static org.hamcrest.Matchers.containsInAnyOrder;
64+
import static org.hamcrest.Matchers.containsString;
6465
import static org.hamcrest.Matchers.emptyString;
6566
import static org.hamcrest.Matchers.equalTo;
6667
import static org.hamcrest.Matchers.is;
@@ -202,10 +203,9 @@ public void testClientUsingManagedIdentity() throws IOException {
202203
final BlobServiceClient client1 = azureStorageService.client("azure1").v1();
203204

204205
// 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"));
209209
}
210210
}
211211
}

0 commit comments

Comments
 (0)