Пример #1
0
        public void SetUp()
        {
            const string mlName = "1ban";
            var domainList = new List<string>{ "example.com" };
            //var tsDir = new TsDir();
            var kernel = new Kernel();
            var logger = new Logger();
            var manageDir = TestUtil.GetTmpDir("TestDir");

            _tsMailSave = new TsMailSave();//MailSaveのモックオブジェクト

            var memberList = new Dat(new[] { CtrlType.TextBox, CtrlType.TextBox, CtrlType.CheckBox, CtrlType.CheckBox, CtrlType.CheckBox, CtrlType.TextBox });
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //一般・読者・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, ""));//一般・読者・×
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, ""));//一般・×・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN", "*****@*****.**", true, false, true, "123"));//管理者・×・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿
            var docs = (from object o in Enum.GetValues(typeof(MlDocKind)) select "").ToList();
            const int maxSummary = 10;
            const int getMax = 10;
            const bool autoRegistration = true;
            const int titleKind = 5;
            var mlOption = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList);

            _ml = new Ml(kernel, logger, _tsMailSave, mlOption, mlName, domainList);
        }
Пример #2
0
        public void SetUp()
        {
            init = new Initialization2();

            ml = init.CreateMl();

            user1 = new MailAddress("*****@*****.**");
            user2 = new MailAddress("*****@*****.**");
            //user3 = new MailAddress("*****@*****.**");
            user4 = new MailAddress("*****@*****.**");
            admin = new MailAddress("*****@*****.**");
            admin2 = new MailAddress("*****@*****.**");
            //mlCtrl = init.MlAddr.Ctrl;
            //mlPost = init.MlAddr.Post;
            mlAdmin = init.MlAddr.Admin;
            //mailDaemon = new MailAddress("*****@*****.**");
            user1Str = string.Format("\"USER1\" <{0}>", user1.ToString());
            //user2Str = string.Format("\"USER2\" <{0}>", user2.ToString());
            //user3Str = string.Format("\"USER3\" <{0}>", user3.ToString());
            user4Str = string.Format("\"USER4\" <{0}>", user4.ToString());
            //adminStr = string.Format("\"ADMIN\" <{0}>", admin.ToString());
            admin2Str = string.Format("\"ADMIN2\" <{0}>", admin2.ToString());
            mlCtrlStr = string.Format("\"1BAN(CTRL)\" <{0}>", init.MlAddr.Ctrl);
            mlPostStr = string.Format("\"1BAN\" <{0}>", init.MlAddr.Post);
            mlAdminStr = init.MlAddr.Admin.ToString();
            //mailDaemonStr = string.Format("\"Mail Delivery Subsystem\"<{0}>", mailDaemon.ToString());

            //init.MailSave.Clear();//初期化
        }
Пример #3
0
        public MlList(Kernel kernel, Server server, MailSave mailSave, List <string> domainList)
        {
            var optionMl = kernel.ListOption.Get("Ml");

            //メーリングストの一覧を取得する
            var dat = (Dat)optionMl.GetValue("mlList");

            if (dat != null)
            {
                foreach (var o2 in dat)
                {
                    if (!o2.Enable)
                    {
                        continue;
                    }
                    //メーリングリスト名の読込
                    var mlName   = o2.StrList[0];
                    var op       = kernel.ListOption.Get("Ml-" + mlName);
                    var logger   = kernel.CreateLogger(mlName, (bool)op.GetValue("useDetailsLog"), server);
                    var mlOption = new MlOption(kernel, op);
                    //無効なメンバ指定の確認と警告
                    foreach (var d in mlOption.MemberList)
                    {
                        var mailAddress = new MailAddress(d.StrList[1]); //メールアドレス
                        if (mailAddress.User != "" && mailAddress.Domain != "")
                        {
                            continue;
                        }
                        if (logger != null)
                        {
                            logger.Set(LogKind.Error, null, 53, string.Format("{0}", d.StrList[1]));
                        }
                    }
                    if (mlOption.MemberList.Count == 0)
                    {
                        logger.Set(LogKind.Error, null, 57, string.Format("{0}", mlName));
                        continue;
                    }
                    var ml = new Ml(kernel, logger, mailSave, mlOption, mlName, domainList);
                    //MLの管理領域の初期化に失敗している場合は、追加しない
                    if (!ml.Status)
                    {
                        continue;
                    }
                    _ar.Add(ml);
                    if (logger != null)
                    {
                        logger.Set(LogKind.Normal, null, 44, mlName);
                    }
                }
            }
        }
