Method, device, equipment and medium for simulating and testing resident certificates
1. A method for simulating and testing resident certificates is characterized in that: the method comprises the following steps:
step 1, acquiring instruction data of a service system;
step 2, judging whether the instruction data meet the set requirements, and if so, entering the next step; if not, ending;
step 3, analyzing the instruction data, and if the instruction data is an equipment instruction, returning corresponding response data;
if the instruction data is a standard instruction, matching the standard instruction with the instruction file, and configuring the corresponding instruction into standard return or non-standard return according to the specification document when the standard instruction is a card searching and selecting instruction; when the standard instruction is an instruction for reading certificate information, returning appointed simulated certificate information or random simulated certificate information according to the configuration file;
and 4, sending the returned data.
2. A method of simulating the testing of resident documents according to claim 1, wherein: the simulated certificate information is as follows: according to the certificate specification, performing data filling on the specified fixed field to generate hexadecimal data; the simulated certificate information is correct certificate sampling information or wrong certificate sampling information.
3. A method of simulating the testing of resident documents according to claim 1, wherein: the instruction file is an ini format file, the ini format file comprises at least one field, each field at least comprises two keys, and one key represents standard instruction data and is used for matching with a received standard instruction; and the other key represents data corresponding to a standard instruction, the data corresponding to the standard instruction comprises two sub-keys, one sub-key represents the type of evidence, and the other sub-key represents a numerical index value for searching data.
4. A method of simulating the testing of resident documents according to claim 1, wherein: analyzing the instruction data in the step 3, and if the instruction data is an equipment instruction, returning corresponding response data further specifically includes: analyzing the instruction data, and if the instruction data is an equipment instruction, returning corresponding response data according to the response file; the response file comprises response data corresponding to at least one device, and the response file is stored in a plaintext mode.
5. A device for simulating and testing resident certificates is characterized in that: the method comprises the following steps: the business instruction analysis system comprises: the device comprises a virtual serial port setting module, a device instruction set module, a standard instruction set module, an information synthesis module and an information return specifying module;
the virtual serial port setting module is used for virtually simulating a pair of virtual serial ports on the test terminal, receiving instruction information of the service process and returning simulated data information;
the equipment instruction set module is used for being compatible with the difference of equipment instructions, different characteristic instructions exist in different manufacturer equipment for limited reading, set data needs to be responded as initial conditions of equipment authentication, and execution operation of a standard flow is performed if the authentication is passed;
the standard instruction set module is used for storing a standard instruction set, files in an ini format are stored as standard instruction files, and each field in each standard instruction file describes one instruction;
the information synthesis module is used for providing a graphical interface for information synthesis and providing an input window for synthesizing the simulation data of the identity card; collecting data sources used in the certificates through a graphical interface according to the specification of the standard file, filling data in each collected field, and finally generating hexadecimal data which is stored in a standard instruction file of a standard instruction set module;
the information return appointing module is used for providing a graphical interface of a selection condition and carrying out a random test, a sequential test or an appointed sequence number test according to the selection condition of the standard instruction set module during data mapping;
receiving the instruction data through a virtual serial port setting module, then analyzing the instruction data, and if the instruction is an equipment instruction, processing the instruction through an equipment instruction set module; if the command is a standard command, the command is processed through a standard command set module, an information synthesis module and an information return appointed module, and then the processed data is sent through a virtual serial port setting module.
6. An apparatus for simulating the testing of resident documents according to claim 5, wherein: the device instruction set module is further specifically: the device instruction set module is used for being compatible with difference of device instructions, different manufacturer devices have different characteristic instructions to perform limited reading, set data are required to be responded to serve as initial conditions of device authentication, execution operation of a standard flow is performed when the authentication is passed, and instructions and data response contents of the device instruction set module are stored as device instruction files in the mode of an ini format file and a plaintext.
7. An apparatus for simulating the testing of resident documents according to claim 5, wherein: the standard instruction set module is further specifically: the file in the ini format is stored as a standard instruction file, each field in the standard instruction file describes one instruction, and each field at least comprises two keys: one key represents standard instruction data for matching the received standard instruction; another key represents the data set of the standard instruction response, which is used to respond to the data set returned under a different instruction set in the standard return.
8. An apparatus for simulating the testing of resident documents according to claim 5, wherein: the information synthesis module is further specifically: the graphical interface is used for providing information synthesis and providing an input window for synthesizing the simulation data of the identity card; the method comprises the steps of collecting a data source used in the certificate through a graphical interface according to the specification of a specification file, filling data in each collected field, generating hexadecimal data, and storing the hexadecimal data in a standard instruction file of a standard instruction set module according to different key values, wherein each field in the standard instruction file comprises two keys, one key comprises two subkeys, one subkey represents the type of the certificate, and the other subkey represents a numerical index value of response data.
9. An electronic 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 method according to any of claims 1 to 4 when executing the program.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 4.
Background
At present, when various domestic organizations such as banks, insurance and the like process related financial services, certificates of cardholders are generally used in the service flow for identity verification. In the process of testing the business process, various certificates are required to be used for testing, and the stability and the robustness of the certificate processing process can be tested. Since the document is an important document for an individual, it cannot be lent out easily and there is a certain risk of damage during the test. Meanwhile, the test card is used for testing, so that few test samples are available, many problems cannot be tested, and the problems are generally left in the actual use process in production. In the actual business process, if the certificate reading is abnormal, the customer may not want to put the certificate in a bank or an equipment manufacturer for problem analysis due to the particularity of the certificate. The problem is solved and analyzed with great technical difficulty.
Disclosure of Invention
The invention aims to solve the technical problem of providing a method, a device, equipment and a medium for simulating and testing resident certificates, so that the workload of developers and testers is reduced, and the product development efficiency is improved.
In a first aspect, the present invention provides a method of simulating the testing of resident documents, comprising:
step 1, acquiring instruction data of a service system;
step 2, judging whether the instruction data meet the set requirements, and if so, entering the next step; if not, ending;
step 3, analyzing the instruction data, and if the instruction data is an equipment instruction, returning corresponding response data;
if the instruction data is a standard instruction, matching the standard instruction with the instruction file, and configuring the corresponding instruction into standard return or non-standard return according to the specification document when the standard instruction is a card searching and selecting instruction; when the standard instruction is an instruction for reading certificate information, returning appointed simulated certificate information or random simulated certificate information according to the configuration file;
and 4, sending the returned data.
Further, the simulated certificate information is as follows: according to the certificate specification, performing data filling on the specified fixed field to generate hexadecimal data; the simulated certificate information is correct certificate sampling information or wrong certificate sampling information.
Further, the instruction file is an ini format file, the ini format file comprises at least one field, each field at least comprises two keys, and one key represents standard instruction data and is used for matching with the received standard instruction; and the other key represents data corresponding to a standard instruction, the data corresponding to the standard instruction comprises two sub-keys, one sub-key represents the type of evidence, and the other sub-key represents a numerical index value for searching data.
Further, the analyzing the instruction data in step 3, and if the instruction data is an equipment instruction, returning the corresponding response data further specifically includes: analyzing the instruction data, and if the instruction data is an equipment instruction, returning corresponding response data according to the response file; the response file comprises response data corresponding to at least one device, and the response file is stored in a plaintext mode.
In a second aspect, the present invention provides apparatus for simulating the testing of resident documents, comprising: the business instruction analysis system comprises: the device comprises a virtual serial port setting module, a device instruction set module, a standard instruction set module, an information synthesis module and an information return specifying module;
the virtual serial port setting module is used for virtually simulating a pair of virtual serial ports on the test terminal, receiving instruction information of the service process and returning simulated data information;
the equipment instruction set module is used for being compatible with the difference of equipment instructions, different characteristic instructions exist in different manufacturer equipment for limited reading, set data needs to be responded as initial conditions of equipment authentication, and execution operation of a standard flow is performed if the authentication is passed;
the standard instruction set module is used for storing a standard instruction set, files in an ini format are stored as standard instruction files, and each field in each standard instruction file describes one instruction;
the information synthesis module is used for providing a graphical interface for information synthesis and providing an input window for synthesizing the simulation data of the identity card; collecting data sources used in the certificates through a graphical interface according to the specification of the standard file, filling data in each collected field, and finally generating hexadecimal data which is stored in a standard instruction file of a standard instruction set module;
the information return appointing module is used for providing a graphical interface of a selection condition and carrying out a random test, a sequential test or an appointed sequence number test according to the selection condition of the standard instruction set module during data mapping;
receiving the instruction data through a virtual serial port setting module, then analyzing the instruction data, and if the instruction is an equipment instruction, processing the instruction through an equipment instruction set module; if the command is a standard command, the command is processed through a standard command set module, an information synthesis module and an information return appointed module, and then the processed data is sent through a virtual serial port setting module.
Further, the device instruction set module is further specifically configured to: the device instruction set module is used for being compatible with difference of device instructions, different manufacturer devices have different characteristic instructions for limited reading, set data are required to be responded as initial conditions of device authentication, execution operation of a standard flow is carried out if the authentication is passed, and instructions and data response contents of the device instruction set module are stored as device instruction files in the mode of ini-format files and plain texts
Further, the standard instruction set module is further specifically: the file in the ini format is stored as a standard instruction file, each field in the standard instruction file describes one instruction, and each field at least comprises two keys: one key represents standard instruction data for matching the received standard instruction; another key represents the data set of the standard instruction response, which is used to respond to the data set returned under a different instruction set in the standard return.
Further, the information synthesis module is further specifically: the graphical interface is used for providing information synthesis and providing an input window for synthesizing the simulation data of the identity card; the method comprises the steps of collecting a data source used in the certificate through a graphical interface according to the specification of a specification file, filling data in each collected field, generating hexadecimal data, and storing the hexadecimal data in a standard instruction file of a standard instruction set module according to different key values, wherein each field in the standard instruction file comprises two keys, one key comprises two subkeys, one subkey represents the type of the certificate, and the other subkey represents a numerical index value of response data.
In a third aspect, the present invention provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of the first aspect when executing the program.
In a fourth aspect, the invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of the first aspect.
One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:
according to the method, the device, the equipment and the medium provided by the embodiment of the application, through data simulation of the Chinese resident identification card, only an equipment instruction set needs to be added or deleted when a new device is adapted, the service system flow called by an upper layer does not need to be modified, and the operation is convenient.
The virtual serial port function in the invention can completely cancel the bringing in of equipment;
the information synthesis function in the invention can simulate a large amount of certificate information, and the standard set has the characteristics of clearness and understandability and simple modification, thereby reducing the workload of developers and testers and improving the efficiency of product development;
the instruction analysis method has strong universality, improves the code multiplexing efficiency and reduces the error risk. The idea of separating the instruction set from the instruction analysis can be quickly transplanted to other products with similar working modes, and the instruction analysis code with higher universality can obviously improve the stability and the robustness of the code, so that the subsequent work becomes simple and efficient, and the effect of 'once and for all' is achieved; in addition, the expansibility of instruction processing can quickly locate the problem position when the program is abnormal; because the format of the plaintext instruction set contains a large amount of instruction information, each part of data of the instruction can be quickly separated from the instruction processing module of the application program, so that the instruction processing program becomes simple.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
The invention will be further described with reference to the following examples with reference to the accompanying drawings.
FIG. 1 is a schematic diagram of a framework of a business instruction parsing system according to the present invention;
FIG. 2 is a flow chart of the testing steps of the present invention;
FIG. 3 is a flowchart of a method according to an embodiment of the invention.
Detailed Description
By providing the method, the device, the equipment and the medium for simulating and testing the resident certificates, a set of mature and stable certificate data simulation scheme is needed in order to quickly test the certificate card reading function in the business process, improve the development efficiency and enhance the stability and the robustness of product codes. In the whole development process, two systems are generally involved, namely a bank client system and an equipment reading system of an equipment manufacturer, wherein the equipment manufacturer provides an integrated library for the equipment client system to call, and equipment of the equipment manufacturer uses a serial port to read data of a certificate module. If the certificate information can be correctly simulated, various certificate information can be tested as much as possible in the actual testing process, and the problems that certificates are borrowed everywhere, testing data is incomplete, and the certificates cannot be simulated for checking due to abnormal reading data are solved.
The technical scheme in the embodiment of the application has the following general idea:
as shown in fig. 1, the service instruction parsing system of the present invention is divided into five sub-modules: the device comprises a virtual serial port setting module (101), a device instruction set module (102), a standard instruction set module (103), an information synthesis module (104) and an information return specifying module (105).
The virtual serial port setting module 101 is used for virtually simulating a pair of virtual serial ports on the test terminal to prepare for simulating the device processing flow. The method is mainly used for receiving instruction information of the business process and returning the simulated data information.
The device command set module 102 is mainly used to accommodate differences in device commands. Different manufacturer equipment has different characteristic instructions for limiting reading. Response data is needed as an initial condition for device authentication, and the standard flow execution operation is performed when the authentication is passed. The instruction and data response content of the module exist in a file in an ini format and are stored in a plaintext mode, and a user can modify the file. The compatibility to different equipment models is expanded.
The standard instruction set module 103 is a standard instruction set provided by the police department, and exists in an ini file, each field in the ini file describes an instruction, and each field at least comprises two keys: one key represents standard instruction data for matching the received standard instruction; another key represents a data set of standard instruction response, which is used for responding to data sets returned under different instruction sets in the standard return, and the data set responded is in a fixed format; the standard instruction refers to an instruction set of a public security department, normally comprises three instructions, two are status instructions, one is a data instruction, and can simulate data returned by different certificates.
The information synthesis module 104 is a graphical interface, provides an input window for synthesizing the simulation data of the ID card, and is mainly operated to collect data sources used in the China ID card through the graphical interface according to the GA-T490-charge 2019 ID card machine-readable information specification. And (3) filling data in each collected field, and finally generating hexadecimal data with length of 1295 or 1297 or 2321 bytes. And saved in the. ini file of 103 according to different key values. Each field in the ini file contains two keys, wherein one key comprises two sub-keys. One sub-key represents the type of document, with the difference being fingerprint data and no fingerprint data. The other sub-key represents the numerical index value of the response data and provides navigation for quickly finding the data during testing;
the information return specifying module 105 is a graphical interface, and specifies 103 a selection condition for data mapping so as to perform functions of setting a random test, a sequential test, a specified sequence number test, and the like. The pressure test of a single card, the random test of a plurality of cards and the sequential test are fully simulated, and the test samples are diversified.
As shown in fig. 2, the simulation test of the identity card of the chinese residents of the present invention mainly comprises the following steps:
(201) and receiving instruction data from the service system from the virtual equipment communication port and storing the instruction data into a cache.
(202) And extracting instruction data in the cache, performing data comparison analysis in the configuration file, finding out whether the instruction meets the requirement range, directly returning the instruction which does not meet the requirement, and performing continuous processing analysis on the data which meets the requirement.
(203) When the command is analyzed to be the device command, the ini file in 102 is called, the response data set corresponding to the command in the configuration file is returned, and the continuous operation of the process is ensured. Of course, there is no device command necessary at this time, and the main goal of adding this step is not to change the design flow of the device.
(204) When the standard instruction is resolved, the ini file in 103 is called.
(205) When analyzing the instruction for searching and selecting the card, the corresponding instruction in 103 can be configured into standard return (data organized according to the standard specification) or non-standard return (data in the serial standard specification, data with incomplete or wrong receiving of simulation data) according to the specification document (GA/T490-2019) to fully test the service logic function in the service flow.
(206) When the certificate information reading instruction is analyzed, a piece of appointed or random simulated certificate information can be returned according to the ini file in the 103, and the selected information is placed into a sending cache.
(207) For the graphical interface, according to the ini file of 103, modes such as serial number, sequential test, random test and the like of the existing simulation data can be selected to return the certificate information. If no simulation data exists, the diversified data synthesis can be carried out according to the fixed field specified in the GA-T490-2019 resident identification card machine-readable information specification. When synthesizing data, the synthesis may be correct and rare sample synthesis or incorrect sample synthesis. And providing various normal and abnormal data cases for case test.
(208) And sending the cache data to be sent through the virtual serial port.
Example one
As shown in fig. 3, this embodiment provides a first aspect, and the invention provides a method for simulating the testing of resident credentials, comprising:
step 1, acquiring instruction data of a service system;
step 2, judging whether the instruction data meet the set requirements, and if so, entering the next step; if not, ending;
step 3, analyzing the instruction data, and if the instruction data is an equipment instruction, returning corresponding response data according to the response file; the response file comprises response data corresponding to at least one device, and the response file is stored in a plaintext mode;
if the instruction data is a standard instruction, matching the standard instruction with the instruction file, and configuring the corresponding instruction into standard return or non-standard return according to the specification document when the standard instruction is a card searching and selecting instruction; when the standard instruction is an instruction for reading certificate information, returning appointed simulated certificate information or random simulated certificate information according to the configuration file, wherein the simulated certificate information is as follows: according to the certificate specification, performing data filling on the specified fixed field to generate hexadecimal data; the simulated certificate information is correct certificate sampling information or wrong certificate sampling information, the instruction file is an ini format file, the ini format file comprises at least one field, each field at least comprises two keys, and one key represents standard instruction data and is used for matching with a received standard instruction; the other key represents data corresponding to a standard instruction, the data corresponding to the standard instruction comprises two sub-keys, one sub-key represents the type of evidence, and the other sub-key represents a numerical index value and is used for searching data;
and 4, sending the returned data.
Based on the same inventive concept, the application also provides a device corresponding to the method in the first embodiment, which is detailed in the second embodiment.
Example two
In this embodiment, there is provided an apparatus for simulating and testing resident documents, comprising: the business instruction analysis system comprises: the device comprises a virtual serial port setting module, a device instruction set module, a standard instruction set module, an information synthesis module and an information return specifying module;
the virtual serial port setting module is used for virtually simulating a pair of virtual serial ports on the test terminal, receiving instruction information of the service process and returning simulated data information;
the device instruction set module is used for being compatible with the difference of device instructions, different manufacturer devices have different characteristic instructions for limited reading, set data needs to be responded to serve as initial conditions of device authentication, and execution operation of a standard flow is performed if the authentication is passed;
the standard instruction set module is used for storing a standard instruction set, and files in an ini format are stored as standard instruction files, each field in each standard instruction file describes one instruction, and each field at least comprises two keys: one key represents standard instruction data for matching the received standard instruction; another key represents a data set of standard instruction responses, which is used for responding to data sets returned under different instruction sets in the standard return;
the information synthesis module is used for providing a graphical interface for information synthesis and providing an input window for synthesizing the simulation data of the identity card; collecting a data source used in the certificate through a graphical interface according to the specification of a standard file, filling data in each collected field, finally generating hexadecimal data, and storing the hexadecimal data in a standard instruction file of a standard instruction set module according to different key values, wherein each field in the standard instruction file comprises two keys, one key comprises two subkeys, one subkey represents the type of the certificate, and the other subkey represents a digital index value of response data; the specification file is as follows: and the GA-T490-2019 resident identification card machine-readable information specification.
The information return appointing module is used for providing a graphical interface of a selection condition and carrying out a random test, a sequential test or an appointed sequence number test according to the selection condition of the standard instruction set module during data mapping;
receiving the instruction data through a virtual serial port setting module, then analyzing the instruction data, and if the instruction is an equipment instruction, processing the instruction through an equipment instruction set module; if the command is a standard command, the command is processed through a standard command set module, an information synthesis module and an information return appointed module, and then the processed data is sent through a virtual serial port setting module.
Since the apparatus described in the second embodiment of the present invention is an apparatus used for implementing the method of the first embodiment of the present invention, based on the method described in the first embodiment of the present invention, a person skilled in the art can understand the specific structure and the deformation of the apparatus, and thus the details are not described herein. All the devices adopted in the method of the first embodiment of the present invention belong to the protection scope of the present invention.
Based on the same inventive concept, the application provides an electronic device embodiment corresponding to the first embodiment, which is detailed in the third embodiment.
EXAMPLE III
The embodiment provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, any one of the embodiments may be implemented.
Since the electronic device described in this embodiment is a device used for implementing the method in the first embodiment of the present application, based on the method described in the first embodiment of the present application, a specific implementation of the electronic device in this embodiment and various variations thereof can be understood by those skilled in the art, and therefore, how to implement the method in the first embodiment of the present application by the electronic device is not described in detail herein. The equipment used by those skilled in the art to implement the methods in the embodiments of the present application is within the scope of the present application.
Based on the same inventive concept, the application provides a storage medium corresponding to the fourth embodiment, which is described in detail in the fourth embodiment.
Example four
The present embodiment provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, any one of the first embodiment can be implemented.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Although specific embodiments of the invention have been described above, it will be understood by those skilled in the art that the specific embodiments described are illustrative only and are not limiting upon the scope of the invention, and that equivalent modifications and variations can be made by those skilled in the art without departing from the spirit of the invention, which is to be limited only by the appended claims.
- 上一篇:石墨接头机器人自动装卡簧、装栓机
- 下一篇:一种避免漏采样的FPGA在线调试方法