Exemplo n.º 1
0
        /// <exception cref="System.Exception"/>
        private void _testUserName(bool anonymous)
        {
            PseudoAuthenticationHandler handler = new PseudoAuthenticationHandler();

            try
            {
                Properties props = new Properties();
                props.SetProperty(PseudoAuthenticationHandler.AnonymousAllowed, bool.ToString(anonymous
                                                                                              ));
                handler.Init(props);
                HttpServletRequest  request  = Org.Mockito.Mockito.Mock <HttpServletRequest>();
                HttpServletResponse response = Org.Mockito.Mockito.Mock <HttpServletResponse>();
                Org.Mockito.Mockito.When(request.GetQueryString()).ThenReturn(PseudoAuthenticator
                                                                              .UserName + "=" + "user");
                AuthenticationToken token = handler.Authenticate(request, response);
                NUnit.Framework.Assert.IsNotNull(token);
                Assert.Equal("user", token.GetUserName());
                Assert.Equal("user", token.GetName());
                Assert.Equal(PseudoAuthenticationHandler.Type, token.GetType()
                             );
            }
            finally
            {
                handler.Destroy();
            }
        }
Exemplo n.º 2
0
        public virtual void TestInit()
        {
            PseudoAuthenticationHandler handler = new PseudoAuthenticationHandler();

            try
            {
                Properties props = new Properties();
                props.SetProperty(PseudoAuthenticationHandler.AnonymousAllowed, "false");
                handler.Init(props);
                Assert.Equal(false, handler.GetAcceptAnonymous());
            }
            finally
            {
                handler.Destroy();
            }
        }
Exemplo n.º 3
0
        public virtual void TestAnonymousOff()
        {
            PseudoAuthenticationHandler handler = new PseudoAuthenticationHandler();

            try
            {
                Properties props = new Properties();
                props.SetProperty(PseudoAuthenticationHandler.AnonymousAllowed, "false");
                handler.Init(props);
                HttpServletRequest  request  = Org.Mockito.Mockito.Mock <HttpServletRequest>();
                HttpServletResponse response = Org.Mockito.Mockito.Mock <HttpServletResponse>();
                AuthenticationToken token    = handler.Authenticate(request, response);
                NUnit.Framework.Assert.IsNull(token);
            }
            finally
            {
                handler.Destroy();
            }
        }
Exemplo n.º 4
0
        public virtual void TestAnonymousOn()
        {
            PseudoAuthenticationHandler handler = new PseudoAuthenticationHandler();

            try
            {
                Properties props = new Properties();
                props.SetProperty(PseudoAuthenticationHandler.AnonymousAllowed, "true");
                handler.Init(props);
                HttpServletRequest  request  = Org.Mockito.Mockito.Mock <HttpServletRequest>();
                HttpServletResponse response = Org.Mockito.Mockito.Mock <HttpServletResponse>();
                AuthenticationToken token    = handler.Authenticate(request, response);
                Assert.Equal(AuthenticationToken.Anonymous, token);
            }
            finally
            {
                handler.Destroy();
            }
        }