示例#1
0
        public void Login() {
            LoginConfiguration config = new LoginConfiguration();
            config.Load("login-module-node");

            LoginContext context = new LoginContext(config);
            Assert.AreEqual(true, context.Login());
        }
示例#2
0
        public void LoginWithNoModule() {
            LoginConfiguration config = new LoginConfiguration();
            config.Load("with-namespace");

            LoginContext context = new LoginContext(config);
            Assert.AreEqual(false, context.Login());
        }
示例#3
0
        public void Logout() {
            LoginConfiguration config = new LoginConfiguration();
            config.Load("login-module-node");

            LoginContext context = new LoginContext(config);
            Assert.IsNotNull(context.Subject);

            context.Logout();
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationManager"/>
 /// class by using the given <see cref="LoginContext"/> and
 /// <see cref="ICacheProvider"/>.
 /// </summary>
 /// <param name="login_context">
 /// A <see cref="LoginContext"/> object that can be used to authenticate
 /// subjects.
 /// </param>
 /// <param name="cache">
 /// A <see cref="ICacheProvider"/> that can be used to store authenticated
 /// subjects.
 /// </param>
 public AuthenticationManager(LoginContext login_context,
                              ICacheProvider cache)
 {
     if (login_context == null || cache == null)
     {
         throw new ArgumentNullException(login_context == null
   ? "login_context"
   : "cache");
     }
     login_context_ = login_context;
     cache_         = cache;
 }
示例#5
0
    public void should_abort_when_authentication_fail() {
      Mock
        .Arrange(() => module_.ControlFlag)
        .Returns(LoginModuleControlFlag.Required);
      Mock
        .Arrange(
          () => module_.Login(Arg.IsAny<IAuthCallbackHandler>(), subject_))
        .Returns(AuthenticationInfos.Failed());
      Mock
        .Arrange(() => module_.Commit(Arg.IsAny<IAuthenticationInfo>()))
        .OccursNever();
      Mock
        .Arrange(() => module_.Abort(Arg.IsAny<IAuthenticationInfo>()))
        .MustBeCalled();

      var callback = new NopAuthCallbackHandler();
      var context = new LoginContext(new[] {module_});

      Assert.That(context.Login(subject_, callback), Is.False);
      Mock.Assert(module_);
    }
示例#6
0
 public HttpAuthenticationManager(LoginContext login_context,
                                  ICacheProvider cache) : base(login_context, cache)
 {
 }
示例#7
0
 public void NullLoginConfiguration() {
     LoginContext lc = new LoginContext((ILoginConfiguration) null);
 }
示例#8
0
 public void NullCallbackHandler() {
     LoginContext lc = new LoginContext((IAuthCallbackHandler)null);
 }
示例#9
0
 public void NullSubject()
 {
     LoginContext lc = new LoginContext((Subject)null);
 }
示例#10
0
    public void should_authenticate_a_valid_user() {
      var callback = new NopAuthCallbackHandler();
      var context = new LoginContext(new[] {module_});

      Assert.That(context.Login(subject_, callback), Is.True);
    }