Interface testing method and device, computer equipment and storage medium

By obtaining at least two verification policies, processing the interface parameters of the test interface and generating verification parameters, the problem of inefficient testing of open application programming interfaces in the prior art is solved, and the multiplexing of interface parameters and the improvement of testing efficiency is achieved.

CN119690834APending Publication Date: 2025-03-25MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411771781.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The prior art is inefficient when testing the Open Application Programming Interface (Open API), especially when gateway authentication rules change or interface parameters change, it is necessary to rewrite the preprocessor, resulting in a decrease in testing efficiency.

Method used

By obtaining at least two verification policies, the interface parameters of the test interface are processed, verification parameters are generated, and the interface test request is generated using these verification parameters, sent to the test interface, and the test results are received. This method does not require the use of its corresponding preprocessor for each test interface, and realizes the multiplexing of interface parameters.

Benefits of technology

Simplifies the test process, improves the testing efficiency of the test interface, and avoids the need to rewrite preprocessors due to interface changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690834A_ABST
    Figure CN119690834A_ABST
Patent Text Reader

Abstract

The invention discloses an interface test method and device, computer equipment and a storage medium, and the method comprises the steps: obtaining at least two verification strategies, processing interface parameters of a test interface according to the at least two verification strategies, and obtaining verification parameters; generating an interface test request containing the verification parameter, and sending the interface test request to the test interface; and the test result generated by the test interface based on the interface test request is received, so that the test process is simplified, the interface parameters of the test interface can be quickly processed through the verification strategy of the proxy interface, and the interface test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of testing technology, and in particular to an interface testing method, device, computer equipment and storage medium. Background Art

[0002] With the rapid development of the software industry, in addition to providing standardized software operation services (Software as a Service, SAAS) products, companies also provide open platform interfaces for third parties to integrate and customize their own products. Open data interface refers to the act of encapsulating the website's services into a series of computer-readable data interfaces, and then opening them up for use by third-party developers. Correspondingly, the open application programming interface (Application Programming Interface, API) is called the open application programming interface (Open Application Programming Interface, Open API). In order to ensure the security of the call, these interfaces provided to third parties often require gateway authentication and meet specific encryption rules before they can be called.

[0003] Therefore, before calling these interfaces, these open interfaces need to be tested to ensure the security of the call. How to test this type of open interface has become one of the hot issues in current research. Summary of the invention

[0004] In response to the above technical problems, the embodiments of the present application provide an interface testing method, apparatus, computer equipment and storage medium, which can improve the efficiency of interface testing.

[0005] In a first aspect, an embodiment of the present application provides an interface testing method, comprising:

[0006] Acquire at least two verification strategies, and process interface parameters of the test interface according to the at least two verification strategies to obtain verification parameters;

[0007] Generate an interface test request including verification parameters, and send the interface test request to the test interface;

[0008] Receive test results generated by the test interface based on the interface test request.

[0009] In a second aspect, an embodiment of the present application provides an interface testing device, comprising:

[0010] A processing module, used to obtain at least two verification strategies, and process the interface parameters of the test interface according to the at least two verification strategies to obtain verification parameters;

[0011] A generation module, used for generating an interface test request including verification parameters, and sending the interface test request to a test interface;

[0012] The receiving module is used to receive the test result generated by the test interface based on the interface test request.

[0013] In a third aspect, an embodiment of the present application further provides a computer device, including a memory storing a plurality of instructions; a processor loads instructions from the memory to execute the steps of any one of the interface testing methods provided in the embodiments of the present application.

[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the steps of any one of the interface testing methods provided in the embodiment of the present application.

[0015] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of any one of the interface testing methods provided in the embodiments of the present application.

[0016] The scheme of the application embodiment is adopted, by obtaining at least two verification strategies, processing the interface parameters of the test interface according to the at least two verification strategies, and obtaining the verification parameters. Since the at least two verification strategies can process the interface parameters of any test interface to obtain the corresponding verification parameters, there is no need to distinguish the test interface, and the verification parameters of any test interface can be obtained by using at least two verification strategies. Therefore, an interface test request containing the verification parameters is generated, and the interface test request is sent to the test interface, so that the test interface can be tested based on the interface test request. The test result generated by the test interface based on the interface test request is received. Therefore, when testing the test interface, only at least two verification strategies need to be used to generate an interface test request containing the verification parameters, so that during the test process, there is no need to distinguish the test interface, and the corresponding interface test request can be generated to test the test interface, which simplifies the test process and improves the test efficiency of the test interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0018] Figure 1 It is a schematic diagram of the application environment of the interface testing method provided in the embodiment of the present application;

