Skip to content

Commit

Permalink
Change to isAdminDn
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Nov 9, 2023
1 parent 527e2d2 commit dc0047c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/opensearch/commons/authuser/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public String getRequestedTenant() {
return requestedTenant;
}

public boolean isSuperUser(Settings settings) {
public boolean isAdminDn(Settings settings) {
if (settings == null) {
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/opensearch/commons/authuser/UserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void testParseUserStringMalformed() {
}

@Test
public void testUserIsSuperUserTrue() {
public void testUserIsAdminDnTrue() {
Settings settings = Settings
.builder()
.putList(ConfigConstants.OPENSEARCH_SECURITY_AUTHCZ_ADMIN_DN, List.of("CN=kirk,OU=client,O=client,L=test, C=de"))
Expand All @@ -219,11 +219,11 @@ public void testUserIsSuperUserTrue() {
);
String str = tc.getTransient(OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT);
User user = User.parse(str);
assertTrue(user.isSuperUser(settings));
assertTrue(user.isAdminDn(settings));
}

@Test
public void testUserIsSuperUserFalse() {
public void testUserIsAdminDnFalse() {
Settings settings = Settings
.builder()
.putList(ConfigConstants.OPENSEARCH_SECURITY_AUTHCZ_ADMIN_DN, List.of("CN=spock,OU=client,O=client,L=test, C=de"))
Expand All @@ -236,14 +236,14 @@ public void testUserIsSuperUserFalse() {
);
String str = tc.getTransient(OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT);
User user = User.parse(str);
assertFalse(user.isSuperUser(settings));
assertFalse(user.isAdminDn(settings));
}

@Test
public void testUserOrSettingsAreNullOrEmpty() {
Settings settings = Settings.EMPTY;
User user = User.parse("username|backend_role1|role1");
assertFalse(user.isSuperUser(null));
assertFalse(user.isSuperUser(settings));
assertFalse(user.isAdminDn(null));
assertFalse(user.isAdminDn(settings));
}
}

0 comments on commit dc0047c

Please sign in to comment.