@@ -116,14 +116,14 @@ public void testUGILoginFromKeytab() throws Exception {
116
116
117
117
UserGroupInformation .loginUserFromKeytab (principal , keytab .getPath ());
118
118
UserGroupInformation ugi = UserGroupInformation .getLoginUser ();
119
- assertTrue (
120
- ugi . isFromKeytab (), "UGI should be configured to login from keytab" );
119
+ assertTrue (ugi . isFromKeytab (),
120
+ "UGI should be configured to login from keytab" );
121
121
122
122
User user = getUser (ugi .getSubject ());
123
123
assertNotNull (user .getLogin ());
124
124
125
- assertTrue (
126
- user . getLastLogin () > beforeLogin , "User login time is less than before login time, "
125
+ assertTrue (user . getLastLogin () > beforeLogin ,
126
+ "User login time is less than before login time, "
127
127
+ "beforeLoginTime:" + beforeLogin + " userLoginTime:" + user .getLastLogin ());
128
128
}
129
129
@@ -139,8 +139,7 @@ public void testUGIReLoginFromKeytab() throws Exception {
139
139
140
140
UserGroupInformation .loginUserFromKeytab (principal , keytab .getPath ());
141
141
UserGroupInformation ugi = UserGroupInformation .getLoginUser ();
142
- assertTrue (
143
- ugi .isFromKeytab (), "UGI should be configured to login from keytab" );
142
+ assertTrue (ugi .isFromKeytab (), "UGI should be configured to login from keytab" );
144
143
145
144
// Verify relogin from keytab.
146
145
User user = getUser (ugi .getSubject ());
@@ -154,8 +153,8 @@ public void testUGIReLoginFromKeytab() throws Exception {
154
153
ugi .reloginFromKeytab ();
155
154
final long secondLogin = user .getLastLogin ();
156
155
final LoginContext login2 = user .getLogin ();
157
- assertTrue (
158
- secondLogin > firstLogin , "User should have been able to relogin from keytab" );
156
+ assertTrue (secondLogin > firstLogin ,
157
+ "User should have been able to relogin from keytab" );
159
158
assertNotNull (login2 );
160
159
assertNotSame (login1 , login2 );
161
160
}
@@ -174,8 +173,7 @@ public void testUGIForceReLoginFromKeytab() throws Exception {
174
173
175
174
UserGroupInformation .loginUserFromKeytab (principal , keytab .getPath ());
176
175
UserGroupInformation ugi = UserGroupInformation .getLoginUser ();
177
- assertTrue (
178
- ugi .isFromKeytab (), "UGI should be configured to login from keytab" );
176
+ assertTrue (ugi .isFromKeytab (), "UGI should be configured to login from keytab" );
179
177
180
178
// Verify relogin from keytab.
181
179
User user = getUser (ugi .getSubject ());
@@ -190,8 +188,8 @@ public void testUGIForceReLoginFromKeytab() throws Exception {
190
188
ugi .forceReloginFromKeytab ();
191
189
final long secondLogin = user .getLastLogin ();
192
190
final LoginContext login2 = user .getLogin ();
193
- assertTrue (
194
- secondLogin > firstLogin , "User should have been able to relogin from keytab" );
191
+ assertTrue (secondLogin > firstLogin ,
192
+ "User should have been able to relogin from keytab" );
195
193
assertNotNull (login2 );
196
194
assertNotSame (login1 , login2 );
197
195
}
@@ -287,11 +285,9 @@ public void testUGIRefreshFromKeytab() throws Exception {
287
285
assertEquals (UserGroupInformation .AuthenticationMethod .KERBEROS ,
288
286
ugi .getAuthenticationMethod ());
289
287
assertTrue (ugi .isFromKeytab ());
290
- assertTrue (
291
- UserGroupInformation .isKerberosKeyTabLoginRenewalEnabled ());
292
- assertTrue (
293
- UserGroupInformation .getKerberosLoginRenewalExecutor ()
294
- .isPresent ());
288
+ assertTrue (UserGroupInformation .isKerberosKeyTabLoginRenewalEnabled ());
289
+ assertTrue (UserGroupInformation .getKerberosLoginRenewalExecutor ()
290
+ .isPresent ());
295
291
}
296
292
297
293
@ Test
@@ -312,13 +308,11 @@ public void testUGIRefreshFromKeytabDisabled() throws Exception {
312
308
313
309
UserGroupInformation ugi = UserGroupInformation .getLoginUser ();
314
310
assertEquals (UserGroupInformation .AuthenticationMethod .KERBEROS ,
315
- ugi .getAuthenticationMethod ());
311
+ ugi .getAuthenticationMethod ());
316
312
assertTrue (ugi .isFromKeytab ());
317
- assertFalse (
318
- UserGroupInformation .isKerberosKeyTabLoginRenewalEnabled ());
319
- assertFalse (
320
- UserGroupInformation .getKerberosLoginRenewalExecutor ()
321
- .isPresent ());
313
+ assertFalse (UserGroupInformation .isKerberosKeyTabLoginRenewalEnabled ());
314
+ assertFalse (UserGroupInformation .getKerberosLoginRenewalExecutor ()
315
+ .isPresent ());
322
316
}
323
317
324
318
private static KerberosTicket getTicket (UserGroupInformation ugi ) {
@@ -331,10 +325,8 @@ private static KerberosTicket getTicket(UserGroupInformation ugi) {
331
325
// the expected principal.
332
326
private static KerberosTicket checkTicketAndKeytab (UserGroupInformation ugi ,
333
327
KerberosPrincipal principal , boolean expectIsKeytab ) {
334
- assertEquals (
335
- principal .getName (), ugi .getUserName (), "wrong principal" );
336
- assertEquals (
337
- expectIsKeytab , ugi .isFromKeytab (), "is not keytab" );
328
+ assertEquals (principal .getName (), ugi .getUserName (), "wrong principal" );
329
+ assertEquals (expectIsKeytab , ugi .isFromKeytab (), "is not keytab" );
338
330
KerberosTicket ticket = getTicket (ugi );
339
331
assertNotNull (ticket , "no ticket" );
340
332
assertEquals (principal , ticket .getClient (), "wrong principal" );
@@ -438,9 +430,9 @@ public Void run() throws IOException {
438
430
// original login user not affected.
439
431
extLoginUser .reloginFromKeytab ();
440
432
assertSame (extLoginUserTicket ,
441
- checkTicketAndKeytab (extLoginUser , principal2 , false ));
433
+ checkTicketAndKeytab (extLoginUser , principal2 , false ));
442
434
assertSame (originalLoginUserTicket ,
443
- checkTicketAndKeytab (originalLoginUser , principal1 , true ));
435
+ checkTicketAndKeytab (originalLoginUser , principal1 , true ));
444
436
445
437
// verify original login user gets a new ticket, new login user
446
438
// not affected.
@@ -540,8 +532,7 @@ public Void call() throws Exception {
540
532
});
541
533
// wait for the thread to block on the barrier in the logout of the
542
534
// relogin.
543
- assertTrue (
544
- latch .await (2 , TimeUnit .SECONDS ), "first relogin didn't block" );
535
+ assertTrue (latch .await (2 , TimeUnit .SECONDS ), "first relogin didn't block" );
545
536
546
537
// although the logout removed the keytab instance, verify the ugi
547
538
// knows from its login params that it is supposed to be from a keytab.
0 commit comments