|
@@ -53,14 +53,17 @@ import org.elasticsearch.xpack.core.security.authc.support.TokensInvalidationRes
|
|
|
import org.elasticsearch.xpack.core.security.user.User;
|
|
|
import org.elasticsearch.xpack.core.watcher.watch.ClockMock;
|
|
|
import org.elasticsearch.xpack.security.support.SecurityIndexManager;
|
|
|
-import org.junit.After;
|
|
|
import org.elasticsearch.xpack.security.test.SecurityMocks;
|
|
|
import org.hamcrest.Matchers;
|
|
|
+import org.junit.After;
|
|
|
import org.junit.AfterClass;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.BeforeClass;
|
|
|
|
|
|
+import javax.crypto.SecretKey;
|
|
|
import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.security.GeneralSecurityException;
|
|
|
import java.time.Clock;
|
|
|
import java.time.Instant;
|
|
@@ -70,8 +73,6 @@ import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-import javax.crypto.SecretKey;
|
|
|
-
|
|
|
import static java.time.Clock.systemUTC;
|
|
|
import static org.elasticsearch.repositories.ESBlobStoreTestCase.randomBytes;
|
|
|
import static org.elasticsearch.test.ClusterServiceUtils.setState;
|
|
@@ -721,6 +722,11 @@ public class TokenServiceTests extends ESTestCase {
|
|
|
assertThat(authToken, Matchers.nullValue());
|
|
|
}
|
|
|
|
|
|
+ public void testHashedTokenIsUrlSafe() {
|
|
|
+ final String hashedId = TokenService.hashTokenString(UUIDs.randomBase64UUID());
|
|
|
+ assertEquals(hashedId, URLEncoder.encode(hashedId, StandardCharsets.UTF_8));
|
|
|
+ }
|
|
|
+
|
|
|
private TokenService createTokenService(Settings settings, Clock clock) throws GeneralSecurityException {
|
|
|
return new TokenService(settings, clock, client, licenseState, securityMainIndex, securityTokensIndex, clusterService);
|
|
|
}
|