Interface verification method, device, equipment and program product
By training the interface verification model to automatically output the expected response parameters, the high cost and misjudgment problems caused by reliance on manual rules are solved, and efficient, accurate and intelligent interface verification is achieved.
Patent Information
- Application Number
- CN202510941668.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2025-10-17
AI Technical Summary
In the existing technology, interface testing and verification rely on manually preset rules and manual matching verification, which leads to high rule maintenance costs, lack of flexibility and insufficient verification accuracy. It is difficult to adapt to complex business scenarios and is prone to misjudgment or missed judgment.
The interface verification model is trained based on a sample data set covering different business scenarios and different types of interfaces. The interface verification model is used to automatically output expected response parameters, and the verification results are determined through similarity calculation, reducing manual intervention.
It improves the efficiency and accuracy of interface verification, reduces the probability of misjudgment, is suitable for complex business scenarios and different types of interfaces, and realizes intelligent verification of interfaces.
Smart Images

Figure CN120803884A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to software testing techniques, and in particular, to an interface verification method, apparatus, device and program product. BACKGROUND
[0002] Interface testing and verification is an important part of software quality assurance. In related technologies, the interface testing and verification method is usually to set the interface expected return result based on the preset rules, match the interface actual return result with the interface expected return result, and verify whether the interface has the expected function. The matching and verification method relying on the preset rules needs manual management of rules and manual matching and verification.
[0003] However, with the increase of interface complexity and data diversity, the matching and verification method relying on manual work is time-consuming and cannot fully adapt to complex business scenarios, which may lead to misjudgment or omission. SUMMARY
[0004] Embodiments of the present disclosure provide an interface verification method, apparatus, device and program product to solve the above technical problems to some extent.
[0005] In one aspect of the embodiments of the present disclosure, an interface verification method is provided, which includes: obtaining an interface request parameter of a to-be-verified interface and an interface response parameter output by the to-be-verified interface after processing the interface request parameter; inputting the interface request parameter into a pre-trained interface verification model to output an expected response parameter via the interface verification model, wherein the interface verification model is trained based on a sample data set covering different business scenarios and different types of interfaces; determining a verification result of the to-be-verified interface based on a difference between the interface response parameter and the expected response parameter.
[0006] In one exemplary embodiment, the sample data set includes positive and negative sample pairs, and the positive sample pairs include sample request parameters, positive sample response parameters and negative sample response parameters corresponding to the sample request parameters; The method further includes: inputting the positive and negative sample pairs into the interface verification model, and training the interface verification model based on a contrastive loss function, the contrastive loss function being used to minimize the distance of the positive sample response parameters in the model space corresponding to the interface verification model in the same positive and negative sample pair, and maximize the distance of the negative sample response parameters in the model space corresponding to the interface verification model in the same positive and negative sample pair.
[0007] In an example embodiment, the inputting the interface request parameter into the pre-trained interface verification model comprises: The inputting the interface request parameter into the pre-trained interface verification model comprises: The outputting the expected response parameter determined based on the positive sample set by the interface verification model.
[0008] In an example embodiment, the sample data in the sample data set comprises at least one of: The historical traffic data of different types of sample interfaces, wherein the historical traffic data of the sample interface comprises historical request parameters and corresponding historical response parameters of the sample interface; The sample request parameters and sample response parameters constructed for different types of sample interfaces; The sample response parameters simulated and generated based on the business knowledge and interface structure of the business scenario corresponding to the sample interface.
[0009] In an example embodiment, the determining the verification result of the interface to be verified based on the difference between the interface response parameter and the expected response parameter comprises: Calculating the vector similarity between the vector corresponding to the interface response parameter and the vector corresponding to the expected response parameter; In response to the vector similarity being greater than the similarity threshold value corresponding to the interface to be verified, determining that the verification result is verified; In response to the vector similarity being less than the similarity threshold value corresponding to the interface to be verified, determining that the verification result is not verified.
[0010] In an example embodiment, after calculating the similarity between the vector corresponding to the interface response parameter and the vector corresponding to the expected response parameter, the method further comprises: Obtaining the similarity threshold value corresponding to the interface to be verified, wherein the similarity threshold value is positively correlated with the field complexity returned by the interface to be verified.
[0011] In an example embodiment, the method further comprises: Obtaining the misjudgment verification result of the interface to be verified, wherein the misjudgment verification result is an incorrect verification result; In response to the number of misjudgment verification results of the interface to be verified being greater than a preset number threshold value, adjusting the similarity threshold value corresponding to the interface to be verified.
[0012] Another aspect of this embodiment provides an interface verification device, including: A parameter acquisition module is used to obtain the interface request parameters of the interface to be verified, and the interface response parameters output after the interface to be verified processes the interface request parameters; A model processing module is used to input the interface request parameters into a pre-trained interface verification model, and output expected response parameters through the interface verification model, wherein the interface verification model is trained based on a sample data set covering different business scenarios and different types of interfaces; The result determination module is used to determine the verification result of the interface to be verified based on the difference between the interface response parameter and the expected response parameter.
[0013] Another aspect of this embodiment provides an electronic device, including: Memory for storing computer programs; The processor is configured to execute the computer program stored in the memory, and when the computer program is executed, the interface verification method described in any one of the above embodiments is implemented.
[0014] Another aspect of this embodiment provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the interface verification method described in any one of the above embodiments is implemented.
[0015] Another aspect of this embodiment provides a computer program product, including a computer program. When the computer program is executed by a processor, the interface verification method described in any one of the above embodiments is implemented.
[0016] In an embodiment of the present disclosure, a pre-trained interface verification model is used to process the interface request parameters of the interface to be verified to obtain expected response parameters corresponding to the interface request parameters, wherein the interface verification model is trained based on a sample data set covering a variety of different business scenarios and different types of interfaces, so that the trained interface verification model can process the interface request parameters of different types of interfaces to be verified in complex business scenarios to obtain accurate expected response parameters, thereby determining the verification result of the interface to be verified based on the difference between the expected response parameters and the actual interface response parameters of the interface to be verified, and realizing intelligent verification of the interface without relying on the formulation and management of manual rules, which helps to improve the efficiency of interface verification and helps to reduce the probability of missed judgment. In addition, the pre-trained interface verification model can be applied to the verification of different types of interfaces in complex business scenarios, and can generate accurate expected response parameters. Interface verification is performed based on the accurate expected response parameters, which helps to improve the accuracy of the interface verification results and reduce the probability of misjudgment.
[0017] The technical solutions of the present disclosure will be further described in detail below with reference to the drawings and examples. BRIEF DESCRIPTION OF DRAWINGS
[0018] The accompanying drawings, which form a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0019] The present disclosure can be more clearly understood and appreciated by reference to the following detailed description of embodiments, taken in conjunction with the accompanying drawings, in which: Figure 1 A flowchart of an interface verification method provided for an exemplary embodiment of the present disclosure; Figure 2 A flowchart of a process of generating an expected response parameter provided for an exemplary embodiment of the present disclosure; Figure 3 A flowchart of a process of determining a verification result provided for an exemplary embodiment of the present disclosure; Figure 4 A structural schematic diagram of interface verification provided for an exemplary embodiment of the present disclosure; Figure 5 A structural schematic diagram of an interface verification apparatus provided for an exemplary embodiment of the present disclosure; Figure 6 A structural schematic diagram of an interface verification apparatus provided for another exemplary embodiment of the present disclosure; Figure 7 A structural schematic diagram of an interface verification apparatus provided for yet another exemplary embodiment of the present disclosure; Figure 8 A structural schematic diagram of an electronic device provided for an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0020] Various exemplary embodiments of the present disclosure will now be described in detail below with reference to the accompanying drawings. Note that the relative arrangement, numerical expressions, and numerical values of components and steps set forth in these embodiments do not limit the scope of the present disclosure unless specifically stated otherwise.
[0021] Those skilled in the art can understand that the terms "first", "second", and the like in the embodiments of the present disclosure are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they represent a necessary logical sequence between them.
[0022] It should also be understood that in the embodiments of the present disclosure, "multiple" can refer to two or more, and "at least one" can refer to one, two, or more.
[0023] It should also be understood that for any component, data, or structure mentioned in the embodiments of the present disclosure, unless specifically limited or given a contrary implication by the context or prior art, it can generally be understood as one or more.
[0024] In addition, the term "and / or" in the present disclosure is merely a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone. In addition, the character " / " in the present disclosure generally represents that the front and rear associated objects are in an "or" relationship.
[0025] It should also be understood that the description of the various embodiments of the present disclosure focuses on the differences between the various embodiments, and the same or similar parts can be referred to each other, and for the sake of brevity, will not be repeated.
[0026] At the same time, it should be understood that, for the convenience of description, the size of each part shown in the drawings is not drawn according to the actual proportional relationship.
[0027] The following description of at least one example embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0028] Techniques, methods, and devices known to those of ordinary skill in the relevant art can not be discussed in detail, but should be considered part of the specification where appropriate.
[0029] It should be noted that similar reference numbers and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further discussed in subsequent drawings.
[0030] Embodiments of the present disclosure can be applied to terminal devices, computer systems, servers, and other electronic devices, which can operate with many other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with terminal devices, computer systems, servers, and other electronic devices include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, mainframe computer systems, and distributed cloud computing technology environments including any of the above systems, and the like.
[0031] Electronic devices such as terminal devices, computer systems, servers, and the like can be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules can include routines, programs, objects, components, logic, data structures, and the like, that perform particular tasks or implement particular abstract data types. Computer systems / server can be practiced in distributed cloud computing environments with other computer systems coupled to communicate over a communication network. In a distributed cloud computing environment, program modules can be located in local or remote computer system storage media including memory storage devices.
[0032] The traditional interface test verification relies on manual preset rules and manual matching verification. By comparing the actual return result of the interface with the preset expected return result, it is verified whether the interface works as expected. However, with the increase of interface complexity and data diversity, the mode relying on manual preset rules and manual matching rules has the following disadvantages: 1. High rule maintenance cost: The preset rules need to be updated according to the business logic, especially in the case of complex and frequent business changes, which requires a lot of manual cost and time cost; 2. Lack of flexibility: The traditional verification mode is based on preset rules or thresholds, which requires manual construction of parameters and manual comparison verification, and cannot fully adapt to complex business scenarios, fuzzy rule matching or abnormal situations; 3. Insufficient verification accuracy: The traditional verification mode is difficult to combine the interface verification result with the business logic deeply, and is prone to misjudgment or omission.
[0033] In the embodiments of the present disclosure, a sample data set covering various business scenarios and different types of interfaces is used to train an interface verification model, so that the interface verification model can automatically output the expected response parameters according to the interface request parameters of the input interface to be verified, and automatically determine the verification result based on the expected response parameters and the actual returned interface response parameters, without relying on manual work, and can be applied to various business scenarios and different types of interfaces, which helps to improve the interface verification efficiency and the accuracy of the verification result.
[0034] As shown in Figure 1 The flowchart of the interface verification method provided by an example embodiment of the present disclosure is shown, which can be used for the above-mentioned electronic device, and the method includes steps 101-103: Step 101, obtaining the interface request parameters of the interface to be verified, and the interface response parameters output by the interface to be verified after processing the interface request parameters.
[0035] The interface to be verified can be any type of interface in any business scenario. Schematically, the interface to be verified can be an interface for querying information, such as an interface for querying order information, browsing information, product information, etc.
[0036] Interface request parameters are parameters input to the interface to be verified. After receiving the interface request parameters, the interface to be verified can process them to obtain interface response parameters, which are the parameters actually returned by the interface to be verified. For example, taking the interface to be verified as an information query interface, the interface request parameters, including the requested query information, can be processed to obtain interface response parameters, which include the query results obtained based on the requested query information.
[0037] In a possible implementation, for the interface to be verified, at least one set of parameters corresponding to the interface to be verified may be obtained, wherein the set of parameters includes an interface request parameter and an interface response parameter obtained by processing the interface request parameter.
[0038] Step 102: Input the interface request parameters into a pre-trained interface verification model, and the interface verification model outputs the expected response parameters.
[0039] The interface verification model is trained based on a sample data set covering different business scenarios and different types of interfaces. In one possible implementation, the interface verification model can be pre-trained based on sample data corresponding to interfaces in different business scenarios and sample data corresponding to different types of interfaces, so that the interface verification model requires interface response characteristics in different business scenarios and different types of interfaces and outputs accurate expected response parameters. Optionally, the sample data in the sample data set can include at least one of actual historical sample data, artificially constructed data, and sample data obtained by large model simulation.
[0040] The interface verification model is pre-trained through a sample data set so that the trained interface verification model can process interface request parameters corresponding to interfaces in different business scenarios and different types of interfaces, and output the expected response parameters of the interface.
[0041] Optionally, the interface verification model can adopt an Embedding model architecture, for example, a BERT (Bidirectional Encoder Representation from Transformers) model, a RoBERT (Robustly optimized BERT approach) model, a Sentence Embedding model, etc. By adopting the Embedding model architecture, complex text, pictures or structured data can be converted into high-dimensional vectors, which helps to capture the potential relationship between data. In the interface verification scenario, the Embedding model architecture can be more flexible and accurate in analyzing and verifying the interface return result, overcoming the problem that the traditional method is difficult to cope with diversified scenarios.
[0042] In an exemplary example, the BERT model can be adopted as the interface verification model. When training the BERT model, the BERT model can be pre-trained first, and after the pre-training is completed, the BERT model is fine-tuned to obtain the interface verification model for interface verification. In the pre-training process, the BERT model can be trained using a general database to enable the BERT model to learn general language knowledge. Then, the BERT model obtained by pre-training is fine-tuned using a sample data set containing different business scenarios and different types of interfaces, so that it learns the return features of different interfaces. The BERT model obtained by fine-tuning can be used for interface verification of different business scenarios and different types of interfaces. By pre-training to obtain general language representation and then fine-tuning to generate high-quality vector parameters for the interface verification task, the model training efficiency can be improved. Moreover, the BERT model has deep semantic understanding capability. By adopting the BERT model as the interface verification model, complex structured data can be processed, which helps to improve the adaptability to complex business scenarios and can be fully applicable to various interface verification scenarios. The automatic generation of interface expected response parameters can be efficiently and accurately realized, and the intelligent verification of the interface can be realized.
[0043] The expected response parameter is the response parameter expected to be output by the interface after processing the interface request parameter. In the embodiments of the present disclosure, the interface verification model generates the expected response parameter corresponding to the interface request parameter.
[0044] Step 103, determining the verification result of the interface to be verified based on the difference between the interface response parameter and the expected response parameter.
[0045] After generating the expected response parameter, the difference between the expected response parameter and the interface response parameter can be used to determine the verification result of the interface to be verified.
[0046] In a possible implementation, the verification result can be determined based on a similarity between the preset response parameter and the interface response parameter. When the similarity is greater than a similarity threshold, the verification result can be determined as a verification pass; and when the similarity is not greater than the similarity threshold, the verification result can be determined as a verification fail. Optionally, the similarity threshold can be a preset similarity threshold, and a specific value of the similarity threshold can be adjusted according to a business scenario and a type of the interface to be verified. Illustratively, the similarity threshold can be 0.8.
[0047] By comparing the interface response parameter and the expected response parameter, the verification result of the interface to be verified can be automatically determined without relying on manual work.
[0048] In the embodiments of the present disclosure, the interface verification model is used to process the interface request parameter of the interface to be verified, to obtain the expected response parameter corresponding to the interface request parameter. The interface verification model is trained based on a sample data set covering multiple different business scenarios and different types of interfaces, so that the interface verification model trained in this way can process the interface request parameter of the interface to be verified in a complex business scenario and of different types, to obtain an accurate expected response parameter. Then, based on the difference between the expected response parameter and the actual interface response parameter of the interface to be verified, the verification result of the interface to be verified can be determined, which can realize intelligent verification of the interface without relying on the establishment and management of manual rules, and can help improve the interface verification efficiency and reduce the probability of missed judgment. In addition, the interface verification model trained in advance can be applied to the verification of interfaces in a complex business scenario and of different types, to generate accurate expected response parameters, and based on the accurate expected response parameters, the interface verification can be performed, which can help improve the accuracy of the interface verification result and reduce the probability of misjudgment.
[0049] In a possible implementation, the sample data set includes positive-negative sample pairs, and each positive-negative sample pair includes a sample request parameter, a positive sample response parameter (also referred to as a correct response parameter) corresponding to the sample request parameter, and a negative sample response parameter (also referred to as an error response parameter). Optionally, one positive-negative sample pair includes one sample request parameter, at least one positive sample response parameter, and at least one negative sample response parameter corresponding to the sample request parameter. For example, for one sample request parameter, multiple positive sample response parameters and multiple negative sample response parameters are included.
[0050] In the embodiments of the present disclosure, the interface verification model is trained by using the sample data set including multiple positive-negative sample pairs. Different positive-negative sample pairs can include different sample request parameters corresponding to different sample interfaces and sample response parameters corresponding to the sample request parameters. Optionally, the sample data in the sample data set includes at least one of the following: The historical traffic data of different types of sample interfaces, wherein the historical traffic data of the sample interface includes historical request parameters and corresponding historical response parameters of the sample interface; sample request parameters and sample response parameters constructed for different types of sample interfaces; and sample response parameters simulated based on the business knowledge and interface structure of the sample interface corresponding to the business scenario.
[0051] The sample data can be obtained from the actual historical data of the sample interface. For a sample interface, the historical request parameters input into the sample interface and the historical response parameters obtained by processing the historical request parameters can be obtained by obtaining the historical traffic data of the sample interface. The correct response parameters in the obtained historical response parameters can be marked as positive samples as positive sample response parameters, and the error response parameters can be marked as negative samples as negative sample response parameters. That is, by obtaining the historical traffic data, sample data composed of historical request parameters and corresponding historical response parameters can be obtained.
[0052] Optionally, in addition to obtaining historical data, sample data can also be manually constructed. Sample request parameters input into the sample interface and corresponding sample response parameters can be constructed for different types of sample interfaces. The constructed sample response parameters include positive sample response parameters (correct response parameters) and negative sample response parameters (error response parameters). Optionally, when constructing sample data based on the sample interface, the corresponding sample response parameters can be constructed for the sample request parameters without return value in the obtained historical traffic data (i.e., the sample interface does not return the sample response parameters corresponding to the sample request parameters), so as to supplement the data based on the historical traffic data.
[0053] In another possible implementation, a large model can also be used to simulate the generation of sample response parameters. The large model is a pre-trained model used to simulate the generation of response parameters based on the business knowledge and interface structure corresponding to the interface. Optionally, for a sample interface, the business knowledge corresponding to the business scenario to which the sample interface belongs and the interface structure of the sample interface can be input into the large model as part of the prompt of the large model, and then the sample request parameters are input into the large model, so that the large model simulates the generation of the sample response parameters corresponding to the sample request parameters based on the business knowledge and interface structure. Optionally, the large model can be used to simulate the generation of correct response parameters and error response parameters.
[0054] Optionally, the sample data set also includes sample data corresponding to typical scenarios, boundary conditions and potential abnormal values, so that the interface verification model can be applicable to various complex scenarios.
[0055] In the embodiments of the present disclosure, the sample data set is constructed according to the historical traffic data of the sample interface, the artificially constructed sample parameters, and the sample parameters generated by the large model simulation, so that the sample data set can cover various different business scenarios and different types of interfaces. The interface verification model is trained by using the sample data set, so that the generalization ability of the trained interface verification model can be improved.
[0056] In a possible implementation, in the training process of the interface verification model, a positive-negative sample pair is input into the interface verification model, and the interface verification model is trained based on a contrast loss function. The contrast loss function is used to minimize the distance of the positive sample response parameters in the same positive-negative sample pair in the model space corresponding to the interface verification model, and maximize the distance of the negative sample response parameters in the same positive-negative sample pair in the model space corresponding to the interface verification model.
[0057] Optionally, the sample data set including a plurality of positive-negative sample pairs can be input into the interface sample model. The interface verification model can process the positive sample response parameters and the negative sample response parameters included in one positive-negative sample pair to obtain the parameter vectors corresponding to the positive sample response parameters and the negative sample response parameters respectively, and train the interface verification model based on a contrast loss function. The contrast loss function is used to minimize the distance of the positive sample response parameters (i.e., different positive sample response parameters corresponding to the same sample request parameter) in the same positive-negative sample pair in the model space corresponding to the interface verification model, i.e., to minimize the distance of the parameter vectors of the plurality of positive sample response parameters included in the positive-negative sample pair in the vector space (embedding space); and is also used to maximize the distance of the negative sample response parameters (i.e., different negative sample response parameters corresponding to the same sample request parameter) in the same positive-negative sample pair in the model space corresponding to the interface verification model, i.e., to maximize the distance of the parameter vectors of the plurality of negative sample response parameters included in the positive-negative sample pair in the vector space. The interface verification model is trained by using the contrast loss function, so that the positive sample response parameters corresponding to the same sample request parameter can be gathered in the model space, and the negative sample response parameters are dispersed in the model space, so that the trained interface verification model can determine the corresponding gathered correct response parameters for the interface request parameters.
[0058] Optionally, the contrast loss function can adopt any function that can be used to minimize the distance of the positive samples and maximize the distance of the negative samples, and the present embodiment does not make any limitation in this regard. For example, the InfoNCE loss function can be adopted.
[0059] In a possible implementation, when a training end condition is met, the training of the model can be ended. Optionally, the training end condition includes at least one of the following: the training round reaches a preset number threshold; the training duration reaches a preset duration; and the function value of the loss function meets a convergence condition.
[0060] In the embodiments of the present disclosure, the interface verification model is trained based on the positive and negative sample pairs and the contrast loss function, so that the positive samples corresponding to the sample request parameters are gathered in the model space, and the negative samples are dispersed in the model space, so that the interface verification model obtained by training can quickly determine the corresponding gathered positive samples when receiving the interface request parameters, thereby obtaining the corresponding correct response parameters, i.e., the expected response parameters, which helps to improve the accuracy and generation efficiency of the expected response parameters.
[0061] In a possible implementation, as shown in FIG. 1, the step 102 further includes steps 1021-1022. Figure 2 The step 1021 includes the following steps 1021-1022. The step 1021 includes the following steps 1021-1022.
[0062] The positive sample set is obtained after minimizing the distance of the positive sample response parameters in the model space.
[0063] After the interface request parameters are input into the pre-trained interface verification model, the interface verification model can determine the positive sample set of the interface request parameters in the model space. The positive sample set corresponding to the interface request parameters includes a correct response parameter set composed of the sample request parameters corresponding to the interface request parameters and the corresponding positive sample response parameters in the model space. The sample request parameters corresponding to the interface request parameters are the same or similar request parameters as the interface request parameters. The similar request parameters can be parameters with a similarity higher than a preset threshold. The preset threshold can be pre-set according to requirements.
[0064] The step 1022 includes the following steps 1021-1022.
[0065] In a possible implementation, the interface verification model can determine the expected response parameters based on the positive sample set and output the expected response parameters. After determining the positive sample set corresponding to the interface request parameters, one parameter can be selected from the correct response parameters included in the positive sample set as the expected response parameter. In another possible implementation, the mean of the parameter vectors of the correct response parameters included in the positive sample set can be determined as the expected response parameter.
[0066] In the embodiments of the present disclosure, the pre-trained interface verification model can quickly determine the positive sample set corresponding to the interface request parameters in the model space, and output the corresponding expected response parameters based on the positive sample set, which helps to improve the accuracy of the generated expected response parameters and helps to improve the generation efficiency of the expected response parameters.
[0067] In a possible implementation, as shown in FIG. 1, the step 102 further includes steps 1021-1022.Figure 3 As shown in the above step 103, the step 103 further includes steps 1031-1033. In step 1031, a vector similarity between the interface response parameter corresponding vector and the expected response parameter corresponding vector is calculated.
[0068] Optionally, the similarity between the interface response parameter embedding and the expected response parameter embedding can be calculated, wherein the embedding of the interface response parameter can be obtained by vectorizing the interface response parameter, and the expected response parameter embedding can be the parameter output by the interface verification model.
[0069] When calculating the vector similarity, the cosine similarity or the Euclidean distance between the embeddings can be calculated, and the cosine similarity or the Euclidean distance can be determined as the vector similarity, which is not limited in the embodiment.
[0070] In step 1032, in response to the vector similarity being greater than the similarity threshold value corresponding to the interface to be verified, it is determined that the verification result is verified.
[0071] In step 1033, in response to the vector similarity being less than the similarity threshold value corresponding to the interface to be verified, it is determined that the verification result is not verified.
[0072] In a possible implementation, when the calculated vector similarity is greater than the similarity threshold value corresponding to the interface to be verified, it is determined that the verification result is verified. When the calculated vector similarity is less than the similarity threshold value corresponding to the interface to be verified, it is determined that the verification result is not verified.
[0073] Optionally, when the parameters of the interface to be verified include multiple groups of parameters (i.e., multiple interface request parameters and corresponding multiple interface response parameters), the verification result can be determined according to the similarities corresponding to the multiple groups of parameters. In a possible implementation, the interface verification model can generate corresponding expected response parameters for the multiple interface request parameters respectively, calculate the vector similarities between the multiple expected response parameters and the interface response parameters corresponding thereto respectively, and obtain multiple vector similarities. When a preset proportion of the multiple vector similarities is greater than the similarity threshold value, it is determined that the verification result is verified. When there is no preset proportion of the multiple vector similarities greater than the similarity threshold value, the verification result is not verified. Illustratively, when 90% of the multiple vector similarities is greater than the similarity threshold value, it is determined that the verification result is verified.
[0074] In the embodiments of the present disclosure, the similarity between the embedding of the real interface response parameter returned by the to-be-verified interface and the embedding corresponding to the expected response parameter is calculated to determine the verification result, thereby realizing intelligent verification of the to-be-verified interface. As a vectorization representation technology, embedding can convert complex text, pictures or structured data into high-dimensional vectors, which helps to capture the potential relationship between data. In the interface verification scenario, based on embedding, the interface returned parameter can be more flexible and more accurate for analysis and verification, which can improve the accuracy of the verification result and be suitable for diversified scenarios.
[0075] In the above embodiments, the similarity threshold of the to-be-verified interface is used for result verification. Alternatively, the similarity threshold of the to-be-verified interface can be a preset fixed threshold or a specific threshold set for the to-be-verified interface. In a possible implementation, after the vector similarity is calculated, the similarity threshold corresponding to the to-be-verified interface needs to be obtained, and the similarity threshold is positively correlated with the field complexity of the to-be-verified interface returned.
[0076] Since the parameter complexity (i.e., field complexity) returned after being processed by different interfaces is different, due to the limitation of interface functions, there can be some interfaces with low field complexity returned, and then the interface response parameter obtained by processing the interface request parameter of the interface can have large difference with the expected response parameter, and a lower similarity threshold needs to be set. That is, the similarity threshold of the interface is positively correlated with the field complexity returned by the interface, and the higher the field complexity returned, the higher the similarity threshold that can be used.
[0077] In a possible implementation, the field complexity returned by the to-be-verified interface can be determined according to the interface function limitation and interface structure of the to-be-verified interface, and the more complex the interface function or interface structure is, the higher the field complexity returned is. Alternatively, the field complexity can also be determined according to the number of field types of the returned field, wherein the number of field types is positively correlated with the field complexity, that is, the higher the number of different types of field types contained in the returned field, the higher the field complexity. After the field complexity is determined, the similarity threshold of the to-be-verified interface can be generated according to the field complexity and stored.
[0078] Illustratively, when it is determined that the field complexity returned by the to-be-verified interface belongs to a first complexity, the similarity threshold is determined to be a first threshold; and when it is determined that the field complexity returned by the to-be-verified interface belongs to a second complexity, the similarity threshold can be a second threshold, wherein the first complexity is higher than the second complexity, and the first threshold is higher than the second threshold. Illustratively, the first threshold can be 0.8, and the second threshold can be 0.7.
[0079] In a possible implementation, after determining the verification result of the interface to be verified, the misjudged verification result can be recorded, and the method further includes steps a-b. Step a, obtaining the misjudged verification result of the interface to be verified recorded.
[0080] In a possible implementation, the verification result of the interface to be verified can be determined by a human, and it is determined whether there is a misjudged verification result. If there is, the misjudged verification result is recorded for subsequent processing.
[0081] In a possible implementation, when the misjudged verification result acquisition signal is received, the misjudged verification result of the interface to be verified recorded can be obtained from the stored database. In another possible implementation, the misjudged verification result recorded can be obtained at a preset time as a period. Alternatively, the number of misjudged verification results, i.e., the total number of misjudged verification results, can be obtained.
[0082] Step b, in response to the number of misjudged verification results of the interface to be verified being greater than a preset number threshold, adjusting the similarity threshold corresponding to the interface to be verified.
[0083] In the case where the misjudged verification result of the interface to be verified is greater than the preset number threshold, the similarity threshold of the interface to be verified can be adjusted. Alternatively, the adjusted similarity threshold can be lower than the original similarity threshold of the interface to be verified. In an illustrative example, the original similarity threshold of the interface to be verified can be lowered by a preset percentage, such as 5%.
[0084] In a possible implementation, the adjustment ratio of the similarity threshold can also be determined according to the proportion of the misjudged verification result in the total verification result. The proportion of the number of misjudged verification results in the total number of verification results is positively correlated with the adjustment ratio, that is, the higher the proportion of the number of misjudged verification results, the higher the proportion of the lowered similarity threshold.
[0085] In the embodiments of the present disclosure, the misjudged verification result can be recorded to dynamically adjust the similarity threshold based on the misjudged verification result, which helps to improve the accuracy of the similarity threshold, thereby further improving the accuracy of the interface verification result.
[0086] In a possible implementation, the misjudged results of different types of interfaces can be obtained. When the verification result of different types of interfaces all has a misjudged result, or the number of misjudged verification results of different types of interfaces is greater than a preset number threshold, it indicates that the accuracy of the interface verification model needs to be adjusted. Then, new sample data can be constructed, and the interface verification model can be retrained based on the new sample data to improve the accuracy of the interface verification model in generating expected response parameters.
[0087] Optionally, the new sample data can be constructed based on the updated historical traffic data of different types of sample interfaces, and the sample request parameters and sample response parameters obtained by re-construction for different types of sample interfaces, or based on the business knowledge and interface structure of the sample interface corresponding to the business scenario, the new sample response parameters are simulated and generated for the sample request parameters. The interface verification model is trained by the new sample data, which can further improve the generalization ability of the model, further improve the accuracy of the interface verification model generating the expected response parameters, and thus improve the accuracy of intelligent verification of the interface to be verified.
[0088] As shown in Figure 4 , which shows a structure diagram of interface verification provided by an example embodiment of the present disclosure. First, the positive and negative sample pairs in the sample data set constructed based on the historical traffic data of different types of sample interfaces, the sample request parameters and sample response parameters obtained by construction for different types of sample interfaces, and the sample response parameters simulated and generated for the sample request parameters based on the business knowledge and interface structure of the sample interface corresponding to the business scenario are used to train the interface verification model. After the training is completed, when the interface verification model receives the interface request parameters for the interface to be verified, the corresponding expected response parameters can be output. By comparing the expected response parameters and the interface response parameters, the verification result of the interface to be verified is determined, and the intelligent verification of the interface is realized.
[0089] In the process of comparing the expected response parameters and the interface response parameters, the embedding of the expected response parameters and the interface response parameters can be compared, which are respectively converted into high-dimensional vectors, which is helpful to capture the potential relationship between the expected response parameters and the interface response parameters. In the interface verification scenario, the verification result is determined based on the similarity between the embeddings, which can more flexibly and accurately analyze and verify the interface return parameters, and is helpful to improve the accuracy of the verification result, and is suitable for diversified scenarios.
[0090] As shown in Figure 5 , which shows a structure block diagram of an interface verification device provided by an example embodiment of the present disclosure. The device comprises: The parameter acquisition module 501 is configured to acquire the interface request parameters of the interface to be verified, and the interface response parameters output by the interface to be verified after processing the interface request parameters; The model processing module 502 is configured to input the interface request parameters into the pre-trained interface verification model, and output the expected response parameters through the interface verification model, wherein the interface verification model is trained based on the sample data set covering different business scenarios and different types of interfaces; The result determination module 503 is configured to determine the verification result of the interface to be verified based on the difference between the interface response parameters and the expected response parameters.
[0091] In an example embodiment, the sample data set includes positive-negative sample pairs, and each positive-negative sample pair includes a sample request parameter, a positive sample response parameter corresponding to the sample request parameter, and a negative sample response parameter corresponding to the sample request parameter. Accordingly, as shown in Figure 6 the interface verification apparatus further includes: a model training module 601 configured to input the positive-negative sample pairs into an interface verification model, and train the interface verification model based on a contrastive loss function, the contrastive loss function being configured to minimize a distance of the positive sample pairs in a model space corresponding to the interface verification model, and maximize a distance of the negative sample pairs in the model space.
[0092] In an example embodiment, the model processing module 502 is further configured to: input the interface request parameter into the pre-trained interface verification model, so that the interface verification model determines a positive sample set of the interface request parameter in a model space corresponding to the interface verification model, the positive sample set being obtained after minimizing a distance of the positive sample response parameters in the model space; output, by the interface verification model, an expected response parameter determined based on the positive sample set.
[0093] In an example embodiment, the sample data in the sample data set includes at least one of the following: historical traffic data of sample interfaces of different types, wherein the historical traffic data of the sample interfaces includes historical request parameters and corresponding historical response parameters of the sample interfaces; sample request parameters and sample response parameters constructed for sample interfaces of different types; sample response parameters simulated based on business knowledge and interface structures of a business scenario corresponding to the sample interfaces.
[0094] In an example embodiment, the result determination module 503 is further configured to: calculate a similarity between the interface response parameter corresponding vector and the expected response parameter corresponding vector; in response to the similarity being greater than a similarity threshold corresponding to the interface to be verified, determine that the verification result is a verification pass; in response to the similarity being less than the similarity threshold corresponding to the interface to be verified, determine that the verification result is a verification fail.
[0095] In an example embodiment, the result determination module 503 is further configured to: obtain a similarity threshold corresponding to the interface to be verified, the similarity threshold being positively correlated with a field complexity returned by the interface to be verified.
[0096] In an example embodiment, as shown in Figure 7 the interface verification apparatus further includes: The result recording module 701 is configured to obtain a misjudgment verification result of the recorded interface to be verified, the misjudgment verification result being a false verification result. The threshold adjusting module 702 is configured to, in response to the number of misjudgment verification results of the interface to be verified being greater than a preset number threshold, adjust the similarity threshold corresponding to the interface to be verified.
[0097] In the embodiments of the present disclosure, the interface request parameter of the interface to be verified is processed by using the pre-trained interface verification model, to obtain the expected response parameter corresponding to the interface request parameter, wherein the interface verification model is trained based on a sample data set covering multiple different business scenarios and different types of interfaces, so that the trained interface verification model can process the interface request parameter of the interface to be verified in a complex business scenario and of different types, to obtain an accurate expected response parameter, so as to determine the verification result of the interface to be verified based on the difference between the expected response parameter and the actual interface response parameter of the interface to be verified, which can realize intelligent verification of the interface, does not need to rely on the formulation and management of artificial rules, helps to improve the interface verification efficiency, and helps to reduce the probability of misjudgment. In addition, the pre-trained interface verification model can be applied to the verification of interfaces of different types in a complex business scenario, can generate accurate expected response parameters, and can help to improve the accuracy of the interface verification result and reduce the probability of misjudgment based on the accurate expected response parameters for interface verification.
[0098] The interface verification device in the embodiments of the present disclosure corresponds to the embodiments of the interface verification method of the present disclosure, and the related content can be mutually referred to, which will not be described here. The beneficial technical effects of the interface verification device in the embodiments of the present disclosure can be referred to the corresponding beneficial technical effects of the corresponding example method part, which will not be described here.
[0099] In addition, the embodiments of the present disclosure also provide an electronic device, comprising: a memory configured to store a computer program; a processor configured to execute the computer program stored in the memory, and when the computer program is executed, the interface verification method of any one of the embodiments of the present disclosure is implemented.
[0100] Figure 8 The structure schematic diagram of an application embodiment of the electronic device of the present disclosure is shown in the following figure. Hereinafter, the electronic device according to the embodiments of the present disclosure will be described with reference to the figure. Figure 8 As shown in the figure, the electronic device comprises one or more processors and a memory. Figure 8
[0101] The processor can be a central processing unit (CPU) or other form of processing unit having data processing and / or instruction executing capabilities, and can control other components in the electronic device to perform desired functions.
[0102] The memory can include one or more computer program products that can include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory, for example, can include random access memory (RAM), cache memory, and / or the like. The non-volatile memory, for example, can include read only memory (ROM), hard disk, flash memory, and / or the like. One or more computer program instructions can be stored on the computer-readable storage media, and the processor can execute the program instructions to implement the interface authentication method of various embodiments of the disclosure described above and / or other desired functions.
[0103] In one example, the electronic device can further include input and output devices, which are interconnected through a bus system and / or other forms of connection mechanisms (not shown).
[0104] In addition, the input device can further include, for example, a keyboard, a mouse, and / or the like.
[0105] The output device can output various information, including the determined distance information, direction information, and / or the like, to the outside. The output device can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and / or the like.
[0106] Of course, in order to simplify, Figure 8 In FIG. 1, only some of the components related to the present disclosure among the components in the electronic device are illustrated, and components such as buses, input / output interfaces, and / or the like are omitted. In addition, the electronic device can further include any other appropriate components according to a specific application.
[0107] In addition to the above-described method and device, an embodiment of the present disclosure can be a computer program product including computer program instructions that, when executed by a processor, cause the processor to perform steps in the interface authentication method according to various embodiments of the present disclosure described in the above parts of the specification.
[0108] The computer program product can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. The embodiments of the present disclosure can be a computer program product, which can include a computer program tangibly embodied in a machine readable storage medium.
[0109] In addition, embodiments of the present disclosure can also be a computer readable storage medium, which stores computer program instructions, and the computer program instructions, when executed by a processor, cause the processor to perform the steps in the interface verification method according to various embodiments of the present disclosure described in the foregoing parts of the specification.
[0110] The computer readable storage medium can take the form of one or more combinations of any type of computer readable medium. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can include, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the above. More specific examples (a non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0111] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware, and the foregoing program can be stored in a computer readable storage medium, and the program executes the steps of the above-mentioned method embodiments when executed; and the foregoing storage medium includes ROM, RAM, magnetic disc or optical disc and various storage medium that can store program code.
[0112] The above describes the basic principles of the present disclosure in combination with specific embodiments, but it should be pointed out that the advantages, advantages, effects and the like mentioned in the present disclosure are only examples and not limitations, and these advantages, advantages, effects and the like cannot be considered as the must-have of each embodiment of the present disclosure. In addition, the above specific details are only for the purpose of example and understanding, and the above details do not limit the present disclosure to the must-use specific details.
[0113] The various embodiments described in this specification are intended to be illustrative only and in no way limit the scope of the application. One skilled in the art will readily recognize from the disclosure herein, possible alternative techniques within the scope of the application. Accordingly, the examples are not to be regarded as limiting, but rather are to be understood to be illustrative of the possible aspects of the application. The various embodiments described in this specification are described in the context of a system. As such, the system embodiments are described in relatively greater detail than the method embodiments, with the understanding that the method embodiments are substantially analogous to the system embodiments.
[0114] The block diagrams of devices, apparatuses, equipment, systems referred to in this disclosure are merely illustrative examples and are not intended to require or imply that the connection, arrangement, configuration must be as shown in the block diagrams. These devices, apparatuses, equipment, systems can be connected, arranged, configured in any manner as will be appreciated by those skilled in the art. Words such as "include," "contain," "have," etc. are open-ended words that are to be interpreted to mean "including but not limited to," and are to be interpreted not to exclude items that do not match the description of the word. The words "or" and "and" as used herein are to be interpreted as the word "and / or," and are to be interpreted not to exclude items that do not match the description of the word. The word "such as" as used herein is to be interpreted as the phrase "such as but not limited to," and is to be interpreted not to exclude items that do not match the description of the word.
[0115] The methods and apparatuses of this disclosure can be implemented in a number of ways. For example, the methods and apparatuses of this disclosure can be implemented using software, hardware, firmware, or any combination of these methods and apparatuses. The order of any steps described above is merely exemplary and the steps of the methods of this disclosure need not be performed in the order described unless otherwise specified. Furthermore, in some embodiments, the methods of this disclosure can also be implemented as a program for use with a computer-based system, the program including a machine-readable medium having stored program instructions that, when executed by a machine, cause the machine to perform the methods of this disclosure. Thus, the disclosure also covers a record medium storing the program for performing the methods of this disclosure.
[0116] It is also important to note that the apparatuses, equipment and methods of this disclosure can be embodied in a number of different forms, including but not limited to a computer-aided design circuit, an application specific integrated circuit, a standard integrated circuit, discrete electronic components, or any combination thereof. The apparatuses, equipment and methods of this disclosure can also be implemented as a program for use with a computer-based system, the program including a machine-readable medium having stored program instructions that, when executed by a machine, cause the machine to perform the methods of this disclosure.
[0117] The above description of disclosed aspects is intended to be illustrative only and not restrictive. Those skilled in the art will readily recognize various modifications to the aspects described herein, and the principles set forth herein can be applied to other aspects without departing from the scope of the disclosure. Thus, the disclosure is not intended to be limited to the aspects described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0118] The above description has been provided for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
Claims
1. An interface verification method, characterized in that: The method comprises: Obtaining interface request parameters of the interface to be verified, and interface response parameters output by the interface to be verified after processing the interface request parameters; Inputting the interface request parameters into a pre-trained interface verification model, and outputting expected response parameters through the interface verification model, wherein the interface verification model is trained based on a sample data set covering different business scenarios and different types of interfaces; Based on the difference between the interface response parameter and the expected response parameter, a verification result of the interface to be verified is determined.
2. The method according to claim 1, characterized in that The sample data set includes positive and negative sample pairs, and the positive and negative sample pairs include sample request parameters and positive sample response parameters and negative sample response parameters corresponding to the sample request parameters; The method further comprises: The positive and negative sample pairs are input into the interface verification model, and the interface verification model is trained based on the contrast loss function, wherein the contrast loss function is used to minimize the distance between the positive sample response parameters in the same positive and negative sample pairs in the corresponding model space of the interface verification model, and to maximize the distance between the negative sample response parameters in the same positive and negative sample pairs in the corresponding model space of the interface verification model.
3. The method according to claim 2, characterized in that The step of inputting the interface request parameters into a pre-trained interface verification model, and outputting expected response parameters via the interface verification model, includes: Inputting the interface request parameters into the pre-trained interface verification model, so that the interface verification model determines a positive sample set of the interface request parameters in the model space corresponding to the interface verification model, wherein the positive sample set is obtained after minimizing the distance of the positive sample response parameters in the model space; The interface verifies that the model outputs expected response parameters determined based on the positive sample set.
4. The method according to claim 2, characterized in that The sample data in the sample data set includes at least one of the following: Historical traffic data of different types of sample interfaces, wherein the historical traffic data of the sample interfaces include historical request parameters and corresponding historical response parameters of the sample interfaces; Sample request parameters and sample response parameters obtained for different types of sample interfaces; Based on the business knowledge and interface structure of the business scenario corresponding to the sample interface, sample response parameters are generated for the sample request parameters simulation.
5. The method according to any one of claims 1 to 4, characterized in that: The determining, based on the difference between the interface response parameter and the expected response parameter, a verification result of the interface to be verified, includes: Calculating the vector similarity between the vector corresponding to the interface response parameter and the vector corresponding to the expected response parameter; In response to the vector similarity being greater than a similarity threshold corresponding to the interface to be verified, determining that the verification result is verification passed; In response to the vector similarity being less than a similarity threshold corresponding to the interface to be verified, determining that the verification result is verification failure.
6. The method according to claim 5, characterized in that After calculating the vector similarity between the vector corresponding to the interface response parameter and the vector corresponding to the expected response parameter, the method further includes: A similarity threshold corresponding to the interface to be verified is obtained, where the similarity threshold is positively correlated with the complexity of the fields returned by the interface to be verified.
7. The method according to claim 5, characterized in that The method further comprises: Obtaining a recorded misjudgment verification result of the interface to be verified, wherein the misjudgment verification result is an erroneous verification result; In response to the number of misjudgment verification results of the interface to be verified being greater than a preset number threshold, the similarity threshold corresponding to the interface to be verified is adjusted.
8. An interface verification device, characterized in that: The device comprises: A parameter acquisition module is used to obtain the interface request parameters of the interface to be verified, and the interface response parameters output after the interface to be verified processes the interface request parameters; A model processing module is used to input the interface request parameters into a pre-trained interface verification model, and output expected response parameters through the interface verification model, wherein the interface verification model is trained based on a sample data set covering different business scenarios and different types of interfaces; The result determination module is used to determine the verification result of the interface to be verified based on the difference between the interface response parameter and the expected response parameter.
9. An electronic device, characterized in that: include: memory for storing computer programs; A processor is used to execute the computer program stored in the memory, and when the computer program is executed, the interface verification method described in any one of claims 1 to 7 is implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the interface verification method described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
System interface verification method and system based on artificial intelligence
CN121070749A