CN107122258B - Method and equipment for checking state code of test interface - Google Patents

Method and equipment for checking state code of test interface Download PDF

Info

Publication number
CN107122258B
CN107122258B CN201710253945.8A CN201710253945A CN107122258B CN 107122258 B CN107122258 B CN 107122258B CN 201710253945 A CN201710253945 A CN 201710253945A CN 107122258 B CN107122258 B CN 107122258B
Authority
CN
China
Prior art keywords
interface
test
called
request
login
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
CN201710253945.8A
Other languages
Chinese (zh)
Other versions
CN107122258A (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.)
Shanghai Raxtone Software Co ltd
Original Assignee
Shanghai Raxtone Software Co 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 Shanghai Raxtone Software Co ltd filed Critical Shanghai Raxtone Software Co ltd
Priority to CN201710253945.8A priority Critical patent/CN107122258B/en
Publication of CN107122258A publication Critical patent/CN107122258A/en
Application granted granted Critical
Publication of CN107122258B publication Critical patent/CN107122258B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1012Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices using codes or arrangements adapted for a specific type of error
    • G06F11/1024Identification of the type of error

Abstract

The method comprises the steps of determining a status code fed back by a called login interface through a request for calling the login interface based on a test interface; checking the feedback state code according to a preset state code to obtain a checking result; and judging whether a message body used for verifying the test result is acquired from the request message of the test interface or not according to the check result. Therefore, different verification results are obtained according to the verification of the state codes, different logics are executed, whether a message body in the request message can be obtained or not can be automatically associated to an error reporting information list according to the state codes of the error reporting types, and corresponding specific error reporting information is searched and returned from the error reporting information list, wherein the specific error reporting information comprises error reasons and corresponding solving methods, so that a tester is guided to carry out efficient and rapid interface testing from different scenes.

Description

