CN112699034A - Virtual login user construction method, device, equipment and storage medium - Google Patents

Virtual login user construction method, device, equipment and storage medium Download PDF

Info

Publication number
CN112699034A
CN112699034A CN202011612007.0A CN202011612007A CN112699034A CN 112699034 A CN112699034 A CN 112699034A CN 202011612007 A CN202011612007 A CN 202011612007A CN 112699034 A CN112699034 A CN 112699034A
Authority
CN
China
Prior art keywords
virtual
virtual user
identification information
preset
service
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.)
Pending
Application number
CN202011612007.0A
Other languages
Chinese (zh)
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.)
Bigo Technology Singapore Pte Ltd
Original Assignee
Bigo Technology Singapore Pte 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 Bigo Technology Singapore Pte Ltd filed Critical Bigo Technology Singapore Pte Ltd
Priority to CN202011612007.0A priority Critical patent/CN112699034A/en
Publication of CN112699034A publication Critical patent/CN112699034A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Abstract

The embodiment of the invention discloses a method, a device, equipment and a storage medium for constructing a virtual login user. Wherein, the method comprises the following steps: receiving a first service request sent by a client, reading virtual user identification information from a virtual user configuration file when a preset request processing component detects that a current operating environment is a development environment and a virtual login user is not detected, storing the virtual user identification information into a thread memory space through the preset request processing component, and obtaining the virtual user identification information from the thread memory space when a service processes the first service request. The technical scheme provided by the embodiment of the invention can effectively solve the problem of user information loss caused by closing login authentication operation in development environment joint debugging test, has very small invasion to a service system, does not need to perform pre-solidification compiling on the user information, and can improve the flexibility of the test process.

Description