[0019] Figure 2 This is a schematic diagram of an embodiment of the interface testing method provided in the embodiments of the present application;

[0020] Figure 3 is a schematic diagram of the basic interface in the interface document provided in the embodiment of the present application;

[0021] Figure 4 is a structural schematic diagram of an interface testing device provided in an embodiment of the present application;

[0022] Figure 5 It is a schematic diagram of the internal structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0024] The interface testing method in one embodiment of the present application can be run on a computer device, which can be a terminal device or a server. When the game interaction method is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0025] In order to better understand the interface testing method, apparatus, computer equipment, storage medium and program product provided in the embodiments of the present application, the application environment applicable to the embodiments of the present application is described below.

[0026] See also Figure 1 , Figure 1 A schematic diagram of an application environment of the interface testing method provided in an embodiment of the present application is shown. As an implementation mode, the interface testing method, the training method of the interface testing model and the interface testing method provided in the embodiment of the present application can be applied to the same computer device. The computer device can be as follows: Figure 1The server 110 shown in the figure can be connected to the terminal device 120 through a network. The network is used to provide a medium for a communication link between the server 110 and the terminal device 120. The network can include various connection types, such as wired communication links, wireless communication links, etc., which are not limited in the embodiments of the present application. Optionally, in other embodiments, the computer device can also be a smart phone, a laptop computer, etc.

[0027] It should be understood that Figure 1 The server 110, network and terminal device 120 are merely illustrative. Depending on the implementation requirements, there may be any number of servers, networks and terminal devices. For example, the server 110 may be a physical server or a server cluster composed of multiple servers, and the terminal device 120 may be a mobile phone, a tablet, a desktop computer, a laptop computer, and the like. It is understood that the embodiments of the present application may also allow multiple terminal devices 120 to access the server 110 at the same time.

[0028] In some embodiments, the terminal device 120 can record the user's voice to obtain the user's audio data. Further, the terminal device 120 sends the user's audio data to the server 110 through the network. After the server 110 receives the user's audio data, the audio data can be processed by the interface testing method described in the embodiment of the present application.

[0029] The following is a detailed description in conjunction with the accompanying drawings. In this embodiment, the execution subject is a terminal device as an example. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.

[0030] In the process of interface testing for open application programming interface (Open API), it is usually necessary to use a test tool, such as the test tool jmeter. The authentication code file package is called through the preprocessor (such as BeanShell) in the test tool, and the gateway authentication parameters are generated according to the encryption algorithm in the authentication code file package. The interface to be tested verifies the interface test request according to the gateway authentication parameters to obtain the verification result.

[0031] When the gateway authentication rules of the interface to be tested change, the authentication code file needs to be regenerated according to the updated gateway authentication rules, and the authentication code file package (OpenAPI.jar package) of the interface to be tested also needs to be replaced in the test tool. If the parameters of the interface to be tested change or a new interface is added, the preprocessor of each interface needs to be rewritten so that the encryption algorithm in the new authentication code file can be used through the rewritten preprocessor. This will make the test efficiency low when testing a large number of application programming interfaces.

[0032] Based on this, an embodiment of the present application proposes an interface testing method, which can process the interface parameters of the test interface through at least two verification strategies configured by the proxy interface to obtain verification parameters, without the need to use the corresponding preprocessor for each test interface to use the encryption algorithm in the authentication code file package; different test interfaces can be reused through the proxy interface and verification strategy in the present application, so that there is no need to distinguish the test interfaces during the test process, and corresponding interface test requests can be generated to test the test interfaces, which simplifies the test process and improves the testing efficiency of the test interfaces.

[0033] Please refer to Figure 2 The specific process of the interface testing method may be as follows: Step S201 to Step S203, wherein:

[0034] S201, obtaining at least two verification strategies, and processing interface parameters of the test interface according to the at least two verification strategies to obtain verification parameters;

[0035] In this embodiment, the test interface refers to the interface to be tested, such as the open application programming interface (Open API) provided by various enterprises. The interface parameters are parameter information corresponding to the test interface, and the interface parameters may include identification information, a key, and a server address corresponding to the test interface. Among them, the identification information is used to identify the source of the test interface, the key is used to verify the interface test request of the test interface, and the server address is the address of the server corresponding to the test interface.

[0036] In some implementations, the interface parameters may include identification information, a key, and a server address corresponding to the test interface.

