diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index b9d2ba1b7c6..b67ad27c7f3 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -456,6 +456,9 @@ Trunk (Unreleased) HADOOP-9372. Fix bad timeout annotations on tests. (Arpit Agarwal via suresh) + HADOOP-9376. TestProxyUserFromEnv fails on a Windows domain joined machine. + (Ivan Mitic via suresh) + Release 2.0.4-beta - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestProxyUserFromEnv.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestProxyUserFromEnv.java index b83f91b3065..65756fcdd39 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestProxyUserFromEnv.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestProxyUserFromEnv.java @@ -42,6 +42,15 @@ public class TestProxyUserFromEnv { BufferedReader br = new BufferedReader (new InputStreamReader(pp.getInputStream())); String realUser = br.readLine().trim(); + + // On Windows domain joined machine, whoami returns the username + // in the DOMAIN\\username format, so we trim the domain part before + // the comparison. We don't have to special case for Windows + // given that Unix systems do not allow slashes in usernames. + int backslashIndex = realUser.indexOf('\\'); + if (backslashIndex != -1) { + realUser = realUser.substring(backslashIndex + 1); + } assertEquals(realUser, realUgi.getUserName()); } }