public string GetToken(string v) { ApiResult apiResult; var jsonStr = ""; var decrypt = AesUtility.Decrypt(v); try { var model = decrypt.FromJson <GetTokenModel.Input>(); var checkResult = model.IsValid <string>(); if (checkResult.ErrorCode != EnumItem.Get(Ref.ErrorCode._000).FinalValue) { jsonStr = ReturnJsonString(checkResult); return(jsonStr); } var service = new SecurityService(); apiResult = service.Execute(model); jsonStr = ReturnJsonString(apiResult); } catch (Exception ex) { LogRecord.Create() .SetMessage(ex.Message) .Error() ; } return(jsonStr); }
public void IsValidTest() { GetTokenModel model1 = new GetTokenModel(); var result1 = model1.IsValid <ApiResult>(); var expected = EnumItem.Get(Ref.ErrorCode._002).FinalValue; var actual = result1.ErrorCode; Assert.AreEqual(expected, actual); }
public void IsValidTest() { GetTokenModel.Input model1 = new GetTokenModel.Input(); var result1 = model1.IsValid <GetTokenModel.Ouput>(); var expected = EnumItem.Get(Ref.ErrorCode._002).FinalValue; var actual = result1.ErrorCode; Assert.AreEqual(expected, actual); GetTokenModel.Input model2 = new GetTokenModel.Input(); model2.CallTime = DateTime.Now.ToString("yyyyMMddhhmmss"); model2.MachineID = "machineA"; model2.Mask = model1.GetInMask(); model2.CallTime = DateTime.Now.ToString("yyyyMMddhhmmss"); var result2 = model2.IsValid <GetTokenModel.Ouput>(); var exp = EnumItem.Get(Ref.ErrorCode._001).FinalValue; var act = result2.ErrorCode; Assert.AreEqual(exp, act); }