[0037] Since the test interface usually refers to a series of open data interfaces that are easily recognized by computers and encapsulate the services of the target website. Therefore, the relevant resources of the target website can be obtained through the test interface. The identification information is used to identify the source of the test interface, and multiple test interfaces can correspond to the same identification information. The identification information can be determined based on the port to which the test interface belongs. When the ports to which the test interface belongs are different, the identification information corresponding to the test interface is different.

[0038] For example, in some implementations, the test interface is an open data interface of the target website, and the identification information is information used to identify the target website, such as the ID of the target website, or the name code of the target website.

[0039] Alternatively, in some other implementations, the test interface is an open data interface of the target application, and the identification information is information for identifying the target application, such as an ID of the target application, or a name code of the target application.

[0040] The key may be a randomly generated key or a key agreed upon by the client and the server corresponding to the test interface. The client sends an interface test request to the server corresponding to the test interface, so that the server can verify the received interface test request, generate the corresponding test result, and return the test result to the client. The server address is the address of the server corresponding to the test interface, and the server corresponding to the test interface can be accessed through the server address.

[0041] Through identification information, keys and server addresses, accurate generation of test requests for different test interfaces can be achieved, thereby enabling accurate testing of different test interfaces through the generated test requests.

[0042] In some implementations, the interface parameters of the test interface may be determined by an initial test request sent by the client, wherein the client may be a computer device in the embodiment of the present application, or a terminal device connected to the computer device in the embodiment of the present application via wireless or wired connection.

[0043] Exemplarily, the initial test request includes an initial request header and an initial request body, wherein the initial request header includes identification information and a key corresponding to the test interface. The initial request body includes a server address corresponding to the test interface. The initial test request sent by the client is parsed to obtain interface parameters.

[0044] In other implementations, the client may also generate an authentication file package according to the gateway authentication rules of the test interface, and determine the interface parameters of the test interface based on the authentication file package. Specifically, the authentication file package sent by the client is received through the proxy interface, and the parsing strategy configured by the proxy interface is called to parse the authentication file package to obtain the interface parameters of the test interface.

[0045] The verification policy is a policy for verifying interface test requests, and the verification policy may include a preset authentication policy for the test interface. The verification policy may generate verification parameters, and then generate an interface test request based on the verification parameters, so that the server can verify the legitimacy of the interface test request based on the verification parameters in the received interface test request, thereby ensuring the access security of the test interface.

[0046] The interface test request for accessing the test interface may be verified by means of the verification parameters, so as to verify whether the interface test request has the authority to access the test interface and whether it complies with a preset format specification.

[0047] S202, generating an interface test request including verification parameters, and sending the interface test request to a test interface;

[0048] In this embodiment, the verification parameter can be used as a request header of the interface test request, and the request header and the server address corresponding to the test interface are concatenated to generate an interface test request, and the interface test request is sent to the test interface.

[0049] S203, receiving a test result generated by the test interface based on the interface test request.

[0050] Since the interface test request includes a verification parameter, the received interface test request can be verified by using the verification parameter.

[0051] Exemplarily, an interface test request is sent to a test interface, and the corresponding server is accessed through the test interface. The server parses the interface test request and obtains the verification parameters carried in the interface test request. The server verifies the verification parameters, determines whether the interface test request has access rights, and whether the interface test request conforms to the preset format specification, and obtains the corresponding test results. If the server determines that the interface test request has access rights and conforms to the preset format specification, it responds to the interface test request and returns the verification pass information to the client. If the server determines that the interface test request does not have access rights or does not conform to the preset format specification, it returns the verification failure information to the client.

[0052] In the embodiment of the present application, at least two verification strategies are obtained, and the interface parameters of the test interface are processed according to the at least two verification strategies to obtain the verification parameters. Since at least two verification strategies can process the interface parameters of any test interface to obtain the corresponding verification parameters, there is no need to distinguish the test interface, and the verification parameters of any test interface can be obtained by using at least two verification strategies. Therefore, an interface test request containing the verification parameters is generated, and the interface test request is sent to the test interface, so that the test interface can be tested based on the interface test request. The test result generated by the test interface based on the interface test request is received. Therefore, when testing the test interface, only at least two verification strategies need to be used to generate an interface test request containing the verification parameters, so that there is no need to distinguish the test interface during the test process, and the corresponding interface test request can be generated to test the test interface, which simplifies the test process and improves the test efficiency of the test interface.

[0053] In some embodiments of the present application, the interface parameters of the test interface are processed according to at least two verification strategies to obtain verification parameters, including:

[0054] Call the proxy interface that matches the test interface;

[0055] At least two verification strategies are executed through the proxy interface to process the interface parameters of the test interface to obtain verification parameters.

[0056] The proxy interface is a pre-set interface, and the proxy interface can be configured with at least two verification strategies. For example, the proxy interface can be a base / post_for_v5_notoken interface, and the verification strategy configured by the proxy interface can process the interface parameters to obtain the verification parameters of the test interface.

[0057] In some embodiments, the proxy interface may include multiple basic interfaces, and the encapsulated policies may be loaded through different basic interfaces. For example, the proxy interface includes a first basic interface and a second basic interface, the first basic interface encapsulates a first verification policy, and the second basic interface encapsulates a second verification policy. The first verification policy can be loaded through the first basic interface, and the second verification policy can be loaded through the second basic interface.

[0058] like Figure 3 As shown, Figure 3 A schematic diagram of a basic interface in an interface document corresponding to a proxy service provided in an embodiment of the present application. The proxy interface may include: Figure 3Multiple basic interfaces shown. For example, the proxy interface may include a first basic interface, a second basic interface, and a third basic interface. The first basic interface may be / base / compare_signature_v5; the second basic interface may be / base / faddcallback; and the third basic interface may be / base / post_for_v5.

[0059] Among them, multiple proxy interfaces and public interfaces can be configured in the proxy service. When the proxy service receives the interface parameters of the test interface sent by the client of the test tool, it can call the proxy interface matching the test interface, and execute at least two verification strategies through the proxy interface to process the interface parameters of the test interface and obtain verification parameters.

[0060] In some implementations, request parameters of the test interface may also be preconfigured in the proxy service.

[0061] By processing the interface parameters through at least two verification strategies loaded by the proxy interface, the verification parameters can be obtained. For example, according to the first verification strategy of at least two verification strategies, the interface parameters are processed to generate the first interface parameters; according to the second verification strategy of at least two verification strategies, the first interface parameters are processed to generate the verification parameters.

[0062] In some embodiments of the present application, the above-mentioned generating an interface test request including verification parameters includes:

[0063] Determine the request header based on the verification parameters;

[0064] Generate an interface test request based on the request header and the server address corresponding to the test interface.

[0065] In this embodiment, the verification parameter can be introduced into a preset first request header to obtain a request header of an interface test request corresponding to the test interface, wherein the first request header is a request header including the first verification parameter.

[0066] For example, the first request header is requestHeaders. By executing requestHeaders.put("X-FASC-Sign", FddCryptUtil.sign(FddCryptUtil.sortParameter sObject(requestHeaders), timestamp, key)), the verification parameters can be introduced into the first request header to obtain the request header of the interface test request corresponding to the test interface.

[0067] Among them, "X-FASC-Sign" is a verification parameter, and the value of the verification parameter "X-FASC-Sign" is FddCryptUtil.sign(FddCryptUtil.sortParametersObject(requestHeaders),timestamp,key).

[0068] The server corresponding to the test interface is the server that provides the test interface. Through the test interface, the server can be accessed to obtain specific resources or perform specific operations. The server address corresponding to the test interface can be obtained through the interface parameters. Therefore, the request header determined according to the verification parameters and the server address are spliced ​​to obtain the interface test request.

[0069] In some implementations, a request body of an interface test request may also be generated according to the requested service type. The interface test request is obtained by concatenating the request header, the server address and the request body determined by the verification parameters, so as to obtain data for a specific service or perform a specific operation through the generated interface test request.

[0070] For example, by executing HttpResponse httpResponse = HttpToolKit.invokePost(requestHost, requestHeaders, body), an interface test request is generated.

[0071] Among them, httpResponse is the interface test request, requestHost is the server address, requestHeaders is the request header determined according to the verification parameters, and body is the request body. Among them, the server address can be obtained by executing String requestHost = post_json.getString ("url"), and post_json.getString ("url") is an example address.

[0072] This embodiment determines the request header of the interface test request according to the verification parameters, and generates the interface test request based on the request header and the server address, thereby realizing efficient assembly of the interface test request, so that the generated interface test request can quickly access the server corresponding to the test interface.

[0073] In some embodiments of the present application, the at least two verification strategies include a parameter generation strategy and an encryption strategy;

[0074] Processing interface parameters of the test interface according to at least two verification strategies to obtain verification parameters includes:

[0075] Generate a first verification parameter based on the parameter generation strategy and the interface parameter;

[0076] The first verification parameter is encrypted based on the encryption policy to generate a verification parameter.

