Skip to content

Commit

Permalink
Switch to assertThat in obo authenticator test
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 committed Aug 24, 2023
1 parent cb3406a commit 682379d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.opensearch.security.user.AuthCredentials;
import org.opensearch.security.util.FakeRestRequest;

import static org.hamcrest.Matchers.equalTo;

public class OnBehalfOfAuthenticatorTest {
final static String clusterName = "cluster_0";
final static String enableOBO = "true";
Expand Down Expand Up @@ -147,6 +149,10 @@ public void testNonSpecifyOBOSetting() throws Exception {

@Test
public void testBearer() throws Exception {
Map<String, String> expectedAttributes = new HashMap<>();
expectedAttributes.put("attr.jwt.iss", "cluster_0");
expectedAttributes.put("attr.jwt.sub", "Leonard McCoy");
expectedAttributes.put("attr.jwt.aud", "ext_0");

String jwsToken = Jwts.builder()
.setIssuer(clusterName)
Expand All @@ -165,7 +171,7 @@ public void testBearer() throws Exception {
Assert.assertEquals("Leonard McCoy", credentials.getUsername());
Assert.assertEquals(0, credentials.getSecurityRoles().size());
Assert.assertEquals(0, credentials.getBackendRoles().size());
Assert.assertEquals(3, credentials.getAttributes().size());
Assert.assertThat(credentials.getAttributes(), equalTo(expectedAttributes));
}

@Test
Expand Down

0 comments on commit 682379d

Please sign in to comment.