Exemple #1
0
        public void CRAM_MD5による認証_失敗()
        {
            //setUp
            const bool usePlain = false;
            const bool useLogin = false;
            const bool useCramMd5 = true;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);

            var str = sut.Job("AUTH CRAM-MD5");

            var hash = Md5.Hash("user2", Base64.Decode(str.Substring(4)));
            var expected = (String)null;

            //exercise
            var actual = sut.Job(Base64.Encode(string.Format("user1 {0}", hash)));

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #2
0
        public void LOGIN_初期パラメータ付_による認証_成功()
        {
            //setUp
            const bool usePlain = false;
            const bool useLogin = true;
            const bool useCramMd5 = false;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);

            var str = String.Format("AUTH login {0}", Base64.Encode("user1"));
            Assert.That(sut.Job(str), Is.EqualTo("334 UGFzc3dvcmQ6"));
            Assert.That(sut.Job(Base64.Encode("user1")), Is.EqualTo("235 Authentication successful."));

            var expected = true;

            //exercise
            var actual = sut.IsFinish;

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #3
0
        public void CRAM_MD5による認証_成功()
        {
            //setUp
            const bool usePlain = false;
            const bool useLogin = false;
            const bool useCramMd5 = true;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);

            var str = sut.Job("AUTH CRAM-MD5");

            var hash = Md5.Hash("user1", Base64.Decode(str.Substring(4)));
            Assert.That(sut.Job(Base64.Encode(string.Format("user1 {0}", hash))),Is.EqualTo("235 Authentication successful."));
            var expected = true;

            //exercise
            var actual = sut.IsFinish;

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #4
0
        public void LOGINによる認証_失敗()
        {
            //setUp
            const bool usePlain = false;
            const bool useLogin = true;
            const bool useCramMd5 = false;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);

            Assert.That(sut.Job("AUTH LOGIN"), Is.EqualTo("334 VXNlcm5hbWU6"));
            Assert.That(sut.Job(Base64.Encode("user1")), Is.EqualTo("334 UGFzc3dvcmQ6"));

            String expected = null;
            //exercise
            var actual = sut.Job(Base64.Encode("xxx"));

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #5
0
        public void 無効なAUTHコマンド2()
        {
            //setUp
            const bool usePlain = false; //無効になっている
            const bool useLogin = true;
            const bool useCramMd5 = true;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);

            var expected = "500 command not understood: AUTH PLAIN\r\n";
            //exercise
            var actual = sut.Job("AUTH PLAIN");//本来は、正しいコマンドだが

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #6
0
        public void 無効なAUTHコマンド()
        {
            //setUp
            const bool usePlain = true;
            const bool useLogin = true;
            const bool useCramMd5 = true;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);

            var expected = "504 Unrecognized authentication type.";

            //exercise
            var actual = sut.Job("AUTH XXXX");

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #7
0
        public void PLAINによる認証_成功()
        {
            //setUp
            const bool usePlain = true;
            const bool useLogin = false;
            const bool useCramMd5 = false;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);
            Assert.That(sut.Job("AUTH PLAIN"), Is.EqualTo("334 "));
            Assert.That(sut.Job(Base64.Encode("user1\0user1\0user1")), Is.EqualTo("235 Authentication successful."));
            var expected = true;

            //exercise
            var actual = sut.IsFinish;

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #8
0
        public void PLAINによる認証_失敗()
        {
            //setUp
            const bool usePlain = true;
            const bool useLogin = false;
            const bool useCramMd5 = false;
            var sut = new SmtpAuth(_smtpAuthUserList, usePlain, useLogin, useCramMd5);
            Assert.That(sut.Job("AUTH PLAIN"), Is.EqualTo("334 "));
            String expected = null;

            //exercise
            var actual = sut.Job(Base64.Encode("user1\0user1\0user2"));

            //verify
            Assert.That(actual, Is.EqualTo(expected));
        }