Esempio n. 1
0
        public async Task <VerifyModel> payfoneVerify(VerifyRequestModel input)  //verify endpoint
        {
            input.requestId = Guid.NewGuid().ToString();

            string body = JsonConvert.SerializeObject(input, Newtonsoft.Json.Formatting.None,
                                                      new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });
            String a = await ProcessToken();

            var request = new HttpRequestMessage()
            {
                RequestUri = new Uri("https://api.staging.payfone.com/identity/verify/v2"),
                Method     = HttpMethod.Post,
                Content    = new System.Net.Http.StringContent(body, Encoding.UTF8, "application/json")
            };

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accesstoken);
            request.Headers.Add("Accept", "application/json");
            try
            {
                var response = await client.SendAsync(request);

                var responseBody = await response.Content.ReadAsStringAsync();

                VerifyModel model = JsonConvert.DeserializeObject <VerifyModel>(responseBody);
                return(model);
            } catch (AggregateException ex)
            {
                Console.WriteLine(String.Format("Error in request. Http Status Code: {0}", ex.InnerExceptions[0]));
                return(null);
            }
        }
        public void  是同花順是順子()
        {
            List <CardModel> cards = new List <CardModel>
            {
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.A
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.K
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.J
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Ten
                },
                new CardModel {
                    Type = CardTypeEnum.Club, Value = CardEnum.Q
                },
            };
            VerifyModel verify     = cards.GetVerifyModel();
            bool        isValidate = new StraightFlushCardVerify(verify).IsValidate();

            Assert.IsFalse(isValidate);
        }
Esempio n. 3
0
        public void  是三條是對子()
        {
            List <CardModel> cards = new List <CardModel>
            {
                new CardModel {
                    Type = CardTypeEnum.Club, Value = CardEnum.Two
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Three
                },
                new CardModel {
                    Type = CardTypeEnum.Heart, Value = CardEnum.Four
                },
                new CardModel {
                    Type = CardTypeEnum.Spade, Value = CardEnum.A
                },
                new CardModel {
                    Type = CardTypeEnum.Club, Value = CardEnum.A
                },
            };
            VerifyModel verify     = cards.GetVerifyModel();
            bool        isValidate = new ThreeOfAKindCardVerify(verify).IsValidate();

            Assert.IsFalse(isValidate);
        }
Esempio n. 4
0
        public void NullAssertUnit()
        {
            //类型
            VerifyModel model = null;

            model.IsNull();
            model.NotNull();

            //引用类型
            string str = "";

            //默认值和NULL都为true
            str.IsNull();
            str.NotNull();
            str.IsNull(false);
            str.NotNull(false);

            //值类型
            int value = 0;

            //默认值和NULL都为true
            value.IsNull();
            value.IsNull(false);
            value.NotNull();
            value.NotNull(false);

            Assert.IsTrue(true);
        }
        public object VerifyPerson(VerifyModel model)
        {
            if (!ModelState.IsValid)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Exception, GlobalConstant.参数异常.ToString(), null));
            }
            Bane_User user = operateContext.bllSession.Bane_User.Select(s => s.user_identify == model.user_identify).FirstOrDefault();

            if (null == user)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Error, "系统不存在此身份证的用户,请核对后再试!", null));
            }
            //1.验证成功自动生成尿检记录
            operateContext.bllSession.Bane_UrinalysisRecord.AutoAddUrinalysisRecordUser(model.user_identify);
            //2.更新下次尿检时间
            Bane_UrinalysisTimeSet set = operateContext.bllSession.Bane_UrinalysisTimeSet.Select(s => s.user_type.Equals(user.user_type), o => o.gap_month, true).FirstOrDefault();
            int addMonth = 1;

            if (set != null)
            {
                addMonth = set.gap_month;
            }
            user.ur_next_date = DateTime.Now.AddMonths(addMonth);
            operateContext.bllSession.Bane_User.Modify(user, s => s.user_identify == model.user_identify, "ur_next_date");
            return(operateContext.RedirectWebApi(WebResultCode.Ok, "验证成功流程任务已启动", null));
        }
        public void WhenSpotProductDoesNotHaveClashThenThatIsValidAndDoNotLogWarning()
        {
            // Arrange
            var product = _fixture
                          .Build <Product>()
                          .Without(p => p.ClashCode)
                          .Create();

            var spot = _fixture
                       .Build <Spot>()
                       .With(p => p.Product, product.Externalidentifier)
                       .Create();

            var productsByExternalReferences = new[] { product }.IndexListByExternalID();

            var clashesByExternalReferences = ImmutableDictionary <string, Clash> .Empty;
            var logWarningMessages          = new List <string>();

            // Act
            IReadOnlyCollection <Spot> allSpots = new List <Spot> {
                spot
            };

            VerifyModel.VerifySpotProductsReferences(
                _dummySalesAreaName,
                allSpots,
                productsByExternalReferences,
                clashesByExternalReferences,
                logWarningMessages.Add
                );

            // Assert
            Assert.Empty(logWarningMessages);
        }
        public void WhenSpotReferencedProductIsNotFoundThenLogWarning()
        {
            // Arrange
            var spot = _fixture
                       .Build <Spot>()
                       .With(p => p.Product, _fixture.Create <string>())
                       .Create();

            IImmutableDictionary <string, Product> productsByExternalReferences = Enumerable.Empty <Product>().IndexListByExternalID();
            var clashesByExternalReferences = ImmutableDictionary <string, Clash> .Empty;
            var logWarningMessages          = new List <string>();

            // Act
            IReadOnlyCollection <Spot> allSpots = new List <Spot> {
                spot
            };

            VerifyModel.VerifySpotProductsReferences(
                _dummySalesAreaName,
                allSpots,
                productsByExternalReferences,
                clashesByExternalReferences,
                logWarningMessages.Add
                );

            // Assert
            Assert.Contains(
                $"Product {spot.Product} for sales area {_dummySalesAreaName} is referenced by " +
                $"spot(s) {spot.ExternalSpotRef} but it does not exist",
                logWarningMessages
                );
        }
