Beispiel #1
0
        public async Task InvalidDomainRejected()
        {
            var channel = new MockSmtpChannel();
            var builder = new MockMailBuilder();
            var user    = new MockUserStore(false);
            var command = new MailCommand(
                channel,
                builder,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") }),
                user);

            command.Initialize("FROM:!!!!");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.InvalidArguments);
            Assert.Null(builder.PendingMail);
        }
Beispiel #2
0
        public async Task VailToInternal()
        {
            var channel = new MockSmtpChannel();
            var builder = new MockMailBuilder();
            var user    = new MockUserStore(true);
            var command = new MailCommand(
                channel,
                builder,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") }),
                user);

            command.Initialize("FROM:<>");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.Okay);
            Assert.NotNull(builder.PendingMail);
            Assert.Equal("", builder.PendingMail.FromPath.Mailbox);
        }
Beispiel #3
0
        public async Task FromWrongMailboxRejected()
        {
            var channel = new MockSmtpChannel {
                AuthenticatedUser = new UserData("*****@*****.**")
            };
            var builder = new MockMailBuilder();
            var user    = new MockUserStore(false);
            var command = new MailCommand(
                channel,
                builder,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") }),
                user);

            command.Initialize("FROM:<*****@*****.**>");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.MailboxUnavailable);
            Assert.Null(builder.PendingMail);
        }
Beispiel #4
0
        public async Task VailMailWithUnknownRejected()
        {
            var channel = new MockSmtpChannel {
                AuthenticatedUser = new UserData("*****@*****.**")
            };
            var builder = new MockMailBuilder();
            var user    = new MockUserStore(true);
            var command = new MailCommand(
                channel,
                builder,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") }),
                user);

            command.Initialize("FROM:<*****@*****.**> EVIL=FAIL");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.ParameterNotImplemented);
            Assert.Null(builder.PendingMail);
        }
Beispiel #5
0
        public async Task VailMailAcceptedWithReturnPathRejected()
        {
            var channel = new MockSmtpChannel {
                AuthenticatedUser = new UserData("*****@*****.**")
            };
            var builder = new MockMailBuilder();
            var user    = new MockUserStore(true);
            var command = new MailCommand(
                channel,
                builder,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") }),
                user);

            command.Initialize("FROM:<@other:[email protected]>");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.InvalidArguments);
            Assert.Null(builder.PendingMail);
        }
Beispiel #6
0
        public async Task VailMailWithParametersAccepted()
        {
            var channel = new MockSmtpChannel {
                AuthenticatedUser = new UserData("*****@*****.**")
            };
            var builder = new MockMailBuilder();
            var user    = new MockUserStore(true);
            var command = new MailCommand(
                channel,
                builder,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") }),
                user);

            command.Initialize("FROM:<*****@*****.**> BODY=7BIT");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.Okay);
            Assert.NotNull(builder.PendingMail);
            Assert.Equal("*****@*****.**", builder.PendingMail.FromPath.Mailbox);
        }
Beispiel #7
0
        public async Task MailInProgressRejected()
        {
            var channel = new MockSmtpChannel();
            var message = new SmtpMailMessage(new SmtpPath(null));
            var builder = new MockMailBuilder
            {
                PendingMail = message
            };
            var user    = new MockUserStore(false);
            var command = new MailCommand(
                channel,
                builder,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") }),
                user);

            command.Initialize("FROM:<*****@*****.**>");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.BadSequence);
            Assert.Same(message, builder.PendingMail);
        }