-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: extract reason from error in AWSSdk2Transport (#493)
* MAINT: extract reason from error Signed-off-by: George Chen <[email protected]> * MAINT: add change log Signed-off-by: George Chen <[email protected]> * MAINT: remove unwanted string Signed-off-by: George Chen <[email protected]> * TST: AwsSdk2SecurityIT Signed-off-by: George Chen <[email protected]> * MAINT: header Signed-off-by: George Chen <[email protected]> --------- Signed-off-by: George Chen <[email protected]> (cherry picked from commit 89d154d) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5dc144c
commit 98269d3
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...lient/src/test/java/org/opensearch/client/opensearch/integTest/aws/AwsSdk2SecurityIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.client.opensearch.integTest.aws; | ||
|
||
import org.junit.Test; | ||
import org.opensearch.client.opensearch.OpenSearchClient; | ||
import org.opensearch.client.opensearch._types.OpenSearchException; | ||
import org.opensearch.client.opensearch.cluster.GetClusterSettingsRequest; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertThrows; | ||
|
||
public class AwsSdk2SecurityIT extends AwsSdk2TransportTestCase { | ||
private static final String DEFAULT_MESSAGE = "authentication/authorization failure"; | ||
@Test | ||
public void testUnAuthorizedException() { | ||
final OpenSearchClient client = getClient(false, null, null); | ||
final GetClusterSettingsRequest request = new GetClusterSettingsRequest.Builder() | ||
.includeDefaults(true) | ||
.build(); | ||
final OpenSearchException ex = assertThrows( | ||
OpenSearchException.class, () -> client.cluster().getSettings(request)); | ||
assertFalse(ex.getMessage().contains(DEFAULT_MESSAGE)); | ||
} | ||
} |