Exemple #1
0
        public virtual void TestUGILoginFromKeytab()
        {
            UserGroupInformation.SetShouldRenewImmediatelyForTests(true);
            string   principal = "foo";
            FilePath keytab    = new FilePath(workDir, "foo.keytab");

            kdc.CreatePrincipal(keytab, principal);
            UserGroupInformation.LoginUserFromKeytab(principal, keytab.GetPath());
            UserGroupInformation ugi = UserGroupInformation.GetLoginUser();

            Assert.True("UGI should be configured to login from keytab", ugi
                        .IsFromKeytab());
            // Verify relogin from keytab.
            User user       = ugi.GetSubject().GetPrincipals <User>().GetEnumerator().Next();
            long firstLogin = user.GetLastLogin();

            ugi.ReloginFromKeytab();
            long secondLogin = user.GetLastLogin();

            Assert.True("User should have been able to relogin from keytab"
                        , secondLogin > firstLogin);
        }