equal
deleted
inserted
replaced
58 rewriteMaxRetries(-1); |
58 rewriteMaxRetries(-1); |
59 test1(5000, 4); // 1 1 2 2 |
59 test1(5000, 4); // 1 1 2 2 |
60 test1(5000, 2); // 2 2 |
60 test1(5000, 2); // 2 2 |
61 |
61 |
62 // For tryLess |
62 // For tryLess |
63 Security.setProperty("krb5.kdc.bad.policy", "tryless"); |
63 Security.setProperty("krb5.kdc.bad.policy", "tryless:1," + BadKdc.toReal(5000)); |
64 rewriteMaxRetries(4); |
64 rewriteMaxRetries(4); |
65 test1(4000, 7); // 1 1 1 1 2 1 2 |
65 test1(4000, 7); // 1 1 1 1 2 1 2 |
66 test1(4000, 4); // 1 2 1 2 |
66 test1(4000, 4); // 1 2 1 2 |
67 |
67 |
68 rewriteMaxRetries(1); |
68 rewriteMaxRetries(1); |
92 * One round of test for max_retries and timeout. |
92 * One round of test for max_retries and timeout. |
93 * @param timeout the expected timeout |
93 * @param timeout the expected timeout |
94 * @param count the expected total try |
94 * @param count the expected total try |
95 */ |
95 */ |
96 private static void test1(int timeout, int count) throws Exception { |
96 private static void test1(int timeout, int count) throws Exception { |
97 String timeoutTag = "timeout=" + timeout; |
97 String timeoutTag = "timeout=" + BadKdc.toReal(timeout); |
98 ByteArrayOutputStream bo = new ByteArrayOutputStream(); |
98 ByteArrayOutputStream bo = new ByteArrayOutputStream(); |
99 PrintStream oldout = System.out; |
99 PrintStream oldout = System.out; |
100 System.setOut(new PrintStream(bo)); |
100 System.setOut(new PrintStream(bo)); |
101 Context c = Context.fromJAAS("client"); |
101 Context c = Context.fromJAAS("client"); |
102 System.setOut(oldout); |
102 System.setOut(oldout); |
190 break; |
190 break; |
191 } |
191 } |
192 if (s.startsWith("[realms]")) { |
192 if (s.startsWith("[realms]")) { |
193 // Reconfig global setting |
193 // Reconfig global setting |
194 fw.write("max_retries = 2\n"); |
194 fw.write("max_retries = 2\n"); |
195 fw.write("kdc_timeout = 5000\n"); |
195 fw.write("kdc_timeout = " + BadKdc.toReal(5000) + "\n"); |
196 } else if (s.trim().startsWith("kdc = ")) { |
196 } else if (s.trim().startsWith("kdc = ")) { |
197 if (value != -1) { |
197 if (value != -1) { |
198 // Reconfig for realm |
198 // Reconfig for realm |
199 fw.write(" max_retries = " + value + "\n"); |
199 fw.write(" max_retries = " + value + "\n"); |
200 fw.write(" kdc_timeout = " + (value*1000) + "\n"); |
200 fw.write(" kdc_timeout = " + BadKdc.toReal(value*1000) + "\n"); |
201 } |
201 } |
202 // Add a bad KDC as the first candidate |
202 // Add a bad KDC as the first candidate |
203 fw.write(" kdc = localhost:33333\n"); |
203 fw.write(" kdc = localhost:33333\n"); |
204 } |
204 } |
205 fw.write(s + "\n"); |
205 fw.write(s + "\n"); |