Method and equipment for checking state code of test interface
Technical Field
The present application relates to the field of computers, and in particular, to a method and an apparatus for checking a status code of a test interface.
Background
With the development of the test industry, functional tests, performance tests and automatic tests successively appear, at present, the architecture of most of platforms is no longer the traditional MVC structure, the system continuously develops towards the directions of distribution, service centralization and high availability, the system architecture is numerous and complex nowadays, interfaces among systems are numerous and diverse, the traditional functional tests, performance tests and automatic tests are difficult to meet the requirements of system development, a more effective and practical test mode capable of being continuously carried out is urgently needed to ensure the quality of the system, the traditional interface tests mainly aim at the test of a single interface, linkage tests of a plurality of interfaces cannot be carried out, return data of a front interface cannot be transmitted, and the test and the quick iteration are difficult.
At present, Postman is an interface testing tool which can adapt to most service scenes, is convenient and quick, and a flow chart of an overall architecture idea is shown in fig. 1. The above-mentioned framework needs to manually configure too many parameters, and manually checks whether the interface returned data is an expected result, without clear and efficient status code check.
Content of application
An object of the present application is to provide a method and an apparatus for checking a status code of a test interface, which solve the problem of checking a status code in a message-free body in the prior art.
According to an aspect of the present application, there is provided a method for checking a status code of a test interface, the method including:
determining a status code fed back by the called login interface based on a request of calling the login interface by the test interface;
checking the feedback state code according to a preset state code to obtain a checking result;
and judging whether a message body used for verifying the test result is acquired from the request message of the test interface or not according to the check result.
Further, before determining the status code fed back by the called login interface based on the request of the test interface calling the login interface, the method comprises the following steps:
acquiring a test request of the test interface;
determining a login interface called by the test interface according to the test request of the test interface;
and determining the configuration file according to the called login interface.
Further, determining the status code fed back by the called login interface based on the request of the test interface calling the login interface comprises:
determining a configuration file corresponding to the called login interface based on a request of calling the login interface by the test interface;
acquiring session unique identification information corresponding to the called login interface from the local file according to the account in the configuration file;
and determining a feedback state code according to the processing state of the called login interface.
Further, determining whether to acquire a message body for verifying the test result from the request message of the test interface according to the check result, includes:
and if the verification result is that the called login interface is correctly processed, acquiring a message body for verifying the test result from the request message of the test interface.
Further, determining whether to acquire a message body for verifying the test result from the request message of the test interface according to the check result, includes:
and if the verification result is that the validity period of the session unique identifier of the called login interface is expired, sending a request for logging in again by the called login interface.
Further, after sending the request for logging back to the called login interface, the method includes:
generating login parameters and encryption information according to the environment where the re-login request is located and the port name;
and logging in according to the login parameters and the encryption information, and acquiring the session unique identifier of the called login interface stored in a local file.
Further, determining whether to acquire a message body for verifying the test result from the request message of the test interface according to the check result, includes:
and if the verification result is that the called login interface is not processed correctly and the validity period of the session unique identifier of the called login interface is not expired, acquiring error reporting information.
Further, after acquiring the error information, the method includes:
and judging whether the test interface is tested successfully or not according to the error reporting information.
According to another aspect of the present application, there is also provided an apparatus for checking a status code of a test interface, the apparatus including:
the determining device is used for determining the state code fed back by the called login interface based on the request of the test interface for calling the login interface;
the checking device is used for checking the feedback state code according to a preset state code to obtain a checking result;
and the judging device is used for acquiring a message body used for verifying the test result from the request message of the test interface according to the verification result.
Further, the apparatus comprises:
the acquisition request device is used for acquiring the test request of the test interface;
the calling device is used for determining a login interface called by the test interface according to the test request of the test interface;
and the query device is used for determining the configuration file according to the called login interface.
Further, the determining means is configured to:
determining a configuration file corresponding to the called login interface based on a request of calling the login interface by the test interface;
acquiring session unique identification information corresponding to the called login interface from the local file according to the account in the configuration file;
and determining a feedback state code according to the processing state of the called login interface.
Further, the judging device is configured to:
and if the verification result is that the called login interface is correctly processed, acquiring a message body for verifying the test result from the request message of the test interface.
Further, the judging device is configured to:
and if the verification result is that the validity period of the session unique identifier of the called login interface is expired, sending a request for logging in again by the called login interface.
Further, the judging device is configured to:
generating login parameters and encryption information according to the environment where the re-login request is located and the port name;
and logging in according to the login parameters and the encryption information, and acquiring the session unique identifier of the called login interface stored in a local file.
Further, the judging device is configured to:
and the error reporting device is used for acquiring error reporting information if the verification result is that the called login interface is not processed correctly and the validity period of the session unique identifier of the called login interface is not expired.
Further, the judging device is configured to:
and judging whether the test interface is tested successfully or not according to the error reporting information.
Compared with the prior art, the method and the device determine the state code fed back by the called login interface through the request of calling the login interface based on the test interface; checking the feedback state code according to a preset state code to obtain a checking result; and judging whether a message body used for verifying the test result is acquired from the request message of the test interface or not according to the check result. Therefore, different verification results are obtained according to the verification of the state codes, different logics are executed, whether a message body in the request message can be obtained or not can be automatically associated to an error reporting information list according to the state codes of the error reporting types, and corresponding specific error reporting information is searched and returned from the error reporting information list, wherein the specific error reporting information comprises error reasons and corresponding solving methods, so that a tester is guided to carry out efficient and rapid interface testing from different scenes.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 illustrates an architecture diagram of interface testing in the prior art;
FIG. 2 is a schematic diagram illustrating an interface architecture of an efficient hierarchical server side according to an embodiment of the present application;
FIG. 3 illustrates a flow diagram of a method for status code checking of a test interface, provided in accordance with an aspect of the present application;
FIG. 4 is a flow chart illustrating checking of a status code in a message header according to an embodiment of the present application;
fig. 5 is a schematic structural diagram illustrating an apparatus for checking a status code of a test interface according to another aspect of the present application.
The same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
In a typical configuration of the present application, the terminal, the device serving the network, and the trusted party each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
FIG. 2 is a schematic diagram illustrating an interface architecture of an efficient hierarchical server side according to an embodiment of the present application; firstly, running a script, and loading an environment, a Uniform Resource Locator (URL), a port name, an account number, request parameters, an assertion condition and a structured query statement (SQL statement); loading a configuration file, taking out a session unique identifier (SID) stored in a local file according to an account, loading an encryption template to generate encryption information, automatically generating a legal message header (header) according to an incoming parameter, after requesting an interface, judging whether the interface correctly processes the request by analyzing the content returned by a server, if so, taking out the content of a message Body (Body), connecting a corresponding database when an SQL statement is incoming, executing the SQL statement, returning a query result, processing the query result into a JSON format, checking whether a corresponding value (value) is correct by traversing a key (key), if so, passing the test, and if not, outputting a test result of the local round; and when the taken Body content is not transmitted into the SQL statement, entering a static assertion flow, judging whether the result meets the service requirement through assertion conditions, if so, passing the test, if not, failing the test, judging whether other unexecuted cases exist, and if so, reading the next case for testing. And if the login is successful, the acquired SID stores a local file in a key value pair mode, the SID stored in the local file is taken out according to an account number, and the test process is executed. When the interface is not processed correctly and the SID is not expired, the error information is extracted, and if the result is an expected result, the test is successful.
Through the interface test architecture diagram shown in fig. 2, the problem of weak script universality is solved, and through the design of shallow encapsulation, template mode and the like of data and modules, after receiving an execution command, the script can automatically generate a parameter set corresponding to the execution command without manually configuring excessive parameters, so that quick and convenient execution is realized. The problem of locally reading and writing files is solved, the key data are stored to the local, the storage format is Dictionary (Dictionary), data are read in the later period, the corresponding value (value) can be found through a key (key), the problem that an external library cannot be introduced is solved, the encrypted data are directly returned to a calling function, the problem that the data cannot be read and written in the database is solved, the specified database can be connected to obtain or update test related data, the problem that the assertion mode is too single is solved, after the interface returned data and the database query data are obtained, whether the assertion interface data are accurate or not can be rapidly and massively judged in a key-value comparison mode, meanwhile, by using the framework, an Application Program Interface (API) can be opened for other tests or open frameworks, and expansion can be carried out.
The test mode of the interface architecture diagram shown in fig. 2 is used, a clear and efficient status code processing flow is provided, which is embodied in the verification of the status code in the Header, and different processing flows are provided according to the status code returned by the interface, so as to determine whether the Body can be acquired. The specific implementation mode is realized by the following embodiments:
fig. 3 is a schematic flow chart illustrating a method for checking a status code of a test interface according to an aspect of the present application, where the method includes: step S11-step S13, wherein in step S11, the status code fed back by the called login interface is determined based on the request of the test interface calling the login interface; in step S12, verifying the feedback status code according to a preset status code to obtain a verification result; in step S13, it is determined whether to acquire a message body for verifying the test result from the request message of the test interface according to the verification result. Therefore, different verification results are obtained according to the verification of the state code, so that different logics are executed, and whether the message body in the request message can be obtained or not is judged. The method can automatically associate to an error reporting information list according to the state code of the type of the error report, and search and return corresponding specific error reporting information in the error reporting information list, wherein the specific error reporting information comprises error reasons and corresponding solving methods, so that a tester is guided to perform efficient and rapid interface test under different scenes.
Specifically, in step S11, determining a status code fed back by the called login interface based on the request of the test interface to call the login interface; here, after a legal request message is automatically generated according to the incoming parameters, the login interface is called, the data returned by the called interface is acquired, and the status code in the header (header) in the request message, for example, the status code is 1XX, 8XX, etc., is acquired from the returned data.
Specifically, in step S12, the feedback status code is verified according to a preset status code, and a verification result is obtained; and checking the fed back state code according to the preset state code, and if the preset state code is 1XX, 8XX, 4XX or other, judging which specific state code information in the fed back state code and the preset state code is matched to obtain a checking result so as to judge whether the interface is successfully called.
Specifically, in step S13, it is determined whether to acquire a message body for verifying the test result from the request message of the test interface according to the check result. Here, the preset status codes may be classified into three types: the state code representing the correct processing of the interface, the state code representing the expired SID and the state code representing the error information efficiently and clearly acquire the condition of the calling interface and determine the test result through the distributed logic for processing different state codes.
In an embodiment of the present application, before determining a status code fed back by a called login interface based on a request of a test interface calling the login interface, the method includes: step S101, obtaining a test request of the test interface; step S102, determining a login interface called by the test interface according to the test request of the test interface; step S103, determining the configuration file according to the called login interface. Here, a login interface that needs to be called by the test interface is obtained according to a test request of the test interface, if in the ticket refunding flow, "login interface-ticket purchasing interface-ticket refunding interface", the ticket refunding interface needs to call the SID of the login interface, a login interface corresponding to the obtained test request of the ticket refunding interface is determined first, and then a configuration file is obtained, and then in step S11, the configuration file corresponding to the called login interface is determined based on the request of the test interface for calling the login interface; acquiring session unique identification information corresponding to the called login interface from the local file according to the account in the configuration file; and determining a feedback state code according to the processing state of the called login interface. And acquiring a session unique identifier (SID) corresponding to the called login interface according to an account in the configuration file to identify the user, wherein the SID can be used as a legal certificate of the called login interface to ensure the safety of the server. And determining a feedback status code according to the processing status of the called login interface, such as a status code correctly processed by the interface or a status code of expired called SID or other error information.
In an embodiment of the present application, in step S13, if the verification result is that the called login interface is correctly processed, a message body for verifying the test result is obtained from the request message of the test interface. For example, the status code is 1XX, which indicates that the call is successful, and the data returned by the interface can be directly transferred to the subfunction, where the data returned by the interface is the message body in the request message, and the message body can be acquired only when the interface processes correctly.
In an embodiment of the present application, in step S13, if the validity period of the session unique identifier of the called login interface has expired, a request for logging back on the called login interface is sent. For example, when the called login interface is not correctly processed, it is necessary to determine whether the SID of the called login interface is expired, and if the status code is 8XX, it indicates that the used SID is expired, and a new temporary session identifier needs to be obtained by logging in again, specifically, the following method is used to obtain the SID:
after the request for re-login of the called login interface is sent, login parameters and encryption information are generated according to the environment where the request for re-login is located and the port name; and logging in according to the login parameters and the encryption information, and acquiring the session unique identifier of the called login interface stored in a local file. In an embodiment of the application, the environment refers to a general name of computer hardware, software, network equipment and historical data necessary for completing software testing work, and the environment may be a testing environment, a development environment or an environment of other applications.
It should be noted that the SID has a valid period, for example, a new SID is recorded at a certain time in the afternoon of the day, and the newly recorded SID can be acquired when the non-login interface is called in a day from the time, and the acquisition from the login interface does not need to be repeated. In fig. 2, parameters and encryption information for login are generated according to the environment request port, and after login is successful, since an SID which has not expired is stored locally, the SID is obtained from a local file according to an account in a configuration file for subsequent data communication.
In a specific scenario of the application, for example, in a scenario of testing a ticket purchasing interface, it is first determined whether a logged account number has a SID locally, if so, when a parameter is transmitted to the ticket purchasing interface, the SID is directly uploaded, the ticket purchasing interface determines whether the SID is legal according to the received parameter including the SID, if the SID is expired, a corresponding status code, for example, 8Xx, is directly fed back, which indicates that the locally taken SID is expired, at this time, an operation script needs to automatically log in again, updates the original SID, and then requests the ticket purchasing interface according to the updated SID.
In an embodiment of the present application, in step S13, if the verification result is that the called login interface is not correctly processed and the validity period of the session unique identifier of the called login interface is not expired, an error notification message is obtained. For example, when the called login interface is not correctly processed and the used SID is not expired, an error message may occur, the status code is 4XX or other, the called interface has an error, and no result data may be returned. Outputting specific error reporting information through an error reporting information query module, wherein the specific error reporting information may include an error uniform resource locator (url), a login of a user at another terminal, an interface parameter error, an analysis error, a coding error, a service coding error, an erroneous login check code, and the like, if the error reporting information meets an expected result, the test is passed, otherwise, the test fails, if the interface test is performed, the expected result is to return the error reporting information that the user has logged at another terminal, after the test, a status code showing error information is obtained, the specific error reporting information is obtained according to the status code, the test result is clearly obtained and compared with the expected result, if the expected result is consistent, the test is successful, and if the expected result is consistent, the error reporting information may be stored in a key value pair manner, so that specific content of the error reporting information is not obtained from an interface protocol document, the detailed contents of error reporting can be clearly and quickly obtained.
Fig. 4 is a schematic diagram illustrating a process of checking a status code in a message header in an embodiment of the present application, where first, a receiver receives returned data based on a result of an interface request, acquires the status code, and determines whether an interface is correctly processed according to the status code, and if the status code is 1XX, the interface is successfully called and correctly processed, and the interface returned data is transferred to a subfunction; if the interface is not correctly processed, whether the used SID is overdue or not is judged according to the status code, if yes, the login interface needs to be requested again, if not, whether the status is in other status is judged, if the status code is 4XX or other, the interface is called to be in error, the interface return data cannot be returned, namely, the message body (body) in the request message cannot be obtained, and at the moment, the error information query module needs to be read to obtain the specific error information. Thereby, clear and efficient verification of the state code in the Header is completed.
Fig. 5 is a schematic structural diagram illustrating an apparatus for checking a status code of a test interface according to another aspect of the present application, where the apparatus includes: the device comprises a determining device 11, a verifying device 12 and a judging device 13, wherein the determining device 11 is used for determining a status code fed back by a called login interface based on a request of calling the login interface by a test interface; the checking device 12 is used for checking the feedback state code according to a preset state code to obtain a checking result; and a judging device 13, configured to judge whether to obtain a message body used for verifying the test result from the request message of the test interface according to the check result. Therefore, different verification results are obtained according to the verification of the state codes, different logics are executed, whether a message body in the request message can be obtained or not can be automatically associated to an error reporting information list according to the state codes of the error reporting types, and corresponding specific error reporting information is searched and returned from the error reporting information list, wherein the specific error reporting information comprises error reasons and corresponding solving methods, so that a tester is guided to carry out efficient and rapid interface testing from different scenes.
FIG. 2 is a schematic diagram illustrating an interface architecture of an efficient hierarchical server side according to an embodiment of the present application; firstly, running a script, and loading an environment, a Uniform Resource Locator (URL), a port name, an account number, request parameters, an assertion condition and a structured query statement (SQL statement); loading a configuration file, taking out a session unique identifier (SID) stored in a local file according to an account, loading an encryption template to generate encryption information, automatically generating a legal message header (header) according to an incoming parameter, after requesting an interface, judging whether the interface correctly processes the request by analyzing the content returned by a server, if so, taking out the content of a message Body (Body), connecting a corresponding database when an SQL statement is incoming, executing the SQL statement, returning a query result, processing the query result into a JSON format, checking whether a corresponding value (value) is correct by traversing a key (key), if so, passing the test, and if not, outputting a test result of the local round; and when the taken Body content is not transmitted into the SQL statement, entering a static assertion flow, judging whether the result meets the service requirement through assertion conditions, if so, passing the test, if not, failing the test, judging whether other unexecuted cases exist, and if so, reading the next case for testing. And if the login is successful, the acquired SID stores a local file in a key value pair mode, the SID stored in the local file is taken out according to an account number, and the test process is executed. When the interface is not processed correctly and the SID is not expired, the error information is extracted, and if the result is an expected result, the test is successful.
Through the interface test architecture diagram shown in fig. 2, the problem of weak script universality is solved, and through the design of shallow encapsulation, template mode and the like of data and modules, after receiving an execution command, the script can automatically generate a parameter set corresponding to the execution command without manually configuring excessive parameters, so that quick and convenient execution is realized. The problem of locally reading and writing files is solved, the key data are stored to the local, the storage format is Dictionary (Dictionary), data are read in the later period, the corresponding value (value) can be found through a key (key), the problem that an external library cannot be introduced is solved, the encrypted data are directly returned to a calling function, the problem that the data cannot be read and written in the database is solved, the specified database can be connected to obtain or update test related data, the problem that the assertion mode is too single is solved, after the interface returned data and the database query data are obtained, whether the assertion interface data are accurate or not can be rapidly and massively judged in a key-value comparison mode, meanwhile, by using the framework, an Application Program Interface (API) can be opened for other tests or open frameworks, and expansion can be carried out.
The test mode of the interface architecture diagram shown in fig. 2 is used, a clear and efficient status code processing flow is provided, which is embodied in the verification of the status code in the Header, and different processing flows are provided according to the status code returned by the interface, so as to determine whether the Body can be acquired. The specific implementation manner is implemented by the device shown in fig. 5:
specifically, the determining device 11 is configured to determine, based on a request for the test interface to call the login interface, a status code fed back by the called login interface; here, after a legal request message is automatically generated according to the incoming parameters, the login interface is called, the data returned by the called interface is acquired, and the status code in the header (header) in the request message, for example, the status code is 1XX, 8XX, etc., is acquired from the returned data.
Specifically, the checking device 12 is configured to check the fed back status code according to a preset status code to obtain a checking result; and checking the fed back state code according to the preset state code, and if the preset state code is 1XX, 8XX, 4XX or other, judging which specific state code information in the fed back state code and the preset state code is matched to obtain a checking result so as to judge whether the interface is successfully called.
Specifically, the determining device 13 is configured to determine whether to obtain a message body used for verifying the test result from the request message of the test interface according to the check result. Here, the preset status codes may be classified into three types: the state code representing the correct processing of the interface, the state code representing the expired SID and the state code representing the error information efficiently and clearly acquire the condition of the calling interface and determine the test result through the distributed logic for processing different state codes.
In an embodiment of the present application, before determining a status code fed back by a called login interface based on a request of a test interface calling the login interface, the apparatus includes: an obtaining request device 101, configured to obtain a test request of the test interface; the calling device 102 is used for determining a login interface called by the test interface according to the test request of the test interface; and the query device 103 is configured to determine the configuration file according to the called login interface. Here, a login interface that needs to be called by the test interface is obtained according to a test request of the test interface, if in a ticket refunding flow, "login interface-ticket purchasing interface-ticket refunding interface", the ticket refunding interface needs to call an SID of the login interface, a login interface corresponding to the obtained test request of the ticket refunding interface is determined first, and then a configuration file is obtained, and then a determining device 11 is used for determining the configuration file corresponding to the called login interface based on the request of the test interface for calling the login interface; acquiring session unique identification information corresponding to the called login interface from the local file according to the account in the configuration file; and determining a feedback state code according to the processing state of the called login interface. And acquiring a session unique identifier (SID) corresponding to the called login interface according to an account in the configuration file to identify the user, wherein the SID can be used as a legal certificate of the called login interface to ensure the safety of the server. And determining a feedback status code according to the processing status of the called login interface, such as a status code correctly processed by the interface or a status code of expired called SID or other error information.
In an embodiment of the present application, the determining device 13 is configured to obtain a message body used for verifying the test result from the request message of the test interface if the verification result is that the called login interface is correctly processed. For example, the status code is 1XX, which indicates that the call is successful, and the data returned by the interface can be directly transferred to the subfunction, where the data returned by the interface is the message body in the request message, and the message body can be acquired only when the interface processes correctly.
In an embodiment of the present application, the determining device 13 is configured to send a request for logging back on the called login interface if the validity period of the session unique identifier of the called login interface has expired. For example, when the called login interface is not correctly processed, it is necessary to determine whether the SID of the called login interface is expired, and if the status code is 8XX, it indicates that the used SID is expired, and a new temporary session identifier needs to be obtained by logging in again, specifically, the following method is used to obtain the SID:
after the request for re-login of the called login interface is sent, login parameters and encryption information are generated according to the environment where the request for re-login is located and the port name; and logging in according to the login parameters and the encryption information, and acquiring the session unique identifier of the called login interface stored in a local file. In an embodiment of the application, the environment refers to a general name of computer hardware, software, network equipment and historical data necessary for completing software testing work, and the environment may be a testing environment, a development environment or an environment of other applications.
It should be noted that the SID has a valid period, for example, a new SID is recorded at a certain time in the afternoon of the day, and the newly recorded SID can be acquired when the non-login interface is called in a day from the time, and the acquisition from the login interface does not need to be repeated. In fig. 2, parameters and encryption information for login are generated according to the environment and the request port, and after login is successful, since an SID which has not expired is stored locally, the SID is obtained from a local file according to an account in a configuration file for subsequent data communication.
In a specific scenario of the application, for example, in a scenario of testing a ticket purchasing interface, it is first determined whether a logged account number has a SID locally, if so, when a parameter is transmitted to the ticket purchasing interface, the SID is directly uploaded, the ticket purchasing interface determines whether the SID is legal according to the received parameter including the SID, if the SID is expired, a corresponding status code, for example, 8Xx, is directly fed back, which indicates that the locally taken SID is expired, at this time, an operation script needs to automatically log in again, updates the original SID, and then requests the ticket purchasing interface according to the updated SID.
In an embodiment of the present application, the determining device 13 is configured to obtain the error report information if the verification result indicates that the called login interface is not correctly processed and the validity period of the session unique identifier of the called login interface is not expired. For example, when the called login interface is not correctly processed and the used SID is not expired, an error message may occur, the status code is 4XX or other, the called interface has an error, and no result data may be returned. The specific error reporting information is output through the error reporting information query module, wherein the specific detailed error reporting information can comprise an error uniform resource locator (url), the user logs in at other terminals, the interface parameter error, the analysis error, the coding error, the service coding error, the wrong login check code and the like, if the error reporting information accords with an expected result, the test is passed, otherwise, the test is failed, if the interface test is carried out, the expected result is the error reporting information that the user logs in at other terminals, after the test, a state code showing the error information is obtained through the state code, the specific error reporting information is obtained according to the state code, the test result is clearly obtained and compared with the expected result, and if the error reporting information is consistent, the test success is shown.
Fig. 4 is a schematic diagram illustrating a process of checking a status code in a message header in an embodiment of the present application, where first, a receiver receives returned data based on a result of an interface request, acquires the status code, and determines whether an interface is correctly processed according to the status code, and if the status code is 1XX, the interface is successfully called and correctly processed, and the interface returned data is transferred to a subfunction; if the interface is not correctly processed, whether the used SID is overdue or not is judged according to the status code, if yes, the login interface needs to be requested again, if not, whether the status is in other status is judged, if the status code is 4XX or other, the interface is called to be in error, the interface return data cannot be returned, namely, the message body (body) in the request message cannot be obtained, and at the moment, the error information query module needs to be read to obtain the specific error information. Therefore, clear and efficient verification of the state code in the Header is completed, and the error reporting information can be stored in a key value pair mode, so that the specific content of the error reporting information is not acquired from the interface protocol document any more, and the detailed error reporting content is clearly and quickly acquired.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.

