Skip to content

Commit

Permalink
Test 403
Browse files Browse the repository at this point in the history
  • Loading branch information
n1v0lg committed Aug 8, 2023
1 parent ed37b3c commit 03a5b61
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.test.XContentTestUtils;
Expand All @@ -36,6 +37,7 @@

import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.emptyArray;
import static org.hamcrest.Matchers.equalTo;

public class GetApiKeysRestIT extends SecurityOnTrialLicenseRestTestCase {
private static final SecureString END_USER_PASSWORD = new SecureString("end-user-password".toCharArray());
Expand Down Expand Up @@ -145,6 +147,11 @@ public void testGetApiKeysWithActiveOnlyFlagAndMultipleUsers() throws Exception
).getApiKeyInfos(),
emptyArray()
);
var ex = expectThrows(
ResponseException.class,
() -> getApiKeysWithRequestParams(MANAGE_OWN_API_KEY_USER, Map.of("active_only", "true", "owner", "false"))
);
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(403));
assertResponseContainsApiKeyIds(
getApiKeysWithRequestParams(randomBoolean() ? Map.of() : Map.of("active_only", "false")),
manageOwnApiKeyUserApiKeyId,
Expand Down

0 comments on commit 03a5b61

Please sign in to comment.