Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ public void testLoginWithUserKeytabAndPrincipal() throws Exception {
}

@Test
public void testAuthUtilLogin() throws Exception {
public void testAuthUtilLoginWithExistingLoginUser() throws Exception {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update this test to only cover the case where a Kerberos user is already logged in.

String clientKeytab = getClientKeytabForTesting();
String clientPrincipal = getClientPrincipalForTesting();
Configuration conf = getSecuredConfiguration();
conf.set(AuthUtil.HBASE_CLIENT_KEYTAB_FILE, clientKeytab);
conf.set(AuthUtil.HBASE_CLIENT_KERBEROS_PRINCIPAL, clientPrincipal);
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab(clientPrincipal, clientKeytab);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this issue has been bothering me for a while, and I can confirm this makes the test pass.

However, if we do this, we no longer test if AuthUtil.loginClient actually performs the login for the user. I think we could create a separate user principal, log in as that user, and then test whether ⁠AuthUtil.loginClient correctly logs in the original user and returns that user.


User user = AuthUtil.loginClient(conf);
assertTrue(user.isLoginFromKeytab());
Expand Down