diff --git a/src/main/java/org/elasticsearch/shield/authc/support/Hasher.java b/src/main/java/org/elasticsearch/shield/authc/support/Hasher.java index 19066bcf21f..4090ad8cdc2 100644 --- a/src/main/java/org/elasticsearch/shield/authc/support/Hasher.java +++ b/src/main/java/org/elasticsearch/shield/authc/support/Hasher.java @@ -63,7 +63,7 @@ public enum Hasher { private static final String BCRYPT_PREFIX_Y = "$2y$"; private static final String SHA1_PREFIX = "{SHA}"; private static final String PLAIN_PREFIX = "{plain}"; - private static final boolean CRYPT_SUPPORTED = !OsUtils.WINDOWS; + static final boolean CRYPT_SUPPORTED = !OsUtils.WINDOWS; public static Hasher resolve(String name, Hasher defaultHasher) { if (name == null) { diff --git a/src/test/java/org/elasticsearch/shield/authc/support/HasherTests.java b/src/test/java/org/elasticsearch/shield/authc/support/HasherTests.java index 4a78b36910e..7a3f626047d 100644 --- a/src/test/java/org/elasticsearch/shield/authc/support/HasherTests.java +++ b/src/test/java/org/elasticsearch/shield/authc/support/HasherTests.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.shield.authc.support; +import org.elasticsearch.common.os.OsUtils; import org.elasticsearch.test.ElasticsearchTestCase; import org.junit.Test; @@ -20,7 +21,11 @@ public class HasherTests extends ElasticsearchTestCase { assertTrue(hasher.verify(passwd, "$2a$05$zxnP0vdREMxnEpkLCDI2OuSaSk/QEKA2.A42iOpI6U2u.RLLOWm1e".toCharArray())); assertTrue(hasher.verify(passwd, "$2a$10$FMhmFjwU5.qxQ/BsEciS9OqcJVkFMgXMo4uH5CelOR1j4N9zIv67e".toCharArray())); assertTrue(hasher.verify(passwd, "$apr1$R3DdqiAZ$aljIkaIVPSarmDMlJUBBP.".toCharArray())); - assertTrue(hasher.verify(passwd, "hsP1PYSLsEEvs".toCharArray())); + if (!Hasher.CRYPT_SUPPORTED) { + assertTrue(hasher.verify(passwd, "test123".toCharArray())); + } else { + assertTrue(hasher.verify(passwd, "hsP1PYSLsEEvs".toCharArray())); + } assertTrue(hasher.verify(passwd, "{plain}test123".toCharArray())); assertTrue(hasher.verify(passwd, "{SHA}cojt0Pw//L6ToM8G41aOKFIWh7w=".toCharArray())); }