[0077] In this embodiment, the first verification parameter is a parameter for authority verification between the client and the server corresponding to the test interface, and is used to verify whether the interface test request has the corresponding authority to access the server corresponding to the test interface.

[0078] In some implementations, the first verification parameter may be an access token for accessing a server corresponding to the test interface. By carrying the access token in the interface test request, the server corresponding to the test interface may verify the access token upon receiving the interface test request to determine whether to respond to the interface test request.

[0079] The parameter generation strategy refers to a strategy for generating the first verification parameter, and the parameter generation strategy can be encapsulated into a function for the proxy interface to call. Exemplarily, in order to improve the reusability of the parameter generation strategy, the logic of the parameter generation strategy can be encapsulated into a first function, and the first function can be called by the proxy interface. When it is necessary to generate the first verification parameter of the test interface, the first function can be called through the proxy interface to load the parameter generation strategy. Then, the interface parameters are processed through the loaded parameter generation strategy to generate the first verification parameter. For example, the interface parameters are combined, or assignment operations are performed through the loaded parameter generation strategy to generate the first verification parameter.

[0080] The encryption strategy is a strategy for encrypting the first verification parameter. In some implementations, a preset encryption algorithm, such as a symmetric encryption algorithm or an asymmetric encryption algorithm, can be encapsulated as a second function. The second function can be called through a proxy interface to load the encryption strategy. Then, the first verification parameter is encrypted through the loaded encryption strategy to generate a verification parameter.

[0081] By loading the parameter generation strategy and encryption strategy through the proxy interface, the parameter generation strategy and encryption strategy can be quickly loaded, thereby improving the test efficiency of the interface. In addition, since the parameter generation strategy and encryption strategy are universal, the interface parameters of different test interfaces can be processed according to the encryption strategy and parameter generation strategy to generate corresponding verification parameters, so as to realize the reuse of the parameter generation strategy and encryption strategy, and further improve the test efficiency for different test interfaces.

[0082] In some embodiments of the present application, the above-mentioned generating the first verification parameter based on the parameter generation strategy and the interface parameter includes:

[0083] Get the default authentication parameters;

[0084] Based on the parameter generation strategy, the interface parameters and the default verification parameters are processed to generate the first verification parameters.

[0085] In this embodiment, the default verification parameters may be pre-set verification parameters or default parameters obtained by loading parameter generation policies through the proxy interface. The default verification parameters include but are not limited to parameters such as random value (nonce), timestamp (timestamp), encryption type (SignType), authorization mode (granttype), token request platform (tokenRequestHost) and version (versions).

[0086] In some implementations, the interface parameters and default verification parameters may be processed according to the parameter generation strategy to generate the first verification parameter. The processing may be a combination and / or assignment operation.

[0087] This embodiment obtains preset default verification parameters, processes interface parameters and default verification parameters through parameter generation strategy, and generates first verification parameters, which can achieve accurate determination of the first verification parameters, thereby enabling accurate verification of interface test requests based on the first verification parameters.

[0088] In some embodiments of the present application, the above-mentioned processing of the interface parameters and the default verification parameters based on the parameter generation strategy to generate the first verification parameters includes:

[0089] Initializing the default verification parameter to generate a second verification parameter;

[0090] Based on the parameter generation strategy, the interface parameters and the second verification parameters are encapsulated to generate a function;

[0091] Generate a first verification parameter through a function.

[0092] The default verification parameter may be initialized according to the initialization instruction to obtain the second verification parameter.

[0093] In some embodiments, if the default verification parameters include a random value (nonce), a timestamp (timestamp), an encryption type (SignType), an authorization mode (granttype), a token request platform (tokenRequestHost), and a version (versions), then the initialization of the default verification parameters includes initialization of the random value (nonce), initialization of the timestamp (timestamp), initialization of the encryption type (SignType), initialization of the authorization mode (granttype), initialization of the token request platform (tokenRequestHost), and initialization of the version (versions).

[0094] Exemplarily, the random value (nonce) can be initialized by executing "String nonce = cmd.getUUID()". Wherein, cmd.getUUID() is the default value of the random value. The timestamp (timestamp) can be initialized by executing "String timestamp = Long.toString (System.currentTimeMillis())".

[0095] Among them, Long.toString(System.currentTimeMillis()) is the default value of the timestamp.

[0096] The encryption type (SignType) can be initialized by executing "public String SignType = "HMAC-SHA256"". Among them, "HMAC-SHA256" is the default value of the encryption type.