Claims (14)

1. A method for status code checking of a test interface, wherein the method comprises:
determining a status code fed back by the called login interface based on a request of calling the login interface by the test interface;
checking the feedback state code according to a preset state code to obtain a checking result;
judging whether a message body used for verifying the test result is acquired from the request message of the test interface or not according to the check result;
wherein, judging whether to obtain a message body for verifying the test result from the request message of the test interface according to the check result comprises:
and if the verification result is that the validity period of the session unique identifier of the called login interface is expired, sending a request for logging in again by the called login interface.
2. The method of claim 1, wherein determining the status code of the called logon interface feedback based on a request by the test interface to call the logon interface comprises:
acquiring a test request of the test interface;
determining a login interface called by the test interface according to the test request of the test interface;
and determining a configuration file according to the called login interface.
3. The method of claim 2, wherein determining the status code of the called logon interface feedback based on the test interface's request to call the logon interface comprises:
determining a configuration file corresponding to the called login interface based on a request of calling the login interface by the test interface;
acquiring session unique identification information corresponding to the called login interface from a local file according to the account in the configuration file;
and determining a feedback state code according to the processing state of the called login interface.
4. The method of claim 1, wherein determining whether to obtain a message body for verifying a test result from a request message of the test interface according to the check result comprises:
and if the verification result is that the called login interface is correctly processed, acquiring a message body for verifying the test result from the request message of the test interface.
5. The method of claim 1, wherein sending the request for the called login interface to re-login comprises:
generating login parameters and encryption information according to the environment where the re-login request is located and the port name;
and logging in according to the login parameters and the encryption information, and acquiring the session unique identifier of the called login interface stored in a local file.
6. The method of claim 1, wherein determining whether to obtain a message body for verifying a test result from a request message of the test interface according to the check result comprises:
and if the verification result is that the called login interface is not processed correctly and the validity period of the session unique identifier of the called login interface is not expired, acquiring error reporting information.
7. The method of claim 6, wherein obtaining the error information comprises:
and judging whether the test interface is tested successfully or not according to the error reporting information.
8. An apparatus for status code verification of a test interface, wherein the apparatus comprises:
the determining device is used for determining the state code fed back by the called login interface based on the request of the test interface for calling the login interface;
the checking device is used for checking the feedback state code according to a preset state code to obtain a checking result;
the judging device is used for acquiring a message body used for verifying the test result from the request message of the test interface according to the verification result;
wherein the judging means is configured to:
and if the verification result is that the validity period of the session unique identifier of the called login interface is expired, sending a request for logging in again by the called login interface.
9. The apparatus of claim 8, wherein the apparatus comprises:
the acquisition request device is used for acquiring the test request of the test interface;
the calling device is used for determining a login interface called by the test interface according to the test request of the test interface;
and the query device is used for determining the configuration file according to the called login interface.
10. The apparatus of claim 9, wherein the determining means is configured to:
determining a configuration file corresponding to the called login interface based on a request of calling the login interface by the test interface;
acquiring session unique identification information corresponding to the called login interface from a local file according to the account in the configuration file;
and determining a feedback state code according to the processing state of the called login interface.
11. The apparatus of claim 8, wherein the determining means is configured to:
and if the verification result is that the called login interface is correctly processed, acquiring a message body for verifying the test result from the request message of the test interface.
12. The apparatus of claim 8, wherein the determining means is configured to:
generating login parameters and encryption information according to the environment where the re-login request is located and the port name;
and logging in according to the login parameters and the encryption information, and acquiring the session unique identifier of the called login interface stored in a local file.
13. The apparatus of claim 8, wherein the determining means is configured to:
and the error reporting device is used for acquiring error reporting information if the verification result is that the called login interface is not processed correctly and the validity period of the session unique identifier of the called login interface is not expired.
14. The apparatus of claim 13, wherein the determining means is configured to:
and judging whether the test interface is tested successfully or not according to the error reporting information.
CN201710253945.8A 2017-04-18 2017-04-18 Method and equipment for checking state code of test interface Active CN107122258B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710253945.8A CN107122258B (en) 2017-04-18 2017-04-18 Method and equipment for checking state code of test interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710253945.8A CN107122258B (en) 2017-04-18 2017-04-18 Method and equipment for checking state code of test interface

