技术领域technical field
本发明涉及软件测试技术领域,尤其涉及一种模拟服务器响应方法及系统。The invention relates to the technical field of software testing, in particular to a method and system for simulating server response.
背景技术Background technique
随着计算机软件工业的发展,软件项目越来越庞大,分工也越来越细,由于项目各个分支的实际进度不同,有时在前端程序已经到测试阶段,部分配套的后端程序还不能提供相应的服务,或是后端程序服务不稳定时,使得前端程序不能按照日程进行测试,拖延前端测试进度;同时在有些解决方案中,使用硬编码的形式,根据后台程序服务实际完成情况,决定是否调用后台服务,但是因为业务逻辑的复杂和后台服务进度不断地变化,这种方式的维护过于复杂。With the development of the computer software industry, software projects are becoming larger and larger, and the division of labor is becoming more and more detailed. Because the actual progress of each branch of the project is different, sometimes the front-end program has reached the testing stage, and some supporting back-end programs cannot provide corresponding information. service, or when the service of the back-end program is unstable, the front-end program cannot be tested according to the schedule, which delays the progress of the front-end test; at the same time, in some solutions, the form of hard coding is used to decide whether to Call the background service, but because of the complexity of the business logic and the constantly changing progress of the background service, the maintenance of this method is too complicated.
发明内容Contents of the invention
本发明的主要目的在于提供一种模拟服务器响应方法及系统,旨在减小因为外部系统因素造成的测试进度拖延以及简化为前端测试提供服务的后台服程序的配置。The main purpose of the present invention is to provide a method and system for simulating server response, aiming at reducing the delay of test progress caused by external system factors and simplifying the configuration of background service programs that provide services for front-end testing.
为实现上述目的,本发明提供一种模拟服务器响应方法,所述模拟服务器响应方法包括以下步骤:To achieve the above object, the present invention provides a simulated server response method, the simulated server response method comprising the following steps:
根据通过第一可视化窗口获取的信息设置预设拦截规则;Setting preset interception rules according to the information obtained through the first visualization window;
接收终端对目标服务器的请求;Receive the terminal's request to the target server;
判断所述请求是否匹配所述预设拦截规则;judging whether the request matches the preset interception rule;
若是,则根据所述预设拦截规则响应所述终端;If so, responding to the terminal according to the preset interception rule;
若否,则透传所述请求至所述目标服务器。If not, transparently transmit the request to the target server.
优选地,所述根据通过第一可视化窗口获取的信息设置预设拦截规则包括:Preferably, the setting of preset interception rules according to the information obtained through the first visualization window includes:
提供所述第一可视化窗口,所述第一可视化窗口用于接收新建的拦截规则;providing the first visualization window, the first visualization window is used to receive a new interception rule;
接收所述新建的拦截规则,并保存所述新建的拦截规则为所述预设拦截规则。receiving the newly created interception rule, and saving the newly created interception rule as the preset interception rule.
优选地,在接收所述新建的拦截规则,并保存所述新建的拦截规则为所述预设拦截规则之后,所述根据通过第一可视化窗口获取的信息设置预设拦截规则还包括:Preferably, after receiving the newly created interception rule and saving the newly created interception rule as the preset interception rule, setting the preset interception rule according to the information obtained through the first visualization window further includes:
提供第二可视化窗口,所述第二可视化窗口用于接收对已经保存的拦截规则的查询和显示查询结果;A second visualization window is provided, and the second visualization window is used for receiving a query of the saved interception rules and displaying query results;
接收从所述显示查询结果中选择的拦截规则为要使用的所述预设拦截规则。Accepting the interception rule selected from the displayed query results as the preset interception rule to be used.
优选地,当所述请求匹配所述预设拦截规则时,所述根据所述预设拦截规则响应所述终端还包括:Preferably, when the request matches the preset interception rule, the responding to the terminal according to the preset interception rule further includes:
获取所述请求中的终端信息;Obtain the terminal information in the request;
根据所述终端信息发送模拟响应至所述终端。Sending an analog response to the terminal according to the terminal information.
优选地,所述判断所述请求是否匹配所述预设拦截规则包括:Preferably, the judging whether the request matches the preset interception rule includes:
获取所述请求中的请求地址;Obtain the request address in the request;
判断所述请求地址是否包括指定的字段;judging whether the request address includes a specified field;
若是,则判断所述请求匹配预设拦截规则;If so, then judging that the request matches a preset interception rule;
若否,则判断所述请求不匹配预设拦截规则。If not, it is determined that the request does not match the preset interception rule.
此外还提供一种模拟服务器响应系统,所述模拟服务器响应系统包括:In addition, a simulated server response system is provided, and the simulated server response system includes:
设置模块,用于根据通过第一可视化窗口获取的信息设置预设拦截规则;A setting module, configured to set preset interception rules according to the information obtained through the first visualization window;
接收模块,用于接收终端对目标服务器的请求;A receiving module, configured to receive a request from a terminal to a target server;
判断模块,用于判断所述请求是否匹配所述预设拦截规则;A judging module, configured to judge whether the request matches the preset interception rule;
拦截模块,用于当所述请求匹配所述预设拦截规则时,根据所述预设拦截规则响应所述终端;An interception module, configured to respond to the terminal according to the preset interception rule when the request matches the preset interception rule;
透传模块,用于当所述请求不匹配所述预设拦截规则时,则透传所述请求至所述目标服务器。A transparent transmission module, configured to transparently transmit the request to the target server when the request does not match the preset interception rule.
优选地,所述设置模块包括:Preferably, the setting module includes:
新建单元,用于提供所述第一可视化窗口,所述第一可视化窗口用于接收新建的拦截规则;A newly-creating unit, configured to provide the first visualization window, and the first visualization window is used to receive a newly-created interception rule;
第一接收单元,用于接收所述新建的拦截规则,并保存所述新建的拦截规则为所述预设拦截规则。The first receiving unit is configured to receive the newly created interception rule, and save the newly created interception rule as the preset interception rule.
优选地,所述设置模块还包括:Preferably, the setting module also includes:
查询单元,用于提供第二可视化窗口,所述第二可视化窗口用于接收对已经保存的拦截规则的查询和显示查询结果;A query unit, configured to provide a second visualization window, the second visualization window is used to receive queries on saved interception rules and display query results;
第二接收单元,用于接收从所述显示查询结果中选择的拦截规则为要使用的所述预设拦截规则。The second receiving unit is configured to receive the interception rule selected from the displayed query results as the preset interception rule to be used.
优选地,所述拦截模块包括:Preferably, the interception module includes:
第一获取单元,用于获取所述请求中的终端信息;a first obtaining unit, configured to obtain terminal information in the request;
发送单元,用于根据所述终端信息发送模拟响应至所述终端。A sending unit, configured to send an analog response to the terminal according to the terminal information.
优选地,所述判断模块包括:Preferably, the judging module includes:
第二获取单元,用于获取所述请求中的请求地址;a second obtaining unit, configured to obtain the request address in the request;
第一判断单元,用于判断所述请求地址是否包括指定的字段;A first judging unit, configured to judge whether the request address includes a specified field;
第二判断单元,用于当所述请求地址包括指定的字段时,判断所述请求匹配预设拦截规则;A second judging unit, configured to judge that the request matches a preset interception rule when the request address includes a specified field;
第三判断单元,用于当所述请求地址不包括指定的字段时,判断所述请求不匹配预设拦截规则。A third judging unit, configured to judge that the request does not match a preset interception rule when the request address does not include a specified field.
本发明通过根据通过第一可视化窗口获取的信息设置预设拦截规则;接收终端对目标服务器的请求;判断所述请求是否匹配所述预设拦截规则;若是,则根据所述预设拦截规则响应所述终端;若否,则透传所述请求至所述目标服务器。本发明通过为用户提供可视化窗口,使得用户无需安装,直接访问页面,便能进行设置预设拦截规则,从而方便的进行模拟响应,为前端提供了预设的数据,减小因为外部系统因素造成的测试进度拖延;同时可视化操作简单,用户只需关注请求匹配规则以及返回数据,无需关心其他细节,可以实现快速地对模拟服务器进行配置,简化为前端测试提供服务的后台服程序的配置。The present invention sets preset interception rules according to the information obtained through the first visualization window; receives the terminal's request to the target server; judges whether the request matches the preset interception rule; if so, responds according to the preset interception rule The terminal; if not, transparently transmit the request to the target server. The present invention provides the user with a visual window, so that the user can directly access the page without installation, and then set the preset interception rules, so as to facilitate the simulated response, provide the preset data for the front end, and reduce the risk caused by external system factors. At the same time, the visualization operation is simple. Users only need to pay attention to the request matching rules and the returned data, and do not need to care about other details. It can quickly configure the simulation server and simplify the configuration of the background server program that provides services for the front-end test.
附图说明Description of drawings
图1为本发明模拟服务器响应方法第一实施例的流程示意图;FIG. 1 is a schematic flow diagram of a first embodiment of a method for simulating a server response in the present invention;
图2为本发明模拟服务器响应方法第二实施例中根据通过第一可视化窗口获取的信息设置预设拦截规则步骤的细化流程示意图;FIG. 2 is a schematic diagram of the refinement of the steps of setting preset interception rules according to the information obtained through the first visualization window in the second embodiment of the simulated server response method of the present invention;
图3为本发明模拟服务器响应方法第三实施例中根据通过第一可视化窗口获取的信息设置预设拦截规则步骤的细化流程示意图;FIG. 3 is a schematic diagram of a detailed flow chart of the steps of setting preset interception rules according to the information obtained through the first visualization window in the third embodiment of the simulated server response method of the present invention;
图4为本发明模拟服务器响应方法第四实施例中根据所述预设拦截规则响应所述终端步骤的细化流程示意图;FIG. 4 is a schematic diagram of a detailed process of responding to the terminal according to the preset interception rules in the fourth embodiment of the simulated server response method of the present invention;
图5为本发明模拟服务器响应方法第五实施例中判断所述请求是否匹配所述预设拦截规则步骤的细化流程示意图;FIG. 5 is a schematic diagram of a detailed flow chart of the step of judging whether the request matches the preset interception rule in the fifth embodiment of the simulated server response method of the present invention;
图6为本发明模拟服务器响应系统第一实施例的功能模块示意图;6 is a schematic diagram of functional modules of the first embodiment of the simulation server response system of the present invention;
图7为本发明模拟服务器响应系统第二实施例中设置模块的细化功能模块示意图;FIG. 7 is a schematic diagram of a detailed functional module of the setting module in the second embodiment of the simulated server response system of the present invention;
图8为本发明模拟服务器响应系统第三实施例中设置模块的细化功能模块示意图;FIG. 8 is a schematic diagram of a detailed functional module of the setting module in the third embodiment of the simulated server response system of the present invention;
图9为本发明模拟服务器响应系统第四实施例中拦截模块的细化功能模块示意图;FIG. 9 is a schematic diagram of the detailed functional modules of the interception module in the fourth embodiment of the simulated server response system of the present invention;
图10为本发明模拟服务器响应系统第五实施例中判断模块的细化功能模块示意图。FIG. 10 is a schematic diagram of detailed functional modules of the judging module in the fifth embodiment of the simulated server response system of the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the purpose of the present invention, functional characteristics and advantages will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
本发明提供一种模拟服务器响应方法,参照图1,在本发明模拟服务器响应方法第一实施例中,所述模拟服务器响应方法包括以下步骤:The present invention provides a method for simulating a server response. Referring to FIG. 1, in the first embodiment of the method for simulating a server response in the present invention, the method for simulating a server response includes the following steps:
步骤S10,根据通过第一可视化窗口获取的信息设置预设拦截规则;Step S10, setting preset interception rules according to the information obtained through the first visualization window;
步骤S20,接收终端对目标服务器的请求;Step S20, receiving the terminal's request to the target server;
所述终端为用户使用浏览器或其他能与服务器进行通信的客户端,在本实施例中所述终端为接收用户指令和所述目标服务局进行通信的代理服务器。The terminal is a client that the user uses a browser or can communicate with the server. In this embodiment, the terminal is a proxy server that receives user instructions and communicates with the target service bureau.
步骤S30,判断所述请求是否匹配所述预设拦截规则;Step S30, judging whether the request matches the preset interception rule;
若是,则执行步骤S40,根据所述预设拦截规则响应所述终端;If so, execute step S40 to respond to the terminal according to the preset interception rules;
若否,则执行步骤S50,透传所述请求至所述目标服务器。If not, step S50 is performed to transparently transmit the request to the target server.
当用户使用所述代理服务器和所述目标服务器进行通信时,拦截所述代理服务器发送的所有请求,并对所述请求使用预设拦截规则进行过滤,所述预设拦截规则根据所述请求的内容,判断是否匹配预设规则,当符合所述预设拦截规则时,阻止所述请求进一步传送,并根据所述预设拦截规则响应所述终端,所述响应为预设的响应信息,所述响应信用于模拟所述目标服务器的响应。When the user uses the proxy server to communicate with the target server, all requests sent by the proxy server are intercepted, and the requests are filtered using preset interception rules, and the preset interception rules are based on the request content, judging whether it matches a preset rule, and when the preset interception rule is met, prevent the request from being further transmitted, and respond to the terminal according to the preset interception rule, the response is preset response information, the The response message is used to simulate the response of the target server.
具体地在本实施例中,用户打开指定页面,根据页面提示设置自己需要的预设拦截规则。所述预设拦截规则具体为,当请求的目标地址中包含以下字段时:“fastpayment/redbonus/pay_success_get_tips.html”,为所述终端返回一个模拟所述目标服务器响应的模拟数据。当接受到所述终端访问所述目标服务器的请求时,通过解析所述请求,获取所述请求的请求地址为:“www.vip.com/fastpayment/redbonus/pay_success_get_tips.html”,则为所述终端返回预设的模拟所述目标服务器响应的模拟数据作为模拟响应信息;若所述请求的请求地址为:“www.vip.com/notnonap/redbonus/pay_success_get_tips.html”,则不匹配所述预设拦截规则,直接透传所述请求至所述目标服务器。Specifically, in this embodiment, the user opens a specified page, and sets the preset interception rules he needs according to the prompts on the page. Specifically, the preset interception rule is, when the target address of the request contains the following field: "fastpayment/redbonus/pay_success_get_tips.html", return a simulation data simulating the response of the target server to the terminal. When receiving the request from the terminal to access the target server, by analyzing the request, the request address of the request is obtained: "www.vip.com/fastpayment/redbonus/pay_success_get_tips.html", then the The terminal returns the preset simulation data that simulates the response of the target server as the simulation response information; if the request address of the request is: "www.vip.com/notnonap/redbonus/pay_success_get_tips.html", it does not match the preset An interception rule is set to transparently transmit the request to the target server directly.
本实施例中为用户提供可视化窗口,使得用户无需安装,直接访问页面,便能进行设置预设拦截规则,从而方便的进行模拟响应,为前端提供了预设的数据,减小因为外部系统因素造成的测试进度拖延;同时可视化操作简单,用户只需关注请求匹配规则以及返回数据,无需关心其他细节,可以实现快速地对模拟服务器进行配置,简化为前端测试提供服务的后台服程序的配置。In this embodiment, a visual window is provided for the user, so that the user can directly access the page without installation, and then set the preset interception rules, so as to facilitate the simulated response, provide preset data for the front end, and reduce the external system factors. The test progress is delayed; at the same time, the visualization operation is simple. Users only need to pay attention to the request matching rules and the returned data, and do not need to care about other details. It can quickly configure the simulation server and simplify the configuration of the background server program that provides services for the front-end test.
需要说明的是,有些实施例中所述预设拦截规则还会根据所述请求判断所述终端的类型,在匹配预设规则后,针对不同的终端返回不同的预设信息作为模拟响应。It should be noted that, in some embodiments, the preset interception rules will also determine the type of the terminal according to the request, and after matching the preset rules, different preset information will be returned for different terminals as simulated responses.
请参照图2,基于本发明模拟服务器响应方法第一实施例,在本发明模拟服务器响应方法第二实施例中,所述根据通过第一可视化窗口获取的信息设置预设拦截规则包括:Please refer to FIG. 2, based on the first embodiment of the simulated server response method of the present invention, in the second embodiment of the simulated server response method of the present invention, the setting of preset interception rules according to the information obtained through the first visualization window includes:
步骤S11,提供所述第一可视化窗口,所述第一可视化窗口用于接收新建的拦截规则;Step S11, providing the first visualization window, the first visualization window is used to receive the new interception rule;
步骤S12,接收所述新建的拦截规则,并保存所述新建的拦截规则为所述预设拦截规则。Step S12, receiving the newly created interception rule, and saving the newly created interception rule as the preset interception rule.
在所述第一可视化窗口的输入信息包括:所要拦截终端的IP地址、所要拦截所述目标服务器的域名、所述拦截请求的地址包括的字段和拦截后预设的响应信息。通过使用表单的形式,使用户在有提示信息的前提下快速的创建拦截规则,使得创建过程简单又快速;同时因为拦截规则中包括终端的IP地址,使得针对每个不同来源服务器能够返回不同的结果,各服务器可以独立配置规则,互不干扰。The input information in the first visualization window includes: the IP address of the terminal to be intercepted, the domain name of the target server to be intercepted, the fields included in the address of the interception request, and preset response information after interception. By using the form, users can quickly create interception rules on the premise of prompt information, making the creation process simple and fast; at the same time, because the interception rules include the IP address of the terminal, it is possible to return different IP addresses for each different source server As a result, each server can configure rules independently without interfering with each other.
请参照图3,基于本发明模拟服务器响应方法第二实施例,在本发明模拟服务器响应方法第三实施例中,所述根据通过第一可视化窗口获取的信息设置预设拦截规则包括:Please refer to FIG. 3 , based on the second embodiment of the simulated server response method of the present invention, in the third embodiment of the simulated server response method of the present invention, the setting of preset interception rules according to the information obtained through the first visualization window includes:
步骤S13,提供第二可视化窗口,所述第二可视化窗口用于接收对已经保存的拦截规则的查询和显示查询结果;Step S13, providing a second visualization window, the second visualization window is used to receive the query of the saved interception rules and display the query results;
步骤S14,接收从所述显示查询结果中选择的拦截规则为要使用的所述预设拦截规则。Step S14, receiving the interception rule selected from the displayed query results as the preset interception rule to be used.
在用户保存所述拦截规则后,在保存某些特定规则汇合成的规则集作为应用场景,所述应用该场景规则集可以多次复现某一特定场景,无需再配置测试数据,实现了拦截规则的复用。After the user saves the interception rules, a rule set composed of certain specific rules is saved as an application scenario, and the application of the scenario rule set can reproduce a specific scenario multiple times without reconfiguring test data, and the interception is realized. Reuse of rules.
具体地在本实施例中,所述第二可视化窗口为另一网页,在所述第二可视化窗口中提供了表单,使得用户可以根据自己的需要检索已经保存的拦截规则,在所述第二可视化窗口返回结果后,用户根据自己需要在所述结果中选择要实施的拦截规则,在接收到用户所选择的拦截规则后,设置所选择的拦截规则为要使用的所述预设拦截规则。Specifically in this embodiment, the second visualization window is another web page, and a form is provided in the second visualization window, so that users can retrieve saved interception rules according to their own needs, and in the second visualization window After the visualization window returns the result, the user selects the interception rule to be implemented in the result according to his needs, and after receiving the interception rule selected by the user, sets the selected interception rule as the preset interception rule to be used.
请参照图4,基于本发明模拟服务器响应方法第一实施例,在本发明模拟服务器响应方法第四实施例中,当所述请求匹配所述预设拦截规则时,所述步骤S40包括:Please refer to FIG. 4 , based on the first embodiment of the simulated server response method of the present invention, in the fourth embodiment of the simulated server response method of the present invention, when the request matches the preset interception rule, the step S40 includes:
步骤S41,获取所述请求中的终端信息;Step S41, obtaining terminal information in the request;
步骤S42,根据所述终端信息发送模拟响应至所述终端。Step S42, sending a simulated response to the terminal according to the terminal information.
对每个请求的来源进行区分,针对每个不同类型的请求返回不同的模拟响应,对于各个终端的请求进行独立拦截规则,互不干扰,从而减少配置次数。Differentiate the source of each request, return different simulated responses for each different type of request, and implement independent interception rules for each terminal request without interfering with each other, thereby reducing the number of configurations.
在本实施例中,当接收的所述请求来源为A时,所述请求的地址符合预设拦截规则,为其发送专门为A准备的预设响应,所述预设响应为符合A的模拟所述目标服务器的响应;当接收的所述请求来源为B时,所述请求的地址和前述A的请求地址相同,都符合预设拦截规则,为其发送专门为B准备的预设响应,所述预设响应为符合B的模拟所述目标服务器的响应。In this embodiment, when the source of the received request is A, the address of the request conforms to the preset interception rules, and a preset response specially prepared for A is sent to it, and the preset response is a simulation that complies with A The response of the target server; when the source of the received request is B, the address of the request is the same as the request address of the aforementioned A, and both comply with the preset interception rules, and a preset response specially prepared for B is sent to it, The preset response is a response that conforms to B and simulates the target server.
请参照图5,基于本发明模拟服务器响应方法第一实施例,在本发明模拟服务器响应方法第五实施例中,所述判断所述请求是否匹配所述预设拦截规则包括:Please refer to FIG. 5 , based on the first embodiment of the simulated server response method of the present invention, in the fifth embodiment of the simulated server response method of the present invention, the judging whether the request matches the preset interception rule includes:
步骤S31,获取所述请求中的请求地址;Step S31, obtaining the request address in the request;
步骤S32,判断所述请求地址是否包括指定的字段;Step S32, judging whether the request address includes a specified field;
若是,则执行步骤S33,判断所述请求匹配预设拦截规则;If so, execute step S33 to determine that the request matches a preset interception rule;
若否,则执行步骤S34,判断所述请求不匹配预设拦截规则。If not, step S34 is executed to determine that the request does not match the preset interception rule.
通过使用请求中的请求地址作为判断条件,具体在本实施例中,判断所述请求地址中是否包括指定的字段“fastpayment”,例如请求地址为:“www.vip.com/fastpayment/redbonus/pay_success_get_tips.html”,则判断所述请求匹配预设拦截规则;如果请求地址为:“www.vip.com/fastpay_____ment/redbonus/pay_success_get_tips.html”,则判断所述请求不匹配预设拦截规则。通过使用请求地址作为判断条件,加快了对所述请求是否匹配所述预设拦截规则的判断,提高了处理效率。By using the request address in the request as the judgment condition, specifically in this embodiment, it is judged whether the specified field "fastpayment" is included in the request address, for example, the request address is: "www.vip.com/fastpayment/redbonus/pay_success_get_tips .html", it is determined that the request matches the preset interception rules; if the request address is: "www.vip.com/fastpay_____ment/redbonus/pay_success_get_tips.html", it is determined that the request does not match the preset interception rules. By using the request address as the judgment condition, the judgment on whether the request matches the preset interception rule is accelerated, and the processing efficiency is improved.
本发明提供一种模拟服务器响应系统,参照图6,在本发明模拟服务器响应系统第一实施例中,所述模拟服务器响应系统包括:The present invention provides a simulated server response system. Referring to FIG. 6, in the first embodiment of the simulated server response system of the present invention, the simulated server response system includes:
设置模块10,用于根据通过第一可视化窗口获取的信息设置预设拦截规则;A setting module 10, configured to set preset interception rules according to information obtained through the first visualization window;
接收模块20,用于接收终端对目标服务器的请求;A receiving module 20, configured to receive a request from a terminal to a target server;
所述终端为用户使用浏览器或其他能与服务器进行通信的客户端,在本实施例中所述终端为接收用户指令和所述目标服务局进行通信的代理服务器。The terminal is a client that the user uses a browser or can communicate with the server. In this embodiment, the terminal is a proxy server that receives user instructions and communicates with the target service bureau.
判断模块30,用于判断所述请求是否匹配所述预设拦截规则;A judging module 30, configured to judge whether the request matches the preset interception rule;
拦截模块40,用于当所述请求匹配所述预设拦截规则时,根据所述预设拦截规则响应所述终端;An interception module 40, configured to respond to the terminal according to the preset interception rule when the request matches the preset interception rule;
透传模块50,用于当所述请求不匹配所述预设拦截规则时,则透传所述请求至所述目标服务器。The transparent transmission module 50 is configured to transparently transmit the request to the target server when the request does not match the preset interception rule.
当用户使用所述代理服务器和所述目标服务器进行通信时,拦截所述代理服务器发送的所有请求,并对所述请求使用预设拦截规则进行过滤,所述预设拦截规则根据所述请求的内容,判断是否匹配预设规则,当符合所述预设拦截规则时,阻止所述请求进一步传送,并根据所述预设拦截规则响应所述终端,所述响应为预设的响应信息,所述响应信用于模拟所述目标服务器的响应。When the user uses the proxy server to communicate with the target server, all requests sent by the proxy server are intercepted, and the requests are filtered using preset interception rules, and the preset interception rules are based on the request content, judging whether it matches a preset rule, and when the preset interception rule is met, prevent the request from being further transmitted, and respond to the terminal according to the preset interception rule, the response is preset response information, the The response message is used to simulate the response of the target server.
具体地在本实施例中,用户打开指定页面,根据页面提示设置自己需要的预设拦截规则。所述预设拦截规则具体为,当请求的目标地址中包含以下字段时:“fastpayment/redbonus/pay_success_get_tips.html”,为所述终端返回一个模拟所述目标服务器响应的模拟数据。当接受到所述终端访问所述目标服务器的请求时,通过解析所述请求,获取所述请求的请求地址为:“www.vip.com/fastpayment/redbonus/pay_success_get_tips.html”,则为所述终端返回预设的模拟所述目标服务器响应的模拟数据作为模拟响应信息;若所述请求的请求地址为:“www.vip.com/notnonap/redbonus/pay_success_get_tips.html”,则不匹配所述预设拦截规则,直接透传所述请求至所述目标服务器。Specifically, in this embodiment, the user opens a specified page, and sets the preset interception rules he needs according to the prompts on the page. Specifically, the preset interception rule is, when the target address of the request contains the following field: "fastpayment/redbonus/pay_success_get_tips.html", return a simulation data simulating the response of the target server to the terminal. When receiving the request from the terminal to access the target server, by analyzing the request, the request address of the request is obtained: "www.vip.com/fastpayment/redbonus/pay_success_get_tips.html", then the The terminal returns the preset simulation data that simulates the response of the target server as the simulation response information; if the request address of the request is: "www.vip.com/notnonap/redbonus/pay_success_get_tips.html", it does not match the preset An interception rule is set to transparently transmit the request to the target server directly.
本实施例中为用户提供可视化窗口,使得用户无需安装,直接访问页面,便能进行设置预设拦截规则,从而方便的进行模拟响应,为前端提供了预设的数据,减小因为外部系统因素造成的测试进度拖延;同时可视化操作简单,用户只需关注请求匹配规则以及返回数据,无需关心其他细节,可以实现快速地对模拟服务器进行配置,简化为前端测试提供服务的后台服程序的配置。In this embodiment, a visual window is provided for the user, so that the user can directly access the page without installation, and then set the preset interception rules, so as to facilitate the simulated response, provide preset data for the front end, and reduce the external system factors. The test progress is delayed; at the same time, the visualization operation is simple. Users only need to pay attention to the request matching rules and the returned data, and do not need to care about other details. It can quickly configure the simulation server and simplify the configuration of the background server program that provides services for the front-end test.
需要说明的是,有些实施例中所述预设拦截规则还会根据所述请求判断所述终端的类型,在匹配预设规则后,针对不同的终端返回不同的预设信息作为模拟响应。It should be noted that, in some embodiments, the preset interception rules will also determine the type of the terminal according to the request, and after matching the preset rules, different preset information will be returned for different terminals as simulated responses.
请参照图7,基于本发明模拟服务器响应系统第一实施例,在本发明模拟服务器响应系统第二实施例中,所述设置模块包括:Please refer to FIG. 7, based on the first embodiment of the simulated server response system of the present invention, in the second embodiment of the simulated server response system of the present invention, the setting module includes:
新建单元11,用于提供所述第一可视化窗口,所述第一可视化窗口用于接收新建的拦截规则;The creation unit 11 is configured to provide the first visualization window, and the first visualization window is used to receive the newly created interception rule;
第一接收单元12,用于接收所述新建的拦截规则,并保存所述新建的拦截规则为所述预设拦截规则。The first receiving unit 12 is configured to receive the newly created interception rule, and save the newly created interception rule as the preset interception rule.
在所述第一可视化窗口的输入信息包括:所要拦截终端的IP地址、所要拦截所述目标服务器的域名、所述拦截请求的地址包括的字段和拦截后预设的响应信息。通过使用表单的形式,使用户在有提示信息的前提下快速的创建拦截规则,使得创建过程简单又快速;同时因为拦截规则中包括终端的IP地址,使得针对每个不同来源服务器能够返回不同的结果,各服务器可以独立配置规则,互不干扰。The input information in the first visualization window includes: the IP address of the terminal to be intercepted, the domain name of the target server to be intercepted, the fields included in the address of the interception request, and preset response information after interception. By using the form, users can quickly create interception rules on the premise of prompt information, making the creation process simple and fast; at the same time, because the interception rules include the IP address of the terminal, it is possible to return different IP addresses for each different source server As a result, each server can configure rules independently without interfering with each other.
请参照图8,基于本发明模拟服务器响应系统第二实施例,在本发明模拟服务器响应系统第三实施例中,所述设置模块还包括:Please refer to FIG. 8, based on the second embodiment of the simulated server response system of the present invention, in the third embodiment of the simulated server response system of the present invention, the setting module further includes:
查询单元13,用于提供第二可视化窗口,所述第二可视化窗口用于接收对已经保存的拦截规则的查询和显示查询结果;The query unit 13 is configured to provide a second visualization window, and the second visualization window is used to receive the query of the saved interception rules and display the query result;
第二接收单元14,用于接收从所述显示查询结果中选择的拦截规则为要使用的所述预设拦截规则。The second receiving unit 14 is configured to receive the interception rule selected from the displayed query results as the preset interception rule to be used.
在用户保存所述拦截规则后,在保存某些特定规则汇合成的规则集作为应用场景,所述应用该场景规则集可以多次复现某一特定场景,无需再配置测试数据,实现了拦截规则的复用。After the user saves the interception rules, a rule set composed of certain specific rules is saved as an application scenario, and the application of the scenario rule set can reproduce a specific scenario multiple times without reconfiguring test data, and the interception is realized. Reuse of rules.
具体地在本实施例中,所述第二可视化窗口为另一网页,在所述第二可视化窗口中提供了表单,使得用户可以根据自己的需要检索已经保存的拦截规则,在所述第二可视化窗口返回结果后,用户根据自己需要在所述结果中选择要实施的拦截规则,在接收到用户所选择的拦截规则后,设置所选择的拦截规则为要使用的所述预设拦截规则。Specifically in this embodiment, the second visualization window is another web page, and a form is provided in the second visualization window, so that users can retrieve saved interception rules according to their own needs, and in the second visualization window After the visualization window returns the result, the user selects the interception rule to be implemented in the result according to his needs, and after receiving the interception rule selected by the user, sets the selected interception rule as the preset interception rule to be used.
请参照图9,基于本发明模拟服务器响应系统第一实施例,在本发明模拟服务器响应系统第四实施例中,所述拦截模块40包括:Please refer to FIG. 9, based on the first embodiment of the simulated server response system of the present invention, in the fourth embodiment of the simulated server response system of the present invention, the interception module 40 includes:
第一获取单元41,用于获取所述请求中的终端信息;A first obtaining unit 41, configured to obtain terminal information in the request;
发送单元42,用于根据所述终端信息发送模拟响应至所述终端。The sending unit 42 is configured to send an analog response to the terminal according to the terminal information.
对每个请求的来源进行区分,针对每个不同类型的请求返回不同的模拟响应,对于各个终端的请求进行独立拦截规则,互不干扰,从而减少配置次数。Differentiate the source of each request, return different simulated responses for each different type of request, and implement independent interception rules for each terminal request without interfering with each other, thereby reducing the number of configurations.
在本实施例中,当第一获取单元41确认接收的所述请求来源为A时,所述请求的地址符合预设拦截规则,发送单元42为其发送专门为A准备的预设响应,所述预设响应为符合A的模拟所述目标服务器的响应;当当第一获取单元41确认接收的所述请求来源为B时,所述请求的地址和前述A的请求地址相同,都符合预设拦截规则,发送单元42为其发送专门为B准备的预设响应,所述预设响应为符合B的模拟所述目标服务器的响应。In this embodiment, when the first obtaining unit 41 confirms that the received request source is A, the address of the request conforms to the preset interception rule, and the sending unit 42 sends a preset response specially prepared for A, so The preset response is the response of simulating the target server conforming to A; when the first obtaining unit 41 confirms that the source of the request received is B, the address of the request is the same as the request address of the aforementioned A, and both conform to the preset For the interception rule, the sending unit 42 sends a preset response specially prepared for B, where the preset response is a response that complies with B and simulates the target server.
请参照图10,基于本发明模拟服务器响应系统第一实施例,在本发明模拟服务器响应系统第五实施例中,所述判断模块包括:Please refer to FIG. 10 , based on the first embodiment of the simulated server response system of the present invention, in the fifth embodiment of the simulated server response system of the present invention, the judgment module includes:
第二获取单元31,用于获取所述请求中的请求地址;The second obtaining unit 31 is configured to obtain the request address in the request;
第一判断单元32,用于判断所述请求地址是否包括指定的字段;A first judging unit 32, configured to judge whether the request address includes a specified field;
第二判断单元33,用于当所述请求地址包括指定的字段时,判断所述请求匹配预设拦截规则;The second judging unit 33 is configured to judge that the request matches a preset interception rule when the request address includes a specified field;
第三判断单元34,用于当所述请求地址不包括指定的字段时,判断所述请求不匹配预设拦截规则。The third judging unit 34 is configured to judge that the request does not match a preset interception rule when the request address does not include a specified field.
通过使用请求中的请求地址作为判断条件,具体在本实施例中,判断所述请求地址中是否包括指定的字段“fastpayment”,例如请求地址为:“www.vip.com/fastpayment/redbonus/pay_success_get_tips.html”,则判断所述请求匹配预设拦截规则;如果请求地址为:“www.vip.com/fastpay_____ment/redbonus/pay_success_get_tips.html”,则判断所述请求不匹配预设拦截规则。通过使用请求地址作为判断条件,加快了对所述请求是否匹配所述预设拦截规则的判断,提高了处理效率。By using the request address in the request as the judgment condition, specifically in this embodiment, it is judged whether the specified field "fastpayment" is included in the request address, for example, the request address is: "www.vip.com/fastpayment/redbonus/pay_success_get_tips .html", it is determined that the request matches the preset interception rules; if the request address is: "www.vip.com/fastpay_____ment/redbonus/pay_success_get_tips.html", it is determined that the request does not match the preset interception rules. By using the request address as the judgment condition, the judgment on whether the request matches the preset interception rule is accelerated, and the processing efficiency is improved.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technical fields , are all included in the scope of patent protection of the present invention in the same way.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611231631.XACN106681922B (en) | 2016-12-27 | 2016-12-27 | Simulation server response method and system |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611231631.XACN106681922B (en) | 2016-12-27 | 2016-12-27 | Simulation server response method and system |
| Publication Number | Publication Date |
|---|---|
| CN106681922Atrue CN106681922A (en) | 2017-05-17 |
| CN106681922B CN106681922B (en) | 2021-03-02 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201611231631.XAActiveCN106681922B (en) | 2016-12-27 | 2016-12-27 | Simulation server response method and system |
| Country | Link |
|---|---|
| CN (1) | CN106681922B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108268375A (en)* | 2018-01-12 | 2018-07-10 | 深圳壹账通智能科技有限公司 | Applied program testing method, device, computer equipment and storage medium |
| CN108345543A (en)* | 2018-03-02 | 2018-07-31 | 财付通支付科技有限公司 | A kind of data processing method, device, equipment and storage medium |
| CN108345535A (en)* | 2017-12-26 | 2018-07-31 | 阿里巴巴集团控股有限公司 | Mock test methods, device and equipment |
| CN108768960A (en)* | 2018-05-10 | 2018-11-06 | 腾讯科技(深圳)有限公司 | Method for detecting virus, device, storage medium and computer equipment |
| CN109582556A (en)* | 2017-09-29 | 2019-04-05 | 阿里巴巴集团控股有限公司 | Test method, the device and system of a kind of application program in running of mobile terminal situation |
| CN109710437A (en)* | 2018-10-29 | 2019-05-03 | 努比亚技术有限公司 | A kind of application logs in optimization method, terminal and computer readable storage medium |
| CN111078571A (en)* | 2019-12-20 | 2020-04-28 | 广州品唯软件有限公司 | Test method, terminal device and computer-readable storage medium for simulated response |
| CN111679980A (en)* | 2020-06-03 | 2020-09-18 | 中国银行股份有限公司 | Background data simulation method and device |
| CN111708702A (en)* | 2020-06-18 | 2020-09-25 | 深圳前海微众银行股份有限公司 | Simulation test method, client, server, system and readable storage medium |
| CN112131118A (en)* | 2020-09-25 | 2020-12-25 | 平安国际智慧城市科技股份有限公司 | Mock test method, device, electronic device and computer-readable storage medium |
| CN115883153A (en)* | 2022-11-24 | 2023-03-31 | 杭州安恒信息技术股份有限公司 | Website access control method, device, equipment and storage medium |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6763342B1 (en)* | 1998-07-21 | 2004-07-13 | Sentar, Inc. | System and method for facilitating interaction with information stored at a web site |
| CN101556609A (en)* | 2009-05-19 | 2009-10-14 | 杭州信杨通信技术有限公司 | Customer behavior analysis and service system based on web contents |
| US20110150189A1 (en)* | 2009-12-22 | 2011-06-23 | Cyara Solutions Pty Ltd | Integrated testing platform for contact centres |
| CN102215242A (en)* | 2010-04-09 | 2011-10-12 | 英业达股份有限公司 | Event response method and system for client based on server |
| CN102404191A (en)* | 2010-09-10 | 2012-04-04 | 腾讯科技(深圳)有限公司 | Routing method and device |
| CN102833125A (en)* | 2011-06-17 | 2012-12-19 | 腾讯科技(深圳)有限公司 | Test server, test system adopting test server, and test method |
| CN103150238A (en)* | 2011-12-07 | 2013-06-12 | 阿里巴巴集团控股有限公司 | Service request processing method, simulation performance test method and simulation performance test device |
| CN104035859A (en)* | 2013-03-07 | 2014-09-10 | 腾讯科技(深圳)有限公司 | Visualized automatic testing method and system thereof |
| CN104199725A (en)* | 2014-09-27 | 2014-12-10 | 上海瀚之友信息技术服务有限公司 | Service interface data simulation method and system |
| CN104461903A (en)* | 2014-12-26 | 2015-03-25 | 北京奇虎科技有限公司 | Method and device for testing client side based on browser |
| CN105471665A (en)* | 2014-08-21 | 2016-04-06 | 北京奇虎科技有限公司 | Website function testing method, website function testing system and website server |
| CN106055383A (en)* | 2016-05-26 | 2016-10-26 | 北京京东尚科信息技术有限公司 | Request processing method and device |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6763342B1 (en)* | 1998-07-21 | 2004-07-13 | Sentar, Inc. | System and method for facilitating interaction with information stored at a web site |
| CN101556609A (en)* | 2009-05-19 | 2009-10-14 | 杭州信杨通信技术有限公司 | Customer behavior analysis and service system based on web contents |
| US20110150189A1 (en)* | 2009-12-22 | 2011-06-23 | Cyara Solutions Pty Ltd | Integrated testing platform for contact centres |
| CN102215242A (en)* | 2010-04-09 | 2011-10-12 | 英业达股份有限公司 | Event response method and system for client based on server |
| CN102404191A (en)* | 2010-09-10 | 2012-04-04 | 腾讯科技(深圳)有限公司 | Routing method and device |
| CN102833125A (en)* | 2011-06-17 | 2012-12-19 | 腾讯科技(深圳)有限公司 | Test server, test system adopting test server, and test method |
| CN103150238A (en)* | 2011-12-07 | 2013-06-12 | 阿里巴巴集团控股有限公司 | Service request processing method, simulation performance test method and simulation performance test device |
| CN104035859A (en)* | 2013-03-07 | 2014-09-10 | 腾讯科技(深圳)有限公司 | Visualized automatic testing method and system thereof |
| CN105471665A (en)* | 2014-08-21 | 2016-04-06 | 北京奇虎科技有限公司 | Website function testing method, website function testing system and website server |
| CN104199725A (en)* | 2014-09-27 | 2014-12-10 | 上海瀚之友信息技术服务有限公司 | Service interface data simulation method and system |
| CN104461903A (en)* | 2014-12-26 | 2015-03-25 | 北京奇虎科技有限公司 | Method and device for testing client side based on browser |
| CN106055383A (en)* | 2016-05-26 | 2016-10-26 | 北京京东尚科信息技术有限公司 | Request processing method and device |
| Title |
|---|
| ANDREA MATTA等: ""Event Relationship Graph Lite: Event based modeling for simulation-optimization of control policies in discrete event systems"", 《PROCEEDINGS OF THE WINTER SIMULATION CONFERENCE 2014》* |
| XUEJUN LIU等: ""Development and evaluation of the question and answer system for core courses"", 《INFORMATION TECHNOLOGY BASED PROCEEDINGS OF THE FIFTH INTERNATIONAL CONFERENCE ONHIGHER EDUCATION AND TRAINING, 2004. ITHET 2004.》* |
| 黄冬泉等: ""Web服务器的过载模拟和性能测量"", 《计算机工程与科学》* |
| 黄桂敏等: ""一种改进WWW服务器响应时间的调度方法"", 《计算机工程与应用》* |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109582556A (en)* | 2017-09-29 | 2019-04-05 | 阿里巴巴集团控股有限公司 | Test method, the device and system of a kind of application program in running of mobile terminal situation |
| CN109582556B (en)* | 2017-09-29 | 2022-04-12 | 阿里巴巴集团控股有限公司 | Method, device and system for testing running condition of application program in mobile terminal |
| CN108345535A (en)* | 2017-12-26 | 2018-07-31 | 阿里巴巴集团控股有限公司 | Mock test methods, device and equipment |
| CN108268375A (en)* | 2018-01-12 | 2018-07-10 | 深圳壹账通智能科技有限公司 | Applied program testing method, device, computer equipment and storage medium |
| CN108345543B (en)* | 2018-03-02 | 2021-08-17 | 财付通支付科技有限公司 | Data processing method, device, equipment and storage medium |
| CN108345543A (en)* | 2018-03-02 | 2018-07-31 | 财付通支付科技有限公司 | A kind of data processing method, device, equipment and storage medium |
| CN108768960A (en)* | 2018-05-10 | 2018-11-06 | 腾讯科技(深圳)有限公司 | Method for detecting virus, device, storage medium and computer equipment |
| CN109710437A (en)* | 2018-10-29 | 2019-05-03 | 努比亚技术有限公司 | A kind of application logs in optimization method, terminal and computer readable storage medium |
| CN111078571A (en)* | 2019-12-20 | 2020-04-28 | 广州品唯软件有限公司 | Test method, terminal device and computer-readable storage medium for simulated response |
| CN111078571B (en)* | 2019-12-20 | 2024-02-02 | 广州品唯软件有限公司 | Test method for analog response, terminal equipment and computer readable storage medium |
| CN111679980A (en)* | 2020-06-03 | 2020-09-18 | 中国银行股份有限公司 | Background data simulation method and device |
| CN111708702A (en)* | 2020-06-18 | 2020-09-25 | 深圳前海微众银行股份有限公司 | Simulation test method, client, server, system and readable storage medium |
| CN112131118A (en)* | 2020-09-25 | 2020-12-25 | 平安国际智慧城市科技股份有限公司 | Mock test method, device, electronic device and computer-readable storage medium |
| CN115883153A (en)* | 2022-11-24 | 2023-03-31 | 杭州安恒信息技术股份有限公司 | Website access control method, device, equipment and storage medium |
| Publication number | Publication date |
|---|---|
| CN106681922B (en) | 2021-03-02 |
| Publication | Publication Date | Title |
|---|---|---|
| CN106681922A (en) | Simulation server response method and system | |
| CN110149388B (en) | Method, device and equipment for connecting HTTPDNS (hypertext transport protocol version transport protocol DNS) server | |
| US10693734B2 (en) | Traffic pattern detection and presentation in container-based cloud computing architecture | |
| US11087005B2 (en) | IoT device risk assessment | |
| CN105025081B (en) | Monitor the method for mobile device used | |
| AU2015267387B2 (en) | Method and apparatus for automating the building of threat models for the public cloud | |
| CN109726108B (en) | Front-end code testing method, device, system and medium based on analog data | |
| CN106354634A (en) | Interface testing method and device | |
| US11843674B2 (en) | Virtual workspace experience visualization and optimization | |
| US10812346B1 (en) | Application discovery and dependency mapping | |
| CN108183838B (en) | Method and device for testing source NAT function | |
| CN103684885B (en) | A kind of Website server access exception determines method and device | |
| CN106357609A (en) | User creation method and system, public network server and private cloud equipment | |
| WO2021151314A1 (en) | Dns automatic performance test method, apparatus, device, and readable storage medium | |
| CN111831550A (en) | Joint debugging test method and device | |
| CN112988608A (en) | Data testing method and device, computer equipment and storage medium | |
| CN106815150B (en) | Server-side interface test system and method | |
| CN110233774B (en) | A detection method, distributed detection method and system for a Socks proxy server | |
| CN107634871A (en) | A connectivity test method, device and system | |
| CN115146309A (en) | Privacy compliance detection method, device, server, terminal and storage medium | |
| CN106682014B (en) | Game display data generation method and device | |
| CN108345508A (en) | Interface calls test method and device | |
| US20130226984A1 (en) | Method and apparatus of providing optimized web browser communications | |
| CN112527453B (en) | Virtualization information simulation system, method and computer-readable storage medium | |
| CN114285779A (en) | Method, device and system for processing test request |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| TA01 | Transfer of patent application right | Effective date of registration:20171204 Address after:510000 Guangzhou City, Guangzhou, Guangdong, Fangcun Avenue, one of the 314 self compiled Applicant after:GUANGZHOU PINWEI SOFTWARE Co.,Ltd. Address before:Liwan District Fangcun Huahai street Guangzhou city Guangdong province 510000 No. 20 self 1-5 building (only for office use) Applicant before:GUANGZHOU VIPSHOP INFORMATION TECHNOLOGY Co.,Ltd. | |
| TA01 | Transfer of patent application right | ||
| TA01 | Transfer of patent application right | Effective date of registration:20210121 Address after:Room 903, no.6, Lane 1588, Shenchang Road, Minhang District, Shanghai 201100 Applicant after:SHANGHAI PINSHUN INFORMATION TECHNOLOGY Co.,Ltd. Address before:510000 No. 314, Fangcun Avenue, Liwan District, Guangzhou City, Guangdong Province Applicant before:GUANGZHOU PINWEI SOFTWARE Co.,Ltd. | |
| TA01 | Transfer of patent application right | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| TR01 | Transfer of patent right | Effective date of registration:20250912 Address after:Room 902, No. 6, Lane 1588, Shenchang Road, Minhang District, Shanghai 201100 Patentee after:Shanghai Pinwei Information Technology Co.,Ltd. Country or region after:China Address before:Room 903, no.6, Lane 1588, Shenchang Road, Minhang District, Shanghai 201100 Patentee before:SHANGHAI PINSHUN INFORMATION TECHNOLOGY CO.,LTD. Country or region before:China |