From e1ba3f815874dec287a27b96ac3ea5ad1ea36768 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Fri, 7 Dec 2012 15:23:49 +0000 Subject: [PATCH] HDFS-4236. Remove artificial limit on username length introduced in HDFS-4171. Contributed by Alejandro Abdelnur. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1418356 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/hadoop/lib/wsrs/UserProvider.java | 5 ++--- .../apache/hadoop/lib/wsrs/TestUserProvider.java | 13 ------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/web/resources/UserParam.java | 5 ++--- .../apache/hadoop/hdfs/web/resources/TestParam.java | 11 ----------- 5 files changed, 7 insertions(+), 30 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/UserProvider.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/UserProvider.java index 4db42c21ac..fd59b19dc3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/UserProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/UserProvider.java @@ -53,10 +53,9 @@ public UserParam(String user) { public String parseParam(String str) { if (str != null) { int len = str.length(); - if (len < 1 || len > 31) { + if (len < 1) { throw new IllegalArgumentException(MessageFormat.format( - "Parameter [{0}], invalid value [{1}], it's length must be between 1 and 31", - getName(), str)); + "Parameter [{0}], it's length must be at least 1", getName())); } } return super.parseParam(str); diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestUserProvider.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestUserProvider.java index 2bba4f090d..694e8dc318 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestUserProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestUserProvider.java @@ -108,13 +108,6 @@ public void userNameEmpty() { userParam.parseParam(""); } - @Test - @TestException(exception = IllegalArgumentException.class) - public void userNameTooLong() { - UserProvider.UserParam userParam = new UserProvider.UserParam("username"); - userParam.parseParam("a123456789012345678901234567890x"); - } - @Test @TestException(exception = IllegalArgumentException.class) public void userNameInvalidStart() { @@ -135,12 +128,6 @@ public void userNameMinLength() { assertNotNull(userParam.parseParam("a")); } - @Test - public void userNameMaxLength() { - UserProvider.UserParam userParam = new UserProvider.UserParam("username"); - assertNotNull(userParam.parseParam("a123456789012345678901234567890")); - } - @Test public void userNameValidDollarSign() { UserProvider.UserParam userParam = new UserProvider.UserParam("username"); diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index bb3099d955..135c38f245 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -572,6 +572,9 @@ Release 2.0.3-alpha - Unreleased HDFS-4282. TestEditLog.testFuzzSequences FAILED in all pre-commit test (todd) + HDFS-4236. Remove artificial limit on username length introduced in + HDFS-4171. (tucu via suresh) + BREAKDOWN OF HDFS-3077 SUBTASKS HDFS-3077. Quorum-based protocol for reading and writing edit logs. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserParam.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserParam.java index ead8e54882..36e128feed 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserParam.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserParam.java @@ -38,10 +38,9 @@ private static String validateLength(String str) { MessageFormat.format("Parameter [{0}], cannot be NULL", NAME)); } int len = str.length(); - if (len < 1 || len > 31) { + if (len < 1) { throw new IllegalArgumentException(MessageFormat.format( - "Parameter [{0}], invalid value [{1}], it's length must be between 1 and 31", - NAME, str)); + "Parameter [{0}], it's length must be at least 1", NAME)); } return str; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/resources/TestParam.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/resources/TestParam.java index 0e06de319a..c228c1f298 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/resources/TestParam.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/resources/TestParam.java @@ -244,11 +244,6 @@ public void userNameEmpty() { assertNull(userParam.getValue()); } - @Test(expected = IllegalArgumentException.class) - public void userNameTooLong() { - new UserParam("a123456789012345678901234567890x"); - } - @Test(expected = IllegalArgumentException.class) public void userNameInvalidStart() { new UserParam("1x"); @@ -265,12 +260,6 @@ public void userNameMinLength() { assertNotNull(userParam.getValue()); } - @Test - public void userNameMaxLength() { - UserParam userParam = new UserParam("a123456789012345678901234567890"); - assertNotNull(userParam.getValue()); - } - @Test public void userNameValidDollarSign() { UserParam userParam = new UserParam("a$");