Skip to content

HBASE-30042 Test AuthUtil.loginClient with existing Kerberos login#8002

Merged
junegunn merged 2 commits intoapache:masterfrom
jinhyukify:HBASE-30042
Mar 31, 2026
Merged

HBASE-30042 Test AuthUtil.loginClient with existing Kerberos login#8002
junegunn merged 2 commits intoapache:masterfrom
jinhyukify:HBASE-30042

Conversation

@jinhyukify
Copy link
Copy Markdown
Contributor


@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.

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.

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.

Thank you for your feedback.

I updated my test a bit.

AuthUtil.loginClient has the following branches:

1. No Kerberos credentials (not logged in)

I think this cannot be tested in MiniKdc environment. Even without an explicit login, AuthUtil.loginClient picks up the kinit principal from the ticket cache, which fails with KerberosName$NoMatchingRule because we don't have auth_to_local rules configured. So I just skipped.

2. Kerberos credentials exist (already logged in)

  • 2-a. Current login principal matches conf → return as-is (testAuthUtilLoginWithExistingLoginUser)
  • 2-b. Mismatch → re-login with the configured principal (testAuthUtilLoginWithDifferentExistingUser)

Both cases are now covered.

@junegunn junegunn merged commit f59bc9a into apache:master Mar 31, 2026
15 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants