Inheritance: System.Web.UI.Page
        public void Any(Logout request)
        {
            AuthService authService = base.ResolveService<AuthService>();
            authService.Delete(new Auth {
                provider = AuthService.LogoutAction
            });

            var cache = authService.TryResolve<IRedisClientsManager>();
            if(cache!=null){
                var sessionId = authService.GetSessionId();

                var pattern = string.Format("urn:{0}:*", sessionId);
                cache.Execute(client=>{
                    var keys =client.SearchKeys(pattern);
                    client.RemoveAll(keys);
                });

            }
        }
 protected void Logout_Click(object sender, EventArgs e)
 {
     Logout.logoutUser();
 }
Esempio n. 3
0
        private void AnalyzePacket(NetworkStream stream, byte[] buffer)
        {
            Packet packet = (Packet)Packet.Deserialize(buffer);

            if (packet == null)
            {
                return;
            }

            switch ((int)packet.packet_Type)
            {
            case (int)PacketType.Login:
            {
                // 받은 패킷을 Login class 로 deserialize 시킴
                Login login = (Login)Packet.Deserialize(buffer);

                setLog(string.Format("ID : {0}, PWD : {1}", login.id_str, login.pw_str));

                // 전송할 패킷을 LoginResult class 로 serialize 시킴
                LoginResult loginResult = new LoginResult();
                loginResult.packet_Type = (int)PacketType.Login_RESULT;
                string id = CheckLogin(login.id_str, login.pw_str);
                if (id.Length != 0)
                {
                    if (Utils.CheckTimeleft(GetTimeLeft(id)))
                    {
                        setLog(string.Format("Login : {0} ", login.id_str));
                        loginResult.result = true;
                        loginResult.reason = id;
                        AddUserToList(id, login.id_str);
                    }
                    else
                    {
                        loginResult.result = false;
                        setLog("failed Login");
                        loginResult.reason = "시간을 충전하세요";
                    }
                }
                else
                {
                    loginResult.result = false;
                    setLog("failed Login");
                    loginResult.reason = "아이디와 비밀번호를 확인 하시기 바랍니다.";
                }

                Array.Clear(buffer, 0, buffer.Length);
                Packet.Serialize(loginResult).CopyTo(buffer, 0);
                stream.Write(buffer, 0, buffer.Length);

                setLog("");
            }
            break;

            case (int)PacketType.Member_REGISTER:
            {
                // 받은 패킷을 MemberRegister class 로 deserialize 시킴
                MemberRegister memberRegister = (MemberRegister)Packet.Deserialize(buffer);

                setLog(string.Format("ID : {0}, PWD : {1}",
                                     memberRegister.id_str, memberRegister.pw_str));

                // 전송할 패킷을 LoginResult class 로 serialize 시킴
                MemberRegisterResult mrResult = new MemberRegisterResult();
                mrResult.packet_Type = (int)PacketType.Member_REGISTER_RESULT;
                if (InsertNeUser(memberRegister.id_str, memberRegister.pw_str))
                {
                    mrResult.result = true;
                    mrResult.reason = "회원 가입이 정상적으로 되었습니다.";
                    setLog(string.Format("succeed register : {0}", memberRegister.id_str));
                }
                else
                {
                    mrResult.result = false;
                    mrResult.reason = "회원가입 오류입니다.";
                    setLog("failed register");
                }

                Array.Clear(buffer, 0, buffer.Length);
                Packet.Serialize(mrResult).CopyTo(buffer, 0);
                stream.Write(buffer, 0, buffer.Length);

                setLog("");
            }
            break;

            case (int)PacketType.GetTime:    // get time
                // 받은 패킷을 MemberRegister class 로 deserialize 시킴
                GetTime gt = (GetTime)Packet.Deserialize(buffer);

                setLog(string.Format("request timeleft.{0}-{1}",
                                     gt.id_str, gt.timeleft));
                gt.timeleft = GetTimeLeft(gt.id_str);

                Array.Clear(buffer, 0, buffer.Length);
                Packet.Serialize(gt).CopyTo(buffer, 0);
                stream.Write(buffer, 0, buffer.Length);

                setLog("");
                break;

            case (int)PacketType.Logout:
                // 받은 패킷을 MemberRegister class 로 deserialize 시킴
                Logout lo = (Logout)Packet.Deserialize(buffer);

                setLog(string.Format("Logout:{0}- save tileleft {1}",
                                     lo.id_str, lo.timeleft));

                SaveUserTimeLeft(lo.id_str, lo.timeleft);
                RemoveListItem(lvUser, lo.id_str);
                Array.Clear(buffer, 0, buffer.Length);

                //LogoutResult lr = new LogoutResult();
                //lr.packet_Type = (int)PacketType.Logout_Result;
                //lr.result = true;
                //lr.reason = "normal";
                //Packet.Serialize(lr).CopyTo(buffer, 0);
                //stream.Write(buffer, 0, buffer.Length);
                break;
            }
            //stream.Close();
        }
 public object Any(Logout request)
 {
     var authResponse = AuthService.Authenticate(new Auth { provider = "logout" });
     return HttpResult.Redirect(Url.Content("~"));
 }
Esempio n. 5
0
        public void Logout()
        {
            Logout logout = new Logout(driver);

            logout.LogoutToMakeMyTrip();
        }
Esempio n. 6
0
        public static void UserClicksLogoutButton(IWebDriver driver)
        {
            var page = new Logout(driver);

            page.ClickLogoutButton();
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary <string, string> rep = new Dictionary <string, string>();

            rep[Key.STATUS] = Key.ERROR;
            try
            {
                string cmd = Request[Key.CMD];

                //  if login
                if (cmd.Equals(Key.LOGIN))
                {
                    rep = new org.mobileapi.server.windows.portal.code.Login().go(Request, Response);
                    Session[Key.SESSION_LOGGEDON] = "false";
                    if (rep[Key.STATUS].Equals(Key.OK))
                    {
                        Session[Key.SESSION_LOGGEDON] = "true";
                    }
                    Response.Write(new JavaScriptSerializer().Serialize(rep));
                    return;
                }

                if (cmd.Equals(Key.REGISTER))
                {
                    // Configure - this should go to Global.asa
                    FileLoader.ServerPath = HttpContext.Current.Server.MapPath("/");
                    Emailer.Configure(ConfigurationSettings.AppSettings[Key.MAILSERVER_HOST], Convert.ToInt32(ConfigurationSettings.AppSettings[Key.MAILSERVER_PORT]));

                    rep = new Register().go(Request, Response);
                    string reply = new JavaScriptSerializer().Serialize(rep);
                    Response.Write(reply);
                    return;
                }

                // check if sessi9on exists
                if (!Session[Key.SESSION_LOGGEDON].Equals("true"))
                {
                    rep[Key.MESSAGE] = "No session";
                    Response.Write(new JavaScriptSerializer().Serialize(rep));
                    return;
                }

                // Handle Commands
                switch (cmd)
                {
                case Key.LOGOUT:
                    rep = new Logout().go(Request, Response);
                    Session[Key.SESSION_LOGGEDON] = "false";
                    return;

                default:
                    return;
                }
                Response.Clear();
                Response.Write(new JavaScriptSerializer().Serialize(rep));
            }
            catch (Exception err)
            {
                Console.WriteLine(err);
                Response.Clear();
                Response.Write(new JavaScriptSerializer().Serialize(rep));
            }
        }
Esempio n. 8
0
        public Boolean InitialiseAllApiObj()
        {
            Boolean Ret;

            objLogin      = new Login(AppSupport.URL + WFConstants.API_LOGIN);
            objread       = new Read(AppSupport.URL + WFConstants.API_READ);
            objGetWI      = new GetWorkItem(AppSupport.URL + WFConstants.API_GETWORKITEM);
            objGetData    = new GetData(AppSupport.URL + WFConstants.API_GETDATA);
            objUpload     = new Upload(AppSupport.URL + WFConstants.API_UPLOADFILE);
            objDownload   = new Download(AppSupport.URL + WFConstants.API_DOWNLOADFILE);
            objwqu        = new WorkQUpdation(AppSupport.URL + WFConstants.API_WORKQUPDATE);
            objDocumentum = new Documentum(AppSupport.URL);
            objLogout     = new Logout(AppSupport.URL + WFConstants.API_LOGOUT);

            objLogin.LoginId  = AppConfiguration.GetValueFromAppConfig("LoginId", "");
            objLogin.Password = AppConfiguration.GetValueFromAppConfig("Password", "");

            Ret = objLogin.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            Ret = objread.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            Ret = objGetData.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            Ret = objUpload.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            Ret = objDownload.Initialise();
            if (!Ret)
            {
                return(false);
            }

            Ret = objwqu.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            Ret = objGetWI.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            Ret = objDocumentum.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            Ret = objLogout.Initialise();
            if (!Ret)
            {
                return(Ret);
            }

            return(Ret);
        }
Esempio n. 9
0
 private void btnLogout_Click(object sender, EventArgs e)
 {
     Logout?.Invoke();
 }
Esempio n. 10
0
 public void Handle(Logout message)
 {
     this.Content = ServiceLocator.Resolve <SignInViewModel>();
 }
