public void Authenticate_Returns_ClientFinalMessage()
        {
            var mockedService = new Mock <IIOService>();

            mockedService.Setup(x => x.Execute(It.IsAny <SaslStart>(), It.IsAny <IConnection>()))
            .Returns(new OperationResult <string>()
            {
                Status  = ResponseStatus.AuthenticationContinue,
                Message = "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096"
            });


            mockedService.Setup(x => x.Execute(It.IsAny <SaslStep>(), It.IsAny <IConnection>()))
            .Returns(new OperationResult <string>()
            {
                Status  = ResponseStatus.AuthenticationContinue,
                Message = "v=rmF9pqV8S7suAoZWja4dJRkFsKQ="
            });

            var mockedConnection = new Mock <IConnection>();
            var authenticator    = new ScramShaMechanism(new DefaultTranscoder(), MechanismType.ScramSha1);

            authenticator.ClientNonce = "fyko+d2lbbFgONRv9qkxdawL";
            authenticator.Authenticate(mockedConnection.Object, "user", "pencil");

            var expected = "c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts=";

            Assert.AreEqual(expected, authenticator.ClientFinalMessage);
        }
        public void When_InValid_Credentials_Provided_Authenticate_Returns_False()
        {
            var authenticator = new ScramShaMechanism(_ioService, new DefaultTranscoder(), MechanismType.ScramSha1);
            _ioService.SaslMechanism = authenticator;

            foreach (var connection in _ioService.ConnectionPool.Connections)
            {
                var isAuthenticated = authenticator.Authenticate(connection, "authenticated", "secret2");
                Assert.IsFalse(isAuthenticated);
            }
        }
        public void When_InValid_Credentials_Provided_Authenticate_Returns_False()
        {
            var authenticator = new ScramShaMechanism(new DefaultTranscoder(), MechanismType.ScramSha1);

            _ioService.SaslMechanism = authenticator;

            foreach (var connection in _ioService.ConnectionPool.Connections)
            {
                var isAuthenticated = authenticator.Authenticate(connection, "authenticated", "secret2");
                Assert.IsFalse(isAuthenticated);
            }
        }
        public void Authenticate_Returns_ClientFinalMessage()
        {
            var mockedService = new Mock<IIOService>();
            mockedService.Setup(x => x.Execute(It.IsAny<SaslStart>(), It.IsAny<IConnection>()))
                .Returns(new OperationResult<string>()
                {
                    Status = ResponseStatus.AuthenticationContinue,
                    Message = "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096"
                });


            mockedService.Setup(x => x.Execute(It.IsAny<SaslStep>(), It.IsAny<IConnection>()))
                .Returns(new OperationResult<string>()
                {
                    Status = ResponseStatus.AuthenticationContinue,
                    Message = "v=rmF9pqV8S7suAoZWja4dJRkFsKQ="
                });

            var mockedConnection = new Mock<IConnection>();
            var authenticator = new ScramShaMechanism(mockedService.Object, new DefaultTranscoder(), MechanismType.ScramSha1);
            authenticator.ClientNonce = "fyko+d2lbbFgONRv9qkxdawL";
            authenticator.Authenticate(mockedConnection.Object, "user", "pencil");

            var expected = "c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts=";
            Assert.AreEqual(expected, authenticator.ClientFinalMessage);
        }