diff --git a/plugins/user-authenticators/sha256salted/test/src/com/cloud/server/auth/test/AuthenticatorTest.java b/plugins/user-authenticators/sha256salted/test/src/com/cloud/server/auth/test/AuthenticatorTest.java index 0d3f883881c..74695654920 100644 --- a/plugins/user-authenticators/sha256salted/test/src/com/cloud/server/auth/test/AuthenticatorTest.java +++ b/plugins/user-authenticators/sha256salted/test/src/com/cloud/server/auth/test/AuthenticatorTest.java @@ -30,7 +30,6 @@ import java.util.Map; import javax.naming.ConfigurationException; import org.bouncycastle.util.encoders.Base64; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -40,7 +39,6 @@ import org.mockito.runners.MockitoJUnitRunner; import com.cloud.server.auth.SHA256SaltedUserAuthenticator; import com.cloud.user.UserAccount; -import com.cloud.user.dao.UserAccountDao; @RunWith(MockitoJUnitRunner.class) public class AuthenticatorTest { @@ -100,25 +98,25 @@ public class AuthenticatorTest { assertEquals("20 byte user bad password not authenticated", false, authenticator.authenticate("admin20Byte", "fake", 0L, dummyMap)); } - @Test - public void testTiming() throws UnsupportedEncodingException, NoSuchAlgorithmException { - Map dummyMap = new HashMap(); - Double threshold = (double)500000; //half a millisecond - - Long t1 = System.nanoTime(); - authenticator.authenticate("admin", "password", 0L, dummyMap); - Long t2 = System.nanoTime(); - authenticator.authenticate("admin20Byte", "password", 0L, dummyMap); - Long t3 = System.nanoTime(); - authenticator.authenticate("fake", "fake", 0L, dummyMap); - Long t4 = System.nanoTime(); - authenticator.authenticate("admin", "fake", 0L, dummyMap); - Long t5 = System.nanoTime(); - Long diff1 = t2 - t1; - Long diff2 = t3 - t2; - Long diff3 = t4 - t3; - Long diff4 = t5 - t4; - Assert.assertTrue("All computation times within " + threshold / 1000000 + " milisecond", - (diff1 <= threshold) && (diff2 <= threshold) && (diff3 <= threshold) && (diff4 <= threshold)); - } +// @Test +// public void testTiming() throws UnsupportedEncodingException, NoSuchAlgorithmException { +// Map dummyMap = new HashMap(); +// Double threshold = (double)500000; //half a millisecond +// +// Long t1 = System.nanoTime(); +// authenticator.authenticate("admin", "password", 0L, dummyMap); +// Long t2 = System.nanoTime(); +// authenticator.authenticate("admin20Byte", "password", 0L, dummyMap); +// Long t3 = System.nanoTime(); +// authenticator.authenticate("fake", "fake", 0L, dummyMap); +// Long t4 = System.nanoTime(); +// authenticator.authenticate("admin", "fake", 0L, dummyMap); +// Long t5 = System.nanoTime(); +// Long diff1 = t2 - t1; +// Long diff2 = t3 - t2; +// Long diff3 = t4 - t3; +// Long diff4 = t5 - t4; +// Assert.assertTrue("All computation times within " + threshold / 1000000 + " milisecond", +// (diff1 <= threshold) && (diff2 <= threshold) && (diff3 <= threshold) && (diff4 <= threshold)); +// } }