private void verifyCaching(DefaultUGIProvider provider, ImpersonationRequest aliceImpRequest, ImpersonationRequest bobImpRequest, UGIWithPrincipal aliceUGIWithPrincipal, UGIWithPrincipal bobUGIWithPrincipal) throws IOException { // Fetch the bob UGI again, it should still return the valid one Assert.assertSame(bobUGIWithPrincipal, provider.getConfiguredUGI(bobImpRequest)); // Invalid the cache, getting of Alice UGI should pass, while getting of Bob should fails provider.invalidCache(); Assert.assertNotSame(aliceUGIWithPrincipal, provider.getConfiguredUGI(aliceImpRequest)); try { provider.getConfiguredUGI(bobImpRequest); Assert.fail("Expected IOException when getting UGI for " + bobImpRequest); } catch (IOException e) { // Expected } }
UGIWithPrincipal eveUGIWithPrincipal = provider.getConfiguredUGI(bobImpRequest); Assert.assertEquals(UserGroupInformation.AuthenticationMethod.KERBEROS, eveUGIWithPrincipal.getUGI().getAuthenticationMethod());