Skip to content

Commit

Permalink
Fix testMalformedRefreshTokens
Browse files Browse the repository at this point in the history
  • Loading branch information
albertzaharovits committed Jul 24, 2023
1 parent 7ec895b commit 6d96118
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,6 @@ private void mockTokenForRefreshToken(
.realmRef(realmRef)
.build(false);

final SearchHit hit = new SearchHit(randomInt(), "token_" + userToken.getId());
BytesReference source = TokenService.createTokenDocument(
userToken,
storedAccessToken,
Expand Down Expand Up @@ -1236,10 +1235,14 @@ private void mockTokenForRefreshToken(
assertThat(bool.filter().get(1), instanceOf(TermQueryBuilder.class));
TermQueryBuilder refreshFilter = (TermQueryBuilder) bool.filter().get(1);
assertThat(refreshFilter.fieldName(), is("refresh_token.token"));
assertThat(refreshFilter.value(), is(storedRefreshToken));
hit.sourceRef(docSource);

final SearchHits hits = new SearchHits(new SearchHit[] { hit }, null, 1);
final SearchHits hits;
if (storedRefreshToken.equals(refreshFilter.value())) {
SearchHit hit = new SearchHit(randomInt(), "token_" + userToken.getId());
hit.sourceRef(docSource);
hits = new SearchHits(new SearchHit[] { hit }, null, 1);
} else {
hits = SearchHits.EMPTY_WITH_TOTAL_HITS;
}
when(response.getHits()).thenReturn(hits);
listener.onResponse(response);
return Void.TYPE;
Expand Down

0 comments on commit 6d96118

Please sign in to comment.