/// <exception cref="System.IO.IOException"/> public object Run() { UserGroupInformation current = UserGroupInformation.GetCurrentUser(); NUnit.Framework.Assert.IsFalse(current.Equals(login)); Assert.Equal(current, fakeUser); Assert.Equal(0, current.GetGroupNames().Length); return(null); }
/// <exception cref="System.Exception"/> public virtual void TestEqualsWithRealUser() { UserGroupInformation realUgi1 = UserGroupInformation.CreateUserForTesting("RealUser" , GroupNames); UserGroupInformation proxyUgi1 = UserGroupInformation.CreateProxyUser(UserName, realUgi1 ); UserGroupInformation proxyUgi2 = new UserGroupInformation(proxyUgi1.GetSubject()); UserGroupInformation remoteUgi = UserGroupInformation.CreateRemoteUser(UserName); Assert.Equal(proxyUgi1, proxyUgi2); NUnit.Framework.Assert.IsFalse(remoteUgi.Equals(proxyUgi1)); }
/// <exception cref="System.Exception"/> public virtual void TestEquals() { UserGroupInformation uugi = UserGroupInformation.CreateUserForTesting(UserName, GroupNames ); Assert.Equal(uugi, uugi); // The subjects should be different, so this should fail UserGroupInformation ugi2 = UserGroupInformation.CreateUserForTesting(UserName, GroupNames ); NUnit.Framework.Assert.IsFalse(uugi.Equals(ugi2)); NUnit.Framework.Assert.IsFalse(uugi.GetHashCode() == ugi2.GetHashCode()); // two ugi that have the same subject need to be equal UserGroupInformation ugi3 = new UserGroupInformation(uugi.GetSubject()); Assert.Equal(uugi, ugi3); Assert.Equal(uugi.GetHashCode(), ugi3.GetHashCode()); }
/// <summary>Test login method</summary> /// <exception cref="System.Exception"/> public virtual void TestLogin() { conf.Set(CommonConfigurationKeys.HadoopUserGroupMetricsPercentilesIntervals, PercentilesInterval .ToString()); UserGroupInformation.SetConfiguration(conf); // login from unix UserGroupInformation ugi = UserGroupInformation.GetCurrentUser(); Assert.Equal(UserGroupInformation.GetCurrentUser(), UserGroupInformation .GetLoginUser()); Assert.True(ugi.GetGroupNames().Length >= 1); VerifyGroupMetrics(1); // ensure that doAs works correctly UserGroupInformation userGroupInfo = UserGroupInformation.CreateUserForTesting(UserName , GroupNames); UserGroupInformation curUGI = userGroupInfo.DoAs(new _PrivilegedExceptionAction_185 ()); // make sure in the scope of the doAs, the right user is current Assert.Equal(curUGI, userGroupInfo); // make sure it is not the same as the login user NUnit.Framework.Assert.IsFalse(curUGI.Equals(UserGroupInformation.GetLoginUser()) ); }