Esempio n. 8
0
        /// <summary>
        /// 使用Http请求与使用token令牌构造验证数据。
        /// </summary>
        /// <param name="context">Http请求实例</param>
        /// <param name="token">令牌</param>
        /// <returns>验证数据实体类</returns>
        public static VerifyModel CreateVerifyModel(HttpContext context, string token)
        {
            VerifyModel verifyModel = CreateVerifyModel(context);

            verifyModel.Token = token;
            return(verifyModel);
        }
Esempio n. 9
0
        public void 葫蘆()
        {
            List <CardModel> cards = new List <CardModel>
            {
                new CardModel {
                    Type = CardTypeEnum.Club, Value = CardEnum.Three
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Three
                },
                new CardModel {
                    Type = CardTypeEnum.Heart, Value = CardEnum.A
                },
                new CardModel {
                    Type = CardTypeEnum.Spade, Value = CardEnum.A
                },
                new CardModel {
                    Type = CardTypeEnum.Club, Value = CardEnum.A
                },
            };
            VerifyModel verify     = cards.GetVerifyModel();
            bool        isValidate = new FullHouseCardVerify(verify).IsValidate();

            Assert.IsTrue(isValidate);
        }
Esempio n. 10
0
        /// <summary>
        /// 验证消息
        /// </summary>
        protected virtual bool VerifyMessage(HttpContext context)
        {
            VerifyModel verifyModel = Verify.CreateVerifyModel(context, configModel.Token);//构造验证数据.

            this.verifyModel = verifyModel;

            if (Verify.VerifyModelValues(context, verifyModel) == false)
            {
                return(false);
            }

            //是否申请接入(首次接入)
            if (Verify.IsRequestJoin(verifyModel.Echostr) == true)
            {
                AllowJoinWeiXin(context, verifyModel.Echostr);
                return(false);//是接入请求,表明该消息无业务意义,只是一个握手而已,流程可以到此结束。
            }

            if (Verify.IsEncrypt(verifyModel) == true) //密文模式
            {
                return(true);                          //返回,交由腾讯验证类去处理。
            }
            else //是明文模式,交由我们自己处理。
            {
                //是否来自微信?
                if (Verify.IsFromWeiXin(context, verifyModel) == false)
                {
                    return(false);//不是微信,验证不通过。
                }
            }

            return(true);
        }