[0097] The authorization mode (granttype) can be initialized by executing "public String granttype="client_credential"".

[0098] Among them, "client_credential" is the default value of the authorization mode. The token request platform (tokenRequestHost) can be initialized by executing "StringtokenRequestHost=requestHost.substring(0,requestHost.indexOf("v5 / ")+3)".

[0099] Among them, requestHost.substring(0,requestHost.indexOf("v5 / ")+3) is the default value of the token request platform.

[0100] By executing "String versions="5.1"", the versions can be initialized. "5.1" is the default value of the version.

[0101] By initializing the default verification parameters, the second verification parameters obtained after initialization can be made more stable, avoiding program running errors due to non-initialization, and further ensuring the reliability and stability of the first verification parameters generated by the second verification parameters and interface parameters.

[0102] Furthermore, since the parameter generation strategy encapsulates the method of processing each interface parameter and the second verification parameter, the function corresponding to the parameter generation strategy can be updated through the interface parameter and the second verification parameter to obtain the updated function. When the first verification parameter needs to be generated, the updated function can be called and assigned to the verification parameter (such as the preset access token) to obtain the first verification parameter.

[0103] Exemplarily, the parameter generation strategy can be encapsulated as a first function, such as a function corresponding to the getAPPtoken method. The first function is updated according to the interface parameter and the second verification parameter to obtain an updated first function. The first function is assigned to a preset access token, such as an X-FASC-AccessToken token, to obtain a first verification parameter.

[0104] Exemplarily, the first verification parameter may be generated by executing the following instruction: requestHeaders.put("X-FASC-AccessToken",getAppToken(tokenRequestHost,appId,key,versions)).

[0105] Among them, tokenRequestHost and versions are the second verification parameters, and appId and key are interface parameters. The obtained interface parameters and second verification parameters are encapsulated into a function corresponding to the getAppToken method, and then the function corresponding to the encapsulated getAppToken method is called and assigned to the access token X-FASC-AccessToken to obtain the first verification parameter.

[0106] "X-FASC-AccessToken",getAppToken(tokenRequestHost,appId,key,versions) is the first verification parameter.

[0107] Through the parameter generation strategy, the interface parameters and the second verification parameters are encapsulated to generate a function, so that the first verification parameter is generated quickly and accurately through the generated function, further improving the efficiency of obtaining the first verification parameter.

[0108] In some embodiments of the present application, the above-mentioned encrypting the first verification parameter based on the encryption policy to generate the verification parameter includes:

[0109] Generate a first request header according to the first verification parameter;

[0110] Encrypt the first request header based on the encryption policy to generate verification parameters;

[0111] Generate an interface test request containing verification parameters, including:

[0112] Introduce the verification parameter into the first request header to obtain the request header of the interface test request;

[0113] Generate an interface test request based on the request header and the server address corresponding to the test interface.

[0114] In this embodiment, the second request header is a request header including a second verification parameter. The second verification parameter obtained after initialization is introduced into the constructed basic request header to obtain the second request header. The basic request header can be an empty request header, or a request header including a default verification parameter, or a preset initial request header.

[0115] For example, by executing requestHeaders.put("X-FASC-Sign-Type",SignType), the initialized encryption type SignType can be introduced into the basic request header requestHeaders.

[0116] By executing requestHeaders.put("X-FASC-Timestamp",timestamp), the initialized timestamp timestamp can be introduced into the basic request header requestHeaders.

[0117] By executing requestHeaders.put("X-FASC-Nonce",nonce), the initialized random value nonce can be introduced into the basic request header requestHeaders.

[0118] The first verification parameter is introduced into the second request header to obtain the first request header.

[0119] The first request header is used as an encryption object of the encryption strategy, and the first request header is encrypted by the encryption strategy to obtain a verification parameter. The verification parameter is introduced into the first request header to obtain a request header of the interface test request.

[0120] By generating a first request header through a first verification parameter and encrypting the first request header according to an encryption policy to generate a verification parameter, rapid encryption of the verification parameter can be achieved, and further the request header of the interface test request can be rapidly generated through the verification parameter.

[0121] The interface testing method proposed in this application is described below in conjunction with a specific implementation scenario.

[0122] The preset test tool jmeter is used as the client, and the proxy interface is used as the pre-set third-party interface. Among them, the test interface is an open application programming interface (Open API).

[0123] Configure the interface parameters of the test interface in the test tool jmeter to generate an authentication file package for the test interface. The test tool sends the authentication file package to the proxy interface, which parses the authentication file package to obtain the interface parameters of the test interface.