Virtual login user construction method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a method, a device, equipment and a storage medium for constructing a virtual login user.
Background
In order to facilitate management of a service system, a user is usually required to log in by using a self account number, which is convenient for recording an execution object of each service operation.
In the development process of a service system requiring login authentication, a front-end and back-end joint debugging test is generally performed in a development environment, and the login authentication operation can be closed in order to simplify the authentication operation of calling a back-end interface by a front end, but this may cause failure in acquiring user information by the back-end operation when a client service request is received, and the client service request cannot be normally processed. In order to solve the problem, in the existing scheme, virtual user information is written in a code for directly reading and using a service code, that is, a virtual login user is constructed, however, the processing mode needs to modify many places in the code, the invasiveness of the whole service system is large, the user information is solidified, if a test requirement for switching other users exists, the codes with the user information need to be modified one by one, and the codes can take effect after the service is restarted, thereby seriously affecting the test efficiency.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a storage medium for constructing a virtual login user, which can optimize a construction scheme of the virtual login user in the existing development environment.
In a first aspect, an embodiment of the present invention provides a method for constructing a virtual login user, where the method is applied to a server in a service system, and the method includes:
receiving a first service request sent by a client;
when the current operating environment is detected to be a development environment through the preset request processing component and a virtual login user is not detected, reading virtual user identification information from a virtual user configuration file;
and storing the virtual user identification information into a thread memory space through the preset request processing component, so that a service can acquire the virtual user identification information from the thread memory space when processing the first service request.
In a second aspect, an embodiment of the present invention provides a virtual login user constructing apparatus, configured at a server in a service system, where the apparatus includes:
the first service request receiving module is used for receiving a first service request sent by a client;
the virtual user identification information acquisition module is used for reading virtual user identification information from the virtual user configuration file when the current operating environment is detected to be a development environment through the preset request processing component and a virtual login user is not detected;
and the virtual user identification information storing module is used for storing the virtual user identification information into a thread memory space through the preset request processing component, so that the service can acquire the virtual user identification information from the thread memory space when processing the first service request.
In a third aspect, an embodiment of the present invention provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the virtual login user construction method provided in the embodiment of the present invention when executing the computer program.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the virtual login user construction method provided in the embodiment of the present invention.
According to the virtual login user construction scheme provided by the embodiment of the invention, after a service end in a service system receives a first service request sent by a client, a preset request processing component detects that a current operating environment is a development environment and a virtual login user is not detected, virtual user identification information is read from a virtual user configuration file and stored in a thread memory space corresponding to the first service request, so that the service can acquire the virtual user identification information from the thread memory space when processing the first service request. By adopting the technical scheme, the virtual user identification information is stored in the form of the configuration file, after a client service request is received in a development environment and before the request reaches the service, the virtual user identification information is obtained from the configuration file by the preset request processing component and is added into the thread memory space corresponding to the request, so that when the service request of the client is processed by the service, the virtual user identification information can be successfully obtained from the corresponding thread memory space, which is equivalent to the virtual login user constructed in a service system, the service can perform related service processing based on the virtual user identification information of the virtual login user, the problem of user information loss caused by closing login authentication operation in the development environment joint debugging test is effectively solved, and the construction process of the virtual login user is completed by the preset request processing component, only the logic for acquiring the user identification information needs to be modified, the invasion to a service system is very small, the user information does not need to be solidified and compiled in advance, and the flexibility of the test process can be improved.
Drawings
Fig. 1 is a schematic flowchart of a method for constructing a virtual login user according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a method for constructing a virtual login user according to another embodiment of the present invention;
fig. 3 is a schematic flowchart of another virtual login user construction method according to an embodiment of the present invention;
fig. 4 is a block diagram illustrating a structure of a virtual login user constructing apparatus according to an embodiment of the present invention;
fig. 5 is a block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures. In addition, the embodiments and features of the embodiments in the present invention may be combined with each other without conflict.
Fig. 1 is a schematic flowchart of a virtual login user constructing method according to an embodiment of the present invention, where the method is applied to a server in a business system, and may be executed by a virtual login user constructing apparatus, where the apparatus may be implemented by software and/or hardware, and may generally be integrated in a computer device such as a server. The method provided by the embodiment of the invention can be suitable for constructing the application scene of the virtual login user under the condition that the user login authentication operation needs to be closed when the joint debugging test is carried out in the development environment of the service system. As shown in fig. 1, the method includes:
step 101, receiving a first service request sent by a client.
In this step, the first service request may be any service request sent by any client to a server in the service system, and is not limited specifically. The specific form of the first service request may be determined by a communication Protocol between the client and the server, for example, the first service request may be a HyperText Transfer Protocol (HTTP) request.
And 102, reading virtual user identification information from a virtual user configuration file when the current operating environment is detected to be a development environment through a preset request processing component and a virtual login user is not detected.
For example, the preset request processing component may be a component written based on a request processing object, and the request processing object may be understood as an object capable of processing a client service request entering the system before the client service request reaches the service processing logic. For example, the preset request processing component may be implemented based on a Filter (Filter) in service connector (servlet) technology. A filter is a request processing object commonly used in the service connector technology, and the object can process each http request entering the system before reaching the service processing logic (such as adding a request header or modifying a request parameter, etc.), and theoretically, the filter can perform any custom processing on the http request. servlets are Java servlets, which are called servlets or service connectors for short, are server-side programs written in Java, have platform and protocol independent characteristics, and have the main function of interactively browsing and generating data to generate dynamic Web content. Of course, the preset request processing component can also be implemented based on other types of request processing objects, and can be selected according to actual situations.
For example, the preset request processing component may provide a call interface to the outside, and in this step, the call interface may be used to call the preset request processing component, so as to implement subsequent related operations through the preset request processing component.
The operating environment in the server may include a development environment, a production environment, a test environment, a grayscale environment, and the like. In the development environment, joint debugging testing can be performed, and in the embodiment of the invention, joint debugging testing is mainly performed in the development environment, so that the development environment in the embodiment of the invention can also be called a joint debugging environment or a dev joint debugging environment, and a general external user (which can also be understood as a common user) cannot access the dev environment, so that the development environment is an environment used by developers. In the embodiment of the present invention, after receiving the first service request, it may be determined whether the current operating environment is a development environment, and a specific determination manner is not limited, for example, the determination may be performed by querying operating environment configuration information and the like. When the current operating environment is determined to be the development environment, whether the simulated login user exists is continuously judged, specifically, whether the relevant user information of the simulated login user exists in the system or not, such as a user name and the like, is inquired. Upon determining that a virtual login user is not detected, then a simulated login user (which may be referred to as a mock user) needs to be constructed.
For example, the server may store a virtual user profile, and the virtual user profile may include virtual user identification information, such as a user name, a user code number, or a user id. Other information associated with the virtual user identification information, such as user permission information, may also be included in the virtual user profile. It should be noted that the virtual meaning may be understood that the user does not really log in the server by entering a login authentication manner such as an account name and a password, and therefore, the virtual user may be a real user or a user defined by the user.
Step 103, storing the virtual user identifier information in a thread memory space through the preset request processing component, so that the service can obtain the virtual user identifier information from the thread memory space when processing the first service request.
For the case that the real user successfully logs in, user information such as a user name and the like can be generally obtained from a client service request, for example, from a request header. However, after the user login authentication operation is deleted, there is no situation that the real user successfully logs in, so that the user information cannot be obtained from the client service request when the service (which may be understood as a service implemented by the service logic code, and may also be understood as a service code here) processes the client service request. In the embodiment of the present invention, the execution logic of the preset request processing component and the implementation of the service are both in one thread, which can also be understood as a thread for processing the first service request, and before the first service request reaches the service, the virtual user identification information is stored in the thread memory space through the preset request processing component, so that when the service processes the first service request, the virtual user identification information can be directly obtained from the thread memory space, and further the identity of the virtual user is known, and the first service request can be successfully processed.
In the method for constructing the virtual login user provided in the embodiment of the invention, after receiving a first service request sent by a client, a server in a service system detects that a current operating environment is a development environment through a preset request processing component and a virtual login user is not detected, virtual user identification information is read from a virtual user configuration file and stored in a thread memory space corresponding to the first service request, so that the service can acquire the virtual user identification information from the thread memory space when processing the first service request. By adopting the technical scheme, the virtual user identification information is stored in the form of the configuration file, after a client service request is received in a development environment and before the request reaches the service, the virtual user identification information is obtained from the configuration file by the preset request processing component and is added into the thread memory space corresponding to the request, so that when the service request of the client is processed by the service, the virtual user identification information can be successfully obtained from the corresponding thread memory space, which is equivalent to the virtual login user constructed in a service system, the service can perform related service processing based on the virtual user identification information of the virtual login user, the problem of user information loss caused by closing login authentication operation in the development environment joint debugging test is effectively solved, and the construction process of the virtual login user is completed by the preset request processing component, only the logic for acquiring the user identification information needs to be modified, the invasion to a service system is very small, the user information does not need to be solidified and compiled in advance, and the flexibility of the test process can be improved.
In some embodiments, reading, by the preset request processing component, virtual user identification information from a virtual user profile includes: and reading the virtual user identification information and the virtual user authority information from the virtual user configuration file through the preset request processing component. After the reading of the virtual user identification information and the virtual user permission information from the virtual user configuration file by the preset request processing component, the method further includes: constructing a virtual authentication object meeting the requirement of an authentication framework of the service system according to the virtual user authority information through the preset request processing component; and storing the virtual authentication object into a thread memory space through the preset request processing component, so that a service can acquire virtual user authority information contained in the virtual authentication object from the thread memory space when processing the first service request. The method has the advantages that the service can be ensured to successfully acquire the user identification information and the user right information, and then some operations needing authentication can be tested, so that the service types covered by the joint debugging test are more extensive and comprehensive, the test effect is improved, and the product performance is ensured.
Illustratively, the virtual user authority information may be represented as a virtual user role, and may also be represented as an authority item specifically owned by the virtual user. In a service system, the same user role generally has multiple rights, that is, the virtual user role and the rights items specifically owned by the virtual user can be in a one-to-many mapping relationship, the one-to-many relationship (which may be referred to as a role rights mapping relationship) can be maintained in the service system, and under the condition that the virtual user role is known, the corresponding rights items can be determined by inquiring the role rights mapping relationship.
For example, in a service system that requires user login authentication, an authentication Framework (also referred to as a Security management Framework or a Security Framework, etc.) is generally used for performing rights management, and a specific type of the authentication Framework in the embodiment of the present invention is not limited, for example, the authentication Framework may be a Spring Security Framework, a Spring book Framework, or a Spring Framework. When the user successfully logs in and authenticates, the authentication framework generates an authentication object which is used for storing the authority information of the current login user, and when a client service request received by the system corresponds to an operation needing authentication, the service generally obtains the authority information of the current login user by reading the authentication object, so as to verify whether the current login user has the authority for performing the operation. Under the condition that the joint debugging test closes the user login authentication operation, the authentication framework cannot generate an authentication object, and the business service cannot acquire the authority information, so that the test of the business service related to the authority control cannot be carried out. In the embodiment of the present invention, the virtual user permission information is obtained from the virtual user configuration file, and the virtual authentication object satisfying the authentication framework requirement adopted by the service system is constructed and stored in the thread memory space corresponding to the first service request.
In some embodiments, besides the user right information, the authentication object may further include other related information of the user, such as name, occupation, gender, mobile phone number, department to which the user belongs, and the like, and may also include user identification information, which may be collectively referred to as user detail information. The virtual user configuration file can store virtual user detail information, the virtual user detail information can be filled into a user-defined user detail object, and then the user detail object is packaged into a virtual authentication object meeting the requirements of an authentication framework.
In some embodiments, the storing the virtual user identifier information into a thread memory space through the preset request processing component includes: and injecting the virtual user identification information into a first preset thread context variable by using a thread local storage (threaded local) technology through the preset request processing component. The thread local storage variable is a thread local variable in JAVA, and all code segments in the same thread can acquire the value of the thread local variable by a get (acquiring) method of the thread local storage variable. The advantage of this arrangement is that the virtual user identification information can be conveniently stored and obtained by using the thread local storage technology. For example, the first predetermined thread context variable may be a custom name, which may be named as UserName, for example, as it is used to store user identification information. Illustratively, the virtual user identification information may be injected into a first preset thread context variable corresponding to the first service request by using a set (set) method in the thread local storage technology.
In some embodiments, the storing the virtual authentication object in a thread memory space by the predetermined request processing component includes: and injecting the virtual authentication object into a second preset thread context variable by using a thread local storage technology through the preset request processing assembly, wherein the second preset thread context variable corresponds to the authentication frame. Similarly, the storage and acquisition of the virtual authentication object can be conveniently realized by utilizing the thread local storage technology. The second preset thread context variable corresponds to the authentication framework, which may be understood as the thread context variable originally used for storing the authentication object in the authentication framework.
In some embodiments, the not detecting a virtual login user comprises: and detecting that the value of the first preset thread context variable or the second preset thread context variable is null. This has the advantage that it can be determined quickly and accurately whether a virtual login user is present.
In some embodiments, after the storing the virtual authentication object in the thread memory space by the preset request processing component, the method further includes: and acquiring corresponding virtual user identification information by using an acquisition method corresponding to the first preset thread context variable in the thread local storage technology through a service, and processing the first service request based on the acquired virtual user identification information. For example, any user in the service system may access the public document, and the first service request may be a public document access request, at this time, when the corresponding service processes the first service request, the virtual user identification information may be obtained, the user initiating the first service request is recorded as the virtual user, and related operations such as returning the content of the public document are executed.
In some embodiments, after the storing the virtual authentication object in the thread memory space by the preset request processing component, the method further includes: and acquiring corresponding virtual user identification information by using an acquisition method corresponding to the first preset thread context variable in the thread local storage technology through a service, acquiring corresponding virtual user permission information by using an acquisition method corresponding to the second preset thread context variable in the thread local storage technology, and processing the first service request based on the acquired virtual user identification information and virtual user permission information. For example, for a certain confidential document, only a user with a designated authority in the service system may access the confidential document, the first service request may be the confidential document access request, at this time, when the corresponding service processes the first service request, the virtual user identification information and the virtual user authority information may be obtained, whether the virtual user has the corresponding authority or not is determined, if not, the confidential document content is rejected to be returned, if yes, the relevant operation such as returning the confidential document content may be performed, and in addition, the user initiating the first service request may also be recorded as the virtual user.
In some embodiments, after receiving the first service request sent by the client, the method further includes: when the preset request processing component detects that the current operating environment is not a development environment, acquiring real user identification information corresponding to the first service request; and storing the real user identification information into a thread memory space through the preset request processing component, so that a service can acquire the real user identification information from the thread memory space when processing the first service request. The method has the advantages that the business service does not need to be processed in a targeted manner aiming at different operating environments by modifying the acquisition logic of the real user identification information of the normally logged-in real user, but the business service is uniformly acquired in the thread memory space, so that the business service side realizes the request processing without perception, the test process is closer to the real use process, and the test accuracy is improved.
For example, storing the real user identifier information into a thread memory space through the preset request processing component may specifically include: and storing the real user identification information into a first preset thread context variable by the preset request processing component by utilizing a thread local storage technology. Correspondingly, the corresponding real user identification information can be acquired by the business service by using the acquiring method corresponding to the first preset thread context variable in the thread local storage technology, and the first business request is processed based on the acquired real user identification information.
Fig. 2 is a schematic flowchart of a method for constructing a virtual login user according to another embodiment of the present invention, and as shown in fig. 2, the method may include:
step 201, receiving a first service request sent by a client.
Step 202, detecting whether the current operating environment is a development environment or not through a preset request processing component, and if so, executing step 203; otherwise, step 208 is performed.
Illustratively, the preset request processing component is based on a filter implementation in service connector technology and may exist in the form of a Jar package.
Step 203, judging whether the first preset thread context variable is empty, if so, executing step 204; otherwise, step 209 is performed.
For example, if the historical service request is not empty, it indicates that the virtual login user has been constructed when the historical service request is received, and the process may directly jump to step 209 to process the first service request by the service. It should be noted that, for the same login user, multiple requests sent to the client are processed by the same thread at the server, and therefore, the service code segment corresponding to the subsequent client service request can obtain relevant information from the thread memory space corresponding to the thread, that is, after the virtual login user is constructed, when the server receives the request sent by the client, the information such as the user name of the virtual login user can be obtained.
And step 204, reading the virtual user identification information and the virtual user authority information from the virtual user configuration file through a preset request processing component.
Step 205, injecting the virtual user identification information into a first preset thread context variable by using a thread local storage technology through a preset request processing component.
And step 206, constructing a virtual authentication object meeting the requirement of the authentication framework of the service system according to the virtual user authority information through a preset request processing component.
Step 207, injecting the virtual authentication object into a second preset thread context variable by the preset request processing component by using the thread local storage technology, and executing step 209.
And the second preset thread context variable is a thread context variable which is specified in the authentication framework and used for storing an authentication object of a real login user.
And step 208, injecting the real user identification information into the first preset thread context variable through the preset request processing component.
For example, in this step, it may also be determined whether the first preset thread context variable is empty, and if the first preset thread context variable is empty, the real user identification information is stored in the first preset thread context variable corresponding to the first service request; if not, it indicates that the real user identification information has been injected into the first preset thread context variable when the historical client service request is received, and the subsequent steps can be continuously executed.
Step 209, acquiring corresponding user identification information by using an acquisition method corresponding to a first preset thread context variable in the thread local storage technology through the service, acquiring corresponding user permission information by using an acquisition method corresponding to a second preset thread context variable in the thread local storage technology, and processing the first service request based on the acquired user identification information and user permission information.
It should be noted that, for an operating environment other than the development environment, such as a production environment, when the real user successfully logs in, the authentication object is automatically generated by the authentication framework and is injected into the second preset thread context variable. After the business service reads the value of the first preset thread context variable and the value of the second preset thread context variable, the business service does not distinguish whether the business service is a virtual user or a real user, and the adopted business processing logics can be the same.
According to the virtual login user construction method provided by the embodiment of the invention, user information specified by a user is automatically injected into all operating environments for developers based on a thread local storage technology and a filter technology, the problem of user information loss under the condition of no login during development environment joint debugging test is solved, most of logic for acquiring the user information is realized in a component compiled based on the filter, theoretically, only one Jar packet needs to be introduced, and a small amount of change codes (such as acquisition positions and other related codes when business services acquire the user information) can realize the injection function of any user information, and the invasion to the original system is small.
In some embodiments, it may further include: receiving a virtual user switching request sent by a client; and when the preset request processing component detects that the current operating environment is a development environment, updating the virtual user configuration file according to the target virtual user identification information contained in the virtual user switching request. The method has the advantages that developers or testers can utilize the client to send virtual user switching requests to update the virtual user configuration files, further the switching of virtual login users can be achieved, and the simulation test of whether users with different roles have abnormity when using a certain function is facilitated.
In some embodiments, the updating the virtual user profile according to the target virtual user identification information included in the virtual user switching request includes: inquiring corresponding target virtual user authority information from a preset mapping relation table according to target virtual user identification information contained in the virtual user switching request, wherein the preset mapping relation table contains the mapping relation between the user identification information and the user authority information; and updating the virtual user configuration file according to the target virtual user identification information and the target virtual user authority information. The method has the advantages that the preset mapping relation table can be configured in advance, the data volume contained in the virtual user switching request is reduced, information loss in the request sending process is avoided, and the switching efficiency and the success rate are improved.
In some embodiments, after the updating the virtual user profile according to the target virtual user identification information included in the virtual user setting request, the method further includes: and re-executing the related operation of reading the virtual user configuration file through the preset request processing component. The method has the advantages that after the configuration file of the virtual user is updated, the virtual login user can be automatically reconstructed, and in the switching process, the service in the service system does not need to be restarted, so that the testing efficiency can be further improved. The re-executing, by the preset request processing component, the operation related to reading the virtual user profile may specifically include: and reading the virtual user identification information from the virtual user configuration file (the updated virtual user configuration file) through the preset request processing component, and storing the virtual user identification information into a thread memory space through the preset request processing component. The related operations described above may also be included, and are not described in detail here.
Fig. 3 is a schematic flowchart of another virtual login user building method provided in the embodiment of the present invention, and as shown in fig. 3, the method may include:
step 301, receiving a client service request.
Step 302, detecting that the current operating environment is a development environment through a preset filter component, judging whether a first preset thread context variable is empty, and if so, executing step 303; otherwise, go to step 307.
Step 303, reading the virtual user name and the virtual user detail information from the virtual user configuration file through a preset filter component.
The details of the virtual user may include the authority of the virtual user and other related information such as the name of the virtual user.
Step 304, the virtual username is injected into the first thread context variable by the preset filter component using thread local storage techniques.
Wherein, the first thread context variable can be marked as Username.
And 305, constructing a virtual authentication object meeting the requirements of the Spriy security framework according to the details of the virtual user through a preset filter component.
For example, a user-defined object, such as a named UserDetail object, may be preset in the preset filter component, the virtual user detail information is filled into the UserDetail object, and the UserDetail object is encapsulated into a virtual authentication object, such as a named mock authentication object.
Step 306, injecting the virtual authentication object into the second thread context variable by the preset filter component using the thread local storage technique.
Wherein, the second thread context variable can be recorded as spring security.
Step 307, acquiring a virtual user name by using an acquisition method corresponding to the first thread context variable in the thread local storage technology through the service, acquiring required virtual user detail information by using an acquisition method corresponding to the second thread context variable, and processing the received client service request based on the acquired virtual user name and the acquired virtual user detail information.
It should be noted that, after the virtual login user is switched, and when a client service request is received, the virtual user name and the virtual user detail information acquired in this step are user information corresponding to the switched virtual login user.
Step 308, judging whether a virtual user switching request sent by the client is received, if so, executing step 309; otherwise, return to execute step 301.
For example, the interface of the user switching user may be packaged in the preset filter component, and may be a Rest interface, and the virtual user switching request may be a Rest request. When the client sends a virtual user switching request, a target virtual user name parameter value can be transmitted.
Step 309, when detecting that the current operating environment is a development environment, querying corresponding target virtual user detail information from a preset mapping relation table according to the target virtual user name, and updating the virtual user configuration file according to the target virtual user name and the target virtual user detail information.
Illustratively, after the step, step 310 may be immediately executed, so that the first thread context variable and the second thread context variable may be updated in time, and when a client service request is subsequently received, processing may be quickly performed based on new virtual login user information, thereby improving testing efficiency.
Optionally, after this step, step 310 may not be executed immediately, and the first thread context variable and the second thread context variable may be cleared, and after a new client request is received, the subsequent steps may be performed. For example, after step 309 is executed, the first thread context variable and the second thread context variable may be cleared, and then step 301 is executed again, where the virtual user profile is updated and the first thread context variable is cleared, and step 303 is executed again, where the virtual user name and the virtual user details information are read from the new virtual user profile.
Step 310, reading the virtual user name and the virtual user detail information from the new virtual user configuration file through a preset filter component.
Step 311, injecting the newly read virtual username into the first thread context variable through the preset filter component.
And step 312, constructing a virtual authentication object meeting the requirements of the Spiri security framework according to the newly read virtual user detail information through a preset filter component.
Step 313, injecting a new virtual authentication object into the second thread context variable by using the thread local storage technology through the preset filter component, and returning to execute step 301.
By adopting the technical scheme, the embodiment of the invention provides a method with extremely low invasiveness for injecting the mock user (virtual login user) under the login-free condition, all authority information of the mock user can be real and complete, so that the method can be used for simulating the login of users with different roles for testing, can realize seamless switching of login users without restarting services, and greatly improves the development and testing efficiency.
Fig. 4 is a block diagram of a virtual login user constructing apparatus according to an embodiment of the present invention, where the apparatus may be implemented by software and/or hardware, and may be generally integrated in a computer device, and may be configured to construct a virtual login user by executing a virtual login user constructing method. As shown in fig. 4, the apparatus includes:
a first service request receiving module 401, configured to receive a first service request sent by a client;
a virtual user identification information obtaining module 402, configured to read virtual user identification information from a virtual user configuration file when a preset request processing component detects that a current operating environment is a development environment and a virtual login user is not detected;
a virtual user identifier information storing module 403, configured to store the virtual user identifier information in a thread memory space through the preset request processing component, so that a service obtains the virtual user identifier information from the thread memory space when processing the first service request.
In the virtual login user constructing device provided in the embodiment of the present invention, after receiving a first service request sent by a client, a service end in a service system detects that a current operating environment is a development environment through a preset request processing component, and when a virtual login user is not detected, reads virtual user identification information from a virtual user configuration file, stores the virtual user identification information in a thread memory space corresponding to the first service request, and provides a service for acquiring the virtual user identification information from the thread memory space when processing the first service request. By adopting the technical scheme, the virtual user identification information is stored in the form of the configuration file, after a client service request is received in a development environment and before the request reaches the service, the virtual user identification information is obtained from the configuration file by the preset request processing component and is added into the thread memory space corresponding to the request, so that when the service request of the client is processed by the service, the virtual user identification information can be successfully obtained from the corresponding thread memory space, which is equivalent to the virtual login user constructed in a service system, the service can perform related service processing based on the virtual user identification information of the virtual login user, the problem of user information loss caused by closing login authentication operation in the development environment joint debugging test is effectively solved, and the construction process of the virtual login user is completed by the preset request processing component, only the logic for acquiring the user identification information needs to be modified, the invasion to a service system is very small, the user information does not need to be solidified and compiled in advance, and the flexibility of the test process can be improved.
The embodiment of the invention provides computer equipment, wherein the virtual login user construction device provided by the embodiment of the invention can be integrated in the computer equipment. Fig. 5 is a block diagram of a computer device according to an embodiment of the present invention. The computer device 500 comprises a memory 501, a processor 502 and a computer program stored on the memory 501 and executable on the processor 502, wherein the processor 502 implements the virtual login user construction method provided by the embodiment of the invention when executing the computer program.
Embodiments of the present invention further provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the virtual login user construction method provided in the embodiments of the present invention.
The virtual login user construction device, the equipment and the storage medium provided in the above embodiments can execute the virtual login user construction method provided in any embodiment of the present invention, and have corresponding functional modules and beneficial effects for executing the method. For technical details that are not described in detail in the above embodiments, reference may be made to a virtual login user construction method provided in any embodiment of the present invention.
Note that the above is only a preferred embodiment of the present invention. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in more detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the claims.

