Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 committed Oct 28, 2023
1 parent 8ecb683 commit 1dc296b
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.opensearch.security.support.ConfigConstants.*;
import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_ENABLED_KEY;
import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_PERMISSIONS_ENABLED_KEY;
import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ROLES_ENABLED;
import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_KEY;
import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL;
import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS;

Expand All @@ -43,8 +46,9 @@ public class ServiceAccountAuthenticationTest {

static final TestSecurityConfig.User ADMIN_USER = new TestSecurityConfig.User("admin").roles(ALL_ACCESS);

// CS-SUPPRESS-SINGLE: RegexpSingleline get Extensions Settings
public static final String SERVICE_ACCOUNT_USER_NAME = "admin-extension";

// CS-ENFORCE-SINGLE
private static final TestSecurityConfig.Role SERVICE_ACCOUNT_ADMIN_ROLE = new TestSecurityConfig.Role("admin-extension-role")
.clusterPermissions("*")
.indexPermissions("*", "system:admin/system_index")
Expand Down Expand Up @@ -87,8 +91,8 @@ public class ServiceAccountAuthenticationTest {

@Test
public void testClusterHealthWithServiceAccountCred() throws JsonProcessingException {
try (TestRestClient client = cluster.getRestClient("admin-extension", DEFAULT_PASSWORD)) {
client.confirmCorrectCredentials("admin-extension");
try (TestRestClient client = cluster.getRestClient(SERVICE_ACCOUNT_USER_NAME, DEFAULT_PASSWORD)) {
client.confirmCorrectCredentials(SERVICE_ACCOUNT_USER_NAME);
TestRestClient.HttpResponse response = client.get("_cluster/health");
response.assertStatusCode(HttpStatus.SC_FORBIDDEN);

Expand All @@ -104,8 +108,8 @@ public void testClusterHealthWithServiceAccountCred() throws JsonProcessingExcep

@Test
public void testReadSysIndexWithServiceAccountCred() {
try (TestRestClient client = cluster.getRestClient("admin-extension", DEFAULT_PASSWORD)) {
client.confirmCorrectCredentials("admin-extension");
try (TestRestClient client = cluster.getRestClient(SERVICE_ACCOUNT_USER_NAME, DEFAULT_PASSWORD)) {
client.confirmCorrectCredentials(SERVICE_ACCOUNT_USER_NAME);
TestRestClient.HttpResponse response = client.get("test-sys-index");
response.assertStatusCode(HttpStatus.SC_OK);
// TODO: REMOVE THIS AND PARSING/CHECKING THE RESPONSE
Expand All @@ -115,8 +119,8 @@ public void testReadSysIndexWithServiceAccountCred() {

@Test
public void testReadNonSysIndexWithServiceAccountCred() {
try (TestRestClient client = cluster.getRestClient("admin-extension", DEFAULT_PASSWORD)) {
client.confirmCorrectCredentials("admin-extension");
try (TestRestClient client = cluster.getRestClient(SERVICE_ACCOUNT_USER_NAME, DEFAULT_PASSWORD)) {
client.confirmCorrectCredentials(SERVICE_ACCOUNT_USER_NAME);
TestRestClient.HttpResponse response = client.get("test-non-sys-index");
response.assertStatusCode(HttpStatus.SC_FORBIDDEN);
// TODO: REMOVE THIS AND PARSING/CHECKING THE RESPONSE
Expand Down

0 comments on commit 1dc296b

Please sign in to comment.