[0124] The proxy interface loads at least two configured verification strategies, processes the obtained interface parameters according to the at least two verification strategies, and generates verification parameters. The proxy interface generates an interface test request according to the verification parameters, and sends the interface test request to the test interface.

[0125] The server corresponding to the test interface verifies the interface test request received through the test interface and responds to the interface test request according to the verification result. If the server verifies the interface test request successfully, it responds to the interface test request and returns the verification pass information to the client; if the server fails to verify the interface test request, it returns the verification fail information to the client.

[0126] When a new test interface needs to be added or modified, it can be achieved by modifying the plaintext request body in the test tool. The plaintext request body can be the interface parameters of the newly added test interface or the interface parameters of the modified test interface.

[0127] In some implementations, testing tools such as postman and metersphere may also be used as clients to call the proxy interface.

[0128] It should be understood that, although each step in the flowcharts involved in the above-mentioned embodiments is displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0129] Based on the same inventive concept, the embodiment of the present application also provides an interface testing device for implementing the interface testing method involved above, and an interface testing device for implementing the interface testing method. The implementation solution provided by the device is similar to the implementation solution recorded in the above method, so the specific limitations in the embodiments of one or more interface testing devices and interface testing devices provided below can refer to the above limitations on the interface testing method and interface testing method, and the specific limitations will not be repeated here.

[0130] This embodiment also provides an interface testing device, which can be integrated into a terminal device. Figure 4 As shown, the interface testing device may include:

[0131] The processing module 401 is used to obtain at least two verification strategies, and process the interface parameters of the test interface according to the at least two verification strategies to obtain verification parameters;

[0132] A generating module 402, configured to generate an interface test request including verification parameters, and send the interface test request to a test interface;

[0133] The receiving module 403 is used to receive the test result generated by the test interface based on the interface test request.

[0134] The above-mentioned interface testing device simplifies the generation of verification parameters, so that the interface parameters of the test interface can be quickly processed through the verification strategy of the proxy interface, thereby improving the generation efficiency of the verification parameters, and further enabling the interface test request generated by the verification parameters to quickly test the test interface, thereby improving the interface testing efficiency.

[0135] In some embodiments of the present application, the processing module 401 obtains at least two verification strategies, processes the interface parameters of the test interface according to the at least two verification strategies, and obtains the verification parameters by specifically performing the following steps:

[0136] Call the proxy interface that matches the test interface;

[0137] At least two verification strategies are executed through the proxy interface to process the interface parameters of the test interface to obtain verification parameters.

[0138] In some embodiments of the present application, the generation module 402 specifically performs the following steps when generating an interface test request including verification parameters:

[0139] Determine the request header based on the verification parameters;

[0140] Generate an interface test request based on the request header and the server address corresponding to the test interface.

[0141] In some embodiments of the present application, the at least two verification strategies include a parameter generation strategy and an encryption strategy. The processing module 401 processes the interface parameters of the test interface according to the at least two verification strategies to obtain the verification parameters, and specifically performs the following steps:

[0142] Generate a first verification parameter based on the parameter generation strategy and the interface parameter;

[0143] The first verification parameter is encrypted based on the encryption policy to generate a verification parameter.

[0144] In some embodiments of the present application, the processing module 401 generates the first verification parameter based on the parameter generation strategy and the interface parameter, and specifically performs the following steps:

[0145] Get the default authentication parameters;

[0146] Based on the parameter generation strategy, the interface parameters and the default verification parameters are processed to generate the first verification parameters.

[0147] In some embodiments of the present application, the processing module 401 processes the interface parameters and the default verification parameters based on the parameter generation strategy to generate the first verification parameter, and specifically performs the following steps:

[0148] Initialize the default verification parameter to generate the second verification parameter;

[0149] Based on the parameter generation strategy, the interface parameters and the second verification parameters are encapsulated to generate a function;

[0150] Generate a first verification parameter through a function.

[0151] In some embodiments of the present application, the processing module 401 encrypts the first verification parameter based on the encryption policy to generate the verification parameter, and specifically performs the following steps:

[0152] Generate a first request header according to the first verification parameter;

[0153] The first request header is encrypted based on the encryption policy to generate verification parameters.

[0154] The above-mentioned generating module 402 specifically performs the following steps when generating an interface test request including verification parameters:

[0155] Introduce the verification parameter into the first request header to obtain the request header of the interface test request;

[0156] Generate an interface test request based on the request header and the server address corresponding to the test interface.

