Esempio n. 1
0
        public void Login()
        {
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone = "13101200141",
                type  = EnumSms.itype.RegLogin
            };

            smsClear.ClearSms(input.phone);
            accountClear.ClearUser(input.phone);
            accountClear.AddUser(input.phone);
            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0);
            var v2 = sms.CheckValidate(input.phone, input.type, "123456", "").Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v2.code == 0);
            var v = Newtonsoft.Json.JsonConvert.SerializeObject(v2.data);

            Newtonsoft.Json.JsonConvert.SerializeObject(v2.data);
            JObject data = Newtonsoft.Json.JsonConvert.DeserializeObject(v) as JObject;

            Assert.IsTrue(data["uid"] != null);

            accountClear.ClearUser(input.phone);
        }
Esempio n. 2
0
        public void SendBingPhoneExist()
        {
            ThreeLoginInfo three = new ThreeLoginInfo()
            {
                openid = "1",
                //类型 1 wx,2 qq,3 wb
                type = 1
            };
            string        token = JWTManager.Encode(three);
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone     = "13101200134",
                type      = EnumSms.itype.BingPhone,
                bingtoken = token
            };

            //添加用户
            smsClear.ClearBingTestUser(input.phone);
            smsClear.AddBingTestUser(input.phone, three.type);
            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 1010102);
            //清除用户
            smsClear.ClearBingTestUser(input.phone);
        }
Esempio n. 3
0
        public void BingPhoneExistBing()
        {
            AccountController account = new AccountController();
            ThreeLoginInfo    three   = new ThreeLoginInfo()
            {
                openid = "13101200146",
                //类型 1 wx,2 qq,3 wb
                type     = 1,
                nickname = "unittest",
            };
            string        token = JWTManager.Encode(three);
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone     = "13101200146",
                type      = EnumSms.itype.BingPhone,
                bingtoken = token,
            };

            smsClear.ClearSms(input.phone);
            accountClear.ClearUser(input.phone);
            accountClear.AddBing(input.phone, three);

            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0);

            var v2 = sms.CheckValidate(input.phone, input.type, "123456", token).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v2.code == 1010203, "已经绑定手机验证失败");
            accountClear.ClearUser(input.phone);
        }
Esempio n. 4
0
        public int Register(string phone)
        {
            AccountController account = new AccountController();
            SmsController     sms     = new SmsController();
            InputSendSms      input   = new InputSendSms()
            {
                phone = phone,
                type  = EnumSms.itype.RegLogin
            };

            smsClear.ClearSms(input.phone);
            accountClear.ClearUser(input.phone);
            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0, "发送短信失败{0}", v1.msg);
            var v2 = sms.CheckValidate(input.phone, input.type, "123456", "").Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v2.code == 0, "验证短信失败{0}", v1.msg);
            var     v    = Newtonsoft.Json.JsonConvert.SerializeObject(v2.data);
            JObject data = Newtonsoft.Json.JsonConvert.DeserializeObject(v) as JObject;

            Assert.IsTrue(data["isExit"].Value <string>() == "1" && data["uid"] == null);
            var v3 = account.SetPwd(data["temptoken"].Value <string>(), input.phone, YJYSoft.YL.Common.Encrypt.MD5Encrypt("123456"), "0", "").Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v3.code == 0, "注册用户失败{0}", v3.msg);

            return(v3.data.uid);
        }
Esempio n. 5
0
        public void TestTypeError()
        {
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone = "13101200132",
                type  = 0
            };
            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 1010101);
        }
Esempio n. 6
0
        public void TestMethod1()
        {
            SmsController     sc    = new SmsController();
            AccountController ac    = new AccountController();
            InputSendSms      input = new InputSendSms()
            {
                phone     = "13179960679",
                type      = EnumSms.itype.RegLogin,
                bingtoken = "133"
            };

            sc.GetValidate(input);
            sc.CheckValidate("13179960679", EnumSms.itype.RegLogin, "123456", "1");
            ac.UpdatePwd("111111", "123456");
        }
Esempio n. 7
0
        public void SendRegLogin()
        {
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone = "13101200133",
                type  = EnumSms.itype.RegLogin
            };

            smsClear.ClearSms(input.phone);
            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0);
            smsClear.ClearSms(input.phone);
        }
Esempio n. 8
0
        public void RegLoginValidErro()
        {
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone = "13101200142",
                type  = EnumSms.itype.RegLogin
            };

            smsClear.ClearSms(input.phone);
            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0, "发送短信失败{0}", v1.msg);
            var v2 = sms.CheckValidate(input.phone, input.type, "123123", "").Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v2.code == 1010201, "验证码出错验证失败");
        }
Esempio n. 9
0
        public void LoginUserDisable()
        {
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone = "13101200143",
                type  = EnumSms.itype.RegLogin
            };

            smsClear.ClearSms(input.phone);
            accountClear.ClearUser(input.phone);
            accountClear.AddUser2(input.phone);
            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0);
            var v2 = sms.CheckValidate(input.phone, input.type, "123456", "").Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v2.code == 1010205, "用户禁用验证失败");

            accountClear.ClearUser(input.phone);
        }
Esempio n. 10
0
        public void FindPwd()
        {
            SmsController     sms     = new SmsController();
            AccountController account = new AccountController();
            InputSendSms      input   = new InputSendSms()
            {
                phone = "13101200147",
                type  = EnumSms.itype.RetrievePassword
            };

            smsClear.ClearSms(input.phone);
            accountClear.ClearUser(input.phone);
            accountClear.AddUser(input.phone);

            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0, "发送短信{0}", v1.msg);

            var v2 = account.FindPwd(input.phone, YJYSoft.YL.Common.Encrypt.MD5Encrypt("123456"), "123456").Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v2.code == 0, "找回密码{0}", v1.msg);
        }
Esempio n. 11
0
        public void BingPhone()
        {
            AccountController account = new AccountController();
            ThreeLoginInfo    three   = new ThreeLoginInfo()
            {
                openid = "13101200144",
                //类型 1 wx,2 qq,3 wb
                type     = 1,
                nickname = "unittest",
            };
            string        token = JWTManager.Encode(three);
            SmsController sms   = new SmsController();
            InputSendSms  input = new InputSendSms()
            {
                phone     = "13101200144",
                type      = EnumSms.itype.BingPhone,
                bingtoken = token,
            };

            smsClear.ClearSms(input.phone);
            accountClear.ClearUser(input.phone);

            var v1 = sms.GetValidate(input).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v1.code == 0);

            var v2 = sms.CheckValidate(input.phone, input.type, "123456", token).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v2.code == 0, "绑定用户验证短信失败{0}", v2.msg);

            var v = Newtonsoft.Json.JsonConvert.SerializeObject(v2.data);

            Newtonsoft.Json.JsonConvert.SerializeObject(v2.data);
            JObject data = Newtonsoft.Json.JsonConvert.DeserializeObject(v) as JObject;
            var     v3   = account.SetPwd(data["temptoken"].Value <string>(), input.phone, YJYSoft.YL.Common.Encrypt.MD5Encrypt("123456"), "1", token).Data as YJYSoft.YL.Common.AjaxResult;

            Assert.IsTrue(v3.code == 0, "绑定用户失败{0}", v3.msg);
            accountClear.ClearUser(input.phone);
        }