Пример #4
0
        public Initialization2()
        {
            var tsDir = new TsDir();
            //var tsOption = new TsOption(tsDir);
            //var manageDir = tsDir.Src + "\\TestDir";

            //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory());
            var optionDef = tsDir.Src + "\\Option.def";

            //Docs
            Docs = new List<string>();
            var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932));
            foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind))) {
                var tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower());
                bool hit = false;
                foreach (var l in lines) {
                    if (l.IndexOf(tag) == 0) {
                        Docs.Add(l.Substring(tag.Length));
                        hit = true;
                        break;
                    }
                }
                if (!hit) {
                    Docs.Add("");
                }
            }

            Kernel = new Kernel(null, null, null, null);
            Logger = Kernel.CreateLogger("LOG", true, null);
            domainList = new List<string>() { "example.com" };
            MlAddr = new MlAddr(mlName, domainList);
            var mailQueue = new MailQueue(tsDir.Src + "TestDir");
            var oneOption = new Option(Kernel,"","");
            var mailBox = new MailBox(Kernel, oneOption);
            MailSave = new MailSave(Kernel,mailBox,Logger,mailQueue,"",domainList);
            MlOption = CreateMlOption();
            //MlUserList = CreateMlUsers();

            Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList);
            //30件のメールを保存
            for (int i = 0; i < 30; i++) {
                var mail = new Mail(null);
                mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
                mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1));
                mail.Init(Encoding.ASCII.GetBytes("1\r\n"));//本文
                mail.Init(Encoding.ASCII.GetBytes("2\r\n"));//本文
                mail.Init(Encoding.ASCII.GetBytes("3\r\n"));//本文

                Ml.Save(mail);
            }
        }
Пример #5
0
        public MlList(Kernel kernel,Server server,MailSave mailSave, List<string> domainList)
        {
            var optionMl = kernel.ListOption.Get("Ml");

            //メーリングストの一覧を取得する
            var dat = (Dat) optionMl.GetValue("mlList");
            if (dat != null){
                foreach (var o2 in dat){
                    if (!o2.Enable)
                        continue;
                    //メーリングリスト名の読込
                    var mlName = o2.StrList[0];
                    var op = kernel.ListOption.Get("Ml-" + mlName);
                    var logger = kernel.CreateLogger(mlName, (bool) op.GetValue("useDetailsLog"), server);
                    var mlOption = new MlOption(kernel,op);
                    //無効なメンバ指定の確認と警告
                    foreach (var d in mlOption.MemberList){
                        var mailAddress = new MailAddress(d.StrList[1]); //メールアドレス
                        if (mailAddress.User != "" && mailAddress.Domain != "")
                            continue;
                        if (logger != null){
                            logger.Set(LogKind.Error, null, 53, string.Format("{0}", d.StrList[1]));
                        }
                    }
                    if (mlOption.MemberList.Count == 0){
                        logger.Set(LogKind.Error, null, 57, string.Format("{0}", mlName));
                        continue;
                    }
                    var ml = new Ml(kernel, logger, mailSave, mlOption, mlName, domainList);
                    //MLの管理領域の初期化に失敗している場合は、追加しない
                    if (!ml.Status)
                        continue;
                    _ar.Add(ml);
                    if (logger != null)
                        logger.Set(LogKind.Normal, null, 44, mlName);
                }
            }
        }
Пример #6
0
        public void SetUp()
        {
            var tsDir = new TsDir();
            _tsOption = new TsOption(tsDir);
            _tsOption.Set("FOLDER", "MailBox", "dir", string.Format("{0}\\MailBox", tsDir.Src));
            //user1,user2,user3
            _tsOption.Set("DAT", "MailBox", "user", "user1\tpass\buser2\tpass\buser3\tpass");

            var kernel = new Kernel(null, null, null, null);
            var logger = new Logger(kernel, "LOG", false, null);
            var manageDir = tsDir.Src + "\\TestDir";
            //MailQueue
            _mailQueue = new MailQueue(tsDir.Src + "\\MailQueue");
            var oneOption = kernel.ListOption.Get("MailBox");

            _mailBox = new MailBox(kernel, oneOption);

            var mailSave = new MailSave(kernel, _mailBox, logger, _mailQueue, "", _domainList);//モック

            var memberList = new Dat();
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //一般・読者・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, ""));//一般・読者・×
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, ""));//一般・×・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6" , "*****@*****.**" , false, false, true, ""));//一般・×・投稿 (Disable)
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN" , "*****@*****.**" , true, false, true, "123"));//管理者・×・投稿
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//管理者・読者・投稿 (Disable)
            var docs = (from object o in Enum.GetValues(typeof(MLDocKind)) select "").ToList();
            const int maxSummary = 10;
            const int getMax = 10;
            const bool autoRegistration = true;
            const int titleKind = 1;
            var mlOption = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList);

            _ml = new Ml(kernel, logger, mailSave, mlOption, _mlName, _domainList);
        }