Exemple #1
0
        public async Task BadSequenceNoMail()
        {
            var channel = new MockSmtpChannel();
            var builder = new MockMailBuilder();
            var command = new RecipientCommand(
                builder,
                channel,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") })
                );

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

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.BadSequence);
            Assert.Null(builder.PendingMail);
        }
Exemple #2
0
        public async Task RejectInvalidMailbox()
        {
            var channel = new MockSmtpChannel();
            var mail    = new SmtpMailMessage(new SmtpPath("*****@*****.**"));
            var builder = new MockMailBuilder {
                PendingMail = mail
            };
            var command = new RecipientCommand(
                builder,
                channel,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    new[] { new SmtpAcceptDomain("test.vaettir.net") })
                );

            command.Initialize("TO:<no-at>");
            await command.ExecuteAsync(CancellationToken.None);

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.InvalidArguments);
            Assert.Same(mail, builder.PendingMail);
        }
Exemple #3
0
        public async Task AcceptRelayDomain()
        {
            var channel = new MockSmtpChannel();
            var mail    = new SmtpMailMessage(new SmtpPath("*****@*****.**"));
            var builder = new MockMailBuilder {
                PendingMail = mail
            };
            var command = new RecipientCommand(
                builder,
                channel,
                TestHelpers.MakeSettings(
                    "test.vaettir.net",
                    relayDomains: new[] { new SmtpRelayDomain("test.vaettir.net", "elsewhere.vaettir.net") })
                );

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

            SmtpTestHelper.AssertResponse(channel, SmtpReplyCode.Okay);
            Assert.Same(mail, builder.PendingMail);
            Assert.Single(mail.Recipents);
            Assert.Equal("*****@*****.**", mail.Recipents[0]);
        }