| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | using System.Collections.Generic;using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;namespace Renci.SshNet.Tests.Classes{    [TestClass]    public class ClientAuthenticationTest_Success_MultiList_SameAllowedAuthenticationsAfterPartialSuccess : ClientAuthenticationTestBase    {        protected override void SetupMocks()        {            var seq = new MockSequence();            SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));            SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));            SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));            ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())                .Returns(NoneAuthenticationMethodMock.Object);            NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))                .Returns(AuthenticationResult.Failure);            ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)                            .Returns(new List<IAuthenticationMethod>                {                    PasswordAuthenticationMethodMock.Object,                    PublicKeyAuthenticationMethodMock.Object,                    KeyboardInteractiveAuthenticationMethodMock.Object,                });            NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password", "publickey" });            PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");            PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");            KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");            PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))                .Returns(AuthenticationResult.PartialSuccess);            PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)                .Returns(new[] {"password", "publickey"});            PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");            PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");            KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");            PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.PartialSuccess);            PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)                .Returns(new[] { "password", "publickey", "keyboard-interactive" });            PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");            PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");            KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");            KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))                .Returns(AuthenticationResult.Success);            SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));            SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));            SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));        }        protected override void Act()        {            ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);        }    }}
 |