Esempio n. 11
0
        public static string CheckRequest(VerifyModel verifyModel)
        {
            //var result = client.NumberVerify.Check(new NumberVerify.CheckRequest
            //{
            //    request_id = verifyModel.RequestId,
            //    code = verifyModel.Code
            //});

            //return result.error_text;

            //=========================

            const string accountSid = "ACcc94bdb5e63f5d18a39cb479b39ccbde";
            const string authToken  = "20c2e1517fddd3dc6f83cbae74dfe9c9";

            TwilioClient.Init(accountSid, authToken);

            var verificationCheck = VerificationCheckResource.Create(
                to: "+84774543399",
                code: verifyModel.Code,
                pathServiceSid: "VAf73a8e1e711d3d54b9e738823e3543ff"
                );

            return("xyz");
        }
        public async Task OnPostWithLoggedInUserAndInvalidModelStateThenReturnPage()
        {
            // Arrange
            _userStore.Setup(
                x => x.FindByIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())
                ).ReturnsAsync(new ApplicationUser());

            var verifyModel = new VerifyModel(GetUserManager(), _verificationService.Object, _logger.Object);
            var context     = new Mock <HttpContext>();
            var session     = new Mock <ISession>();
            var value       = (byte[])null;
            var principal   = new Mock <ClaimsPrincipal>();

            principal.Setup(x => x.FindFirst(It.IsAny <string>()))
            .Returns(new Claim("name", "John Doe"));
            session.Setup(x => x.TryGetValue(It.IsAny <string>(), out value)).Returns(false);
            context.Setup(x => x.Session).Returns(session.Object);
            context.Setup(x => x.User).Returns(principal.Object);
            verifyModel.PageContext.HttpContext = context.Object;

            verifyModel.ModelState.AddModelError("key", "Another error");

            // Act
            var result = await verifyModel.OnPostAsync("");

            // Assert
            Assert.IsType <PageResult>(result);
        }
        public void  是雙對子是對子()
        {
            List <CardModel> cards = new List <CardModel>
            {
                new CardModel {
                    Type = CardTypeEnum.Club, Value = CardEnum.Two
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Two
                },
                new CardModel {
                    Type = CardTypeEnum.Heart, Value = CardEnum.K
                },
                new CardModel {
                    Type = CardTypeEnum.Spade, Value = CardEnum.J
                },
                new CardModel {
                    Type = CardTypeEnum.Club, Value = CardEnum.A
                },
            };
            VerifyModel verify     = cards.GetVerifyModel();
            bool        isValidate = new TwoPairsCardVerify(verify).IsValidate();

            Assert.IsFalse(isValidate);
        }
        public void  花順()
        {
            List <CardModel> cards = new List <CardModel>
            {
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.A
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Three
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Two
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Four
                },
                new CardModel {
                    Type = CardTypeEnum.Diamond, Value = CardEnum.Five
                },
            };
            VerifyModel verify     = cards.GetVerifyModel();
            bool        isValidate = new StraightFlushCardVerify(verify).IsValidate();

            Assert.IsTrue(isValidate);
        }
Esempio n. 15
0
        public async Task <IHttpActionResult> ReCaptchaVerify(VerifyModel Model)
        {
            String secret_key = "6LdSD84UAAAAANYhNhpJUef1_ydrERXTzmVXdH75";
            var    values     = new Dictionary <string, string>
            {
                { "secret", secret_key },
                { "response", Model.ResponseKey }
            };
            var content = new FormUrlEncodedContent(values);
            HttpResponseMessage response = await client.PostAsync("https://www.google.com/recaptcha/api/siteverify", content);

            if (response.IsSuccessStatusCode)
            {
                var          domain       = Request.Headers.Referrer? .GetLeftPart(UriPartial.Authority) ?? Request.Headers.UserAgent.ToString();
                SQL_function sql_function = new SQL_function();
                String       strQuery     = @"INSERT INTO [dbo].[Session] ([ID] ,[UserName] ,[TimeStampt] ,[IP], [isActive]) VALUES (@ID ,@UserName  ,Getdate() ,@IP, 1)";
                SqlCommand   cmd          = new SqlCommand(strQuery);
                cmd.Parameters.Add("@ID", SqlDbType.NVarChar).Value       = Model.ResponseKey.Substring(0, 50);
                cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = "Guest";
                cmd.Parameters.Add("@IP", SqlDbType.NVarChar).Value       = domain;
                sql_function.InsertUpdateData(cmd, "sqlconnString");
            }
            var responseString = await response.Content.ReadAsStringAsync();

            return(Ok(responseString));
        }
