コード例 #1
0
        public async Task PostLoginWithLdapSslErrorShouldNotLogInRemoteUser()
        {
            var user = new ApplicationUser {
                Id = Guid.NewGuid(), UserName = "******"
            };

            _ldapService.When(ls => ls.Authenticate("user", "pass"))
            .Do(ci => throw sama.SslException.CreateException(true, "asdf"));

            var result = await _controller.Login(new LoginViewModel { Username = "******", Password = "******", IsLocal = false });

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            await _signInManager.DidNotReceive().SignInAsync(Arg.Any <ApplicationUser>(), Arg.Any <bool>(), Arg.Any <string>());

            Assert.AreEqual("Could not establish a secure LDAP connection", _controller.ModelState[""].Errors[0].ErrorMessage);
            Assert.AreEqual("Details: asdf", _controller.ModelState[""].Errors[1].ErrorMessage);
        }