Ejemplo n.º 1
0
        public void Login() {
            LoginConfiguration config = new LoginConfiguration();
            config.Load("login-module-node");

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

            LoginContext context = new LoginContext(config);
            Assert.AreEqual(false, context.Login());
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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_);
    }
Ejemplo n.º 6
0
 public HttpAuthenticationManager(LoginContext login_context,
                                  ICacheProvider cache) : base(login_context, cache)
 {
 }
Ejemplo n.º 7
0
 public void NullLoginConfiguration() {
     LoginContext lc = new LoginContext((ILoginConfiguration) null);
 }
Ejemplo n.º 8
0
 public void NullCallbackHandler() {
     LoginContext lc = new LoginContext((IAuthCallbackHandler)null);
 }
Ejemplo n.º 9
0
 public void NullSubject()
 {
     LoginContext lc = new LoginContext((Subject)null);
 }
Ejemplo n.º 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);
    }