Publications (2)

Publication Number Publication Date
CN107122258A CN107122258A (en) 2017-09-01
CN107122258B true CN107122258B (en) 2020-06-02

Family

ID=59724819

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710253945.8A Active CN107122258B (en) 2017-04-18 2017-04-18 Method and equipment for checking state code of test interface

Country Status (1)

Country Link
CN (1) CN107122258B (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107995160A (en) * 2017-10-26 2018-05-04 常熟市第人民医院 A kind of JSON data packet encrypting and decrypting methods based on high in the clouds management and control
CN107992417B (en) * 2017-11-29 2019-01-29 平安科技(深圳)有限公司 Test method, device and equipment, readable storage medium storing program for executing based on storing process
CN107948744B (en) * 2017-12-13 2021-11-09 深圳市雷鸟网络传媒有限公司 Interface detection method, interface detection device, and computer-readable storage medium
CN108108305A (en) * 2018-01-02 2018-06-01 中国银行股份有限公司 A kind of environment availability testing method and system
CN108650149B (en) * 2018-04-24 2021-10-01 平安科技(深圳)有限公司 Server testing method, device, equipment and computer readable storage medium
CN110740071B (en) * 2018-07-18 2021-07-13 优信拍(北京)信息科技有限公司 Method, device and system for monitoring network interface
CN109446068B (en) * 2018-09-26 2024-04-05 平安健康保险股份有限公司 Interface test method, device, computer equipment and storage medium
CN109446093B (en) * 2018-11-05 2022-02-22 郑州云海信息技术有限公司 Method and device for testing expansion platform interface
CN110457228B (en) * 2019-08-22 2022-12-20 携程计算机技术(上海)有限公司 Method and system for comparing interface return messages
CN110798376A (en) * 2019-10-09 2020-02-14 苏宁云计算有限公司 Interface testing method and device, computer equipment and storage medium
CN112749384A (en) * 2019-10-30 2021-05-04 盈甲医疗科技(北京)有限公司 Equipment access method and encryption interface circuit thereof
CN112433933A (en) * 2020-04-09 2021-03-02 上海哔哩哔哩科技有限公司 Method and equipment for automatically testing interface
CN111552698B (en) * 2020-04-21 2023-06-06 重庆富民银行股份有限公司 SQL version control system and method for solving environmental difference
CN112260855B (en) * 2020-09-22 2023-04-18 北京安博通科技股份有限公司 Method, equipment and storage medium for configuring functional module of network equipment
CN112260997B (en) * 2020-09-23 2023-05-26 曙光信息产业(北京)有限公司 Data access method, device, computer equipment and storage medium
CN113676509A (en) * 2021-07-06 2021-11-19 北京思特奇信息技术股份有限公司 Active detection method and system for health state of HTTP (hyper text transport protocol) interface

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981947A (en) * 2011-09-07 2013-03-20 阿里巴巴集团控股有限公司 Data preparation method in test and system provided with the same
CN104935568A (en) * 2015-04-20 2015-09-23 成都康赛信息技术有限公司 Interface authentication signature method facing cloud platform
CN105450461A (en) * 2014-06-05 2016-03-30 阿里巴巴集团控股有限公司 Shunting method and network equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9122848B2 (en) * 2008-06-18 2015-09-01 International Business Machines Corporation Authentication of user interface elements in a web 2.0 environment
US9117027B2 (en) * 2012-09-03 2015-08-25 Tata Consultancy Services Limited Method and system for compliance testing in a cloud storage environment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981947A (en) * 2011-09-07 2013-03-20 阿里巴巴集团控股有限公司 Data preparation method in test and system provided with the same
CN105450461A (en) * 2014-06-05 2016-03-30 阿里巴巴集团控股有限公司 Shunting method and network equipment
CN104935568A (en) * 2015-04-20 2015-09-23 成都康赛信息技术有限公司 Interface authentication signature method facing cloud platform

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
xushizhao.接口自动化测试框架.《https://testerhome.com/topics/3572》.2015,第12-13页. *
如何将A请求中的responseBody中的参数值传入到下一个请求;丹丹;《https://testerhome.com/topics/7614》;20170301;第1-4页 *
接口自动化测试框架;xushizhao;《https://testerhome.com/topics/3572》;20151106;第12-13页 *

Also Published As

Publication number Publication date
CN107122258A (en) 2017-09-01

Similar Documents

Publication Publication Date Title
CN107122258B (en) Method and equipment for checking state code of test interface
CN107122297B (en) Method and equipment for generating request message of test interface
CN107122296B (en) Method and apparatus for data assertion for test interface
CN107092535B (en) Method and apparatus for data storage of test interface
CN111897724B (en) Automatic testing method and device suitable for cloud platform
CN107436844B (en) Method and device for generating interface use case aggregate
CN108628748B (en) Automatic test management method and automatic test management system
CN111818035B (en) Permission verification method and device based on API gateway
CN110570293A (en) method, device, server and storage medium for reimbursing collected invoices
CN110609785A (en) Software interface testing method and device
CN112241362A (en) Test method, test device, server and storage medium
CN112131611B (en) Data correctness verification method, device, equipment, system and storage medium
CN112948195B (en) Interface testing method, device, electronic equipment and storage medium
CN112148574B (en) Performance data acquisition method, computer equipment and storage medium
CN110532186B (en) Method, device, electronic equipment and storage medium for testing by using verification code
CN110618943B (en) Security service test method and device, electronic equipment and readable storage medium
CN108135000B (en) Authentication method and equipment
CN112988589A (en) Interface testing method, device and system
CN111651356A (en) Application program testing method, device and system
CN111026631A (en) Automatic interface detection method and device and server
CN112433933A (en) Method and equipment for automatically testing interface
CN111371650B (en) Flow forwarding-based quasi-production equipment testing method and system
CN112131091B (en) Test method and device and electronic equipment
CN114048145A (en) Transaction checking test method and device, electronic equipment and storage medium
CN117891715A (en) Interface testing method and device, electronic equipment and storage medium

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
GR01 Patent grant