[0157] Based on the same inventive concept, the embodiment of the present application also provides a computer device, which may be a server or a terminal device, and includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above interface testing method when executing the computer program. Thereby, various functions are realized, such as:

[0158] Acquire at least two verification strategies, and process interface parameters of the test interface according to the at least two verification strategies to obtain verification parameters;

[0159] Generate an interface test request including verification parameters, and send the interface test request to the test interface;

[0160] Receive test results generated by the test interface based on the interface test request.

[0161] The computer device proposed in the embodiment of the present application simplifies the generation of verification parameters, so that the interface parameters of the test interface can be quickly processed through the verification strategy of the proxy interface, thereby improving the generation efficiency of the verification parameters, and further enabling the interface test request generated by the verification parameters to quickly test the test interface, thereby improving the interface testing efficiency.

[0162] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0163] In one embodiment, the structural diagram of the computer device can be as follows: Figure 5As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an interface testing method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0164] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0165] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0166] Since the computer program stored in the computer-readable storage medium can execute any one of the interface testing methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the interface testing methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0167] Based on the same inventive concept, the embodiment of the present application further provides a computer program product or a computer program, which includes a computer instruction, and the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional implementations in the above embodiments.

[0168] It should be noted that the object data (including but not limited to user device information, user personal information, etc.) and conversation data involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods.

[0169] Any reference to the memory, database or other media used in the embodiments provided in the present application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (Re RAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0170] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.

[0171] In the above-mentioned interface test device, computer-readable storage medium, computer equipment, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the above-described interface test device, computer-readable storage medium, computer program product, computer equipment, and corresponding units can refer to the description of the interface test method in the above embodiment, and will not be repeated here.

[0172] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0173] The above is a detailed introduction to an interface testing method, device, computer equipment, computer-readable storage medium and computer program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. An interface testing method, characterized in that: The method comprises: Acquire at least two verification strategies, and process interface parameters of the test interface according to the at least two verification strategies to obtain verification parameters; Generate an interface test request including the verification parameters, and send the interface test request to the test interface; Receive a test result generated by the test interface based on the interface test request.

2. The interface testing method according to claim 1, characterized in that: The step of processing the interface parameters of the test interface according to the at least two verification strategies to obtain the verification parameters includes: Calling a proxy interface that matches the test interface; The at least two verification strategies are executed through the proxy interface to process the interface parameters of the test interface to obtain the verification parameters.

3. The interface testing method according to claim 1, characterized in that: The generating of the interface test request including the verification parameter comprises: Determine a request header according to the verification parameters; An interface test request is generated based on the request header and the server address corresponding to the test interface.

4. The interface testing method according to claim 1, characterized in that: The at least two verification strategies include a parameter generation strategy and an encryption strategy; The step of processing the interface parameters of the test interface according to the at least two verification strategies to obtain the verification parameters includes: Based on the parameter generation strategy and the interface parameter, generate a first verification parameter; The first verification parameter is encrypted based on the encryption policy to generate the verification parameter.

5. The interface testing method according to claim 4, characterized in that: The step of generating a first verification parameter based on the parameter generation strategy and the interface parameter includes: Get the default authentication parameters; Based on the parameter generation strategy, the interface parameters and the default verification parameters are processed to generate the first verification parameters.

6. The interface testing method according to claim 5, characterized in that: The step of processing the interface parameter and the default verification parameter based on the parameter generation strategy to generate the first verification parameter includes: Initializing the default verification parameter to generate a second verification parameter; Based on the parameter generation strategy, encapsulate the interface parameter and the second verification parameter to generate a function; The first verification parameter is generated through the function.

7. The interface testing method according to claim 4, characterized in that: The step of encrypting the first verification parameter based on the encryption policy to generate the verification parameter includes: Generate a first request header according to the first verification parameter; Encrypt the first request header based on the encryption strategy to generate the verification parameter; The generating of the interface test request including the verification parameter comprises: Introducing the verification parameter into the first request header to obtain the request header of the interface test request; The interface test request is generated based on the request header and the server address corresponding to the test interface.

8. An interface testing device, characterized in that: The device comprises: A processing module, used to obtain at least two verification strategies, and process the interface parameters of the test interface according to the at least two verification strategies to obtain verification parameters; A generating module, used for generating an interface test request including the verification parameters, and sending the interface test request to the test interface; The receiving module is used to receive the test result generated by the test interface based on the interface test request.

9. A computer device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the interface testing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the interface testing method according to any one of claims 1 to 7.