Skip to content

Commit

Permalink
Add short format ipv6 test
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <dxho@amazon.com>
  • Loading branch information
derek-ho committed Jun 5, 2024
1 parent 9454232 commit a680e92
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/java/org/opensearch/security/auth/UserInjectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ public void testValidInjectUserIpV6() {
assertEquals("2001:db8:3333:4444:5555:6666:7777:8888", injectedUser.getTransportAddress().getAddress());
}

@Test
public void testValidInjectUserIpV6ShortFormat() {
HashSet<String> roles = new HashSet<>();
roles.addAll(Arrays.asList("role1", "role2"));
threadContext.putTransient(ConfigConstants.OPENDISTRO_SECURITY_INJECTED_USER, "user|role1,role2|2001:db8::1:9200");
UserInjector.InjectedUser injectedUser = userInjector.getInjectedUser();
assertEquals("user", injectedUser.getName());
assertEquals(9200, injectedUser.getTransportAddress().getPort());
assertEquals("2001:db8::1", injectedUser.getTransportAddress().getAddress());
}

@Test
public void testInvalidInjectUserIpV6() {
HashSet<String> roles = new HashSet<>();
Expand Down

0 comments on commit a680e92

Please sign in to comment.