Ejemplo n.º 1
0
        public void ConfirmFileAddedToCorrectAccountFolder()
        {
            TestSetup testSetup  = SingletonProvider <TestSetup> .Instance;
            Account   oAccount   = testSetup.AddAccount(_domain, "*****@*****.**", "test");
            var       oSimulator = new ImapClientSimulator();

            // Confirm that the public folder is empty before we start our test.
            string publicDir = GetPublicDirectory();

            CustomAsserts.AssertFilesInDirectory(publicDir, 0);

            // Add a message to the inbox.
            oSimulator.Connect();
            oSimulator.LogonWithLiteral("*****@*****.**", "test");
            oSimulator.SendSingleCommandWithLiteral("A01 APPEND INBOX {4}", "ABCD");

            // Confirm it exists in the IMAP folder.
            Assert.AreEqual(1, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();

            // The public directory should still be empty - the message was added to the user account.
            CustomAsserts.AssertFilesInDirectory(publicDir, 0);

            // There should be a single file in the users directory.
            CustomAsserts.AssertFilesInUserDirectory(oAccount, 1);
        }
Ejemplo n.º 2
0
        public void BounceMessageShouldContainSubjectAndDate()
        {
            Account senderAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Account recipientAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**",
                                                                                          "test");

            recipientAccount.MaxSize = 1;
            recipientAccount.Save();

            // Make sure that no bounce is sent.
            SmtpClientSimulator.StaticSend(senderAccount.Address, recipientAccount.Address, "MySubject", "Test");
            Pop3ClientSimulator.AssertGetFirstMessageText(recipientAccount.Address, "test");

            // Build a 2MB string.
            var builder = new StringBuilder();

            for (int i = 0; i < 11000; i++)
            {
                builder.Append(
                    "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n");
            }
            string text = builder.ToString();

            SmtpClientSimulator.StaticSend(senderAccount.Address, recipientAccount.Address, "Test subject", text);

            // Make sure the recipient did not receive it.
            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
            Pop3ClientSimulator.AssertMessageCount(recipientAccount.Address, "test", 0);
            CustomAsserts.AssertFilesInUserDirectory(recipientAccount, 0);

            // Make sure it bounced.
            string content = Pop3ClientSimulator.AssertGetFirstMessageText(senderAccount.Address, "test");

            Assert.IsTrue(content.Contains("Inbox is full"));
            Assert.IsTrue(content.Contains("Subject: Test subject"));

            // Make sure body contains year.
            int bodyStartPos = content.IndexOf("\r\n\r\n");
            int yearPos      = content.IndexOf(DateTime.Now.Year.ToString(), bodyStartPos);

            Assert.IsTrue(yearPos >= 0);
        }
Ejemplo n.º 3
0
        public void ConfirmFileAddedToCorrectPublicFolder()
        {
            TestSetup testSetup  = SingletonProvider <TestSetup> .Instance;
            Account   oAccount   = testSetup.AddAccount(_domain, "*****@*****.**", "test");
            var       oSimulator = new ImapClientSimulator();

            // Confirm that the public folder is empty before we start our test.
            string publicDir = GetPublicDirectory();

            CustomAsserts.AssertFilesInDirectory(publicDir, 0);

            IMAPFolders folders = _application.Settings.PublicFolders;
            IMAPFolder  folder  = folders.Add("Share");

            folder.Save();

            // Give everyone access to the folder.
            IMAPFolderPermission permission = folder.Permissions.Add();

            permission.PermissionType = eACLPermissionType.ePermissionTypeAnyone;
            permission.set_Permission(eACLPermission.ePermissionLookup, true);
            permission.set_Permission(eACLPermission.ePermissionRead, true);
            permission.set_Permission(eACLPermission.ePermissionInsert, true);
            permission.Save();

            // Add the message to the public folder.
            oSimulator.Connect();
            oSimulator.LogonWithLiteral("*****@*****.**", "test");
            oSimulator.SendSingleCommandWithLiteral("A01 APPEND #Public.Share {4}", "ABCD");

            // Confirm that the message exists in the public folder and not in the inbox.
            Assert.AreEqual(1, oSimulator.GetMessageCount("#Public.Share"));
            Assert.AreEqual(0, oSimulator.GetMessageCount("INBOX"));
            oSimulator.Disconnect();


            // The public directory should now contain the message.
            CustomAsserts.AssertFilesInDirectory(publicDir, 1);

            // There users directory should still be empty.
            CustomAsserts.AssertFilesInUserDirectory(oAccount, 0);
        }
Ejemplo n.º 4
0
        public void TestMaxSizeLimitation()
        {
            Account senderAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Account recipientAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**",
                                                                                          "test");

            recipientAccount.MaxSize = 1;
            recipientAccount.Save();

            // Make sure that no bounce is sent.
            SmtpClientSimulator.StaticSend(senderAccount.Address, recipientAccount.Address, "MySubject", "Test");
            Pop3ClientSimulator.AssertGetFirstMessageText(recipientAccount.Address, "test");

            // Build a 2MB string.
            var builder = new StringBuilder();

            for (int i = 0; i < 11000; i++)
            {
                builder.Append(
                    "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n");
            }
            string text = builder.ToString();

            SmtpClientSimulator.StaticSend(senderAccount.Address, recipientAccount.Address, "MySubject", text);

            // Make sure the list did not receive it.
            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
            Pop3ClientSimulator.AssertMessageCount(recipientAccount.Address, "test", 0);
            CustomAsserts.AssertFilesInUserDirectory(recipientAccount, 0);

            // Make sure it bounced.
            string content = Pop3ClientSimulator.AssertGetFirstMessageText(senderAccount.Address, "test");

            Assert.IsTrue(content.Contains("Inbox is full"));
        }