Esempio n. 11
0
        public void logoutTest()
        {
            Logout log = new Logout(driver);

            log.FlipkartLogout();
        }
 void ProcessMessage(ClientConnection client, Logout message)
 {
     if (client.Avatar != null)
     {
         // remove from world.
         // TODO: do I want to remove the avatar?
         // World.Remove((EntityModel)client.Avatar);
     }
     _log.Info("Logged out '" + client.AuthenticatedUsername + "'.");
     client.Close();
 }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <param name="cts"></param>
        /// <param name="nks"></param>
        /// <param name="t"></param>
        List <object> toContact(List <Contact> list, Dictionary <string, int> nks, long gpid)
        {
            var cts = new List <x_contact>();
            var gps = new List <object>();

            foreach (var c in list)
            {
                var n = c.NickName;
                if (!string.IsNullOrEmpty(c.RemarkName))
                {
                    n = c.RemarkName;
                }
                if (gpid > 0)
                {
                    n += gpid;
                }
                n += user.Uin;
                if (nks.ContainsKey(n))
                {
                    c.RemarkName = c.NickName + (++nks[n]).ToString("000");
                }                                                                                  //SetRemark(c.UserName, c.RemarkName);
                else
                {
                    nks.Add(n, 0); c.RemarkName = n;
                }

                var no = Secret.MD5(n);
                var ct = db.x_contact.FirstOrDefault(t => t.no == no && t.uin == user.Uin);
                if (ct == null)
                {
                    ct = new x_contact()
                    {
                        uin = user.Uin, no = no
                    }
                }
                ;

                ct.user_id     = lg.user_id;
                ct.remarkname  = c.RemarkName;
                ct.nickname    = Tools.RemoveHtml(c.NickName);
                ct.flag        = c.UserName[1] == '@' ? 2 : 1;
                ct.group_id    = gpid;
                ct.membercount = c.MemberCount;
                ct.signature   = c.Signature;
                ct.username    = c.UserName;
                ct.imgurl      = c.HeadImgUrl;

                var m = new Regex("(\\d{11})").Match(c.NickName);
                if (m.Success)
                {
                    ct.tel = m.Groups[1].Value;
                }
                if (ct.contact_id == 0)
                {
                    cts.Add(ct);
                }

                if (c.UserName[1] == '@')
                {
                    gps.Add(new
                    {
                        EncryChatRoomId = c.EncryChatRoomId,
                        UserName        = c.UserName
                    });
                }
            }
            if (cts.Count > 0)
            {
                db.x_contact.InsertAllOnSubmit(cts);
            }
            try
            {
                db.SubmitChanges(ConflictMode.ContinueOnConflict);
                db.SubmitChanges(ConflictMode.FailOnFirstConflict);
            }
            catch (ChangeConflictException)
            {
                foreach (ObjectChangeConflict occ in db.ChangeConflicts)
                {
                    occ.Resolve(RefreshMode.KeepChanges);
                }
            }
            catch (Exception ex)
            {
                outLog("toContact->err:" + ex.Message);
            }
            return(gps);
        }

        /// <summary>
        /// 同步检测
        /// </summary>
        void SyncCheck()
        {
            var url = String.Format("{0}/cgi-bin/mmwebwx-bin/synccheck?r={1}&sid={2}&uin={3}&skey={4}&deviceid={5}&synckey={6}&_{7}", gateway, getcurrentseconds(), baseRequest.Sid, baseRequest.Uin, baseRequest.Skey, baseRequest.DeviceID, synckey, getcurrentseconds());
            var rsp = wc.GetStr(url);

            outLog("synccheck->" + Serialize.ToJson(rsp));

            if (rsp.err)
            {
                return; throw new Exception("心跳同步失败->" + Serialize.ToJson(rsp));
            }

            var reg = new Regex("{retcode:\"(\\d+)\",selector:\"(\\d+)\"}");
            var m   = reg.Match(rsp.data + "");

            var rt  = int.Parse(m.Groups[1].Value);
            var sel = int.Parse(m.Groups[2].Value);

            if (isquit || rt != 0)
            {
                exit(1);
            }
            else if (sel == 2 || sel == 4 || sel == 6)
            {
                wxSync();
            }
        }

        /// <summary>
        /// 消息同步
        /// </summary>
        void wxSync()
        {
            string url = String.Format("{0}/cgi-bin/mmwebwx-bin/webwxsync?sid={1}&skey={2}&pass_ticket={3}", gateway, baseRequest.Sid, baseRequest.Skey, passticket);
            var    o   = new
            {
                BaseRequest = baseRequest,
                SyncKey     = _syncKey,
                rr          = getcurrentseconds()
            };
            var rsp = wc.PostStr(url, Serialize.ToJson(o));

            outLog("sync->" + Serialize.ToJson(rsp));

            if (rsp.err)
            {
                throw new Exception("消息获取失败->" + Serialize.ToJson(rsp));
            }

            _syncKey = Serialize.FromJson <SyncKey>(rsp.data + "", "SyncKey");

            var msglist = Serialize.FromJson <List <Msg> >(rsp.data + "", "AddMsgList");

            foreach (var m in msglist)
            {
                if (m.FromUserName == user.UserName)
                {
                    continue;
                }
                outLog("msg->" + user.Uin + "->" + m.Content);

                if (m.Content.Contains("你的朋友验证请求,") && m.Content.Contains("可以开始聊天了"))
                {
                    var rp = db.x_reply.Where(r => r.user_id == lg.user_id);
                }

                //var rps = db.x_reply.FirstOrDefault(o => o.keys)

                NewMsg?.Invoke(m);
            }

            // Debug.WriteLine(user.Uin + "收到消息->" + m.MsgId + "--->>>" + m.Content);
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="ToUserName"></param>
        /// <param name="Content"></param>
        void sendText(string ToUserName, string Content)
        {
            string url = String.Format("{0}/cgi-bin/mmwebwx-bin/webwxsendmsg?pass_ticket={1}", gateway, passticket);

            Content = Content.Replace("<br/>", "\n");
            var o = new
            {
                BaseRequest = baseRequest,
                Msg         = new
                {
                    Type         = 1,
                    Content      = Content,
                    FromUserName = user.UserName,
                    ToUserName   = ToUserName,
                    LocalID      = getcurrentseconds(),
                    ClientMsgId  = getcurrentseconds()
                }
            };

            var rsp = op.PostStr(url, Serialize.ToJson(o));

            outLog("SendMsg->" + Serialize.ToJson(rsp));
        }

        /// <summary>
        /// 发送图片
        /// </summary>
        /// <param name="ToUserName"></param>
        /// <param name="url"></param>
        void sendImg(string ToUserName, string mmid)
        {
            //var mmid = uploadImg(ToUserName, url);
            //if (string.IsNullOrEmpty(mmid)) return;

            string api = String.Format("{0}/cgi-bin/mmwebwx-bin/webwxsendmsgimg?fun=async&f=json&pass_ticket={1}", gateway, passticket);
            var    o   = new
            {
                BaseRequest = baseRequest,
                Msg         = new
                {
                    Type         = 3,
                    MediaId      = mmid,
                    FromUserName = user.UserName,
                    ToUserName   = ToUserName,
                    LocalID      = getcurrentseconds(),
                    ClientMsgId  = getcurrentseconds()
                },
                Scene = 0
            };

            var rsp = op.PostStr(api, Serialize.ToJson(o));

            if (!(rsp.data + "").Contains("\"Ret\": 0"))
            {
                Thread.Sleep(5 * 1000);
            }

            outLog("SendImg->" + Serialize.ToJson(rsp));
        }

        /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="img"></param>
        /// <returns></returns>
        string uploadImg(string img)
        {
            var fs = op.GetFile(img);

            if (fs.err)
            {
                return("");
            }

            string url = gateway.Replace("https://", "https://file.") + "/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json";
            var    o   = new
            {
                UploadType    = 2,
                BaseRequest   = baseRequest,
                ClientMediaId = getcurrentseconds(),
                TotalLen      = (fs.data as byte[]).Length,
                StartPos      = 0,
                DataLen       = (fs.data as byte[]).Length,
                MediaType     = 4
            };

            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("id", "WU_FILE_" + filecount++);
            dict.Add("name", img.Substring(img.LastIndexOf('/') + 1));
            dict.Add("type", Tools.GetMimeType(img.Substring(img.LastIndexOf('.') + 1)));
            dict.Add("lastModifiedDate", "Wed Sep 07 2016 10:38:12 GMT+0800");//DateTime.Now.ToString("r")
            dict.Add("size", (fs.data as byte[]).Length + "");
            dict.Add("mediatype", "pic");
            dict.Add("uploadmediarequest", Serialize.ToJson(o));
            dict.Add("webwx_data_ticket", wc.GetCookie("webwx_data_ticket"));
            dict.Add("pass_ticket", passticket);

            var rsp = op.PostFile(url, dict, fs.data as byte[]);

            outLog("UploadImg->" + Serialize.ToJson(rsp));

            if (rsp.err)
            {
                return("");
            }

            return(Serialize.FromJson <string>(rsp.data + "", "MediaId"));
        }

        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="c"></param>
        void exit(int c)
        {
            outLog("exit");
            isquit = true;

            if (lg != null)
            {
                lg.uuid   = null;
                lg.qrcode = null;
                lg.status = 1;

                try
                {
                    db.SubmitChanges();
                    db.Dispose();
                }
                catch (Exception ex)
                {
                    outLog("exit->err:" + ex.Message);
                }
            }
            if (c == 1)
            {
                Logout?.Invoke();
            }
        }
Esempio n. 14
0
 public void OnMessage(Logout message, SessionID session)
 {
 }
Esempio n. 15
0
 public AccountActionNotification Logout(Logout logout)
 {
     return(SendAccountAction(logout, HttpUtils.BuildUrl(_env, "/customers/logout", FlowStrategy.Account)));
 }
Esempio n. 16
0
        private void CiraTecnicalTest()
        {
            var tcpTransport = new TcpTransport("epp.test.cira.ca", 700, new X509Certificate("cert.pfx", "password"), true);

            var service = new Service(tcpTransport);

            //1. SSL connection establishment
            Console.WriteLine("TEST: 1");
            service.Connect();

            //2. EPP <login> command with your ‘a’ account
            Console.WriteLine("TEST: 2");
            var logingCmd = new Login("username", "password");

            var response = service.Execute(logingCmd);

            PrintResponse(response);

            //3. Using the correct EPP call, get the latest CIRA Registrant Agreement
            Console.WriteLine("TEST: 3");
            var agreementCmd = new GetAgreement();

            var getAgreementResponse = service.Execute(agreementCmd);

            var agreementVersion  = getAgreementResponse.AgreementVersion;
            var agreementText     = getAgreementResponse.Agreement;
            var agreementLanguage = getAgreementResponse.Language;

            PrintResponse(response);
            Console.WriteLine("Agreement Version:{0}", agreementVersion);

            /*
             * 4. Create a Registrant contact using:
             *  -the same ID as your Registrar Number prefixed with the word ‘rant’ (e.g. rant75)
             *  -CPR category CCT
             *  -Full postal information, phone number, fax number, and email address
             *  -Agreed to latest CIRA Registrant Agreement version
             */
            Console.WriteLine("TEST: 4");
            var registrantContact = new Contact("rant" + registrarNumber,
                                                "Registrant Step Four", "Example Inc.",
                                                "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
                                                "*****@*****.**",
                                                new Telephone {
                Value = "+1.6478913606", Extension = "333"
            },
                                                new Telephone {
                Value = "+1.6478913607"
            });


            var registrantContactCmd = new CiraContactCreate(registrantContact);

            registrantContactCmd.CprCategory          = CiraCprCategories.CCT;
            registrantContactCmd.AgreementVersion     = agreementVersion;
            registrantContactCmd.AggreementValue      = "Y";
            registrantContactCmd.Language             = "en";
            registrantContactCmd.OriginatingIpAddress = "127.0.0.1";
            registrantContactCmd.CreatedByResellerId  = registrarNumber;

            var response1 = service.Execute(registrantContactCmd);

            PrintResponse(response1);

            /*
             * 5. Create an administrative contact
             * -the same ID as your Registrar Number prefixed with the word ‘admin’ (e.g. admin75)
             * -using all mandatory elements required for a Canadian administrative contact
             * -omit CPR category (he have not agreed to the CIRA agreement)
             */
            Console.WriteLine("TEST: 5");
            var adminContact = new Contact("admin" + registrarNumber,
                                           "Administrative Step Five", "Example Inc.",
                                           "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
                                           "*****@*****.**",
                                           new Telephone {
                Value = "+1.6478913606", Extension = "333"
            },
                                           new Telephone {
                Value = "+1.6478913607"
            });

            var adminContactCmd = new CiraContactCreate(adminContact);

            adminContactCmd.CprCategory          = null;
            adminContactCmd.AgreementVersion     = null;
            adminContactCmd.AggreementValue      = null;
            adminContactCmd.Language             = "en";
            adminContactCmd.OriginatingIpAddress = "127.0.0.1";
            adminContactCmd.CreatedByResellerId  = registrarNumber;

            const string adminContactId = "admin" + registrarNumber;

            var loginresponse = service.Execute(adminContactCmd);

            PrintResponse(loginresponse);

            //6. Get information for the contact created in operation #4
            Console.WriteLine("TEST: 6");
            var getContactInfo = new ContactInfo(registrantContact.Id);

            var contactInfoResponse = service.Execute(getContactInfo);

            PrintResponse(contactInfoResponse);

            //7. Do a Registrant transfer for domain <registrar number>-3.ca to the Registrant created in operation #4
            Console.WriteLine("TEST: 7");

            //NOTE: registrant transfers are domain updates

            var registrantTransferCmd = new DomainUpdate(registrarNumber + "-3.ca");
            //var registrantTransferCmd = new DomainUpdate("3406310-4.ca");

            var domainChange = new DomainChange {
                RegistrantContactId = registrantContact.Id
            };

            registrantTransferCmd.DomainChange = domainChange;

            var response2 = service.Execute(registrantTransferCmd);

            PrintResponse(response2);

            //8. Update the contact created in operation #4 to no longer have a fax number
            Console.WriteLine("TEST: 8");
            var contactUpdateCmd = new ContactUpdate(registrantContact.Id);

            var contactChange = new ContactChange(registrantContact);

            contactChange.Fax = new Telephone("", "");

            contactUpdateCmd.ContactChange = contactChange;

            //NOTE:the docs say that the cpr category is update for domain contact
            //but they show a sample of a contact update request that does not include the extension
            //NOTE: Organization cannot be entered when CPR Category indicates a non individual - see documentation
            contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension {
                CprCategory = CiraCprCategories.CCT
            });

            var response3 = service.Execute(contactUpdateCmd);

            PrintResponse(response3);

            //8.1 Get contact info and check the fax number dissapeared
            var contactInfoCmd1 = new ContactInfo(registrantContact.Id);

            var contactInfoResponse1 = service.Execute(contactInfoCmd1);

            PrintResponse(contactInfoResponse1);

            //9. Do a domain:check on <registrar number>a.ca
            Console.WriteLine("TEST: 9");
            const string domainStep10 = registrarNumber + "a.ca";

            var domainCheckCmd = new DomainCheck(domainStep10);

            var response4 = service.Execute(domainCheckCmd);

            PrintResponse(response4);

            /*
             * 10. Create a domain using:
             * -a domain name set to <registrar number>a.ca
             * -a Registrant who is a Permanent Resident
             * -the same administrative contact as the Registrant
             * -0 hosts
             * -the minimum registration period
             */
            Console.WriteLine("TEST: 10");
            //NOTE: CPR categories CCT and RES where merged into CCR

            //BUG: the registrant needs to be a Permanent Resident
            //TODO: create a new contact that is a permanent resident
            //10.1
            var registrantContact10 = new Contact("ten" + registrarNumber,
                                                  "Registrant Step Ten", "Example Inc.",
                                                  "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
                                                  "*****@*****.**",
                                                  new Telephone {
                Value = "+1.6478913606", Extension = "333"
            },
                                                  new Telephone {
                Value = "+1.6478913607"
            });


            registrantContactCmd                      = new CiraContactCreate(registrantContact10);
            registrantContactCmd.CprCategory          = CiraCprCategories.RES;
            registrantContactCmd.AgreementVersion     = agreementVersion;
            registrantContactCmd.AggreementValue      = "Y";
            registrantContactCmd.OriginatingIpAddress = "127.0.0.1";
            registrantContactCmd.Language             = "en";
            registrantContactCmd.CreatedByResellerId  = registrarNumber;

            //ContactCreate.MakeContact(registrantContact10,  agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var response5 = service.Execute(registrantContactCmd);

            PrintResponse(response5);

            //10.2
            var domainCreateCmd = new DomainCreate(domainStep10, registrantContact10.Id);

            domainCreateCmd.DomainContacts.Add(new DomainContact(registrantContact10.Id, "admin"));

            //NOTE: password is compulsory
            domainCreateCmd.Password = "******";

            var response6 = service.Execute(domainCreateCmd);

            PrintResponse(response6);

            /*11. Do a host:check on hosts <registrar number>.example.com and <registrar number>.example.net*/
            Console.WriteLine("TEST: 11");
            var hostCheckCmd = new HostCheck(new List <string> {
                registrarNumber + ".example.com", registrarNumber + ".example.net"
            });

            var response7 = service.Execute(hostCheckCmd);

            PrintResponse(response7);

            /*
             * 12. Create 2 hosts with the following name formats:
             * <registrar number>.example.com
             * <registrar number>.example.net
             */
            Console.WriteLine("TEST: 12");
            //CIRA only creates a host at a time

            //12.1
            var hostCreateCmd = new HostCreate(new Host(registrarNumber + ".example.com"));

            var response8 = service.Execute(hostCreateCmd);

            PrintResponse(response8);

            //12.2
            hostCreateCmd = new HostCreate(new Host(registrarNumber + ".example.net"));

            var response9 = service.Execute(hostCreateCmd);

            PrintResponse(response9);

            /*
             * 13. Create a domain using:
             * -a domain name set to <registrar number>b.ca
             * -the pre-populated contact id <registrar number> as the administrative contact
             * -a Registrant who is a Corporation
             * -2 hosts created in operation #12 <- the nameservers
             * -a maximum registration period (10 years)
             */
            Console.WriteLine("TEST: 13");
            //13.1 - Create a corporation

            //If it is a corporation you can not provide company name
            var corporation = new Contact("corp" + registrarNumber, "Acme Corp.", null, "Toronto",
                                          "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                          new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createCorporationContactCmd = ContactCreate.MakeContact(corporation, CiraCprCategories.CCO, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createCorporationContactCmd = new CiraContactCreate(corporation);

            createCorporationContactCmd.CprCategory          = CiraCprCategories.CCO;
            createCorporationContactCmd.AgreementVersion     = agreementVersion;
            createCorporationContactCmd.AggreementValue      = "Y";
            createCorporationContactCmd.OriginatingIpAddress = "127.0.0.1";
            createCorporationContactCmd.Language             = "en";
            createCorporationContactCmd.CreatedByResellerId  = registrarNumber;

            var response10 = service.Execute(createCorporationContactCmd);

            PrintResponse(response10);

            /* var domainUpdateCmd = new DomainUpdate(registrarNumber + "-10.ca");
             *
             * domainUpdateCmd.ToRemove.Status.Add(new Status("", "serverDeleteProhibited"));
             *
             * response = service.Execute(domainUpdateCmd);
             *
             * PrintResponse(response);*/

            //13.2 - Create the domain

            //var createDomainCmd = new DomainCreate(registrarNumber + "b.ca", corporation.Id);
            var createDomainCmd = new DomainCreate(registrarNumber + "b.ca", "corp" + registrarNumber);

            createDomainCmd.Period = new DomainPeriod(10, "y");

            //NOTE:The administrative or technical contact must be an Individual
            //BUG: admin contact needs be the prepopulated 3406310
            createDomainCmd.DomainContacts.Add(new DomainContact(registrarNumber, "admin"));

            //NOTE:Create the host on the Registry system before you assign it to a domain
            createDomainCmd.NameServers.Add(registrarNumber + ".example.com");
            createDomainCmd.NameServers.Add(registrarNumber + ".example.net");

            createDomainCmd.Password = "******";

            var response11 = service.Execute(createDomainCmd);

            PrintResponse(response11);

            /*
             * 14. Create a domain using:
             * - a domain name set to <registrar number>c.ca
             * - a Registrant who is an Association
             * - the administrative contact set to the contact created in operation #5
             * - maximum number of technical contacts assigned to it (max is 3)
             * - 0 hosts
             * - a 2-year term
             */
            Console.WriteLine("TEST: 14");
            var association = new Contact("assoc" + registrarNumber, "Beer Producers Association", null, "Toronto",
                                          "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                          new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createAssociationContactCmd = ContactCreate.MakeContact(association, CiraCprCategories.ASS, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createAssociationContactCmd = new CiraContactCreate(association);

            createAssociationContactCmd.CprCategory          = CiraCprCategories.ASS;
            createAssociationContactCmd.AgreementVersion     = agreementVersion;
            createAssociationContactCmd.AggreementValue      = "Y";
            createAssociationContactCmd.OriginatingIpAddress = "127.0.0.1";
            createAssociationContactCmd.Language             = "en";
            createAssociationContactCmd.CreatedByResellerId  = registrarNumber;

            var response12 = service.Execute(createAssociationContactCmd);

            PrintResponse(response12);

            //tech1
            var tech1 = new Contact("tech1" + registrarNumber, "Technician #1", "Beer Producers Association", "Toronto",
                                    "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                    new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createTech1ContactCmd = ContactCreate.MakeContact(tech1, CiraCprCategories.CCT, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createTech1ContactCmd = new CiraContactCreate(tech1);

            createTech1ContactCmd.CprCategory          = CiraCprCategories.CCT;
            createTech1ContactCmd.AgreementVersion     = agreementVersion;
            createTech1ContactCmd.AggreementValue      = "Y";
            createTech1ContactCmd.OriginatingIpAddress = "127.0.0.1";
            createTech1ContactCmd.Language             = "en";
            createTech1ContactCmd.CreatedByResellerId  = registrarNumber;

            var response13 = service.Execute(createTech1ContactCmd);

            PrintResponse(response13);

            //tech2
            var tech2 = new Contact("tech2" + registrarNumber, "Technician #2", "Beer Producers Association", "Toronto",
                                    "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                    new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createTech2ContactCmd = ContactCreate.MakeContact(tech2, CiraCprCategories.CCT, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createTech2ContactCmd = new CiraContactCreate(tech2);

            createTech2ContactCmd.CprCategory          = CiraCprCategories.CCT;
            createTech2ContactCmd.AgreementVersion     = agreementVersion;
            createTech2ContactCmd.AggreementValue      = "Y";
            createTech2ContactCmd.OriginatingIpAddress = "127.0.0.1";
            createTech2ContactCmd.Language             = "en";
            createTech2ContactCmd.CreatedByResellerId  = registrarNumber;

            var response14 = service.Execute(createTech2ContactCmd);

            PrintResponse(response14);

            //tech1
            var tech3 = new Contact("tech3" + registrarNumber, "Technician #3", "Beer Producers Association", "Toronto",
                                    "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                    new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createTech3ContactCmd = ContactCreate.MakeContact(tech3, CiraCprCategories.CCT, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createTech3ContactCmd = new CiraContactCreate(tech3);

            createTech3ContactCmd.CprCategory          = CiraCprCategories.CCT;
            createTech3ContactCmd.AgreementVersion     = agreementVersion;
            createTech3ContactCmd.AggreementValue      = "Y";
            createTech3ContactCmd.OriginatingIpAddress = "127.0.0.1";
            createTech3ContactCmd.Language             = "en";
            createTech3ContactCmd.CreatedByResellerId  = registrarNumber;


            var response15 = service.Execute(createTech3ContactCmd);

            PrintResponse(response15);

            const string step14domain = registrarNumber + "c.ca";

            createDomainCmd = new DomainCreate(step14domain, association.Id);

            createDomainCmd.Period = new DomainPeriod(2, "y");

            createDomainCmd.DomainContacts.Add(new DomainContact(adminContactId, "admin"));

            createDomainCmd.DomainContacts.Add(new DomainContact(tech1.Id, "tech"));
            createDomainCmd.DomainContacts.Add(new DomainContact(tech2.Id, "tech"));
            createDomainCmd.DomainContacts.Add(new DomainContact(tech3.Id, "tech"));

            createDomainCmd.Password = "******";

            var response16 = service.Execute(createDomainCmd);

            PrintResponse(response16);

            /*
             * 15. Do a host:check for a host which the dot-ca domain name is registered
             */
            Console.WriteLine("TEST: 15");
            hostCheckCmd = new HostCheck("any." + registrarNumber + "b.ca");

            var response17 = service.Execute(hostCheckCmd);

            PrintResponse(response17);

            /*
             * 16. Create 2 subordinate hosts for the domain created in operation #14:
             * - with format ns1.<domain> and ns2.<domain>
             * - with IPv4 address information
             */
            Console.WriteLine("TEST: 16");
            var host1 = new Host("ns1." + step14domain);

            host1.Addresses.Add(new HostAddress("127.0.0.1", "v4"));
            var host2 = new Host("ns2." + step14domain);

            host2.Addresses.Add(new HostAddress("127.0.0.2", "v4"));

            var createHostCmd = new HostCreate(host1);

            var response18 = service.Execute(createHostCmd);

            PrintResponse(response18);

            createHostCmd = new HostCreate(host2);

            response18 = service.Execute(createHostCmd);

            PrintResponse(response18);

            /*
             * 17. Using the correct EPP call, get information on a host
             */
            Console.WriteLine("TEST: 17");
            var hostInfoCmd = new HostInfo(host1.HostName);

            var response19 = service.Execute(hostInfoCmd);

            PrintResponse(response19);

            /*18. Update the domain created in operation #14 such that the hosts created in operation #16 are delegated to the domain explicitly*/
            Console.WriteLine("TEST: 18");
            var domainUpdateCmd = new DomainUpdate(step14domain);

            //NOTE: Nameservers need different IP addresses
            domainUpdateCmd.ToAdd.NameServers = new List <string> {
                host1.HostName, host2.HostName
            };

            var response20 = service.Execute(domainUpdateCmd);

            PrintResponse(response20);

            //19. Update host ns1.<domain> created in operation #16 such that an IPv6 address is added
            Console.WriteLine("TEST: 19");
            var hostUpdateCmd = new HostUpdate(host1.HostName);

            var eppHostUpdateAddRemove = new EppHostUpdateAddRemove();

            eppHostUpdateAddRemove.Adresses = new List <HostAddress> {
                new HostAddress("1080:0:0:0:8:800:2004:17A", "v6")
            };

            hostUpdateCmd.ToAdd = eppHostUpdateAddRemove;

            var response21 = service.Execute(hostUpdateCmd);

            PrintResponse(response21);

            //20. Update host ns1.<domain> created in operation #16 such that an IPv4 address is removed
            Console.WriteLine("TEST: 20");
            hostUpdateCmd = new HostUpdate(host1.HostName);

            eppHostUpdateAddRemove = new EppHostUpdateAddRemove();

            eppHostUpdateAddRemove.Adresses = new List <HostAddress> {
                new HostAddress("127.0.0.1", "v4")
            };

            hostUpdateCmd.ToRemove = eppHostUpdateAddRemove;

            var response22 = service.Execute(hostUpdateCmd);

            PrintResponse(response22);

            //21. Update the status of ns1.<domain> such that it can no longer be updated
            Console.WriteLine("TEST: 21");
            hostUpdateCmd = new HostUpdate(host1.HostName);

            eppHostUpdateAddRemove = new EppHostUpdateAddRemove();

            eppHostUpdateAddRemove.Status = new List <Status> {
                new Status("", "clientUpdateProhibited")
            };

            hostUpdateCmd.ToAdd = eppHostUpdateAddRemove;

            response22 = service.Execute(hostUpdateCmd);
            PrintResponse(response22);

            //22. Using the correct EPP call, get information on a domain name without using WHOIS
            Console.WriteLine("TEST: 22");

            //const string domainStep10 = registrarNumber + "a.ca";

            var domainInfoCmd = new DomainInfo(domainStep10);
            var domainInfo    = service.Execute(domainInfoCmd);

            PrintResponse(domainInfo);

            //23. Renew the domain created in operation #10 such that the domain’s total length of term becomes 3 years
            Console.WriteLine("TEST: 23");
            var renewCmd = new DomainRenew(domainStep10, domainInfo.Domain.ExDate, new DomainPeriod(2, "y"));

            var response23 = service.Execute(renewCmd);

            PrintResponse(response23);

            /*
             * 24. Do a Registrar transfer:
             * - Domain name <registrar number>X2-1.ca, from your ‘e’ Registrar account
             * - Have the system auto-generate the contacts so that their information is identical to the contacts in the ‘e’ account
             */
            Console.WriteLine("TEST: 24");

            var transferCmd = new CiraDomainTransfer(registrarNumber + "X2-1.ca", null, null, new List <string>());

            //var transferCmd = new DomainTransfer("3406310x2-5.ca", null, null, new List<string>());

            transferCmd.Password = "******";
            var response24 = service.Execute(transferCmd);

            PrintResponse(response24);

            /*25. Do a Registrar transfer:
             * - Domain name, <registrar number>X2-2.ca, from your ‘e’ Registrar account
             * - Specify the same Registrant, administrative, and technical contacts used for the domain created in operation #14
             */
            Console.WriteLine("TEST: 25");

            //BUG: did not use all the technical contacts.

            transferCmd = new CiraDomainTransfer(registrarNumber + "X2-2.ca", association.Id, adminContactId, new List <string> {
                tech1.Id, tech2.Id, tech3.Id
            });
            //transferCmd = new DomainTransfer("3406310x2-10.ca", association.Id, adminContactId, new List<string> { tech1.Id, tech2.Id, tech3.Id });

            //Password is mandatory
            //TODO: find it in the control panel
            transferCmd.Password = "******";
            response24           = service.Execute(transferCmd);

            PrintResponse(response24);

            /*
             * 26. Do an update to the domain created in operation #14 to change the administrative contact to the pre-populated contact whose id is of format <registrar number>
             */
            Console.WriteLine("TEST: 26");
            domainUpdateCmd = new DomainUpdate(step14domain);

            //remove the previous admin
            domainUpdateCmd.ToRemove.DomainContacts.Add(new DomainContact(adminContactId, "admin"));

            domainUpdateCmd.ToAdd.DomainContacts.Add(new DomainContact(registrarNumber, "admin"));

            var response25 = service.Execute(domainUpdateCmd);

            PrintResponse(response25);

            /*27. Do an update to the status of the domain created in operation #14 such that it cannot be deleted*/
            Console.WriteLine("TEST: 27");
            domainUpdateCmd = new DomainUpdate(step14domain);

            domainUpdateCmd.ToAdd.Status.Add(new Status("", "clientDeleteProhibited"));

            var response26 = service.Execute(domainUpdateCmd);

            PrintResponse(response26);

            /*28. Do an update to the email address of the pre-populated contact whose id is of format <registrar number> to "*****@*****.**" */
            Console.WriteLine("TEST: 28");
            //28.1 get the contact
            //var contactInfoCmd = new ContactInfo("rant" + registrarNumber);
            var contactInfoCmd = new ContactInfo(registrarNumber);

            contactInfoResponse = service.Execute(contactInfoCmd);

            PrintResponse(contactInfoResponse);

            if (contactInfoResponse.Contact != null)
            {
                //28.2 update the email address

                //ASSERT: contactInfoResponse.Contact != null
                contactUpdateCmd = new ContactUpdate(contactInfoResponse.Contact.Id);

                var contactchage = new ContactChange(contactInfoResponse.Contact);

                contactchage.Email = "*****@*****.**";

                contactUpdateCmd.ContactChange = contactchage;

                //the extensions are compulsory
                contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension {
                    CprCategory = contactInfoResponse.Contact.CprCategory
                });

                var response27 = service.Execute(contactUpdateCmd);

                PrintResponse(response27);
            }
            else
            {
                Console.WriteLine("Error: contact does not exist?");
            }


            /*
             *   29. Do an update to the privacy status for Registrant contact created in operation #4 to now show full detail
             */
            Console.WriteLine("TEST: 29");
            contactUpdateCmd = new ContactUpdate("rant" + registrarNumber);

            //Invalid WHOIS display setting - valid values are PRIVATE or FULL
            contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension {
                WhoisDisplaySetting = "FULL"
            });

            var response28 = service.Execute(contactUpdateCmd);

            PrintResponse(response28);


            /*30. Delete the domain <registrar number>-10.ca*/
            Console.WriteLine("TEST: 30");
            //NOTE:check this domain status

            var deleteDomainCmd = new DomainDelete(registrarNumber + "-10.ca");
            //var deleteDomainCmd = new DomainDelete(registrarNumber + "-9.ca");

            var response29 = service.Execute(deleteDomainCmd);

            PrintResponse(response29);

            /*31. EPP <logout> command*/
            Console.WriteLine("TEST:31");
            var logOutCmd = new Logout();

            service.Execute(logOutCmd);

            /*32. Disconnect SSL connection*/
            Console.WriteLine("TEST: 32");
            service.Disconnect();

            /*33. SSL connection establishment*/
            Console.WriteLine("TEST: 33");
            service.Connect();

            /*34. EPP <login> command with your ‘e’ account*/
            Console.WriteLine("TEST: 34");
            logingCmd = new Login("username", "password");

            response = service.Execute(logingCmd);

            PrintResponse(response);

            /*35. Acknowledge all poll messages*/
            Console.WriteLine("TEST: 35");
            var thereAreMessages = true;

            while (thereAreMessages)
            {
                //request
                var poll = new Poll {
                    Type = PollType.Request
                };

                var pollResponse = (PollResponse)service.Execute(poll);

                PrintResponse(pollResponse);

                if (!String.IsNullOrEmpty(pollResponse.Id))
                {
                    //acknowledge
                    poll = new Poll {
                        Type = PollType.Acknowledge, MessageId = pollResponse.Id
                    };

                    pollResponse = (PollResponse)service.Execute(poll);

                    PrintResponse(pollResponse);
                }

                Console.WriteLine("Messages left in the queue:" + pollResponse.Count);

                thereAreMessages = pollResponse.Count != 0;
            }

            /*36. EPP <logout> command*/
            Console.WriteLine("TEST: 36");
            logOutCmd = new Logout();

            service.Execute(logOutCmd);
        }
Esempio n. 17
0
        private void CiraTecnicalTest()
        {
            var tcpTransport = new TcpTransport("epp.test.cira.ca", 700, new X509Certificate("cert.pfx", "password"), true);

            var service = new Service(tcpTransport);

            //1. SSL connection establishment
            Console.WriteLine("TEST: 1");
            service.Connect();

            //2. EPP <login> command with your ‘a’ account
            Console.WriteLine("TEST: 2");
            var logingCmd = new Login("username", "password");

            var response = service.Execute(logingCmd);

            PrintResponse(response);

            //3. Using the correct EPP call, get the latest CIRA Registrant Agreement
            Console.WriteLine("TEST: 3");
            var agreementCmd = new GetAgreement();

            var getAgreementResponse = service.Execute(agreementCmd);

            var agreementVersion = getAgreementResponse.AgreementVersion;
            var agreementText = getAgreementResponse.Agreement;
            var agreementLanguage = getAgreementResponse.Language;

            PrintResponse(response);
            Console.WriteLine("Agreement Version:{0}", agreementVersion);
            /*
             4. Create a Registrant contact using: 
                -the same ID as your Registrar Number prefixed with the word ‘rant’ (e.g. rant75)
                -CPR category CCT
                -Full postal information, phone number, fax number, and email address
                -Agreed to latest CIRA Registrant Agreement version
             */
            Console.WriteLine("TEST: 4");
            var registrantContact = new Contact("rant" + registrarNumber,
                "Registrant Step Four", "Example Inc.",
                "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
                "*****@*****.**",
                new Telephone { Value = "+1.6478913606", Extension = "333" },
                new Telephone { Value = "+1.6478913607" });


            var registrantContactCmd = new CiraContactCreate(registrantContact);

            registrantContactCmd.CprCategory = CiraCprCategories.CCT;
            registrantContactCmd.AgreementVersion = agreementVersion;
            registrantContactCmd.AggreementValue = "Y";
            registrantContactCmd.Language = "en";
            registrantContactCmd.OriginatingIpAddress = "127.0.0.1";
            registrantContactCmd.CreatedByResellerId = registrarNumber;

            var response1 = service.Execute(registrantContactCmd);

            PrintResponse(response1);

            /*
             5. Create an administrative contact
             -the same ID as your Registrar Number prefixed with the word ‘admin’ (e.g. admin75)
             -using all mandatory elements required for a Canadian administrative contact
             -omit CPR category (he have not agreed to the CIRA agreement)
            */
            Console.WriteLine("TEST: 5");
            var adminContact = new Contact("admin" + registrarNumber,
               "Administrative Step Five", "Example Inc.",
               "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
               "*****@*****.**",
               new Telephone { Value = "+1.6478913606", Extension = "333" },
               new Telephone { Value = "+1.6478913607" });

            var adminContactCmd = new CiraContactCreate(adminContact);

            adminContactCmd.CprCategory = null;
            adminContactCmd.AgreementVersion = null;
            adminContactCmd.AggreementValue = null;
            adminContactCmd.Language = "en";
            adminContactCmd.OriginatingIpAddress = "127.0.0.1";
            adminContactCmd.CreatedByResellerId = registrarNumber;

            const string adminContactId = "admin" + registrarNumber;

            var loginresponse = service.Execute(adminContactCmd);

            PrintResponse(loginresponse);

            //6. Get information for the contact created in operation #4
            Console.WriteLine("TEST: 6");
            var getContactInfo = new ContactInfo(registrantContact.Id);

            var contactInfoResponse = service.Execute(getContactInfo);

            PrintResponse(contactInfoResponse);

            //7. Do a Registrant transfer for domain <registrar number>-3.ca to the Registrant created in operation #4
            Console.WriteLine("TEST: 7");

            //NOTE: registrant transfers are domain updates

            var registrantTransferCmd = new DomainUpdate(registrarNumber + "-3.ca");
            //var registrantTransferCmd = new DomainUpdate("3406310-4.ca");

            var domainChange = new DomainChange { RegistrantContactId = registrantContact.Id };

            registrantTransferCmd.DomainChange = domainChange;

            var response2 = service.Execute(registrantTransferCmd);

            PrintResponse(response2);

            //8. Update the contact created in operation #4 to no longer have a fax number
            Console.WriteLine("TEST: 8");
            var contactUpdateCmd = new ContactUpdate(registrantContact.Id);

            var contactChange = new ContactChange(registrantContact);

            contactChange.Fax = new Telephone("", "");

            contactUpdateCmd.ContactChange = contactChange;

            //NOTE:the docs say that the cpr category is update for domain contact
            //but they show a sample of a contact update request that does not include the extension
            //NOTE: Organization cannot be entered when CPR Category indicates a non individual - see documentation
            contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension { CprCategory = CiraCprCategories.CCT });

            var response3 = service.Execute(contactUpdateCmd);

            PrintResponse(response3);

            //8.1 Get contact info and check the fax number dissapeared
            var contactInfoCmd1 = new ContactInfo(registrantContact.Id);

            var contactInfoResponse1 = service.Execute(contactInfoCmd1);

            PrintResponse(contactInfoResponse1);

            //9. Do a domain:check on <registrar number>a.ca
            Console.WriteLine("TEST: 9");
            const string domainStep10 = registrarNumber + "a.ca";

            var domainCheckCmd = new DomainCheck(domainStep10);

            var response4 = service.Execute(domainCheckCmd);

            PrintResponse(response4);

            /*
             10. Create a domain using:
             -a domain name set to <registrar number>a.ca
             -a Registrant who is a Permanent Resident
             -the same administrative contact as the Registrant
             -0 hosts
             -the minimum registration period
            */
            Console.WriteLine("TEST: 10");
            //NOTE: CPR categories CCT and RES where merged into CCR

            //BUG: the registrant needs to be a Permanent Resident
            //TODO: create a new contact that is a permanent resident
            //10.1 
            var registrantContact10 = new Contact("ten" + registrarNumber,
               "Registrant Step Ten", "Example Inc.",
               "Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
               "*****@*****.**",
               new Telephone { Value = "+1.6478913606", Extension = "333" },
               new Telephone { Value = "+1.6478913607" });


            registrantContactCmd = new CiraContactCreate(registrantContact10);
            registrantContactCmd.CprCategory = CiraCprCategories.RES;
            registrantContactCmd.AgreementVersion = agreementVersion;
            registrantContactCmd.AggreementValue = "Y";
            registrantContactCmd.OriginatingIpAddress = "127.0.0.1";
            registrantContactCmd.Language = "en";
            registrantContactCmd.CreatedByResellerId = registrarNumber;

            //ContactCreate.MakeContact(registrantContact10,  agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var response5 = service.Execute(registrantContactCmd);

            PrintResponse(response5);

            //10.2
            var domainCreateCmd = new DomainCreate(domainStep10, registrantContact10.Id);

            domainCreateCmd.DomainContacts.Add(new DomainContact(registrantContact10.Id, "admin"));

            //NOTE: password is compulsory
            domainCreateCmd.Password = "******";

            var response6 = service.Execute(domainCreateCmd);

            PrintResponse(response6);

            /*11. Do a host:check on hosts <registrar number>.example.com and <registrar number>.example.net*/
            Console.WriteLine("TEST: 11");
            var hostCheckCmd = new HostCheck(new List<string> { registrarNumber + ".example.com", registrarNumber + ".example.net" });

            var response7 = service.Execute(hostCheckCmd);

            PrintResponse(response7);

            /*
             12. Create 2 hosts with the following name formats:
             <registrar number>.example.com
             <registrar number>.example.net
             */
            Console.WriteLine("TEST: 12");
            //CIRA only creates a host at a time

            //12.1
            var hostCreateCmd = new HostCreate(new Host(registrarNumber + ".example.com"));

            var response8 = service.Execute(hostCreateCmd);

            PrintResponse(response8);

            //12.2
            hostCreateCmd = new HostCreate(new Host(registrarNumber + ".example.net"));

            var response9 = service.Execute(hostCreateCmd);

            PrintResponse(response9);

            /*
             13. Create a domain using:
             -a domain name set to <registrar number>b.ca
             -the pre-populated contact id <registrar number> as the administrative contact
             -a Registrant who is a Corporation
             -2 hosts created in operation #12 <- the nameservers
             -a maximum registration period (10 years)
             */
            Console.WriteLine("TEST: 13");
            //13.1 - Create a corporation

            //If it is a corporation you can not provide company name
            var corporation = new Contact("corp" + registrarNumber, "Acme Corp.", null, "Toronto",
                                          "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                          new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createCorporationContactCmd = ContactCreate.MakeContact(corporation, CiraCprCategories.CCO, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createCorporationContactCmd = new CiraContactCreate(corporation);
            createCorporationContactCmd.CprCategory = CiraCprCategories.CCO;
            createCorporationContactCmd.AgreementVersion = agreementVersion;
            createCorporationContactCmd.AggreementValue = "Y";
            createCorporationContactCmd.OriginatingIpAddress = "127.0.0.1";
            createCorporationContactCmd.Language = "en";
            createCorporationContactCmd.CreatedByResellerId = registrarNumber;

            var response10 = service.Execute(createCorporationContactCmd);

            PrintResponse(response10);

            /* var domainUpdateCmd = new DomainUpdate(registrarNumber + "-10.ca");

             domainUpdateCmd.ToRemove.Status.Add(new Status("", "serverDeleteProhibited"));

             response = service.Execute(domainUpdateCmd);

             PrintResponse(response);*/

            //13.2 - Create the domain

            //var createDomainCmd = new DomainCreate(registrarNumber + "b.ca", corporation.Id);
            var createDomainCmd = new DomainCreate(registrarNumber + "b.ca", "corp" + registrarNumber);

            createDomainCmd.Period = new DomainPeriod(10, "y");

            //NOTE:The administrative or technical contact must be an Individual
            //BUG: admin contact needs be the prepopulated 3406310
            createDomainCmd.DomainContacts.Add(new DomainContact(registrarNumber, "admin"));

            //NOTE:Create the host on the Registry system before you assign it to a domain
            createDomainCmd.NameServers.Add(registrarNumber + ".example.com");
            createDomainCmd.NameServers.Add(registrarNumber + ".example.net");

            createDomainCmd.Password = "******";

            var response11 = service.Execute(createDomainCmd);

            PrintResponse(response11);

            /*
             14. Create a domain using: 
             - a domain name set to <registrar number>c.ca
             - a Registrant who is an Association
             - the administrative contact set to the contact created in operation #5
             - maximum number of technical contacts assigned to it (max is 3)
            - 0 hosts
            - a 2-year term
             */
            Console.WriteLine("TEST: 14");
            var association = new Contact("assoc" + registrarNumber, "Beer Producers Association", null, "Toronto",
                                          "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                          new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createAssociationContactCmd = ContactCreate.MakeContact(association, CiraCprCategories.ASS, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createAssociationContactCmd = new CiraContactCreate(association);
            createAssociationContactCmd.CprCategory = CiraCprCategories.ASS;
            createAssociationContactCmd.AgreementVersion = agreementVersion;
            createAssociationContactCmd.AggreementValue = "Y";
            createAssociationContactCmd.OriginatingIpAddress = "127.0.0.1";
            createAssociationContactCmd.Language = "en";
            createAssociationContactCmd.CreatedByResellerId = registrarNumber;

            var response12 = service.Execute(createAssociationContactCmd);

            PrintResponse(response12);

            //tech1
            var tech1 = new Contact("tech1" + registrarNumber, "Technician #1", "Beer Producers Association", "Toronto",
                                          "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                          new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createTech1ContactCmd = ContactCreate.MakeContact(tech1, CiraCprCategories.CCT, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createTech1ContactCmd = new CiraContactCreate(tech1);
            createTech1ContactCmd.CprCategory = CiraCprCategories.CCT;
            createTech1ContactCmd.AgreementVersion = agreementVersion;
            createTech1ContactCmd.AggreementValue = "Y";
            createTech1ContactCmd.OriginatingIpAddress = "127.0.0.1";
            createTech1ContactCmd.Language = "en";
            createTech1ContactCmd.CreatedByResellerId = registrarNumber;

            var response13 = service.Execute(createTech1ContactCmd);

            PrintResponse(response13);

            //tech2
            var tech2 = new Contact("tech2" + registrarNumber, "Technician #2", "Beer Producers Association", "Toronto",
                                          "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                          new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createTech2ContactCmd = ContactCreate.MakeContact(tech2, CiraCprCategories.CCT, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createTech2ContactCmd = new CiraContactCreate(tech2);
            createTech2ContactCmd.CprCategory = CiraCprCategories.CCT;
            createTech2ContactCmd.AgreementVersion = agreementVersion;
            createTech2ContactCmd.AggreementValue = "Y";
            createTech2ContactCmd.OriginatingIpAddress = "127.0.0.1";
            createTech2ContactCmd.Language = "en";
            createTech2ContactCmd.CreatedByResellerId = registrarNumber;

            var response14 = service.Execute(createTech2ContactCmd);

            PrintResponse(response14);

            //tech1
            var tech3 = new Contact("tech3" + registrarNumber, "Technician #3", "Beer Producers Association", "Toronto",
                                          "some where 22", "ON", "M6G2L1", "CA", "*****@*****.**",
                                          new Telephone("+1.1234567890", null), new Telephone("+1.1234567890", null));

            //var createTech3ContactCmd = ContactCreate.MakeContact(tech3, CiraCprCategories.CCT, agreementVersion, "Y", "127.0.0.1", "en", registrarNumber);

            var createTech3ContactCmd = new CiraContactCreate(tech3);
            createTech3ContactCmd.CprCategory = CiraCprCategories.CCT;
            createTech3ContactCmd.AgreementVersion = agreementVersion;
            createTech3ContactCmd.AggreementValue = "Y";
            createTech3ContactCmd.OriginatingIpAddress = "127.0.0.1";
            createTech3ContactCmd.Language = "en";
            createTech3ContactCmd.CreatedByResellerId = registrarNumber;


            var response15 = service.Execute(createTech3ContactCmd);

            PrintResponse(response15);

            const string step14domain = registrarNumber + "c.ca";

            createDomainCmd = new DomainCreate(step14domain, association.Id);

            createDomainCmd.Period = new DomainPeriod(2, "y");

            createDomainCmd.DomainContacts.Add(new DomainContact(adminContactId, "admin"));

            createDomainCmd.DomainContacts.Add(new DomainContact(tech1.Id, "tech"));
            createDomainCmd.DomainContacts.Add(new DomainContact(tech2.Id, "tech"));
            createDomainCmd.DomainContacts.Add(new DomainContact(tech3.Id, "tech"));

            createDomainCmd.Password = "******";

            var response16 = service.Execute(createDomainCmd);

            PrintResponse(response16);

            /*
             15. Do a host:check for a host which the dot-ca domain name is registered
            */
            Console.WriteLine("TEST: 15");
            hostCheckCmd = new HostCheck("any." + registrarNumber + "b.ca");

            var response17 = service.Execute(hostCheckCmd);

            PrintResponse(response17);

            /*
             16. Create 2 subordinate hosts for the domain created in operation #14:
              - with format ns1.<domain> and ns2.<domain>
              - with IPv4 address information
            */
            Console.WriteLine("TEST: 16");
            var host1 = new Host("ns1." + step14domain);
            host1.Addresses.Add(new HostAddress("127.0.0.1", "v4"));
            var host2 = new Host("ns2." + step14domain);
            host2.Addresses.Add(new HostAddress("127.0.0.2", "v4"));

            var createHostCmd = new HostCreate(host1);

            var response18 = service.Execute(createHostCmd);

            PrintResponse(response18);

            createHostCmd = new HostCreate(host2);

            response18 = service.Execute(createHostCmd);

            PrintResponse(response18);

            /*
             17. Using the correct EPP call, get information on a host
            */
            Console.WriteLine("TEST: 17");
            var hostInfoCmd = new HostInfo(host1.HostName);

            var response19 = service.Execute(hostInfoCmd);

            PrintResponse(response19);

            /*18. Update the domain created in operation #14 such that the hosts created in operation #16 are delegated to the domain explicitly*/
            Console.WriteLine("TEST: 18");
            var domainUpdateCmd = new DomainUpdate(step14domain);

            //NOTE: Nameservers need different IP addresses
            domainUpdateCmd.ToAdd.NameServers = new List<string> { host1.HostName, host2.HostName };

            var response20 = service.Execute(domainUpdateCmd);

            PrintResponse(response20);

            //19. Update host ns1.<domain> created in operation #16 such that an IPv6 address is added
            Console.WriteLine("TEST: 19");
            var hostUpdateCmd = new HostUpdate(host1.HostName);

            var eppHostUpdateAddRemove = new EppHostUpdateAddRemove();

            eppHostUpdateAddRemove.Adresses = new List<HostAddress> { new HostAddress("1080:0:0:0:8:800:2004:17A", "v6") };

            hostUpdateCmd.ToAdd = eppHostUpdateAddRemove;

            var response21 = service.Execute(hostUpdateCmd);
            PrintResponse(response21);

            //20. Update host ns1.<domain> created in operation #16 such that an IPv4 address is removed
            Console.WriteLine("TEST: 20");
            hostUpdateCmd = new HostUpdate(host1.HostName);

            eppHostUpdateAddRemove = new EppHostUpdateAddRemove();

            eppHostUpdateAddRemove.Adresses = new List<HostAddress> { new HostAddress("127.0.0.1", "v4") };

            hostUpdateCmd.ToRemove = eppHostUpdateAddRemove;

            var response22 = service.Execute(hostUpdateCmd);
            PrintResponse(response22);

            //21. Update the status of ns1.<domain> such that it can no longer be updated
            Console.WriteLine("TEST: 21");
            hostUpdateCmd = new HostUpdate(host1.HostName);

            eppHostUpdateAddRemove = new EppHostUpdateAddRemove();

            eppHostUpdateAddRemove.Status = new List<Status> { new Status("", "clientUpdateProhibited") };

            hostUpdateCmd.ToAdd = eppHostUpdateAddRemove;

            response22 = service.Execute(hostUpdateCmd);
            PrintResponse(response22);

            //22. Using the correct EPP call, get information on a domain name without using WHOIS
            Console.WriteLine("TEST: 22");

            //const string domainStep10 = registrarNumber + "a.ca";

            var domainInfoCmd = new DomainInfo(domainStep10);
            var domainInfo = service.Execute(domainInfoCmd);

            PrintResponse(domainInfo);

            //23. Renew the domain created in operation #10 such that the domain’s total length of term becomes 3 years
            Console.WriteLine("TEST: 23");
            var renewCmd = new DomainRenew(domainStep10, domainInfo.Domain.ExDate, new DomainPeriod(2, "y"));

            var response23 = service.Execute(renewCmd);
            PrintResponse(response23);

            /*
             24. Do a Registrar transfer:
             - Domain name <registrar number>X2-1.ca, from your ‘e’ Registrar account 
             - Have the system auto-generate the contacts so that their information is identical to the contacts in the ‘e’ account
             */
            Console.WriteLine("TEST: 24");

            var transferCmd = new CiraDomainTransfer(registrarNumber + "X2-1.ca", null, null, new List<string>());
            //var transferCmd = new DomainTransfer("3406310x2-5.ca", null, null, new List<string>());

            transferCmd.Password = "******";
            var response24 = service.Execute(transferCmd);

            PrintResponse(response24);

            /*25. Do a Registrar transfer:
              - Domain name, <registrar number>X2-2.ca, from your ‘e’ Registrar account
              - Specify the same Registrant, administrative, and technical contacts used for the domain created in operation #14
             */
            Console.WriteLine("TEST: 25");

            //BUG: did not use all the technical contacts.

            transferCmd = new CiraDomainTransfer(registrarNumber + "X2-2.ca", association.Id, adminContactId, new List<string> { tech1.Id, tech2.Id, tech3.Id });
            //transferCmd = new DomainTransfer("3406310x2-10.ca", association.Id, adminContactId, new List<string> { tech1.Id, tech2.Id, tech3.Id });

            //Password is mandatory
            //TODO: find it in the control panel
            transferCmd.Password = "******";
            response24 = service.Execute(transferCmd);

            PrintResponse(response24);

            /*
             26. Do an update to the domain created in operation #14 to change the administrative contact to the pre-populated contact whose id is of format <registrar number>
             */
            Console.WriteLine("TEST: 26");
            domainUpdateCmd = new DomainUpdate(step14domain);

            //remove the previous admin
            domainUpdateCmd.ToRemove.DomainContacts.Add(new DomainContact(adminContactId, "admin"));

            domainUpdateCmd.ToAdd.DomainContacts.Add(new DomainContact(registrarNumber, "admin"));

            var response25 = service.Execute(domainUpdateCmd);

            PrintResponse(response25);

            /*27. Do an update to the status of the domain created in operation #14 such that it cannot be deleted*/
            Console.WriteLine("TEST: 27");
            domainUpdateCmd = new DomainUpdate(step14domain);

            domainUpdateCmd.ToAdd.Status.Add(new Status("", "clientDeleteProhibited"));

            var response26 = service.Execute(domainUpdateCmd);

            PrintResponse(response26);

            /*28. Do an update to the email address of the pre-populated contact whose id is of format <registrar number> to "*****@*****.**" */
            Console.WriteLine("TEST: 28");
            //28.1 get the contact
            //var contactInfoCmd = new ContactInfo("rant" + registrarNumber);
            var contactInfoCmd = new ContactInfo(registrarNumber);

            contactInfoResponse = service.Execute(contactInfoCmd);

            PrintResponse(contactInfoResponse);

            if (contactInfoResponse.Contact != null)
            {

                //28.2 update the email address

                //ASSERT: contactInfoResponse.Contact != null
                contactUpdateCmd = new ContactUpdate(contactInfoResponse.Contact.Id);

                var contactchage = new ContactChange(contactInfoResponse.Contact);

                contactchage.Email = "*****@*****.**";

                contactUpdateCmd.ContactChange = contactchage;

                //the extensions are compulsory
                contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension { CprCategory = contactInfoResponse.Contact.CprCategory });

                var response27 = service.Execute(contactUpdateCmd);

                PrintResponse(response27);


            }
            else
            {
                Console.WriteLine("Error: contact does not exist?");
            }


            /*
                 29. Do an update to the privacy status for Registrant contact created in operation #4 to now show full detail
            */
            Console.WriteLine("TEST: 29");
            contactUpdateCmd = new ContactUpdate("rant" + registrarNumber);

            //Invalid WHOIS display setting - valid values are PRIVATE or FULL
            contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension { WhoisDisplaySetting = "FULL" });

            var response28 = service.Execute(contactUpdateCmd);

            PrintResponse(response28);


            /*30. Delete the domain <registrar number>-10.ca*/
            Console.WriteLine("TEST: 30");
            //NOTE:check this domain status

            var deleteDomainCmd = new DomainDelete(registrarNumber + "-10.ca");
            //var deleteDomainCmd = new DomainDelete(registrarNumber + "-9.ca");

            var response29 = service.Execute(deleteDomainCmd);
            PrintResponse(response29);

            /*31. EPP <logout> command*/
            Console.WriteLine("TEST:31");
            var logOutCmd = new Logout();

            service.Execute(logOutCmd);

            /*32. Disconnect SSL connection*/
            Console.WriteLine("TEST: 32");
            service.Disconnect();

            /*33. SSL connection establishment*/
            Console.WriteLine("TEST: 33");
            service.Connect();

            /*34. EPP <login> command with your ‘e’ account*/
            Console.WriteLine("TEST: 34");
            logingCmd = new Login("username", "password");

            response = service.Execute(logingCmd);

            PrintResponse(response);

            /*35. Acknowledge all poll messages*/
            Console.WriteLine("TEST: 35");
            var thereAreMessages = true;

            while (thereAreMessages)
            {
                //request
                var poll = new Poll { Type = PollType.Request };

                var pollResponse = (PollResponse)service.Execute(poll);

                PrintResponse(pollResponse);

                if (!String.IsNullOrEmpty(pollResponse.Id))
                {
                    //acknowledge
                    poll = new Poll { Type = PollType.Acknowledge, MessageId = pollResponse.Id };

                    pollResponse = (PollResponse)service.Execute(poll);

                    PrintResponse(pollResponse);
                }

                Console.WriteLine("Messages left in the queue:" + pollResponse.Count);

                thereAreMessages = pollResponse.Count != 0;
            }

            /*36. EPP <logout> command*/
            Console.WriteLine("TEST: 36");
            logOutCmd = new Logout();

            service.Execute(logOutCmd);


        }
Esempio n. 18
0
        public void logout(string name, string pass)
        {
            Logout lout = new Logout();
            lout.username = name;
            lout.password = pass;

            string send = JsonConvert.SerializeObject(lout);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://authserver.mojang.com/authenticate");

            request.Method = "POST";
            request.ContentType = "application/json";

            byte[] postBytes = Encoding.ASCII.GetBytes(send);

            Stream requestStream = request.GetRequestStream();

            requestStream.Write(postBytes, 0, postBytes.Length);
            requestStream.Close();
        }
Esempio n. 19
0
        public void LogoutTest()
        {
            Logout logout = new Logout(driver);

            logout.LogoutPage();
        }
Esempio n. 20
0
        public static void SendOrdersToRiskifiedExample()
        {
            #region preprocessing and loading config

            string domain    = ConfigurationManager.AppSettings["MerchantDomain"];
            string authToken = ConfigurationManager.AppSettings["MerchantAuthenticationToken"];
            RiskifiedEnvironment riskifiedEnv = (RiskifiedEnvironment)Enum.Parse(typeof(RiskifiedEnvironment), ConfigurationManager.AppSettings["RiskifiedEnvironment"]);

            // Generating a random starting order number
            // we need to send the order with a new order number in order to create it on riskified
            var rand     = new Random();
            int orderNum = rand.Next(1000, 200000);

            // Make orderNum a string to use as customer id
            string idString = $"customerId_{orderNum.ToString()}";

            #endregion

            #region order object creation

            // generate a new order - the sample generates a fixed order with same details but different order number each time
            // see GenerateOrder for more info on how to create the Order objects
            var order = GenerateOrder(orderNum);

            #endregion

            #region sending data to riskified

            // read action from console
            const string menu = "Commands:\n" +
                                "'p' for checkout\n" +
                                "'e' for checkout denied\n" +
                                "'c' for create\n" +
                                "'u' for update\n" +
                                "'s' for submit\n" +
                                "'d' for cancel\n" +
                                "'r' for partial refund\n" +
                                "'f' for fulfill\n" +
                                "'x' for decision\n" +
                                "'h' for historical sending\n" +
                                "'y' for chargeback submission\n" +
                                "'v' for decide (sync only)\n" +
                                "'l' for eligible for Deco payment \n" +
                                "'o' for opt-in to Deco payment \n" +
                                "'account' for account actions menu\n" +
                                "'q' to quit";

            const string accountActionsMenu = "Account Action Commands:\n" +
                                              "'li' for login(account)\n" +
                                              "'cc' for customer create (account)\n" +
                                              "'cu' for customer update (account)\n" +
                                              "'lo' for logout (account)\n" +
                                              "'pw' for password reset (account)\n" +
                                              "'wl' for wishlist (account)\n" +
                                              "'re' for redeem (account)\n" +
                                              "'co' for contact (account)\n" +
                                              "'menu' for main menu\n" +
                                              "'q' to quit";

            Console.WriteLine(menu);
            string commandStr = Console.ReadLine();


            // loop on console actions
            while (commandStr != null && (!commandStr.Equals("q")))
            {
                // the OrdersGateway is responsible for sending orders to Riskified servers
                OrdersGateway gateway = new OrdersGateway(riskifiedEnv, authToken, domain);
                try
                {
                    OrderNotification         res    = null;
                    AccountActionNotification accRes = null;
                    switch (commandStr)
                    {
                    case "menu":
                    case "account":
                        break;

                    case "p":
                        Console.WriteLine("Order checkout Generated with merchant order number: " + orderNum);
                        var orderCheckout = GenerateOrderCheckout(orderNum.ToString());
                        orderCheckout.Id = orderNum.ToString();

                        // sending order checkout for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.Checkout(orderCheckout);
                        break;

                    case "a":
                        Console.WriteLine("Order Advise Generated with merchant order number: " + orderNum);
                        var orderAdviseCheckout = GenerateAdviseOrderCheckout(orderNum.ToString());
                        orderAdviseCheckout.Id = orderNum.ToString();

                        // sending order checkout for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.Advise(orderAdviseCheckout);
                        break;

                    case "e":
                        Console.WriteLine("Order checkout Generated.");
                        var orderCheckoutDenied = GenerateOrderCheckoutDenied(orderNum);

                        Console.Write("checkout to deny id: ");
                        string orderCheckoutDeniedId = Console.ReadLine();

                        orderCheckoutDenied.Id = orderCheckoutDeniedId;

                        // sending order checkout for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.CheckoutDenied(orderCheckoutDenied);
                        break;

                    case "c":
                        Console.WriteLine("Order Generated with merchant order number: " + orderNum);
                        order.Id = orderNum.ToString();
                        orderNum++;
                        // sending order for creation (if new orderNum) or update (if existing orderNum)
                        res = gateway.Create(order);
                        break;

                    case "s":
                        Console.WriteLine("Order Generated with merchant order number: " + orderNum);
                        order.Id = orderNum.ToString();
                        orderNum++;
                        // sending order for submitting and analysis
                        // it will generate a callback to the notification webhook (if defined) with a decision regarding the order
                        res = gateway.Submit(order);
                        break;

                    case "v":
                        Console.WriteLine("Order Generated with merchant order number: " + orderNum);
                        order.Id = orderNum.ToString();
                        orderNum++;
                        // sending order for synchronous decision
                        // it will generate a synchronous response with the decision regarding the order
                        // (for sync flow only)
                        res = gateway.Decide(order);
                        break;

                    case "u":
                        Console.Write("Updated order id: ");
                        string upOrderId = Console.ReadLine();
                        order.Id = int.Parse(upOrderId).ToString();
                        res      = gateway.Update(order);
                        break;

                    case "d":
                        Console.Write("Cancelled order id: ");
                        string canOrderId = Console.ReadLine();
                        res = gateway.Cancel(
                            new OrderCancellation(
                                merchantOrderId: int.Parse(canOrderId),
                                cancelledAt: DateTime.Now,
                                cancelReason: "Customer cancelled before shipping"));
                        break;

                    case "r":
                        Console.Write("Refunded order id: ");
                        string refOrderId = Console.ReadLine();
                        res = gateway.PartlyRefund(
                            new OrderPartialRefund(
                                merchantOrderId: int.Parse(refOrderId),
                                partialRefunds: new[]
                        {
                            new PartialRefundDetails(
                                refundId: "12345",
                                refundedAt: DateTime.Now,              // make sure to initialize DateTime with the correct timezone
                                amount: 5.3,
                                currency: "USD",
                                reason: "Customer partly refunded on shipping fees")
                        }));
                        break;

                    case "f":
                        Console.Write("Fulfill order id: ");
                        string           fulfillOrderId   = Console.ReadLine();
                        OrderFulfillment orderFulfillment = GenerateFulfillment(int.Parse(fulfillOrderId));
                        res = gateway.Fulfill(orderFulfillment);

                        break;

                    case "x":
                        Console.Write("Decision order id: ");
                        string        decisionOrderId = Console.ReadLine();
                        OrderDecision orderDecision   = GenerateDecision(int.Parse(decisionOrderId));
                        res = gateway.Decision(orderDecision);

                        break;

                    case "h":
                        int startOrderNum     = orderNum;
                        var orders            = new List <Order>();
                        var financialStatuses = new[] { "paid", "cancelled", "chargeback" };
                        for (int i = 0; i < 22; i++)
                        {
                            Order o = GenerateOrder(orderNum++);
                            o.FinancialStatus = financialStatuses[i % 3];
                            orders.Add(o);
                        }
                        Console.WriteLine("Orders Generated with merchant order numbers: {0} to {1}", startOrderNum, orderNum - 1);
                        // sending 3 historical orders with different processing state
                        Dictionary <string, string> errors;
                        bool success = gateway.SendHistoricalOrders(orders, out errors);
                        if (success)
                        {
                            Console.WriteLine("All historical orders sent successfully");
                        }
                        else
                        {
                            Console.WriteLine("Some historical orders failed to send:");
                            Console.WriteLine(String.Join("\n", errors.Select(p => p.Key + ":" + p.Value).ToArray()));
                        }
                        break;

                    case "y":
                        Console.Write("Chargeback order id: ");
                        string          chargebackOrderId = Console.ReadLine();
                        OrderChargeback orderChargeback   = GenerateOrderChargeback(chargebackOrderId);
                        res = gateway.Chargeback(orderChargeback);

                        break;

                    case "l":
                        Console.Write("Check Deco eligibility on id: ");
                        string      eligibleOrderId     = Console.ReadLine();
                        OrderIdOnly eligibleOrderIdOnly = GenerateOrderIdOnly(eligibleOrderId);
                        res = gateway.Eligible(eligibleOrderIdOnly);

                        break;

                    case "o":
                        Console.Write("Opt-in to Deco payment on id: ");
                        string      optInOrderId     = Console.ReadLine();
                        OrderIdOnly optInOrderIdOnly = GenerateOrderIdOnly(optInOrderId);
                        res = gateway.OptIn(optInOrderIdOnly);

                        break;

                    case "li":
                        Console.Write("Login account action");
                        Login login = GenerateLogin(idString);

                        accRes = gateway.Login(login);
                        break;

                    case "cc":
                        Console.Write("Customer Create account action");
                        CustomerCreate customerCreate = GenerateCustomerCreate(idString);

                        accRes = gateway.CustomerCreate(customerCreate);
                        break;

                    case "cu":
                        Console.Write("Customer Update account action");
                        CustomerUpdate customerUpdate = GenerateCustomerUpdate(idString);

                        accRes = gateway.CustomerUpdate(customerUpdate);
                        break;

                    case "lo":
                        Console.Write("Logout account action");
                        Logout logout = GenerateLogout(idString);

                        accRes = gateway.Logout(logout);
                        break;

                    case "pw":
                        Console.Write("ResetPasswordRequest account action");
                        ResetPasswordRequest resetPasswordRequest = GenerateResetPasswordRequest(idString);

                        accRes = gateway.ResetPasswordRequest(resetPasswordRequest);
                        break;

                    case "wl":
                        Console.Write("WishlistChanges account action");
                        WishlistChanges wishlistChanges = GenerateWishlistChanges(idString);

                        accRes = gateway.WishlistChanges(wishlistChanges);
                        break;

                    case "re":
                        Console.Write("Redeem account action");
                        Redeem redeem = GenerateRedeem(idString);

                        accRes = gateway.Redeem(redeem);
                        break;

                    case "co":
                        Console.Write("Customer Reach-Out account action");
                        CustomerReachOut customerReachOut = GenerateCustomerReachOut(idString);

                        accRes = gateway.CustomerReachOut(customerReachOut);
                        break;
                    }


                    if (res != null)
                    {
                        Console.WriteLine("\n\nOrder sent successfully:" +
                                          "\nStatus at Riskified: " + res.Status +
                                          "\nOrder ID received:" + res.Id +
                                          "\nDescription: " + res.Description +
                                          "\nWarnings: " + (res.Warnings == null ? "---" : string.Join("        \n", res.Warnings)) + "\n\n");
                    }
                    if (accRes != null)
                    {
                        Console.WriteLine("\n\nAccount Action sent successfully:" +
                                          "\nDecision: " + accRes.Decision);
                    }
                }
                catch (OrderFieldBadFormatException e)
                {
                    // catching
                    Console.WriteLine("Exception thrown on order field validation: " + e.Message);
                }
                catch (RiskifiedTransactionException e)
                {
                    Console.WriteLine("Exception thrown on transaction: " + e.Message);
                }

                // ask for next action to perform
                Console.WriteLine();
                if (commandStr.Equals("account"))
                {
                    Console.WriteLine(accountActionsMenu);
                }
                else
                {
                    Console.WriteLine(menu);
                }
                commandStr = Console.ReadLine();
            }

            #endregion
        }
Esempio n. 21
0
        public void LogoutTest()
        {
            Logout logout = new Logout(driver);

            logout.LogoutFromFlipkart();
        }
Esempio n. 22
0
 public FrmCategory(Logout b)
 {
     InitializeComponent();
     Back = b;
 }
Esempio n. 23
0
 public static void InvokeLogout(Mobile m) => Logout?.Invoke(m);
 public FrmSupplier(Logout ex)
 {
     InitializeComponent();
     Exit = ex;
 }
Esempio n. 25
0
        public void TestLogoutCommand1()
        {
            string expected = File.ReadAllText("LogoutCommand1.xml");

            var command = new Logout();
            command.TransactionId = "ABC-12345";

            Assert.AreEqual(expected, command.ToXml().InnerXml);
        }
Esempio n. 26
0
 private void LogoutClick(object sender, RoutedEventArgs e)
 {
     Logout?.Invoke();
     Close();
 }
Esempio n. 27
0
        public void MyTestInitialize()
        {
            using (ShimsContext.Create())
            {
                // Set up the LoginControllerForTests
                LoginControllerForTests = DependencyResolver.Current.GetService<LoginController>();

                // Set up the LoginViewModelForTests
                var logout = new Logout();
                var myErrorLoggingService = new ErrorLoggingService();
                var mySingleConcurrentLoginRules = new SingleConcurrentLoginRules();
                var mySIMPLSessionEntitiesRepository = new SIMPLSessionEntitiesRepository(myErrorLoggingService);
                var mySingleConConcurrentLoginManager = new SingleConcurrentLoginManager(mySingleConcurrentLoginRules, myErrorLoggingService, mySIMPLSessionEntitiesRepository);
                LoginViewModelForTests = new LoginViewModel(logout, myErrorLoggingService, mySingleConcurrentLoginRules, mySingleConConcurrentLoginManager, mySIMPLSessionEntitiesRepository);
                ConfigControllerForTests = DependencyResolver.Current.GetService<ConfigController>();
            }
        }
Esempio n. 28
0
 private void LogoutBtn_Click(object sender, EventArgs e)
 {
     Logout?.Invoke(sender, EventArgs.Empty);
     MessageBox.Show("You have been logged out!", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }