|
30 | 30 | import javax.naming.ConfigurationException; |
31 | 31 |
|
32 | 32 | import org.bouncycastle.util.encoders.Base64; |
33 | | -import org.junit.Assert; |
34 | 33 | import org.junit.Before; |
35 | 34 | import org.junit.Test; |
36 | 35 | import org.junit.runner.RunWith; |
@@ -100,25 +99,25 @@ public void testAuthentication() throws UnsupportedEncodingException, NoSuchAlgo |
100 | 99 | assertEquals("20 byte user bad password not authenticated", false, authenticator.authenticate("admin20Byte", "fake", 0L, dummyMap)); |
101 | 100 | } |
102 | 101 |
|
103 | | - @Test |
104 | | - public void testTiming() throws UnsupportedEncodingException, NoSuchAlgorithmException { |
105 | | - Map<String, Object[]> dummyMap = new HashMap<String, Object[]>(); |
106 | | - Double threshold = (double)500000; //half a millisecond |
107 | | - |
108 | | - Long t1 = System.nanoTime(); |
109 | | - authenticator.authenticate("admin", "password", 0L, dummyMap); |
110 | | - Long t2 = System.nanoTime(); |
111 | | - authenticator.authenticate("admin20Byte", "password", 0L, dummyMap); |
112 | | - Long t3 = System.nanoTime(); |
113 | | - authenticator.authenticate("fake", "fake", 0L, dummyMap); |
114 | | - Long t4 = System.nanoTime(); |
115 | | - authenticator.authenticate("admin", "fake", 0L, dummyMap); |
116 | | - Long t5 = System.nanoTime(); |
117 | | - Long diff1 = t2 - t1; |
118 | | - Long diff2 = t3 - t2; |
119 | | - Long diff3 = t4 - t3; |
120 | | - Long diff4 = t5 - t4; |
121 | | - Assert.assertTrue("All computation times within " + threshold / 1000000 + " milisecond", |
122 | | - (diff1 <= threshold) && (diff2 <= threshold) && (diff3 <= threshold) && (diff4 <= threshold)); |
123 | | - } |
| 102 | +// @Test |
| 103 | +// public void testTiming() throws UnsupportedEncodingException, NoSuchAlgorithmException { |
| 104 | +// Map<String, Object[]> dummyMap = new HashMap<String, Object[]>(); |
| 105 | +// Double threshold = (double)500000; //half a millisecond |
| 106 | +// |
| 107 | +// Long t1 = System.nanoTime(); |
| 108 | +// authenticator.authenticate("admin", "password", 0L, dummyMap); |
| 109 | +// Long t2 = System.nanoTime(); |
| 110 | +// authenticator.authenticate("admin20Byte", "password", 0L, dummyMap); |
| 111 | +// Long t3 = System.nanoTime(); |
| 112 | +// authenticator.authenticate("fake", "fake", 0L, dummyMap); |
| 113 | +// Long t4 = System.nanoTime(); |
| 114 | +// authenticator.authenticate("admin", "fake", 0L, dummyMap); |
| 115 | +// Long t5 = System.nanoTime(); |
| 116 | +// Long diff1 = t2 - t1; |
| 117 | +// Long diff2 = t3 - t2; |
| 118 | +// Long diff3 = t4 - t3; |
| 119 | +// Long diff4 = t5 - t4; |
| 120 | +// Assert.assertTrue("All computation times within " + threshold / 1000000 + " milisecond", |
| 121 | +// (diff1 <= threshold) && (diff2 <= threshold) && (diff3 <= threshold) && (diff4 <= threshold)); |
| 122 | +// } |
124 | 123 | } |
0 commit comments