Esempio n. 16
0
        public ActionResult Verify(VerifyModel verifyModel)
        {
            var response = _purchasesCommand.Verify(verifyModel.EncodedTransactionReceipt);

            if (response.Status != 0)
            {
                ModelState.AddModelError("Verification", "Verification Failed");
            }
            else
            {
                try
                {
                    //Record the purchase
                    var employer = CurrentEmployer;

                    //Apple productIds are alphanumeric plus '_' and '.'
                    //ProductIds supplied from the app are our Guids with '_' subbed for '-'

                    var productId = new Guid(response.Receipt.ProductId.Replace('_', '-'));

                    var order = _ordersCommand.PrepareOrder(new[] { productId }, null, null, null);
                    _ordersCommand.RecordOrder(employer.Id, order,
                                               CreatePurchaser(employer),
                                               CreateReceipt(response));
                }
                catch (Exception ex)
                {
                    _eventSource.Raise(Event.Error, "Apple Verification", ex, new StandardErrorHandler());
                    ModelState.AddModelError("Verification", "There was a problem adding the credits you purchased to your account. Please contact LinkMe immediately to have these added manually.");
                }
            }

            return(Json(new JsonResponseModel()));
        }
Esempio n. 17
0
        private JsonResponseModel Verify(string encodedTransactionString)
        {
            var model = new VerifyModel {
                EncodedTransactionReceipt = encodedTransactionString
            };

            return(Deserialize <JsonResponseModel>(Post(_purchaseUrl, JsonContentType, Serialize(model))));
        }
        public void Verify_Model_Returns_False()
        {
            Datalist.Clear();
            bool        expected = false;
            VerifyModel _vf      = new VerifyModel(Datalist);
            bool        result   = _vf.Show();

            Assert.AreEqual(expected, result);
        }
Esempio n. 19
0
        public void VerifyUnit()
        {
            VerifyModel model = new VerifyModel();

            //model.StrField = "jskdlfjlsdjlflsdlfjlsdlkf";
            //model.IntField = 10;
            //model.DecimalField = 10.5264m;

            Assert.IsTrue(model.ModelValidation());
        }
        public JsonResult VerificationOTP([FromBody] VerifyModel model)
        {
            var user = _smssender.VerificationOTPLogin(model.otp);

            if (user == null)
            {
                return(Json(JsonResultResponse.ResponseFail("Verification failed. Login failed.")));
            }
            return(Json(JsonResultResponse.ResponseSuccess(user)));
        }
Esempio n. 21
0
        /// <summary>
        /// 验证VerifyModel的值,是否正常。并且带http输出。
        /// </summary>
        /// <param name="context"></param>
        /// <param name="verifyModel"></param>
        /// <returns></returns>
        public static bool VerifyModelValues(HttpContext context, VerifyModel verifyModel)
        {
            if (VerifyModelValues(verifyModel) == false)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("");
                return(false);
            }

            return(true);
        }
Esempio n. 22
0
        /// <summary>
        /// (附带Http响应输出)验证该请求是否来自微信。
        /// </summary>
        /// <param name="context">Http请求实例</param>
        /// <param name="token">令牌</param>
        /// <returns>是true/否false</returns>
        public static bool IsFromWeiXin(HttpContext context, VerifyModel verifyModel)
        {
            if (Verify.IsFromWeiXin(verifyModel) == false)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("欢迎访问久邻接口,请问你是微信吗?");
                return(false);
            }

            return(true);
        }
 public JsonResult VerificationOTP([FromBody] VerifyModel model)
 {
     if (ModelState.IsValid)
     {
         if (_optsender.VerificationOTP(model.otp) == true)
         {
             return(Json(JsonResultResponse.ResponseChange("Verification successed.")));
         }
     }
     return(Json(JsonResultResponse.ResponseFail("Verification failed.")));
 }