Claims (10)

1. A virtual login user construction method is applied to a server side in a business system, and comprises the following steps:
receiving a first service request sent by a client;
when the current operating environment is detected to be a development environment through the preset request processing component and a virtual login user is not detected, reading virtual user identification information from a virtual user configuration file;
and storing the virtual user identification information into a thread memory space through the preset request processing component, so that a service can acquire the virtual user identification information from the thread memory space when processing the first service request.
2. The method of claim 1, wherein reading, by the pre-set request processing component, virtual user identification information from a virtual user profile comprises:
reading virtual user identification information and virtual user authority information from a virtual user configuration file through the preset request processing component;
after the reading of the virtual user identification information and the virtual user permission information from the virtual user configuration file by the preset request processing component, the method further includes:
constructing a virtual authentication object meeting the requirement of an authentication framework of the service system according to the virtual user authority information through the preset request processing component;
and storing the virtual authentication object into a thread memory space through the preset request processing component, so that a service can acquire virtual user authority information contained in the virtual authentication object from the thread memory space when processing the first service request.
3. The method of claim 2, wherein storing the virtual user id information into a thread memory space via the predetermined request processing component comprises:
injecting the virtual user identification information into a first preset thread context variable by the preset request processing component by using a thread local storage technology;
correspondingly, the storing the virtual authentication object in a thread memory space through the preset request processing component includes:
and injecting the virtual authentication object into a second preset thread context variable by using a thread local storage technology through the preset request processing component, wherein the second preset thread context variable corresponds to the authentication frame.
4. The method according to claim 3, further comprising, after storing the virtual authentication object in a thread memory space by the predetermined request processing component:
and acquiring corresponding virtual user identification information by using an acquisition method corresponding to the first preset thread context variable in the thread local storage technology through a service, acquiring corresponding virtual user permission information by using an acquisition method corresponding to the second preset thread context variable in the thread local storage technology, and processing the first service request based on the acquired virtual user identification information and virtual user permission information.
5. The method of claim 1, further comprising, after receiving the first service request sent by the client:
when the preset request processing component detects that the current operating environment is not a development environment, acquiring real user identification information corresponding to the first service request;
and storing the real user identification information into a thread memory space through the preset request processing component, so that a service can acquire the real user identification information from the thread memory space when processing the first service request.
6. The method of claim 1, further comprising:
receiving a virtual user switching request sent by a client;
and when the preset request processing component detects that the current operating environment is a development environment, updating the virtual user configuration file according to the target virtual user identification information contained in the virtual user switching request.
7. The method according to claim 6, wherein said updating the virtual user profile according to the target virtual user identification information included in the virtual user handover request comprises:
inquiring corresponding target virtual user authority information from a preset mapping relation table according to target virtual user identification information contained in the virtual user switching request, wherein the preset mapping relation table contains the mapping relation between the user identification information and the user authority information;
and updating the virtual user configuration file according to the target virtual user identification information and the target virtual user authority information.
8. A virtual login user constructing apparatus, configured to a server in a business system, the apparatus comprising:
the first service request receiving module is used for receiving a first service request sent by a client;
the virtual user identification information acquisition module is used for reading virtual user identification information from the virtual user configuration file when the current operating environment is detected to be a development environment through the preset request processing component and a virtual login user is not detected;
and the virtual user identification information storing module is used for storing the virtual user identification information into a thread memory space through the preset request processing component, so that the service can acquire the virtual user identification information from the thread memory space when processing the first service request.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-7 when executing the computer 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-7.
CN202011612007.0A 2020-12-30 2020-12-30 Virtual login user construction method, device, equipment and storage medium Pending CN112699034A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011612007.0A CN112699034A (en) 2020-12-30 2020-12-30 Virtual login user construction method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011612007.0A CN112699034A (en) 2020-12-30 2020-12-30 Virtual login user construction method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112699034A true CN112699034A (en) 2021-04-23

