Exemplo n.º 1
0
        /// <exception cref="System.Exception"/>
        private void TestValidDelegationTokenHeader()
        {
            HttpServletRequest  request  = Org.Mockito.Mockito.Mock <HttpServletRequest>();
            HttpServletResponse response = Org.Mockito.Mockito.Mock <HttpServletResponse>();

            Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> dToken = (Org.Apache.Hadoop.Security.Token.Token
                                                                                         <DelegationTokenIdentifier>)handler.GetTokenManager().CreateToken(UserGroupInformation
                                                                                                                                                           .GetCurrentUser(), "user");
            Org.Mockito.Mockito.When(request.GetHeader(Org.Mockito.Mockito.Eq(DelegationTokenAuthenticator
                                                                              .DelegationTokenHeader))).ThenReturn(dToken.EncodeToUrlString());
            AuthenticationToken token = handler.Authenticate(request, response);

            Assert.Equal(UserGroupInformation.GetCurrentUser().GetShortUserName
                             (), token.GetUserName());
            Assert.Equal(0, token.GetExpires());
            Assert.Equal(handler.GetType(), token.GetType());
            Assert.True(token.IsExpired());
        }