Exemplo n.º 1
0
        public virtual void TestSerialization()
        {
            TestDelegationToken.TestDelegationTokenIdentifier origToken = new TestDelegationToken.TestDelegationTokenIdentifier
                                                                              (new Text("alice"), new Text("bob"), new Text("colin"));
            TestDelegationToken.TestDelegationTokenIdentifier newToken = new TestDelegationToken.TestDelegationTokenIdentifier
                                                                             ();
            origToken.SetIssueDate(123);
            origToken.SetMasterKeyId(321);
            origToken.SetMaxDate(314);
            origToken.SetSequenceNumber(12345);
            // clone origToken into newToken
            DataInputBuffer  inBuf  = new DataInputBuffer();
            DataOutputBuffer outBuf = new DataOutputBuffer();

            origToken.Write(outBuf);
            inBuf.Reset(outBuf.GetData(), 0, outBuf.GetLength());
            newToken.ReadFields(inBuf);
            // now test the fields
            Assert.Equal("alice", newToken.GetUser().GetUserName());
            Assert.Equal(new Text("bob"), newToken.GetRenewer());
            Assert.Equal("colin", newToken.GetUser().GetRealUser().GetUserName
                             ());
            Assert.Equal(123, newToken.GetIssueDate());
            Assert.Equal(321, newToken.GetMasterKeyId());
            Assert.Equal(314, newToken.GetMaxDate());
            Assert.Equal(12345, newToken.GetSequenceNumber());
            Assert.Equal(origToken, newToken);
        }
Exemplo n.º 2
0
        public virtual void TestGetUserNullOwner()
        {
            TestDelegationToken.TestDelegationTokenIdentifier ident = new TestDelegationToken.TestDelegationTokenIdentifier
                                                                          (null, null, null);
            UserGroupInformation ugi = ident.GetUser();

            NUnit.Framework.Assert.IsNull(ugi);
        }
Exemplo n.º 3
0
        public virtual void TestGetUserWithOwner()
        {
            TestDelegationToken.TestDelegationTokenIdentifier ident = new TestDelegationToken.TestDelegationTokenIdentifier
                                                                          (new Text("owner"), null, null);
            UserGroupInformation ugi = ident.GetUser();

            NUnit.Framework.Assert.IsNull(ugi.GetRealUser());
            Assert.Equal("owner", ugi.GetUserName());
            Assert.Equal(UserGroupInformation.AuthenticationMethod.Token,
                         ugi.GetAuthenticationMethod());
        }