You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ar...@apache.org on 2014/03/11 01:02:15 UTC
svn commit: r1576145 - in /hadoop/common/trunk/hadoop-common-project:
hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java
hadoop-common/CHANGES.txt
Author: arp
Date: Tue Mar 11 00:02:14 2014
New Revision: 1576145
URL: http://svn.apache.org/r1576145
Log:
HADOOP-10394. TestAuthenticationFilter is flaky. (Arpit Agarwal)
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java?rev=1576145&r1=1576144&r2=1576145&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestAuthenticationFilter.java Tue Mar 11 00:02:14 2014
@@ -37,8 +37,13 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
public class TestAuthenticationFilter {
+ private static final long TOKEN_VALIDITY_SEC = 1000;
+
@Test
public void testGetConfiguration() throws Exception {
AuthenticationFilter filter = new AuthenticationFilter();
@@ -123,7 +128,7 @@ public class TestAuthenticationFilter {
String param = request.getParameter("authenticated");
if (param != null && param.equals("true")) {
token = new AuthenticationToken("u", "p", "t");
- token.setExpires((expired) ? 0 : System.currentTimeMillis() + 1000);
+ token.setExpires((expired) ? 0 : System.currentTimeMillis() + TOKEN_VALIDITY_SEC);
} else {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
@@ -139,7 +144,8 @@ public class TestAuthenticationFilter {
try {
FilterConfig config = Mockito.mock(FilterConfig.class);
Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TYPE)).thenReturn("simple");
- Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TOKEN_VALIDITY)).thenReturn("1000");
+ Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TOKEN_VALIDITY)).thenReturn(
+ (new Long(TOKEN_VALIDITY_SEC)).toString());
Mockito.when(config.getInitParameterNames()).thenReturn(
new Vector<String>(Arrays.asList(AuthenticationFilter.AUTH_TYPE,
AuthenticationFilter.AUTH_TOKEN_VALIDITY)).elements());
@@ -148,7 +154,7 @@ public class TestAuthenticationFilter {
Assert.assertTrue(filter.isRandomSecret());
Assert.assertNull(filter.getCookieDomain());
Assert.assertNull(filter.getCookiePath());
- Assert.assertEquals(1000, filter.getValidity());
+ Assert.assertEquals(TOKEN_VALIDITY_SEC, filter.getValidity());
} finally {
filter.destroy();
}
@@ -265,7 +271,7 @@ public class TestAuthenticationFilter {
filter.init(config);
AuthenticationToken token = new AuthenticationToken("u", "p", DummyAuthenticationHandler.TYPE);
- token.setExpires(System.currentTimeMillis() + 1000);
+ token.setExpires(System.currentTimeMillis() + TOKEN_VALIDITY_SEC);
Signer signer = new Signer("secret".getBytes());
String tokenSigned = signer.sign(token.toString());
@@ -298,7 +304,7 @@ public class TestAuthenticationFilter {
filter.init(config);
AuthenticationToken token = new AuthenticationToken("u", "p", "invalidtype");
- token.setExpires(System.currentTimeMillis() - 1000);
+ token.setExpires(System.currentTimeMillis() - TOKEN_VALIDITY_SEC);
Signer signer = new Signer("secret".getBytes());
String tokenSigned = signer.sign(token.toString());
@@ -337,7 +343,7 @@ public class TestAuthenticationFilter {
filter.init(config);
AuthenticationToken token = new AuthenticationToken("u", "p", "invalidtype");
- token.setExpires(System.currentTimeMillis() + 1000);
+ token.setExpires(System.currentTimeMillis() + TOKEN_VALIDITY_SEC);
Signer signer = new Signer("secret".getBytes());
String tokenSigned = signer.sign(token.toString());
@@ -410,7 +416,7 @@ public class TestAuthenticationFilter {
Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TYPE))
.thenReturn(DummyAuthenticationHandler.class.getName());
Mockito.when(config.getInitParameter(AuthenticationFilter
- .AUTH_TOKEN_VALIDITY)).thenReturn("1000");
+ .AUTH_TOKEN_VALIDITY)).thenReturn(new Long(TOKEN_VALIDITY_SEC).toString());
Mockito.when(config.getInitParameter(AuthenticationFilter
.SIGNATURE_SECRET)).thenReturn("secret");
Mockito.when(config.getInitParameterNames()).thenReturn(new
@@ -474,8 +480,7 @@ public class TestAuthenticationFilter {
Signer signer = new Signer("secret".getBytes());
String value = signer.verifyAndExtract(v);
AuthenticationToken token = AuthenticationToken.parse(value);
- Assert.assertEquals(System.currentTimeMillis() + 1000 * 1000,
- token.getExpires(), 100);
+ assertThat(token.getExpires(), not(0L));
if (withDomainPath) {
Assert.assertEquals(".foo.com", cookieMap.get("Domain"));
@@ -549,7 +554,7 @@ public class TestAuthenticationFilter {
Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://foo:8080/bar"));
AuthenticationToken token = new AuthenticationToken("u", "p", "t");
- token.setExpires(System.currentTimeMillis() + 1000);
+ token.setExpires(System.currentTimeMillis() + TOKEN_VALIDITY_SEC);
Signer signer = new Signer("secret".getBytes());
String tokenSigned = signer.sign(token.toString());
@@ -599,7 +604,7 @@ public class TestAuthenticationFilter {
Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://foo:8080/bar"));
AuthenticationToken token = new AuthenticationToken("u", "p", DummyAuthenticationHandler.TYPE);
- token.setExpires(System.currentTimeMillis() - 1000);
+ token.setExpires(System.currentTimeMillis() - TOKEN_VALIDITY_SEC);
Signer signer = new Signer("secret".getBytes());
String tokenSigned = signer.sign(token.toString());
@@ -661,7 +666,7 @@ public class TestAuthenticationFilter {
Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://foo:8080/bar"));
AuthenticationToken token = new AuthenticationToken("u", "p", "invalidtype");
- token.setExpires(System.currentTimeMillis() + 1000);
+ token.setExpires(System.currentTimeMillis() + TOKEN_VALIDITY_SEC);
Signer signer = new Signer("secret".getBytes());
String tokenSigned = signer.sign(token.toString());
@@ -708,7 +713,7 @@ public class TestAuthenticationFilter {
Mockito.reset(response);
AuthenticationToken token = new AuthenticationToken("u", "p", "t");
- token.setExpires(System.currentTimeMillis() + 1000);
+ token.setExpires(System.currentTimeMillis() + TOKEN_VALIDITY_SEC);
Signer signer = new Signer("secret".getBytes());
String tokenSigned = signer.sign(token.toString());
Cookie cookie = new Cookie(AuthenticatedURL.AUTH_COOKIE, tokenSigned);
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1576145&r1=1576144&r2=1576145&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Tue Mar 11 00:02:14 2014
@@ -415,6 +415,8 @@ Release 2.4.0 - UNRELEASED
HADOOP-10395. TestCallQueueManager is flaky. (Arpit Agarwal)
+ HADOOP-10394. TestAuthenticationFilter is flaky. (Arpit Agarwal)
+
BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS
HADOOP-10185. FileSystem API for ACLs. (cnauroth)