예제 #1
0
        public void TestIMAPFolderPermissionAccessGroup()
        {
            Application application = SingletonProvider <TestSetup> .Instance.GetApp();


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

            Group group = SingletonProvider <TestSetup> .Instance.AddGroup("TestGroup");

            IMAPFolders publicFolders = _settings.PublicFolders;
            IMAPFolder  folder        = publicFolders.Add("Share1");

            folder.Save();

            IMAPFolderPermission permission = folder.Permissions.Add();

            permission.PermissionGroupID = group.ID;
            permission.PermissionType    = eACLPermissionType.ePermissionTypeGroup;
            permission.Save();

            CustomAssert.AreEqual(permission.Group.Name, group.Name);

            permission = folder.Permissions.Add();
            permission.PermissionAccountID = account1.ID;
            permission.PermissionType      = eACLPermissionType.ePermissionTypeUser;
            permission.Save();

            CustomAssert.AreEqual(permission.Account.Address, account1.Address);
        }
예제 #2
0
        private void SetupPublicFolders()
        {
            IMAPFolders folders = _application.Settings.PublicFolders;
            IMAPFolder  folder  = folders.Add("Test1");

            folder.Save();

            folder = folders.Add("Test2");
            folder.Save();

            folder = folders.Add("Test3");
            folder.Save();

            folder = folders.Add("ACL");
            folder.Save();

            Domain  domain   = _application.Domains[0];
            Account account1 = SingletonProvider <TestSetup> .Instance.AddAccount(domain, "*****@*****.**", "test");

            IMAPFolderPermission permission = folder.Permissions.Add();

            permission.PermissionType      = eACLPermissionType.ePermissionTypeUser;
            permission.PermissionAccountID = account1.ID;
            permission.set_Permission(eACLPermission.ePermissionAdminister, true);
            permission.set_Permission(eACLPermission.ePermissionInsert, true);
            permission.Save();

            folder = folder.SubFolders.Add("MySubFolder");
            folder.Save();

            Group group1 = _application.Settings.Groups.Add();

            group1.Name = "ACLTestGroup";
            group1.Save();

            permission = folder.Permissions.Add();
            permission.PermissionType    = eACLPermissionType.ePermissionTypeGroup;
            permission.PermissionGroupID = group1.ID;
            permission.set_Permission(eACLPermission.ePermissionLookup, true);
            permission.set_Permission(eACLPermission.ePermissionDeleteMailbox, true);
            permission.Save();
        }
예제 #3
0
        public void TestRenameRootPublicFolder()
        {
            IMAPFolders folders = _application.Settings.PublicFolders;
            IMAPFolder  folder  = folders.Add("ShareA");

            folder.Save();

            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.ePermissionDeleteMailbox, true);
            permission.Save();

            IMAPFolder folder2 = folders.Add("ShareB");

            folder2.Save();

            IMAPFolderPermission permission2 = folder2.Permissions.Add();

            permission2.PermissionType = eACLPermissionType.ePermissionTypeAnyone;
            permission2.set_Permission(eACLPermission.ePermissionLookup, true);
            permission2.set_Permission(eACLPermission.ePermissionRead, true);
            permission2.set_Permission(eACLPermission.ePermissionDeleteMailbox, true);
            permission2.Save();

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

            var simulator1 = new IMAPClientSimulator();

            simulator1.ConnectAndLogon(account.Address, "test");
            CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareA"));
            CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareB"));
            CustomAssert.IsTrue(simulator1.RenameFolder("#Public.ShareA", "#Public.ShareB.ShareA"));
            CustomAssert.IsFalse(simulator1.SelectFolder("#Public.ShareA"));
            CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareB"));
            CustomAssert.IsTrue(simulator1.SelectFolder("#Public.ShareB.ShareA"));
        }
예제 #4
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);
        }
예제 #5
0
        public void TestSaveMessageInPublicIMAPFolder()
        {
            Settings settings = SingletonProvider <TestSetup> .Instance.GetApp().Settings;

            IMAPFolders publicFolders = settings.PublicFolders;

            IMAPFolder testFolder = publicFolders.Add("TestFolder");

            testFolder.Save();

            // Send a message to the account.
            hMailServer.Message oMessage = testFolder.Messages.Add();

            CustomAssert.AreEqual(0, oMessage.State);

            oMessage.Body    = "Välkommen till verkligheten";
            oMessage.Subject = "Hej";
            oMessage.Save();

            CustomAssert.AreEqual(2, oMessage.State);
            CustomAssert.IsTrue(oMessage.Filename.Contains(settings.PublicFolderDiskName));
            CustomAssert.IsFalse(oMessage.Filename.Contains(_domain.Name));
        }
예제 #6
0
        public void TestReplaceFullPathInPublicFolderWithPartialPath()
        {
            Application application = SingletonProvider <TestSetup> .Instance.GetApp();

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

            IMAPFolders publicFolders = _settings.PublicFolders;
            IMAPFolder  folder        = publicFolders.Add("Share1");

            folder.Save();

            hMailServer.Message message = folder.Messages.Add();
            message.Subject = "Test";
            message.Save();

            // Move the message file to another folder.
            string publicFolderPath = Path.Combine(_application.Settings.Directories.DataDirectory, "#Public");
            string fileName         = Path.Combine(publicFolderPath, "randomMail.eml");

            File.Move(message.Filename, fileName);

            // Update the database with the 'invalid' path.
            string sql = string.Format("update hm_messages set messagefilename = '{0}' where messageid = {1}",
                                       TestSetup.Escape(fileName), message.ID);

            SingletonProvider <TestSetup> .Instance.GetApp().Database.ExecuteSQL(sql);

            // Now try to insert the message.
            CustomAssert.IsTrue(_application.Utilities.ImportMessageFromFile(fileName, 0));

            _application.Reinitialize();

            string newMessgaeFilename = _settings.PublicFolders[0].Messages[0].Filename;

            CustomAssert.AreNotEqual(fileName, newMessgaeFilename);
            CustomAssert.IsTrue(File.Exists(newMessgaeFilename));
        }