CN110489322B - MOCK testing method, device, computer equipment and storage medium - Google Patents

MOCK testing method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN110489322B
CN110489322B CN201910610941.XA CN201910610941A CN110489322B CN 110489322 B CN110489322 B CN 110489322B CN 201910610941 A CN201910610941 A CN 201910610941A CN 110489322 B CN110489322 B CN 110489322B
Authority
CN
China
Prior art keywords
keyword
preset
request packet
consistent
data request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910610941.XA
Other languages
Chinese (zh)
Other versions
CN110489322A (en
Inventor
李瑶
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN201910610941.XA priority Critical patent/CN110489322B/en
Publication of CN110489322A publication Critical patent/CN110489322A/en
Application granted granted Critical
Publication of CN110489322B publication Critical patent/CN110489322B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the application provides a MOCK testing method, a MOCK testing device, computer equipment and a storage medium. The method comprises the following steps: decrypting the encrypted data request packet sent by the user terminal according to the preset secret key to obtain a decrypted data request packet; judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decrypted data request packet according to preset keyword information; if the keyword which is consistent with the keyword information exists in the keyword group, acquiring request address information in a decrypted data request packet; calling a service interface corresponding to the request address information to acquire target return data; and sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data. The method is based on the interface test technology, can conveniently and rapidly carry out the MOCK test on the third-party system interface, has good convenience and flexibility, and greatly increases the efficiency of carrying out the MOCK test on the third-party system interface.

Description

MOCK testing method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for testing a MOCK, a computer device, and a storage medium.
Background
The development personnel need to test the developed units in the development process or after the development is completed, and timely find errors and timely repair the errors to ensure the correctness and stability of the developed program, and the MOCK test is a common test mode in the development process. In the prior art, the existing interface is subjected to MOCK test, and the interface is directly called by a test server, however, the call is difficult to be performed when aiming at a third party system, and the problems of insufficient convenience and flexibility exist in the test process, so that the test efficiency is low.
Disclosure of Invention
The application provides a MOCK test method, a device, computer equipment and a storage medium, and aims to solve the problem that in the prior art, the efficiency is low when MOCK test is carried out on a third-party system interface.
In a first aspect, the present application provides a dock test method, including: acquiring an encrypted data request packet sent by a user terminal; if an encrypted data request packet sent by a user terminal is received, decrypting the encrypted data request packet according to a preset secret key to obtain a decrypted data request packet; judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decryption data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords; if the keyword which is consistent with the keyword information exists in the keyword group, acquiring request address information in the decrypted data request packet; calling a service interface corresponding to the request address information to acquire target return data; and sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data.
In a second aspect, the present application provides a dock test apparatus, comprising: the data request packet decryption unit is used for decrypting the encrypted data request packet according to a preset secret key to obtain a decrypted data request packet if the encrypted data request packet sent by the user terminal is received; the keyword judging unit is used for judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decryption data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords; a request address information obtaining unit, configured to obtain request address information in the decrypted data request packet if a keyword consistent with the keyword information exists in the keyword group; the target return data acquisition unit is used for calling a service interface corresponding to the request address information to acquire target return data; and the target return data sending unit is used for sending the target return data to the user terminal so that the user terminal can carry out MOCK test according to the target return data.
In a third aspect, the present application provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the rock test method according to any one of the first aspects when executing the computer program.
In a fourth aspect, the present application also provides a storage medium, wherein the storage medium stores a computer program which, when executed by a processor, causes the processor to perform the rock test method of any one of the first aspects provided above.
The application provides a MOCK testing method, a MOCK testing device, computer equipment and a storage medium. The MOCK test method comprises the steps of obtaining an encrypted data request packet sent by a user terminal; decrypting the encrypted data request packet according to a preset key to generate a decrypted data request packet; if the keyword group contains keyword information consistent with the first preset keyword, acquiring request address information in the decrypted data request packet; calling a service interface corresponding to the request address information to acquire target return data; and sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data. The MOCK test method provided by the application can be used for conveniently and rapidly carrying out MOCK test on the third-party system interface, has good convenience and flexibility, and greatly increases the efficiency of carrying out MOCK test on the third-party system interface.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a MOCK testing method according to an embodiment of the present application;
fig. 2 is a schematic diagram of an application scenario of a MOCK testing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of another flow chart of the MOCK testing method according to the embodiment of the present application;
Fig. 4 is a schematic sub-flowchart of a MOCK testing method according to an embodiment of the present application;
FIG. 5 is a schematic diagram of another sub-flow of the MOCK test method according to the embodiment of the present application;
FIG. 6 is a schematic diagram of another sub-flow of the MOCK test method according to the embodiment of the present application;
FIG. 7 is a schematic block diagram of a MOCK testing device provided by an embodiment of the present application;
FIG. 8 is another schematic block diagram of a MOCK testing device provided by an embodiment of the present application;
FIG. 9 is a schematic block diagram of a subunit of a MOCK testing device provided by an embodiment of the application;
FIG. 10 is a schematic block diagram of another subunit of a MOCK testing device provided by an embodiment of the application;
FIG. 11 is a schematic block diagram of another subunit of a MOCK testing device provided by an embodiment of the present application;
Fig. 12 is a schematic block diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1 and fig. 2, fig. 1 is a flow chart of a MOCK testing method according to an embodiment of the application; fig. 2 is a schematic diagram of an application scenario of a MOCK testing method according to an embodiment of the present application. The MOCK testing method is applied to the management server 10, and is executed through application software installed in the management server 10, and the user terminal 20 and the service interface 30 establish network connection with the management server 10 to realize data information transmission. The management server 10 is an enterprise terminal for performing a dock test method to perform dock test on a third party system, the user terminal 20 is a terminal device for sending data information to the management server 10, such as a desktop computer, a notebook computer, a tablet computer or a mobile phone, and the service interface 30 is a server interface provided by the third party system and available for testing. In fig. 2, only the management server 10 performs information transmission with one user terminal 20 and one service interface 30, and in practical application, the management server 10 may perform information transmission with a plurality of user terminals 20 and a plurality of service interfaces 30 at the same time.
As shown in FIG. 1, the MOCK testing method comprises the following steps S110 to S150.
S110, if the encrypted data request packet sent by the user terminal is received, decrypting the encrypted data request packet according to a preset secret key to obtain a decrypted data request packet.
In the embodiment of the application, if the encrypted data request packet sent by the user terminal is received, the encrypted data request packet is decrypted according to a preset secret key to obtain a decrypted data request packet. A user (tester) communicates with a management server by using a user terminal to realize a test based on a MOCK technology, wherein the MOCK test is a test method for constructing a virtual object for testing some objects which are not easy to construct or easy to acquire in the test process, and the virtual object is the MOCK object, and the process for testing the MOCK object is the MOCK test. The management server obtains an encrypted data request packet sent by the user terminal, so as to call a corresponding service interface according to the encrypted data request packet, and feeds back the obtained target return data to the user terminal. The user terminal performs encryption operation on the data request packet to obtain an encrypted data request packet, and security in the data transmission process can be enhanced by sending the encrypted data request packet to the management server.
The public key of the management server is stored in the user terminal, the data request packet to be sent is encrypted through the public key of the management server to obtain an encrypted data request packet, and the public key of the management server is disclosed to each user terminal. After receiving the encrypted data request packet, the management server decrypts the encrypted data request packet through a preset secret key to obtain a decrypted data request packet, wherein the secret key is private to the management server, the public key of the management server corresponds to the secret key, and the encrypted data can be decrypted only through the secret key of the management server.
S120, judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decrypted data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords.
Judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decrypted data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords. The keyword information comprises a first preset keyword and a second preset keyword, and the keyword group is a group which is correspondingly obtained from the decrypted data request packet and contains a plurality of keywords.
In an embodiment, as shown in fig. 3, step S120a is further included before step S120.
And S120a, carrying out keyword recognition on the decrypted data request packet according to a preset keyword database so as to acquire a keyword group corresponding to the decrypted data request packet.
In the embodiment of the application, a preset keyword database is stored in the management server, the preset keyword database comprises a plurality of preset keywords, and keyword recognition is performed on the decrypted data request packet through the preset keywords, namely, keywords corresponding to the preset keywords in the decrypted data request packet are acquired, and keywords contained in the decrypted data request packet are acquired to obtain the keyword group.
In one embodiment, as shown in fig. 4, step S120 includes steps S121, S122, and S123.
S121, judging whether a keyword consistent with the first preset keyword exists in the keyword group, wherein the first preset keyword is a keyword for representing a test mode.
In the embodiment of the application, the tests performed by the user terminal on the service interface can be divided into two types, one is a rock mode, and the other is a non-rock mode, and whether the encrypted data request packet sent by the user terminal is a rock test can be judged by judging whether a keyword consistent with a first preset keyword exists in the keyword group, wherein the first preset keyword is a keyword for representing the test mode, for example, "rock".
S122, if the keyword group has the keyword consistent with the first preset keyword, judging whether the keyword group has the keyword consistent with the second preset keyword, wherein the second preset keyword is the keyword representing the request address.
If the keyword group contains the keyword consistent with the first preset keyword, the user terminal is considered to perform a test on the service interface as a MOCK test, and whether the keyword group contains a second preset keyword is further judged, wherein the second preset keyword is a keyword for representing a request address, for example, "ste.dbg.m1".
In an embodiment, as shown in fig. 5, step S121 further includes step S121a.
S121a, if no keyword consistent with the first preset keyword exists in the keyword group, generating error reminding information and sending the error reminding information to the user terminal, wherein the error reminding information comprises the first preset keyword and a current time point.
In the embodiment of the present application, the first preset keyword is "rock". Comparing the keyword groups extracted by keyword recognition in the encrypted data request packet sent by the user terminal, and if the keyword groups do not have keywords consistent with the first preset keyword, regarding the test conducted by the user terminal on the service interface as a non-MOCK mode, generating error reminding information and sending the error reminding information to the user terminal to remind the user, wherein the error reminding information comprises the first preset keyword and the current time point, so that the user can modify the data request packet through the user terminal.
S123, if the keyword which is consistent with the second preset keyword exists in the keyword group, judging that the keyword which is consistent with the keyword information exists in the keyword group.
And if the keyword which is consistent with the second preset keyword exists in the keyword group, judging that the keyword which is consistent with the keyword information exists in the keyword group, namely, judging that the keyword which is consistent with the request address keyword exists in the keyword group.
And S130, if the keyword which is consistent with the keyword information exists in the keyword group, acquiring request address information in the decrypted data request packet.
And if the keyword which is consistent with the keyword information exists in the keyword group, namely the test performed on the service interface by the user terminal is a MOCK test, and the keyword which is consistent with the keyword of the request address exists in the keyword group, acquiring the corresponding request address information according to the keyword which is consistent with the second preset keyword, so that the corresponding service interface is conveniently called according to the request address information, and corresponding data information is acquired.
S140, calling a service interface corresponding to the request address information to acquire target return data.
In the embodiment of the application, a preset interface calling table is stored in the management server, and the service interface associated with the request address information can be called and target return data can be obtained by inquiring the service interface according to the preset interface calling table through the acquired request address information.
In one embodiment, as shown in fig. 6, step S140 includes steps S141, S142, and S143.
S141, acquiring a service interface corresponding to the request address information according to a preset interface call table.
In the embodiment of the application, a preset interface call table is stored in the management server, the preset interface call table records the corresponding relation between the request address information and the service interfaces, specifically, one request address information corresponds to one service interface, and through the preset interface call table, one unique service interface corresponding to the request address information sent by the user terminal can be obtained.
S142, calling the service interface and receiving initial data fed back by the service interface.
In the embodiment of the application, the service interface is a server interface which is provided by a third party system and can be used for testing, and initial data fed back by the service interface can be received by calling the service interface.
S143, converting the initial data according to a preset data conversion rule to obtain target return data.
In the embodiment of the application, a preset data conversion rule is also stored in the management server, wherein the preset data conversion rule is a data format specification which is agreed between the management server and the user terminal, the data conversion rule comprises specific format specifications such as a data type requirement, a data length requirement and the like, and according to the data format specification which is agreed in the data conversion rule, the initial data can be subjected to data conversion according to the data format specification so as to obtain target return data corresponding to the initial data.
For example, the type of the initial data fed back by the service interface is "GB18030", the data type in the data conversion rule is required to be "UTF-8", and the data length is 20 characters per line, then the initial data with the format of "GB18030" is converted into the data type of "UTF-8" according to the data conversion rule, and the length of the data with the converted type is normalized by 20 characters per line, so that the target return data can be finally obtained.
And S150, sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data.
And returning the target return data to the user terminal so that the user terminal can perform MOCK test on the service interface according to the target return data.
The application provides a MOCK testing method, a MOCK testing device, computer equipment and a storage medium. The MOCK test method comprises the steps of obtaining an encrypted data request packet sent by a user terminal; decrypting the encrypted data request packet according to a preset key to generate a decrypted data request packet; if the keyword group contains keyword information consistent with the first preset keyword, acquiring request address information in the decrypted data request packet; calling a service interface corresponding to the request address information to acquire target return data; and sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data. The MOCK test method provided by the application can be used for conveniently and rapidly carrying out MOCK test on the third-party system interface, has good convenience and flexibility, and greatly increases the efficiency of carrying out MOCK test on the third-party system interface.
The embodiment of the application also provides a MOCK testing device which is used for executing any embodiment of the MOCK testing method. Specifically, referring to fig. 7, fig. 7 is a schematic block diagram of a dock test device according to an embodiment of the present application. The rock test device may be configured in the management server 10.
As shown in fig. 7, the MOCK testing apparatus 100 includes a data request packet decrypting unit 110, a keyword judging unit 120, a request address information acquiring unit 130, a target return data acquiring unit 140, and a target return data transmitting unit 150.
The data request packet decrypting unit 110 is configured to decrypt the encrypted data request packet according to a preset key to obtain a decrypted data request packet if the encrypted data request packet sent by the user terminal is received.
In the embodiment of the application, if the encrypted data request packet sent by the user terminal is received, the encrypted data request packet is decrypted according to a preset secret key to obtain a decrypted data request packet. A user (tester) communicates with a management server by using a user terminal to realize a test based on a MOCK technology, wherein the MOCK test is a test method for constructing a virtual object for testing some objects which are not easy to construct or easy to acquire in the test process, and the virtual object is the MOCK object, and the process for testing the MOCK object is the MOCK test. The management server obtains an encrypted data request packet sent by the user terminal, so as to call a corresponding service interface according to the encrypted data request packet, and feeds back the obtained target return data to the user terminal. The user terminal performs encryption operation on the data request packet to obtain an encrypted data request packet, and security in the data transmission process can be enhanced by sending the encrypted data request packet to the management server.
The public key of the management server is stored in the user terminal, the data request packet to be sent is encrypted through the public key of the management server to obtain an encrypted data request packet, and the public key of the management server is disclosed to each user terminal. After receiving the encrypted data request packet, the management server decrypts the encrypted data request packet through a preset secret key to obtain a decrypted data request packet, wherein the secret key is private to the management server, the public key of the management server corresponds to the secret key, and the encrypted data can be decrypted only through the secret key of the management server.
The keyword determining unit 120 is configured to determine, according to preset keyword information, whether a keyword consistent with the keyword information exists in a keyword group corresponding to the decrypted data request packet, where the keyword group includes a plurality of keywords.
Judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decrypted data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords. The keyword information comprises a first preset keyword and a second preset keyword, and the keyword group is a group which is correspondingly obtained from the decrypted data request packet and contains a plurality of keywords.
In other embodiments, as shown in fig. 8, the MOCK testing device 100 further includes a subunit: the keyword group acquisition unit 120a.
The keyword group obtaining unit 120a is configured to identify keywords in the decrypted data request packet according to a preset keyword database, so as to obtain a keyword group corresponding to the decrypted data request packet.
In the embodiment of the application, a preset keyword database is stored in the management server, the preset keyword database comprises a plurality of preset keywords, and keyword recognition is performed on the decrypted data request packet through the preset keywords, namely, keywords corresponding to the preset keywords in the decrypted data request packet are acquired, and keywords contained in the decrypted data request packet are acquired to obtain the keyword group.
In other embodiments of the present application, as shown in fig. 9, the keyword determining unit 120 includes a subunit: a first judgment unit 121, a second judgment unit 122, and a judgment result acquisition unit 123.
A first determining unit 121, configured to determine whether a keyword consistent with the first preset keyword exists in the keyword group, where the first preset keyword is a keyword that characterizes a test mode.
In the embodiment of the application, the tests performed by the user terminal on the service interface can be divided into two types, one is a rock mode, and the other is a non-rock mode, and whether the encrypted data request packet sent by the user terminal is a rock test can be judged by judging whether a keyword consistent with a first preset keyword exists in the keyword group, wherein the first preset keyword is a keyword for representing the test mode, for example, "rock".
And a second judging unit 122, configured to judge whether a keyword consistent with the second preset keyword exists in the keyword group if the keyword consistent with the first preset keyword exists in the keyword group, where the second preset keyword is a keyword representing a request address.
If the keyword group contains the keyword consistent with the first preset keyword, the user terminal is considered to perform a test on the service interface as a MOCK test, and whether the keyword group contains a second preset keyword is further judged, wherein the second preset keyword is a keyword for representing a request address, for example, "ste.dbg.m1".
In other embodiments of the present application, as shown in fig. 10, the keyword determining unit 120 further includes a subunit: a reminder information transmitting unit 121a.
And the reminding information sending unit 121a is configured to generate and send error reminding information to the user terminal if no keyword consistent with the first preset keyword exists in the keyword group, where the error reminding information includes the first preset keyword and a current time point.
In the embodiment of the present application, the first preset keyword is "rock". Comparing the keyword groups extracted by keyword recognition in the encrypted data request packet sent by the user terminal, and if the keyword groups do not have keywords consistent with the first preset keyword, regarding the test conducted by the user terminal on the service interface as a non-MOCK mode, generating error reminding information and sending the error reminding information to the user terminal to remind the user, wherein the error reminding information comprises the first preset keyword and the current time point, so that the user can modify the data request packet through the user terminal.
And a judging result obtaining unit 123, configured to determine that a keyword consistent with the keyword information exists in the keyword group if the keyword consistent with the second preset keyword exists in the keyword group.
And if the keyword which is consistent with the second preset keyword exists in the keyword group, obtaining a judging result of the keyword which is consistent with the keyword information in the keyword group, namely, the keyword which is consistent with the request address keyword exists in the keyword group.
And a request address information obtaining unit 130, configured to obtain the request address information in the decrypted data request packet if the keyword group has a keyword consistent with the keyword information.
And if the keyword which is consistent with the keyword information exists in the keyword group, namely the test performed on the service interface by the user terminal is a MOCK test, and the keyword which is consistent with the keyword of the request address exists in the keyword group, acquiring the corresponding request address information according to the keyword which is consistent with the second preset keyword, so that the corresponding service interface is conveniently called according to the request address information, and corresponding data information is acquired.
And the target return data obtaining unit 140 is configured to invoke a service interface corresponding to the request address information to obtain target return data.
In the embodiment of the application, a preset interface calling table is stored in the management server, and the service interface associated with the request address information can be called and target return data can be obtained by inquiring the service interface according to the preset interface calling table through the acquired request address information.
In other embodiments, as shown in fig. 11, the target return data obtaining unit 140 includes a subunit: the service interface acquisition unit 141, the service interface calling unit 142, and the data conversion unit 143.
The service interface obtaining unit 141 is configured to obtain a service interface corresponding to the request address information according to a preset interface call table.
In the embodiment of the application, a preset interface call table is stored in the management server, the preset interface call table records the corresponding relation between the request address information and the service interfaces, specifically, one request address information corresponds to one service interface, and through the preset interface call table, one unique service interface corresponding to the request address information sent by the user terminal can be obtained.
And a service interface calling unit 142, configured to call the service interface and receive initial data fed back by the service interface.
In the embodiment of the application, the service interface is a server interface which is provided by a third party system and can be used for testing, and initial data fed back by the service interface can be received by calling the service interface.
The data conversion unit 143 is configured to convert the initial data according to a preset data conversion rule to obtain target return data.
In the embodiment of the application, a preset data conversion rule is also stored in the management server, wherein the preset data conversion rule is a data format specification which is agreed between the management server and the user terminal, the data conversion rule comprises specific format specifications such as a data type requirement, a data length requirement and the like, and according to the data format specification which is agreed in the data conversion rule, the initial data can be subjected to data conversion according to the data format specification so as to obtain target return data corresponding to the initial data.
And a target return data sending unit 150, configured to send the target return data to the user terminal, so that the user terminal performs a MOCK test according to the target return data.
And returning the target return data to the user terminal so that the user terminal can perform MOCK test on the service interface according to the target return data.
The MOCK testing device provided by the embodiment of the application is applied to the MOCK testing method, and the MOCK testing method is used for acquiring the encrypted data request packet sent by the user terminal; decrypting the encrypted data request packet according to a preset key to generate a decrypted data request packet; if the keyword group contains keyword information consistent with the first preset keyword, acquiring request address information in the decrypted data request packet; calling a service interface corresponding to the request address information to acquire target return data; and sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data. The MOCK test method provided by the application can be used for conveniently and rapidly carrying out MOCK test on the third-party system interface, has good convenience and flexibility, and greatly increases the efficiency of carrying out MOCK test on the third-party system interface.
The above-described rock test apparatus may be implemented in the form of a computer program that can be run on a computer device as shown in fig. 12.
Referring to fig. 12, fig. 12 is a schematic block diagram of a computer device according to an embodiment of the present invention.
With reference to FIG. 12, the computer device 500 includes a processor 502, memory, and a network interface 505 connected by a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032, when executed, may cause the processor 502 to perform a rock test method.
The processor 502 is used to provide computing and control capabilities to support the operation of the overall computer device 500.
The internal memory 504 provides an environment for the execution of a computer program 5032 in the non-volatile storage medium 503, which computer program 5032, when executed by the processor 502, causes the processor 502 to perform a rock test method.
The network interface 505 is used for network communication, such as providing for transmission of data information, etc. It will be appreciated by those skilled in the art that the structure shown in FIG. 12 is merely a block diagram of some of the structures associated with the present inventive arrangements and does not constitute a limitation of the computer device 500 to which the present inventive arrangements may be applied, and that a particular computer device 500 may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
Wherein the processor 502 is configured to execute a computer program 5032 stored in a memory to perform the following functions: if an encrypted data request packet sent by a user terminal is received, decrypting the encrypted data request packet according to a preset secret key to obtain a decrypted data request packet; judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decryption data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords; if the keyword which is consistent with the keyword information exists in the keyword group, acquiring request address information in the decrypted data request packet; calling a service interface corresponding to the request address information to acquire target return data; and sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data.
In an embodiment, before executing the step of determining whether a keyword consistent with the keyword information exists in the keyword group corresponding to the decrypted data request packet according to preset keyword information, the processor 502 further executes the following operations: and carrying out keyword recognition on the decrypted data request packet according to a preset keyword database so as to obtain a keyword group corresponding to the decrypted data request packet.
In an embodiment, when executing the step of determining whether a keyword consistent with the keyword information exists in the keyword group corresponding to the decrypted data request packet according to preset keyword information, the processor 502 executes the following operations: judging whether a keyword consistent with the first preset keyword exists in the keyword group, wherein the first preset keyword is a keyword for representing a test mode; judging whether a keyword consistent with the first preset keyword exists in the keyword group or not, wherein the second preset keyword is a keyword representing a request address; and if the keyword which is consistent with the second preset keyword exists in the keyword group, judging that the keyword which is consistent with the keyword information exists in the keyword group.
In one embodiment, after executing the step of determining whether the keyword group includes a keyword consistent with the first preset keyword, the processor 502 further executes the following operations: if the keyword group does not have the keyword consistent with the first preset keyword, generating error reminding information and sending the error reminding information to the user terminal, wherein the error reminding information comprises the first preset keyword and a current time point.
In one embodiment, the processor 502 performs the following operations when executing the step of calling the service interface corresponding to the request address information to obtain the target return data: acquiring a service interface corresponding to the request address information according to a preset interface call table; calling the service interface and receiving initial data fed back by the service interface; and converting the initial data according to a preset data conversion rule to obtain target return data.
Those skilled in the art will appreciate that the embodiment of the computer device shown in fig. 12 is not limiting of the specific construction of the computer device, and in other embodiments, the computer device may include more or less components than those shown, or certain components may be combined, or a different arrangement of components. For example, in some embodiments, the computer device may include only a memory and a processor, and in such embodiments, the structure and function of the memory and the processor are consistent with the embodiment shown in fig. 12, and will not be described again.
It should be appreciated that in embodiments of the present invention, the Processor 502 may be a Central processing unit (Central ProcessingUnit, CPU), the Processor 502 may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL processors, DSPs), application SPECIFIC INTEGRATED Circuits (ASICs), off-the-shelf Programmable gate arrays (Field-Programmable GATEARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In another embodiment of the invention, a computer-readable storage medium is provided. The computer readable storage medium may be a non-volatile computer readable storage medium. The computer readable storage medium stores a computer program, wherein the computer program when executed by a processor performs the steps of: if an encrypted data request packet sent by a user terminal is received, decrypting the encrypted data request packet according to a preset secret key to obtain a decrypted data request packet; judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decryption data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords; if the keyword which is consistent with the keyword information exists in the keyword group, acquiring request address information in the decrypted data request packet; calling a service interface corresponding to the request address information to acquire target return data; and sending the target return data to the user terminal so that the user terminal performs MOCK test according to the target return data.
In an embodiment, before the step of determining whether the keyword consistent with the keyword information exists in the keyword group corresponding to the decrypted data request packet according to the preset keyword information, the method further includes: and carrying out keyword recognition on the decrypted data request packet according to a preset keyword database so as to obtain a keyword group corresponding to the decrypted data request packet.
In an embodiment, the step of determining whether a keyword consistent with the keyword information exists in the keyword group corresponding to the decrypted data request packet according to preset keyword information includes: judging whether a keyword consistent with the first preset keyword exists in the keyword group, wherein the first preset keyword is a keyword for representing a test mode; judging whether a keyword consistent with the first preset keyword exists in the keyword group or not, wherein the second preset keyword is a keyword representing a request address; and if the keyword which is consistent with the second preset keyword exists in the keyword group, judging that the keyword which is consistent with the keyword information exists in the keyword group.
In an embodiment, after the step of determining whether the keyword group includes a keyword consistent with the first preset keyword, the method further includes: if the keyword group does not have the keyword consistent with the first preset keyword, generating error reminding information and sending the error reminding information to the user terminal, wherein the error reminding information comprises the first preset keyword and a current time point.
In one embodiment, the step of calling the service interface corresponding to the request address information to obtain the target return data includes: acquiring a service interface corresponding to the request address information according to a preset interface call table; calling the service interface and receiving initial data fed back by the service interface; and converting the initial data according to a preset data conversion rule to obtain target return data.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein. Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the units is merely a logical function division, there may be another division manner in actual implementation, or units having the same function may be integrated into one unit, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices, or elements, or may be an electrical, mechanical, or other form of connection.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present invention.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention is essentially or part of what contributes to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a computer-readable storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned computer-readable storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (5)

1. A method of MOCK testing comprising:
if an encrypted data request packet sent by a user terminal is received, decrypting the encrypted data request packet according to a preset secret key to obtain a decrypted data request packet;
Carrying out keyword recognition on the decrypted data request packet according to a preset keyword database so as to obtain a keyword group corresponding to the decrypted data request packet; the preset keyword database comprises a plurality of preset keywords; the keyword group comprises keywords corresponding to preset keywords in the decrypted data request packet;
Judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decryption data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords;
if the keyword which is consistent with the keyword information exists in the keyword group, acquiring request address information in the decrypted data request packet;
calling a service interface corresponding to the request address information to acquire target return data;
The target return data is sent to the user terminal, so that the user terminal performs MOCK test according to the target return data;
The keyword information includes a first preset keyword and a second preset keyword, and the judging whether the keyword consistent with the keyword information exists in the keyword group corresponding to the decrypted data request packet according to the preset keyword information includes:
judging whether a keyword consistent with the first preset keyword exists in the keyword group, wherein the first preset keyword is a keyword for representing a test mode;
Judging whether a keyword consistent with the first preset keyword exists in the keyword group or not, wherein the second preset keyword is a keyword representing a request address;
If the keyword which is consistent with the second preset keyword exists in the keyword group, judging that the keyword which is consistent with the keyword information exists in the keyword group;
the calling the service interface corresponding to the request address information to acquire the target return data comprises the following steps:
acquiring a service interface corresponding to the request address information according to a preset interface call table;
Calling the service interface and receiving initial data fed back by the service interface; the service interface is a server interface which is provided by a third party system and can be tested;
and converting the initial data according to a preset data conversion rule to obtain target return data.
2. The MOCK testing method of claim 1 wherein after the step of determining whether there is a keyword in the keyword group that is consistent with the first preset keyword, the method further comprises:
If the keyword group does not have the keyword consistent with the first preset keyword, generating error reminding information and sending the error reminding information to the user terminal, wherein the error reminding information comprises the first preset keyword and a current time point.
3. A rock test device, comprising:
The data request packet decryption unit is used for decrypting the encrypted data request packet according to a preset secret key to obtain a decrypted data request packet if the encrypted data request packet sent by the user terminal is received;
The keyword group acquisition unit is used for carrying out keyword recognition on the decrypted data request packet according to a preset keyword database so as to acquire a keyword group corresponding to the decrypted data request packet; the preset keyword database comprises a plurality of preset keywords; the keyword group comprises keywords corresponding to preset keywords in the decrypted data request packet;
The keyword judging unit is used for judging whether keywords consistent with the keyword information exist in the keyword groups corresponding to the decryption data request packet according to preset keyword information, wherein the keyword groups comprise a plurality of keywords;
A request address information obtaining unit, configured to obtain request address information in the decrypted data request packet if a keyword consistent with the keyword information exists in the keyword group;
The target return data acquisition unit is used for calling a service interface corresponding to the request address information to acquire target return data;
The target return data sending unit is used for sending the target return data to the user terminal so that the user terminal can perform MOCK test according to the target return data;
The keyword information includes a first preset keyword and a second preset keyword, and the keyword judgment unit includes:
the first judging unit is used for judging whether the keyword group has keywords consistent with the first preset keywords, wherein the first preset keywords are keywords representing a test mode;
a second judging unit, configured to judge whether a keyword consistent with the first preset keyword exists in the keyword group, where the second preset keyword is a keyword representing a request address;
A judging result obtaining unit, configured to determine that a keyword consistent with the keyword information exists in the keyword group if the keyword consistent with the second preset keyword exists in the keyword group;
The target return data acquisition unit includes:
the service interface acquisition unit is used for acquiring a service interface corresponding to the request address information according to a preset interface call table;
A service interface calling unit, configured to call the service interface and receive initial data fed back by the service interface; the service interface is a server interface which is provided by a third party system and can be tested;
And the data conversion unit is used for converting the initial data according to a preset data conversion rule to obtain target return data.
4. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the rock test method according to any one of claims 1 to 2 when executing the computer program.
5. A computer readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, causes the processor to perform the rock test method according to any one of claims 1-2.
CN201910610941.XA 2019-07-08 2019-07-08 MOCK testing method, device, computer equipment and storage medium Active CN110489322B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910610941.XA CN110489322B (en) 2019-07-08 2019-07-08 MOCK testing method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910610941.XA CN110489322B (en) 2019-07-08 2019-07-08 MOCK testing method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110489322A CN110489322A (en) 2019-11-22
CN110489322B true CN110489322B (en) 2024-07-02

Family

ID=68546714

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910610941.XA Active CN110489322B (en) 2019-07-08 2019-07-08 MOCK testing method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110489322B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111294359B (en) * 2020-02-27 2023-09-05 平安养老保险股份有限公司 Pressure testing method, pressure testing device, computer equipment and storage medium
CN111752625A (en) * 2020-06-23 2020-10-09 京东数字科技控股有限公司 Method and device for interface mock
CN112783787A (en) * 2021-02-04 2021-05-11 中国工商银行股份有限公司 Interface test method, device and system and electronic equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106528400A (en) * 2016-09-22 2017-03-22 深圳峰创智诚科技有限公司 MOCK testing method and device
CN109743222A (en) * 2018-12-25 2019-05-10 瑞庭网络技术(上海)有限公司 A kind of data test method and relevant device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109446071A (en) * 2018-09-26 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, interface test device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106528400A (en) * 2016-09-22 2017-03-22 深圳峰创智诚科技有限公司 MOCK testing method and device
CN109743222A (en) * 2018-12-25 2019-05-10 瑞庭网络技术(上海)有限公司 A kind of data test method and relevant device

Also Published As

Publication number Publication date
CN110489322A (en) 2019-11-22

Similar Documents

Publication Publication Date Title
CN109150499B (en) Method and device for dynamically encrypting data, computer equipment and storage medium
CN110489322B (en) MOCK testing method, device, computer equipment and storage medium
WO2021036172A1 (en) Blockchain transaction query method and system
WO2021036170A1 (en) Blockchain transaction processing method and apparatus
WO2021036171A1 (en) Blockchain transaction processing method and apparatus
CN110995720B (en) Encryption method, device, host terminal and encryption chip
CN106790083A (en) Detection method, device and mobile terminal that DNS is kidnapped
CN110659206A (en) Simulation architecture establishing method, device, medium and electronic equipment based on microservice
CN114117482A (en) Database encryption method and device, electronic equipment and storage medium
CN113038463A (en) Communication encryption authentication experimental device
CN112910641A (en) Verification method and device for cross-link transaction supervision, relay link node and medium
CN110232570B (en) Information supervision method and device
CN113296737A (en) Random number generation system, method and device and cloud server
CN116743481A (en) Service security management and control method, device, equipment and storage medium
CN112507014B (en) Data storage method, device and system based on credible account book database
CN112529642B (en) Invoice management method, system, equipment and storage medium based on block chain
US9775043B2 (en) Network locking method and system for wireless terminal
CN114117388A (en) Device registration method, device registration apparatus, electronic device, and storage medium
CN112333150A (en) Data decryption method and device, storage medium and computing equipment
CN111859351A (en) Method, system, server and storage medium for writing information into chip
CN111190824A (en) Monitoring method, monitoring device, terminal equipment and storage medium
CN110781511A (en) Transaction information storage method and device, computer equipment and storage medium
CN109756506A (en) Data ciphering method, device, equipment and storage medium based on GNSS receiver
CN117499159B (en) Block chain-based data transaction method and device and electronic equipment
CN110348235B (en) File detection method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant