|
@@ -17,6 +17,7 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.hdfs.nfs.nfs3;
|
|
|
|
|
|
+import static org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod.KERBEROS;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
import static org.junit.Assert.assertTrue;
|
|
@@ -52,6 +53,29 @@ public class TestDFSClientCache {
|
|
|
assertEquals(MAX_CACHE_SIZE - 1, cache.clientCache.size());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testGetUserGroupInformationSecure() throws IOException {
|
|
|
+ String userName = "user1";
|
|
|
+ String currentUser = "test-user";
|
|
|
+
|
|
|
+
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ UserGroupInformation currentUserUgi
|
|
|
+ = UserGroupInformation.createRemoteUser(currentUser);
|
|
|
+ currentUserUgi.setAuthenticationMethod(KERBEROS);
|
|
|
+ UserGroupInformation.setLoginUser(currentUserUgi);
|
|
|
+
|
|
|
+ DFSClientCache cache = new DFSClientCache(conf);
|
|
|
+ UserGroupInformation ugiResult
|
|
|
+ = cache.getUserGroupInformation(userName, currentUserUgi);
|
|
|
+
|
|
|
+ assertThat(ugiResult.getUserName(), is(userName));
|
|
|
+ assertThat(ugiResult.getRealUser(), is(currentUserUgi));
|
|
|
+ assertThat(
|
|
|
+ ugiResult.getAuthenticationMethod(),
|
|
|
+ is(UserGroupInformation.AuthenticationMethod.PROXY));
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testGetUserGroupInformation() throws IOException {
|
|
|
String userName = "user1";
|
|
@@ -59,8 +83,6 @@ public class TestDFSClientCache {
|
|
|
|
|
|
UserGroupInformation currentUserUgi = UserGroupInformation
|
|
|
.createUserForTesting(currentUser, new String[0]);
|
|
|
- currentUserUgi.setAuthenticationMethod(
|
|
|
- UserGroupInformation.AuthenticationMethod.KERBEROS);
|
|
|
Configuration conf = new Configuration();
|
|
|
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "hdfs://localhost");
|
|
|
DFSClientCache cache = new DFSClientCache(conf);
|