fengnanli commented on a change in pull request #2110:
URL: https://github.com/apache/hadoop/pull/2110#discussion_r447994083
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/security/TestRouterSecurityManager.java
##########
@@ -124,6 +126,71 @@ public void testDelegationTokens() throws IOException {
securityManager.renewDelegationToken(token);
}
+ @Test
+ public void testDelgationTokenTopOwners() throws Exception {
+ List<NameValuePair> topOwners;
+
+ UserGroupInformation user = UserGroupInformation
+ .createUserForTesting("abc", new String[]{"router_group"});
+ UserGroupInformation.setLoginUser(user);
+ Token dt = securityManager.getDelegationToken(new Text("abc"));
+ topOwners = securityManager.getSecretManager().getTopTokenRealOwners(2);
+ assertEquals(1, topOwners.size());
+ assertEquals("abc", topOwners.get(0).getName());
+ assertEquals(1, topOwners.get(0).getValue());
+
+ securityManager.renewDelegationToken(dt);
+ topOwners = securityManager.getSecretManager().getTopTokenRealOwners(2);
+ assertEquals(1, topOwners.size());
+ assertEquals("abc", topOwners.get(0).getName());
+ assertEquals(1, topOwners.get(0).getValue());
+
+ securityManager.cancelDelegationToken(dt);
+ topOwners = securityManager.getSecretManager().getTopTokenRealOwners(2);
+ assertEquals(0, topOwners.size());
+
+
+ // Use proxy user - the code should use the proxy user as the real owner
+ UserGroupInformation routerUser =
+ UserGroupInformation.createRemoteUser("router");
+ UserGroupInformation proxyUser = UserGroupInformation
+ .createProxyUserForTesting("abc",
+ routerUser,
+ new String[]{"router_group"});
+ UserGroupInformation.setLoginUser(proxyUser);
+
+ Token proxyDT = securityManager.getDelegationToken(new Text("router"));
+ topOwners = securityManager.getSecretManager().getTopTokenRealOwners(2);
+ assertEquals(1, topOwners.size());
+ assertEquals("router", topOwners.get(0).getName());
+ assertEquals(1, topOwners.get(0).getValue());
+
+ // router to renew tokens
+ UserGroupInformation.setLoginUser(routerUser);
+ securityManager.renewDelegationToken(proxyDT);
+ topOwners = securityManager.getSecretManager().getTopTokenRealOwners(2);
+ assertEquals(1, topOwners.size());
+ assertEquals("router", topOwners.get(0).getName());
+ assertEquals(1, topOwners.get(0).getValue());
+
+ securityManager.cancelDelegationToken(proxyDT);
+ topOwners = securityManager.getSecretManager().getTopTokenRealOwners(2);
+ assertEquals(0, topOwners.size());
+
Review comment:
will remove
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]