Esempio n. 24
0
        /// <summary>
        /// 验证VerifyModel的值,是否正常。
        /// </summary>
        /// <param name="verifyModel"></param>
        /// <returns></returns>
        public static bool VerifyModelValues(VerifyModel verifyModel)
        {
            if ((string.IsNullOrWhiteSpace(verifyModel.Signature) && string.IsNullOrWhiteSpace(verifyModel.MsgSignature)) || //两个Signature都为空,就不应该了。
                string.IsNullOrWhiteSpace(verifyModel.Token) ||
                string.IsNullOrWhiteSpace(verifyModel.Timestamp) ||
                string.IsNullOrWhiteSpace(verifyModel.Nonce))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 25
0
        public async Task <JsonResult> VerificationPaymentByOTP([FromBody] VerifyModel verify)
        {
            var result = _cart.VerificationPaymentByOTP(verify.otp, verify.UserId);

            if (result == false)
            {
                await Task.Delay(1000);

                return(Json(JsonResultResponse.ResponseFail("Verify failed.")));
            }
            await Task.Delay(1000);

            return(Json(JsonResultResponse.ResponseChange("Verify otp successed.")));
        }
Esempio n. 26
0
        public async Task <JsonResult> PayOnDelivery([FromBody] VerifyModel verify)
        {
            var result = _cart.PayOnDelivery(verify.UserId);

            if (result == false)
            {
                await Task.Delay(1000);

                return(Json(JsonResultResponse.ResponseFail("Payment failed.")));
            }
            await Task.Delay(1000);

            return(Json(JsonResultResponse.ResponseChange("Payment successed.")));
        }
Esempio n. 27
0
        public IActionResult ChangePassword()
        {
            VerifyModel verifyModel = HttpContext.Session.GetObject <VerifyModel>("verifyChangePW");

            if (verifyModel.Status)
            {
                // return change pasword page
                return(View());
            }
            else
            {
                // return to verify page
                return(RedirectToAction("VerifyChangePassword"));
            }
        }
Esempio n. 28
0
        public object VerifyPerson(VerifyModel model)
        {
            if (!ModelState.IsValid)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Exception, GlobalConstant.参数异常.ToString(), null));
            }
            Bane_User user = operateContext.bllSession.Bane_User.Select(s => s.user_identify == model.user_identify).FirstOrDefault();

            if (null == user)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Error, "系统不存在此身份证的用户,请核对后再试!", null));
            }
            //1:验证当前人员是否到达检测时间:检测时间为:下一次时间的前7天内
            int days = (user.ur_next_date - DateTime.Now).Days;//下一次检测时间,当前时间(时间差天数)

            //1.1 判断是否达到检测日期
            if (days > 7)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Error, "当前人员还未到达检测日期,请:" + (days - 7).ToString() + "天后再检测!", null));
            }
            //2:验证成功自动生成尿检记录
            operateContext.bllSession.Bane_UrinalysisRecord.AutoAddUrinalysisRecordUser(model.user_identify);
            //3:更新下次尿检时间
            Bane_UrinalysisTimeSet set = operateContext.bllSession.Bane_UrinalysisTimeSet.Select(s => s.user_type.Equals(user.user_type), o => o.gap_month, true).FirstOrDefault();
            int addMonth = 1,//间隔检测月数
                gapMonth;

            if (set != null)
            {
                addMonth = set.gap_month;
            }
            gapMonth = (addMonth - 1) * 30 + 24;
            if (days < gapMonth)
            {
                user.ur_next_date = user.ur_next_date.AddMonths(addMonth);
            }
            else if (days == gapMonth)
            {
                user.ur_next_date = user.ur_next_date.AddMonths(addMonth * 2);
            }
            else if (days > gapMonth)
            {
                int tempMonth = (days / gapMonth) * addMonth + (days % gapMonth) > 0 ? addMonth : 0;
                user.ur_next_date = user.ur_next_date.AddMonths(tempMonth);
            }
            operateContext.bllSession.Bane_User.Modify(user, s => s.user_identify == model.user_identify, "ur_next_date");
            return(operateContext.RedirectWebApi(WebResultCode.Ok, "验证成功流程任务已启动", null));
        }
        public void OnGetReturnUrlIsAssignedAndPageReturned()
        {
            // Arrange
            var verifyModel = new VerifyModel(GetUserManager(), _verificationService.Object, _logger.Object);
            var context     = new Mock <HttpContext>();

            context.Setup(x => x.User).Returns(new Mock <ClaimsPrincipal>().Object);
            verifyModel.PageContext.HttpContext = context.Object;

            // Act
            var result = verifyModel.OnGet("returnUrl");

            // Assert
            Assert.Equal("returnUrl", verifyModel.ReturnUrl);
            Assert.IsType <PageResult>(result);
        }
Esempio n. 30
0
        public IActionResult ChangePassword(string newPassword)
        {
            VerifyModel verifyModel = HttpContext.Session.GetObject <VerifyModel>("verifyChangePW");

            CredentialModel credential = JsonConvert.DeserializeObject <CredentialModel>(HttpContext.Session.GetString("vm"));
            string          token      = credential.JwToken;
            // get account for update
            Account account = GetApiAccounts.GetAccounts().SingleOrDefault(p => p.AccountId == Int32.Parse(credential.AccountId));

            // update password
            account.AccountPassword = Encryptor.MD5Hash(newPassword);

            GetApiAccounts.Update(account, token);

            return(NoContent());
        }
Esempio n. 31
0
 public ActionResult Index(VerifyModel model)
 {
     return RedirectToAction("Index", "Home");
 }