예제 #1
0
파일: WXPost.cs 프로젝트: yangenping/wxku
 public override ResponseMessage OnLocationMessage(RequestLocation requestLocation)
 {
     return(new ResponseText()
     {
         Content = "收到地址" + requestLocation.Location_X + "|" + requestLocation.Location_Y
     });
 }
예제 #2
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="parameterName"></param>
 /// <param name="parameterValue"></param>
 /// <param name="location"></param>
 /// <param name="test"></param>
 public TestJob(string parameterName, string parameterValue, RequestLocation location, CustomTestDef test)
 {
     // TODO: Complete member initialization
     _parameterName   = parameterName;
     _parameterValue  = parameterValue;
     _requestLocation = location;
     _testDef         = test;
 }
예제 #3
0
        public Task <BaseMessage> HandleLocation(RequestLocation info)
        {
            BaseMessage response = new ResponseText(info)
            {
                Content = Msg
            };

            return(Task.FromResult(response));
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlogRequest"/> class.
 /// </summary>
 public BlogRequest(string host, string subfolder, Uri url, bool isLocal, RequestLocation requestLocation,
     string applicationPath)
 {
     Host = host;
     Subfolder = subfolder;
     RawUrl = url;
     IsLocal = isLocal;
     RequestLocation = requestLocation;
     ApplicationPath = applicationPath;
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlogRequest"/> class.
 /// </summary>
 public BlogRequest(string host, string subfolder, Uri url, bool isLocal, RequestLocation requestLocation,
                    string applicationPath)
 {
     Host            = host;
     Subfolder       = subfolder;
     RawUrl          = url;
     IsLocal         = isLocal;
     RequestLocation = requestLocation;
     ApplicationPath = applicationPath;
 }
예제 #6
0
        public IActionResult GetHomeContent(RequestLocation location)
        {
            var authorization = AuthorizationString();

            if (location == null)
            {
                return(BadRequest());
            }
            var contentHome = homeService.GetHomeContent(authorization);

            return(Ok(contentHome));
        }
        /// <summary>
        /// Constructs definition from tab separated values
        /// </summary>
        /// <param name="tabSeparatedValues"></param>
        public HttpVariableDefinition(string tabSeparatedValues)
        {
            string[] values = tabSeparatedValues.Split(new string [1] {
                Constants.VALUES_SEPARATOR
            }, StringSplitOptions.RemoveEmptyEntries);
            if (values.Length != 3)
            {
                throw new Exception("Improper parameter definition");
            }

            Name     = values[0];
            Location = (RequestLocation)Enum.Parse(typeof(RequestLocation), values[1]);
            Regex    = values[2];
        }
예제 #8
0
        public override int GetHashCode()
        {
            int hashCode = 786331036;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Text);

            hashCode = hashCode * -1521134295 + RequestContact.GetHashCode();
            hashCode = hashCode * -1521134295 + RequestLocation.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <KeyboardButtonPollType?> .Default.GetHashCode(RequestPoll);

            hashCode = hashCode * -1521134295 + EqualityComparer <WebAppInfo?> .Default.GetHashCode(WebApp);

            return(hashCode);
        }
예제 #9
0
        /// <summary>
        /// Returns the specified portion of the request
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public string GetRequestComponentString(RequestLocation location)
        {
            string component = String.Empty;

            switch (location)
            {
            case RequestLocation.Body: component = ContentDataString; break;

            case RequestLocation.Path: component = _path; break;

            case RequestLocation.Query: component = _queryString; break;

            case RequestLocation.Cookies: component = _headers["Cookie"]; break;
            }

            return(component);
        }
예제 #10
0
        /// <summary>
        /// Constructor for a HttpVariables collection
        /// </summary>
        /// <param name="source"></param>
        /// <param name="location"></param>
        public HttpVariables(string source, RequestLocation location) : base(StringComparer.OrdinalIgnoreCase)
        {
            MatchCollection matches;

            _location = location;

            _originalString = source;


            int n = _variablesDefinitions.Count - 1, i;

            for (i = n; i > -1; i--)
            {
                if (_variablesDefinitions[i].Location == location && Utils.IsMatch(_originalString, _variablesDefinitions[i].Regex))
                {
                    _matchingDefinition = _variablesDefinitions[i];

                    break;
                }
            }

            if (_matchingDefinition != null)
            {
                matches = Regex.Matches(_originalString, _matchingDefinition.Regex, RegexOptions.IgnoreCase | RegexOptions.Singleline);


                foreach (Match m in matches)
                {
                    if (m.Groups.Count > 2)
                    {
                        string name = m.Groups[1].Value.Trim();
                        if (!String.IsNullOrWhiteSpace(name) && !this.ContainsKey(name))
                        {
                            this.Add(name, m.Groups[2].Value.Trim());
                        }
                    }
                }
            }
        }
예제 #11
0
        /// <summary>
        /// 接收到客户发来的地理位置消息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="doc"></param>
        private void _OnLocationMessage(HttpContext context, System.Xml.XmlDocument doc)
        {
//            <xml>
//<ToUserName><![CDATA[toUser]]></ToUserName>
//<FromUserName><![CDATA[fromUser]]></FromUserName>
//<CreateTime>1351776360</CreateTime>
//<MsgType><![CDATA[location]]></MsgType>
//<Location_X>23.134521</Location_X>
//<Location_Y>113.358803</Location_Y>
//<Scale>20</Scale>
//<Label><![CDATA[位置信息]]></Label>
//<MsgId>1234567890123456</MsgId>
//</xml>
            string toUserName   = doc.GetElementsByTagName("ToUserName")[0].InnerText;
            string fromUserName = doc.GetElementsByTagName("FromUserName")[0].InnerText;
            string createTime   = doc.GetElementsByTagName("CreateTime")[0].InnerText;
            string location_X   = doc.GetElementsByTagName("Location_X")[0].InnerText;
            string location_Y   = doc.GetElementsByTagName("Location_Y")[0].InnerText;
            string scale        = doc.GetElementsByTagName("Scale")[0].InnerText;
            string label        = doc.GetElementsByTagName("Label")[0].InnerText;
            string msgId        = doc.GetElementsByTagName("MsgId")[0].InnerText;

            RequestLocation rqMsg = new RequestLocation();

            rqMsg.ToUserName   = toUserName;
            rqMsg.FromUserName = fromUserName;
            rqMsg.CreateTime   = new DateTime(long.Parse(createTime));
            rqMsg.Location_X   = location_X;
            rqMsg.Location_Y   = location_Y;
            rqMsg.Label        = label;
            rqMsg.MsgId        = msgId;

            ResponseMessage rpMsg = OnLocationMessage(rqMsg);

            SendResponseMessage(context, rpMsg, rqMsg);
        }
예제 #12
0
        /// <summary>
        /// Executes a set of tests on the specified url
        /// </summary>
        /// <param name="rawRequest"></param>
        /// <param name="rawResponse"></param>
        /// <param name="requestUri"></param>
        /// <param name="parameterName"></param>
        /// <param name="parameterValue"></param>
        /// <param name="testsToExecute"></param>
        public void ExecuteTests(string rawRequest, string rawResponse, Uri requestUri, string parameterName, string parameterValue, RequestLocation location, params CustomTestDef[] testsToExecute)
        {
            //remove any special characters coming from AppScan
            parameterName = CleanupParameterName(parameterName);

            if (!String.IsNullOrWhiteSpace(_testFile.PatternEntityExclusion) && Regex.IsMatch(parameterName, _testFile.PatternEntityExclusion))
            {
                _testController.Log("Skipping tests for entity '{0}' due to exclusion", parameterName);
                return;
            }

            if (!String.IsNullOrWhiteSpace(_testFile.PatternRequestExclusion) && Regex.IsMatch(rawRequest, _testFile.PatternRequestExclusion))
            {
                _testController.Log("Skipping tests for request '{0}' due to exclusion", requestUri);
                return;
            }

            //extract the string in the request that defines our entity
            string entityString = GetEntityString(rawRequest, requestUri, parameterName, parameterValue);


            _testController.Log("Running Custom Tests on '{0}' ({1})", requestUri, parameterName);
            _testController.Log("- Entity string: '{0}'", entityString);

            //get the entity id string which is specified in the definition by $entity_id
            string entityId = GetEntityId(requestUri, parameterName);

            _testController.Log("- Entity id: '{0}'", entityId);



            foreach (CustomTestDef testDef in testsToExecute)
            {
                //update session identifies
                bool useSSL = requestUri.Scheme.Equals("https");



                List <string> mutatedRequestList = GenerateMutatedRequestList(rawRequest, new TestJob(parameterName, parameterValue, location, testDef), entityString, entityId);
                List <string> testResponseList   = new List <string>();
                foreach (string mutatedRequest in mutatedRequestList)
                {
                    //send the test to server
                    var    updMutatedRequest = _testController.UpdateSessionIds(mutatedRequest, useSSL);
                    string testResponse      = _testController.SendTest(updMutatedRequest, requestUri.Host, requestUri.Port, useSSL);
                    testResponseList.Add(testResponse);
                }


                //validate the response and insert a new issue
                ValidateTest(rawRequest, rawResponse, requestUri, parameterName, entityId, testDef, mutatedRequestList, testResponseList);
            }
        }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="name"></param>
 /// <param name="location"></param>
 /// <param name="regex"></param>
 public HttpVariableDefinition(string name, RequestLocation location, string regex)
 {
     Name     = name;
     Location = location;
     Regex    = regex;
 }
예제 #14
0
 /// <summary>
 /// 接收到客户发来的地理位置消息
 /// </summary>
 /// <param name="requestLocation"></param>
 /// <returns></returns>
 public abstract ResponseMessage OnLocationMessage(RequestLocation requestLocation);