Esempio n. 1
0
        public void TestProcessError(string input)
        {
            var method = new PlainAuthMethod();

            string challenge;
            var    result = method.ProcessResponse(Transaction, input, out challenge);

            Assert.False(result);
            Assert.Null(challenge);
        }
Esempio n. 2
0
        public void TestProcessSuccess()
        {
            const string expectedUsername = "******";
            const string expectedPassword = "******";

            var method = new PlainAuthMethod();

            string username          = null;
            string password          = null;
            var    usernamePermanent = false;
            var    passwordPermanent = false;

            Transaction.SetPropertyStringObjectBoolean = (s, v, p) =>
            {
                switch (s)
                {
                case "Username":
                    username          = (string)v;
                    usernamePermanent = p;
                    break;

                case "Password":
                    password          = (string)v;
                    passwordPermanent = p;
                    break;

                default:
                    throw new InvalidOperationException("Invalid name.");
                }
            };

            var    token = string.Format("\0{0}\0{1}", expectedUsername, expectedPassword);
            string challenge;
            var    result = method.ProcessResponse(Transaction, token, out challenge);

            Assert.True(result);
            Assert.Null(challenge);
            Assert.Equal(expectedUsername, username);
            Assert.Equal(expectedPassword, password);
            Assert.True(usernamePermanent);
            Assert.True(passwordPermanent);
        }