From a2f969df11cc2a3fed608cbdcaf2221d7f40a2c6 Mon Sep 17 00:00:00 2001 From: Ioannis Kakavas Date: Mon, 27 Apr 2020 13:02:23 +0300 Subject: [PATCH] adjust test as #54532 is not backported to 7.7 --- .../security/authc/TokenAuthIntegTests.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java index 4e10cedefdf7d..9e5e4cf2eb852 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java @@ -191,13 +191,15 @@ public void testExpiredTokensDeletedAfterExpiration() throws Exception { assertBusy(() -> { if (deleteTriggered.compareAndSet(false, true)) { // invalidate a invalid token... doesn't matter that it is bad... we just want this action to trigger the deletion - InvalidateTokenResponse invalidateResponseTwo = securityClient.prepareInvalidateToken("fooobar") - .setType(randomFrom(InvalidateTokenRequest.Type.values())) - .execute() - .actionGet(); - assertThat(invalidateResponseTwo.getResult().getInvalidatedTokens(), equalTo(0)); - assertThat(invalidateResponseTwo.getResult().getPreviouslyInvalidatedTokens(), equalTo(0)); - assertThat(invalidateResponseTwo.getResult().getErrors().size(), equalTo(0)); + try { + securityClient.prepareInvalidateToken("fooobar") + .setType(randomFrom(InvalidateTokenRequest.Type.values())) + .execute() + .actionGet(); + } catch (ElasticsearchSecurityException e) { + assertEquals("token malformed", e.getMessage()); + assertThat(e.status(), equalTo(RestStatus.UNAUTHORIZED)); + } } client.admin().indices().prepareRefresh(RestrictedIndicesNames.SECURITY_TOKENS_ALIAS).get(); SearchResponse searchResponse = client.prepareSearch(RestrictedIndicesNames.SECURITY_TOKENS_ALIAS)