Family

ID=75511531

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011612007.0A Pending CN112699034A (en) 2020-12-30 2020-12-30 Virtual login user construction method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112699034A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113535744A (en) * 2021-07-09 2021-10-22 深圳市蘑菇财富技术有限公司 Tenant data modification method, system, device and storage medium
CN113938886A (en) * 2021-11-30 2022-01-14 上海派拉软件股份有限公司 Identity authentication platform test method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030014466A1 (en) * 2001-06-29 2003-01-16 Joubert Berger System and method for management of compartments in a trusted operating system
CN101388797A (en) * 2008-11-05 2009-03-18 杭州华三通信技术有限公司 Method for realizing authority control in network management and network management system
US20090089407A1 (en) * 2007-10-02 2009-04-02 Aspect Software Inc. Deployment Wizard
CN110162994A (en) * 2019-04-16 2019-08-23 深圳壹账通智能科技有限公司 Authority control method, system, electronic equipment and computer readable storage medium
CN110262964A (en) * 2019-05-21 2019-09-20 深圳壹账通智能科技有限公司 Test method, device, equipment and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030014466A1 (en) * 2001-06-29 2003-01-16 Joubert Berger System and method for management of compartments in a trusted operating system
US20090089407A1 (en) * 2007-10-02 2009-04-02 Aspect Software Inc. Deployment Wizard
CN101388797A (en) * 2008-11-05 2009-03-18 杭州华三通信技术有限公司 Method for realizing authority control in network management and network management system
CN110162994A (en) * 2019-04-16 2019-08-23 深圳壹账通智能科技有限公司 Authority control method, system, electronic equipment and computer readable storage medium
CN110262964A (en) * 2019-05-21 2019-09-20 深圳壹账通智能科技有限公司 Test method, device, equipment and computer readable storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ALEXANDER STANIK等: "Local authentication and authorization system for immediate setup of cloud environments", 《2013 INTERNATIONAL CONFERENCE ON ADVANCES IN COMPUTING, COMMUNICATIONS AND INFORMATICS (ICACCI)》, 21 October 2013 (2013-10-21), pages 1651 - 1656 *
徐乐: "基于企业服务总线的服务资源共享平台", 《数字技术与应用》, 25 March 2019 (2019-03-25), pages 64 - 66 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113535744A (en) * 2021-07-09 2021-10-22 深圳市蘑菇财富技术有限公司 Tenant data modification method, system, device and storage medium
CN113535744B (en) * 2021-07-09 2023-12-08 深圳市蘑菇财富技术有限公司 Tenant data modification method, system, equipment and storage medium
CN113938886A (en) * 2021-11-30 2022-01-14 上海派拉软件股份有限公司 Identity authentication platform test method, device, equipment and storage medium
CN113938886B (en) * 2021-11-30 2024-04-05 上海派拉软件股份有限公司 Identity authentication platform testing method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109766262B (en) Interface data processing method, automatic testing method, device, equipment and medium
CN107133180B (en) Dynamic page testing method, testing device and storage medium
CN108228444B (en) Test method and device
CN112199652B (en) Login method, terminal, server, system, medium and equipment of application program
CN111625301A (en) Idempotent processing method, apparatus, device and storage medium
CN110928770B (en) Software testing method, device, system, storage medium and electronic equipment
CN109558320A (en) System detection method, device, system, equipment and computer readable storage medium
CN112699034A (en) Virtual login user construction method, device, equipment and storage medium
CN110795174A (en) Application program interface calling method, device, equipment and readable storage medium
CN112671605A (en) Test method and device and electronic equipment
CN112650689A (en) Test method, test device, electronic equipment and storage medium
CN113821254A (en) Interface data processing method, device, storage medium and equipment
CN112035163A (en) Software development kit configuration method, device and storage medium
CN111695098A (en) Multi-distributed cluster access method and device
CN108647139B (en) System test method, device, storage medium and electronic device
CN105681291A (en) Method and system for realizing unified authentication of multiple clients
CN115391188A (en) Scene test case generation method, device, equipment and storage medium
CN109831496B (en) Terminal data debugging method
CN111475763B (en) Webpage running method and device, storage medium and equipment
CN108366040B (en) Programmable firewall logic code detection method and device and electronic equipment
CN111078571A (en) Test method for simulation response, terminal device and computer readable storage medium
CN111064675A (en) Access flow control method, device, network equipment and storage medium
CN105323216A (en) Method and apparatus for transmitting communication links, and terminal
CN115396277B (en) Login state management method, device, equipment and storage medium
CN113901377B (en) Service calling method, device, storage medium and equipment of legacy system

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