Access control list testing method, device and electronic equipment
By generating operating system-specific test matrices and arrays and creating test cases, the problem that the access control list testing tool in the existing technology cannot test different systems, and a comprehensive test of access control lists of different operating systems is realized.
Patent Information
- Application Number
- CN202210530350.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-16
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-05-16
AI Technical Summary
In the prior art, the access control list testing tool cannot test the access control list corresponding to different systems, resulting in the inability to ensure whether the access control list of each system is reasonable.
By obtaining the first test matrix and the second test matrix based on the operating system, an array that the access control list test tool can be identified, and a test case is created based on these arrays to conduct testing of the access control list.
The access control list test tool is implemented to test the access control lists of different operating systems, solving the problem that existing tools cannot be compatible with access control lists of different systems, and improving the operability of the test tool.
Smart Images

Figure CN115129582B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data communication, and in particular to a method, a device and an electronic device for testing an access control list. Background Art
[0002] Access Control List (ACL) can set different file operation permissions for different users, thereby ensuring the security of files in the system.
[0003] In order to ensure the rationality of the access control list, an access control list testing tool is used to test whether the access control list is reasonable. However, the design of access control lists varies greatly among different operating systems, and the current access control list testing tool can only complete the testing of the access control lists corresponding to individual systems. For example, for the deletion permissions of files and directories, the Solaris operating system sets the permissions of the instructions corresponding to the delete key of different users, thereby achieving the control of file and directory deletion permissions for different users. The Linux operating system, on the other hand, sets the extended attribute chattr to achieve the control of file and directory deletion permissions for different users. The current access control list testing tool can only test the ACL corresponding to the Linux operating system, but cannot test whether the ACL corresponding to the Solaris operating system is reasonable.
[0004] Therefore, how to enable the access control list testing tool to test the access control lists corresponding to each system is an important issue that needs to be solved urgently in the industry. Summary of the invention
[0005] The present invention provides a method, device and electronic device for testing an access control list, which are used to solve the defect that the access control list testing tool in the prior art cannot test the access control lists corresponding to different systems, and realize the access control list testing tool to test the access control lists corresponding to different systems.
[0006] The present invention provides a method for testing an access control list, the method comprising:
[0007] Obtain a first test matrix and a second test matrix, wherein the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory;
[0008] Generate a first array based on elements corresponding to the first test matrix, and generate a second array based on elements corresponding to the second test matrix, wherein the first array and the second array are arrays identifiable by an access control list testing tool, the first array is an array corresponding to permissions of a parent directory, and the second array is an array corresponding to permissions of a subdirectory corresponding to the parent directory and / or a file corresponding to the parent directory;
[0009] Corresponding test cases are created based on the first array and the second array respectively, and the access control list is tested based on the test cases.
[0010] Optionally, the step of creating corresponding test cases based on the first array and the second array respectively, and testing the access control list based on the test cases includes:
[0011] Create a first test case based on the first array, and create a second test case based on the second array;
[0012] The first test case is run to test the access control list, and the second test case is nestedly run to test the access control list.
[0013] Optionally, when the number of the first test case is one, the step of running the first test case to test the access control list and nestedly running the second test case to test the access control list includes:
[0014] After initialization configuration, running the first test case to test the access control list;
[0015] After the first test case is run, each of the second test cases is run to test the access control list;
[0016] After each of the second test cases is run, the current test environment is cleared.
[0017] Optionally, when there are multiple first test cases, the step of running the first test case to test the access control list and nestedly running the second test case to test the access control list includes:
[0018] After the initial configuration, the first test case is run to test the access control list;
[0019] After the current first test case is run, each of the second test cases is run to test the access control list;
[0020] After each of the second test cases is finished running, clearing the current test environment;
[0021] The next first test case is used as the current first test case, and the step of running the current first test case to test the access control list is continued, wherein the current first test case corresponds to each of the second test cases.
[0022] Optionally, the test condition includes a first test condition and a second test condition, wherein the first test condition is a test condition corresponding to the permission of the parent directory, and the second test condition is a test condition corresponding to the permission of the subdirectory corresponding to the parent directory and / or the file corresponding to the parent directory;
[0023] Before the step of obtaining the first test matrix and the second test matrix, the method further includes:
[0024] A first test matrix is created based on the first test condition, and a second test matrix is created based on the second test condition.
[0025] Optionally, the first test condition includes the permission type of the access control list and the permission role of the access control list; the second test condition includes the inheritance type of the access control list and the inheritance object of the access control list;
[0026] The step of creating a first test matrix based on the first test condition and creating a second test matrix based on the second test condition includes:
[0027] A first test matrix is created based on the permission type and the test role, and a second test matrix is created based on the inheritance type and the inheritance object.
[0028] Optionally, the step of generating a first array based on elements corresponding to the first test matrix and generating a second array based on elements corresponding to the second test matrix includes:
[0029] Extracting first elements that are not 0 in the first test matrix, and generating a first array based on each of the first elements;
[0030] Second elements that are not 0 in the second test matrix are extracted, and a second array is generated based on each of the second elements.
[0031] Optionally, the step of generating the first array based on each of the first elements includes:
[0032] Generate a first two-dimensional array based on each of the first elements;
[0033] Extracting first data which is not 0 in the first two-dimensional array;
[0034] generating a first array based on each of the first data;
[0035] The step of generating a second array based on each of the second elements comprises:
[0036] generating a second two-dimensional array based on each of the second elements;
[0037] Extracting second data that is not 0 in the second two-dimensional array;
[0038] A second array is generated based on each of the second data.
[0039] The present invention also provides a testing device for access control list, comprising:
[0040] An acquisition module, used to acquire a first test matrix and a second test matrix, wherein the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory;
[0041] A generation module, used to generate a first array based on elements corresponding to the first test matrix, and to generate a second array based on elements corresponding to the second test matrix, wherein the first array and the second array are arrays recognizable by an access control list testing tool, the first array is an array corresponding to permissions of a parent directory, and the second array is an array corresponding to permissions of subdirectories corresponding to the parent directory and / or files corresponding to the parent directory;
[0042] A testing module is used to create corresponding test cases based on the first array and the second array respectively, and test the access control list based on the test cases.
[0043] The present invention also provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned access control list testing methods when executing the program.
[0044] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the access control list testing methods described above are implemented.
[0045] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned methods for testing an access control list are implemented.
[0046] The present invention provides a method, device and electronic device for testing an access control list, wherein a first test matrix and a second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories and / or files corresponding to the parent directory corresponding to the parent directory, a first array is generated based on the elements corresponding to the first test matrix, and a second array is generated based on the elements corresponding to the second test matrix, wherein the first array and the second array are arrays recognizable by an access control list testing tool, the first array is an array corresponding to the permissions of the parent directory, and the second array is an array corresponding to the permissions of the subdirectories and / or files corresponding to the parent directory corresponding to the parent directory, corresponding test cases are created based on the first array and the second array, and the access control list is tested based on the test cases. Since the electronic device can convert the test matrices corresponding to different operating systems into arrays recognizable by the access control list testing tool, and then can generate corresponding test cases based on the arrays, the access control list testing tool can be used to test the access control lists corresponding to different operating systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 It is one of the flow charts of the access control list testing method provided by the present invention;
[0049] Figure 2 This is the second flow chart of the access control list testing method provided by the present invention;
[0050] Figure 3 It is a structural schematic diagram of the access control list testing device provided by the present invention;
[0051] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] In order to implement the access control list testing tool to test the access control lists corresponding to different systems, the present invention provides a method, device, electronic device, non-transitory computer-readable storage medium and computer program product for testing access control lists. Figure 1 A method for detecting an access control list of the present invention is described.
[0054] like Figure 1 As shown, a method for testing an access control list, the method comprising:
[0055] S101, obtaining a first test matrix and a second test matrix.
[0056] Among them, the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory.
[0057] S102: Generate a first array based on elements corresponding to the first test matrix, and generate a second array based on elements corresponding to the second test matrix.
[0058] Among them, the first array and the second array are arrays identifiable by the access control list testing tool, the first array is the array corresponding to the permissions of the parent directory, and the second array is the array corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory.
[0059] S103: Create corresponding test cases based on the first array and the second array respectively, and test the access control list based on the test cases.
[0060] It can be seen that the access control list testing method provided by the present invention can be obtained by obtaining a first test matrix and a second test matrix, wherein the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories and / or files corresponding to the parent directory corresponding to the parent directory, a first array is generated based on the elements corresponding to the first test matrix, and a second array is generated based on the elements corresponding to the second test matrix, wherein the first array and the second array are arrays identifiable by the access control list testing tool, the first array is an array corresponding to the permissions of the parent directory, and the second array is an array corresponding to the permissions of the subdirectories and / or files corresponding to the parent directory corresponding to the parent directory, corresponding test cases are created based on the first array and the second array, and the access control list is tested based on the test cases. Since the electronic device can convert the test matrices corresponding to different operating systems into arrays identifiable by the access control list testing tool, and then can generate corresponding test cases based on the arrays, the access control list testing tool can be used to test the access control lists corresponding to different operating systems.
[0061] When the user needs to test the access control list, a test instruction may be issued through the electronic device. After receiving the test instruction, the electronic device may obtain a first test matrix and a second test matrix for testing the access control list.
[0062] Among them, the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system to which the access control list belongs, and the test conditions can be generated based on the implementation method of the access control list corresponding to the operating system and the permissions of the access control list corresponding to the operating system. It can be seen that the first test matrix and the second test matrix can represent the permissions of the access control list.
[0063] The permissions of the access control list can be access permissions, deletion permissions, collection permissions, inheritance permissions, etc., which are not specifically limited here. Each permission is interrelated and exists independently.
[0064] Specifically, the first test matrix can be a test matrix corresponding to the permissions of the parent directory, the second test matrix can be a test matrix corresponding to the subdirectory corresponding to the parent directory, or a test matrix corresponding to the permissions of the files corresponding to the parent directory, or a test matrix corresponding to the permissions of the subdirectories corresponding to the parent directory and the files corresponding to the parent directory, all of which are reasonable.
[0065] A subdirectory is a directory in a parent directory, a file can be a file in a parent directory, or a file can be a file in a subdirectory. A parent directory can contain multiple subdirectories and / or files, and a subdirectory can contain multiple files. A file contains child files and parent files, a child file is a file in a parent file, and a parent file can contain multiple child files.
[0066] In order to enable the access control list testing tool to test the access control list, the electronic device may convert corresponding elements in the first test matrix and the second test matrix into data recognizable by the access control list testing tool.
[0067] After acquiring the first test matrix and the second test matrix, the electronic device may execute the above step S102, that is, generate a first array based on elements corresponding to the first test matrix, and generate a second array based on elements corresponding to the second test matrix.
[0068] Among them, the first array and the second array are arrays identifiable by the access control list testing tool. The first array is an array corresponding to the permissions of the parent directory, and the second array can be an array corresponding to the permissions of the subdirectories corresponding to the parent directory, or an array corresponding to the permissions of the files corresponding to the parent directory, or an array corresponding to the permissions of the subdirectories corresponding to the parent directory and the files corresponding to the parent directory.
[0069] After obtaining the first array and the second array, the electronic device may execute the above step S103, that is, create corresponding test cases based on the first array and the second array respectively, and test the access control list based on the test cases.
[0070] The access control list testing tool installed in the electronic device can create corresponding test cases based on the first array and the second array respectively, and then test the access control list based on the test cases. Since the electronic device can convert the test matrix corresponding to different operating systems into an array recognizable by the access control list testing tool, and then generate corresponding test cases based on the array, the access control list testing tool can test the access control lists corresponding to different operating systems, that is, it can solve the problem that the current access control list testing tool is not compatible, and improve the operability of the access control list testing tool for different operating systems.
[0071] As an implementation method of the embodiment of the present invention, Figure 2 As shown, the above steps of creating corresponding test cases based on the first array and the second array respectively, and testing the access control list based on the test cases may include:
[0072] S201, creating a first test case based on a first array, and creating a second test case based on a second array.
[0073] S202: Run a first test case to test the access control list, and nestedly run a second test case to test the access control list.
[0074] The access control list testing tool installed in the electronic device can create a first test case that complies with the interface specification based on the data in the first array. Create a second test case that complies with the interface specification based on the data in the second array, wherein the first test case can test whether the permissions of the parent directory corresponding to the access control list are reasonable, and the second test case can test whether the permissions of the subdirectories and / or files corresponding to the access control list are reasonable.
[0075] In order to test whether the access control list meets the needs of different usage scenarios and different users, for each parent directory's permissions, it is possible to test whether the permissions of the subdirectories and / or files corresponding to the parent directory's permissions are reasonable. That is, when the electronic device runs the first test case to test the access control list, it can nestly run the second test case to test the access control list, so that the test scenarios of the access control list can be covered, taking into account the test items of all access control lists, and meeting the needs of different users.
[0076] In one implementation, the test framework in the access control list test tool can use the compilation, connection, and operation methods to test whether the functions of the interface and the behaviors corresponding to the functions can be implemented.
[0077] For example, the electronic device can call the framework acl-runner in the access control list test tool, input the data in the first array into the framework acl-runner, and generate a first test case that complies with the POSIX (Portable Operating System Interface of UNIX) interface specification. The electronic device can input the data in the second array into the framework acl-runner to generate a second test case that complies with the POSIX interface specification. When the interface is in a connected state, the first test case is run to test the access control list, and the second test case is nested to test the access control list, thereby implementing a test on whether the functions of the interface and the behaviors corresponding to the functions can be implemented.
[0078] It can be seen that in this embodiment, the electronic device can create a first test case based on the first array, create a second test case based on the second array, run the first test case to test the access control list, and nestedly run the second test case to test the access control list. In this way, when testing whether the permissions of each parent directory are reasonable, it is possible to test whether the permissions of the subdirectories and / or files corresponding to the permissions of the parent directory are reasonable, thereby being able to test the access control list more comprehensively.
[0079] As an implementation manner of an embodiment of the present invention, when the number of the first test case is one, the step of running the first test case to test the access control list and nestedly running the second test case to test the access control list may include:
[0080] After the initial configuration, the first test case is run to test the access control list.
[0081] After the first test case is run, each second test case is run to test the access control list.
[0082] After each second test case is run, clear the current test environment.
[0083] Before testing the access control list, you can perform initial configuration of the access control list testing tool. For example, the access control list testing tool can create users and user groups, verify interface connection status, check whether the access control list type can be set successfully, etc., without specific limitation here.
[0084] When there is only one first test case, that is, when the parent directory corresponding to the access control list has only one permission, the access control list testing tool can run the first test case to test the access control list. After the first test case is run, run each second test case to test the access control list, thereby running the first test case to test the access control list, and nested running the second test case to test the access control list, so as to test the access control list more comprehensively.
[0085] After running the first test case and each second test case, the electronic device may clear the current test environment of the access control list test tool.
[0086] It can be seen that in this embodiment, for the case where there is only one first test case, the electronic device can run the first test case to test the access control list after the initialization configuration, and after the first test case is run, run each second test case to test the access control list, and after each second test case is run, clear the current test environment. In this way, for the case where there is only one first test case, the access control list can be comprehensively tested.
[0087] As an implementation manner of an embodiment of the present invention, when the number of the first test cases is multiple, the step of running the first test case to test the access control list and nestedly running the second test case to test the access control list may include:
[0088] After the initial configuration, the first test case is run to test the access control list.
[0089] After the current first test case is run, each second test case is run to test the access control list.
[0090] After each second test case is run, clear the current test environment;
[0091] The next first test case is used as the current first test case, and the current first test case is continued to be run to test the access control list.
[0092] After the initial configuration, the access control list testing tool can run the current first test case to test the access control list. After the current first test case is completed, run each second test case to test the access control list. After each second test case is completed, clear the current test environment, wherein the current first test case corresponds to each of the second test cases.
[0093] Then, the next first test case is used as the current first test case, and the step of running the current first test case to test the access control list is continued until all the first test cases and all the second test cases are run.
[0094] For example, there are 2 first test cases: first test case A and first test case B. There are 5 second test cases: second test case a, second test case b, second test case c, second test case d, and second test case e. After the initial configuration, the first test case A is used as the current first test case, and the current first test case, i.e., the first test case A, is run to test the access control list. After the first test case A is run, each second test case is run to test the access control list, i.e., the second test case a, the second test case b, the second test case c, the second test case d, and the second test case e are run to test the access control list. After each second test case is run, the current test environment is cleared.
[0095] Take the first test case B as the current first test case, run the current first test case, i.e., the first test case B, to test the access control list, and after the first test case B is finished running, run each second test case to test the access control list, i.e., run the second test case a, the second test case b, the second test case c, the second test case d, and the second test case e respectively to test the access control list, and after each second test case is finished running, clear the current test environment.
[0096] It can be seen that in this embodiment, for the case where there are multiple first test cases, the electronic device can, after the initialization configuration, run the current first test case to test the access control list, and after the current first test case is run, run each second test case to test the access control list, and after each second test case is run, clear the current test environment, use the next first test case as the current first test case, and continue to run the current first test case to test the access control list. In this way, for the case where there are multiple first test cases, the access control list can be comprehensively tested.
[0097] As an implementation manner of the embodiment of the present invention, the above test condition may include a first test condition and a second test condition.
[0098] Before the step of obtaining the first test matrix and the second test matrix, the method may further include:
[0099] A first test matrix is created based on the first test condition, and a second test matrix is created based on the second test condition.
[0100] The electronic device can create a first test matrix based on a first test condition, and create a second test matrix based on a second test condition, wherein the first test condition can be a test condition corresponding to the permissions of a parent directory, and the second test condition can be a test condition corresponding to the permissions of a subdirectory corresponding to the parent directory, or the second test condition can be a test condition corresponding to the permissions of a file corresponding to the parent directory, or the second test condition can be a test condition corresponding to the permissions of a subdirectory corresponding to the parent directory and a file corresponding to the parent directory, and no specific limitation is made here.
[0101] In this embodiment, the electronic device can create a first test matrix based on the first test condition and create a second test matrix based on the second test condition, so that the electronic device can convert the test matrices corresponding to different operating systems into arrays recognizable by the access control list testing tool, and then generate corresponding test cases to implement testing of access control lists corresponding to different operating systems.
[0102] As an implementation method of an embodiment of the present invention, the above-mentioned first test condition may include the permission type of the access control list and the permission role of the access control list, wherein the permission type of the access control list may be a common permission type or a collection permission type, and the common permission type includes permissions such as adding files, adding directories, deleting files, deleting subfiles, execution permissions, listing directories, reading attribute permissions, reading basic attributes, reading file contents, reading extended attributes, creating extended attributes, modifying files, modifying file attributes, modifying file permissions, and changing file owners, which are not specifically limited here.
[0103] The collection permission types include all permissions, read-only permissions, and write-only permissions. All permissions refer to all common permission types. Read-only permissions refer to permissions involving read in common permission types. For example, read-only permissions may include: listing directories, reading attribute permissions, reading basic attributes, reading file contents, and reading extended attributes. Write-only permission types refer to permissions involving deletion, modification, and other operations in common permission types. For example, write-only permissions may include: adding files, adding directories, deleting files, deleting subfiles, creating extended attributes, modifying files, modifying file attributes, modifying file permissions, and changing file owners.
[0104] The permission roles of the access control list can include owner, group, others, user, etc., and are not specifically limited here.
[0105] The second test condition may include the inheritance type of the access control list and the inheritance object of the access control list, wherein the inheritance type of the access control list may include inheritance of file-related permissions of the parent directory, inheritance of directory-related permissions of the parent directory, only newly created files and / or subdirectories contained in the parent directory inheriting permissions, and all files and / or subdirectories contained in the parent directory inheriting permissions, etc. The inheritance objects of the access control list include files, subdirectories, etc., which are not specifically limited here.
[0106] The steps of creating a first test matrix based on the first test condition and creating a second test matrix based on the second test condition may include:
[0107] A first test matrix is created based on the permission type and the test role, and a second test matrix is created based on the inheritance type and the inheritance object.
[0108] The electronic device can create a first test matrix based on the permission type and the test role. In one embodiment, the electronic device can use the permission type as the row of the first test matrix and the test role as the column of the first test matrix to obtain the first test matrix. In another embodiment, the electronic device can use the test role as the row of the first test matrix and the permission type as the column of the first test matrix to obtain the first test matrix. This is all reasonable.
[0109] The electronic device may create a second test matrix based on the inheritance type and the inheritance object. In one embodiment, the electronic device may use the inheritance type as the row of the second test matrix and the inheritance object as the column of the second test matrix to obtain the second test matrix. In another embodiment, the electronic device may use the inheritance object as the row of the second test matrix and the inheritance type as the column of the second test matrix to obtain the second test matrix. This is also reasonable.
[0110] For example, the permission type is used as the row of the first test matrix, and the test role is used as the column of the first test matrix, wherein the permission type is represented by P, and the permission type includes P1, P2...Pn, and the test role is represented by R, and the test role includes R1, R2...Rm. The first test matrix is shown in Table 1:
[0111] Table 1
[0112]
[0113] The inheritance type is used as the row of the second test matrix, and the inheritance object is used as the column of the second test matrix, where the inheritance type is represented by T, the permission type includes T1, T2...Ta, the inheritance object is represented by O, and the test role includes O1, O2...Ob. The first test matrix is shown in Table 2:
[0114] Table 2
[0115]
[0116]
[0117] As an implementation method, the positions with corresponding authority in the matrix can be assigned a value of 1, and the positions without corresponding authority in the matrix can be assigned a value of 0. In this way, the first test matrix and the second test matrix obtained are matrices composed of 0 and 1 elements.
[0118] It can be seen that in this embodiment, the electronic device can create a first test matrix based on the permission type and the test role, and create a second test matrix based on the inheritance type and the inheritance object. The first test matrix and the second test matrix can cover the test items of all access control lists, so that the electronic device can convert the test matrices corresponding to different operating systems into arrays recognizable by the access control list testing tool, and then generate corresponding test cases to implement testing of access control lists corresponding to different operating systems.
[0119] As an implementation manner of an embodiment of the present invention, the step of generating the first array based on the elements corresponding to the first test matrix and generating the second array based on the elements corresponding to the second test matrix may include:
[0120] First elements that are not 0 in the first test matrix are extracted, and a first array is generated based on each of the first elements.
[0121] In the case where the first test matrix and the second test matrix are matrices composed of 0 and 1 elements, since the position corresponding to the 0 element does not have the corresponding permission, the electronic device can extract the first elements that are not 0 in the first test matrix, and generate a first array based on each first element, so as to remove invalid data and obtain an array that can be recognized by the access control list test tool, so as to speed up the test.
[0122] Second elements that are not 0 in the second test matrix are extracted, and a second array is generated based on each of the second elements.
[0123] Similarly, the electronic device can extract the second element of position 0 in the second test matrix and generate second data based on the second element, so as to remove invalid data and obtain an array recognizable by the access control list test tool to improve test efficiency.
[0124] It can be seen that in this embodiment, invalid data can be removed, so that an array recognizable by the access control list testing tool can be obtained, so as to improve the testing efficiency.
[0125] As an implementation manner of an embodiment of the present invention, the step of generating the first array based on each of the first elements includes:
[0126] A first two-dimensional array is generated based on each of the first elements.
[0127] The first data which is not zero in the first two-dimensional array is extracted.
[0128] A first array is generated based on each of the first data.
[0129] After acquiring each first element, the electronic device may generate a first two-dimensional array based on each first element, wherein the first two-dimensional array is an array with arrays as array elements, and the first two-dimensional array is a computer-recognizable data structure.
[0130] The electronic device can extract the first data that is not 0 in the first two-dimensional array, and then generate a first array based on each first data. At this time, the first array is a sparse array, which can save storage space to facilitate the subsequent transfer of the first array to the access control list testing tool.
[0131] The step of generating the second array based on each of the second elements comprises:
[0132] A second two-dimensional array is generated based on each of the second elements.
[0133] The second data that is not 0 in the second two-dimensional array is extracted.
[0134] A second array is generated based on each of the second data.
[0135] Similarly, after acquiring each second element, the electronic device can generate a second two-dimensional array based on each second element, wherein the second two-dimensional array is an array with arrays as array elements, and the second two-dimensional array is a computer-recognizable data structure.
[0136] The electronic device can extract the second data that is not 0 in the second two-dimensional array, and then generate a second array based on each second data. At this time, the second array is a sparse array, which can save storage space to facilitate the subsequent transfer of the first array to the access control list testing tool.
[0137] It can be seen that in this embodiment, a first array and a second array can be generated, and the first array and the second array are sparse arrays, which can save storage space, so as to facilitate the subsequent transfer of the first array to the access control list testing tool.
[0138] As an implementation method of an embodiment of the present invention, the electronic device can place the most restrictive statement in the access control list at the front position, and then after creating the corresponding test case, it can first test the test case corresponding to the most restrictive statement, and can first filter out a lot of data that does not meet the conditions, thereby improving work efficiency.
[0139] As an implementation of the embodiment of the present invention, after running all the first test cases and the second test cases, the access control list test tool can output the test results, and the electronic device can perform corresponding actions based on the test results.
[0140] Specifically, the test result includes test completion and passing, test completion but failure, and incomplete execution. If the test result is that the test is completed and passed, the electronic device can feedback a test completion message. If the test result is that the test is completed but failed, the electronic device can analyze the test result, and adjust the first test case and the second test matrix according to the analysis result, so as to perform the test again. If the test result is that the execution is incomplete, the electronic device can adjust the first test case and the second test matrix, so as to perform the test again.
[0141] In one implementation, the electronic device may generate a corresponding test report based on multiple test results for the user to view.
[0142] The following is an introduction to the access control list testing method provided by the present invention with reference to examples:
[0143] The hardware used is X86 and ARM, and the software is Solaris and Linux, which form a heterogeneous cluster file system. Four storage devices with a main frequency of 2.10GHZ / dual CPU / memory of 64GB / hard disk of 24*4T / capacity of 6*32GB are used to deploy the heterogeneous cluster file system environment. In this example, the file permission of user abc is tested.
[0144] First, create user abc in each of the four storage devices, and then set the permission for user abc to add files to the specified directory, that is, add_file (add file). When testing a specific permission of the directory, it is necessary to set the execution permission for the directory at the same time, that is, execute (execute). The first test matrix M3 is constructed as shown in Table 3, where add_subdirectory is to add a subdirectory:
[0145] Table 3
[0146]
[0147] On the basis of constructing the above-mentioned first test matrix M3, the permission inheritance of the subdirectories under the directory is tested, and the inheritance permission is set for the subdirectories, namely file_inherit (inheriting the file-related permissions of the parent directory). The second test matrix M4 is shown in Table 4, where dir_inherit is to inherit the directory-related permissions of the parent directory, and inherit_only is that only the newly created files and / or directories inherit the permissions of the parent directory:
[0148] Table 4
[0149]
[0150]
[0151] The first test matrix M3 is a test matrix for testing whether the user abc has the permission to add files to the directory, and the second test matrix M4 is a test matrix for testing whether the file under the subdirectory inherits all permissions of the parent directory.
[0152] The elements in the first test matrix and the second test matrix are converted into data usable by the access control list test tool, that is, the two matrices M3 and M4 are converted into sparse arrays respectively as input data, and the POSIX interface of the access control list test tool can receive the input data.
[0153] Then, the access control list test tool calls acl_runner, and the POSIX interface is organized and constructed according to the input data to form the first test case a, the first test case b, and the second test case in the directory structure.
[0154] After the initial configuration, run the first test case a to test the access control list. After the first test case a is completed, run the second test case to test the access control list. After the second test case is completed, clear the current test environment. Run the first test case b to test the access control list. After the first test case b is completed, run the second test case to test the access control list. After the second test case is completed, clear the current test environment. The access control list test tool generates test results and completes the test of the access control lists corresponding to the four storage devices.
[0155] The access control list testing device provided by the present invention is described below. The access control list testing device described below and the access control list testing method described above can be referred to each other.
[0156] like Figure 3 As shown, a testing device for access control list may include:
[0157] The acquisition module 310 is used to acquire a first test matrix and a second test matrix.
[0158] Among them, the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory.
[0159] The generating module 320 is configured to generate a first array based on elements corresponding to the first test matrix, and to generate a second array based on elements corresponding to the second test matrix.
[0160] Among them, the first array and the second array are arrays identifiable by the access control list testing tool, the first array is the array corresponding to the permissions of the parent directory, and the second array is the array corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory.
[0161] The testing module 330 is used to create corresponding test cases based on the first array and the second array respectively, and test the access control list based on the test cases.
[0162] It can be seen that the access control list testing device provided by the present invention can obtain a first test matrix and a second test matrix, generate a first array based on elements corresponding to the first test matrix, generate a second array based on elements corresponding to the second test matrix, create corresponding test cases based on the first array and the second array, and test the access control list based on the test cases. Since the electronic device can convert the test matrices corresponding to different operating systems into arrays recognizable by the access control list testing tool, and then generate corresponding test cases based on the arrays, the access control list testing tool can test the access control lists corresponding to different operating systems.
[0163] As an implementation of the embodiment of the present invention, the test module 330 may include:
[0164] The first creating unit is used to create a first test case based on the first array, and to create a second test case based on the second array.
[0165] The running unit is used to run the first test case to test the access control list, and nestedly run the second test case to test the access control list.
[0166] As an implementation manner of an embodiment of the present invention, when the number of the first test case is one, the running unit may include:
[0167] The first running subunit is used to run the first test case to test the access control list after the initial configuration.
[0168] A second running subunit is used to run each of the second test cases to test the access control list after the first test case is run;
[0169] The first clearing subunit is used to clear the current test environment after each of the second test cases is executed.
[0170] As an implementation manner of an embodiment of the present invention, when the number of the first test cases is multiple, the above-mentioned running unit may include:
[0171] The third running subunit is used to run the current first test case to test the access control list after the initial configuration.
[0172] The fourth running subunit is used to run each of the second test cases to test the access control list after the current first test case has been run.
[0173] The second clearing subunit is used to clear the current test environment after each of the second test cases is completed.
[0174] The fifth running subunit is used to use the next first test case as the current first test case and continue the step of running the current first test case to test the access control list.
[0175] The current first test case corresponds to each of the second test cases.
[0176] As an implementation of the embodiment of the present invention, the above test condition includes a first test condition and a second test condition.
[0177] The first test condition is a test condition corresponding to the permissions of the parent directory, and the second test condition is a test condition corresponding to the permissions of the subdirectory corresponding to the parent directory and / or the file corresponding to the parent directory.
[0178] The device may also include:
[0179] A creating module is used to create a first test matrix based on the first test condition and create a second test matrix based on the second test condition before the step of obtaining the first test matrix and the second test matrix.
[0180] As an implementation method of an embodiment of the present invention, the first test condition includes the permission type of the access control list and the permission role of the access control list; the second test condition includes the inheritance type of the access control list and the inheritance object of the access control list;
[0181] The above creation module may include:
[0182] The second creation module is used to create a first test matrix based on the permission type and the test role, and to create a second test matrix based on the inheritance type and the inheritance object.
[0183] As an implementation of the embodiment of the present invention, the generation module 320 may include:
[0184] The first extraction unit is used to extract the first elements that are not 0 in the first test matrix, and generate a first array based on each of the first elements.
[0185] The second extraction unit is used to extract the second elements that are not 0 in the second test matrix, and generate a second array based on each of the second elements.
[0186] As an implementation manner of the embodiment of the present invention, the first extraction unit may include:
[0187] The first generating subunit is used to generate a first two-dimensional array based on each of the first elements.
[0188] The first extraction subunit is used to extract first data that is not 0 in the first two-dimensional array.
[0189] The second generating subunit is used to generate a first array based on each of the first data.
[0190] The second extraction subunit may include:
[0191] The third generating subunit is used to generate a second two-dimensional array based on each of the second elements.
[0192] The second extraction subunit is used to extract second data that is not 0 in the second two-dimensional array.
[0193] The fourth generating subunit is used to generate a second array based on each of the second data.
[0194] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the test method of the access control list.
[0195] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0196] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the access control list testing methods provided by the above methods.
[0197] In yet another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the access control list testing method provided by the above methods.
[0198] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0199] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0200] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for testing an access control list, characterized in that: The method comprises: Obtain a first test matrix and a second test matrix, wherein the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory; Generate a first array based on elements corresponding to the first test matrix, and generate a second array based on elements corresponding to the second test matrix, wherein the first array and the second array are arrays identifiable by an access control list testing tool, the first array is an array corresponding to permissions of a parent directory, and the second array is an array corresponding to permissions of a subdirectory corresponding to the parent directory and / or a file corresponding to the parent directory; Creating corresponding test cases based on the first array and the second array respectively, and testing the access control list based on the test cases; The step of creating corresponding test cases based on the first array and the second array respectively, and testing the access control list based on the test cases includes: Create a first test case based on the first array, and create a second test case based on the second array; Running the first test case to test the access control list, and nested running the second test case to test the access control list; When the number of the first test case is one, the step of running the first test case to test the access control list and nestedly running the second test case to test the access control list includes: After initialization configuration, running the first test case to test the access control list; After the first test case is run, each of the second test cases is run to test the access control list; After each of the second test cases is run, the current test environment is cleared.
2. The method according to claim 1, characterized in that When there are multiple first test cases, the step of running the first test case to test the access control list and nestedly running the second test case to test the access control list includes: After the initial configuration, the first test case is run to test the access control list; After the current first test case is run, each of the second test cases is run to test the access control list; After each of the second test cases is finished running, clearing the current test environment; The next first test case is used as the current first test case, and the step of running the current first test case to test the access control list is continued, wherein the current first test case corresponds to each of the second test cases.
3. The method according to claim 1, characterized in that The test condition includes a first test condition and a second test condition, wherein the first test condition is a test condition corresponding to the permission of the parent directory, and the second test condition is a test condition corresponding to the permission of the subdirectory corresponding to the parent directory and / or the file corresponding to the parent directory; Before the step of obtaining the first test matrix and the second test matrix, the method further includes: A first test matrix is created based on the first test condition, and a second test matrix is created based on the second test condition.
4. The method according to claim 3, characterized in that The first test condition includes the permission type of the access control list and the permission role of the access control list; the second test condition includes the inheritance type of the access control list and the inheritance object of the access control list; The step of creating a first test matrix based on the first test condition and creating a second test matrix based on the second test condition includes: A first test matrix is created based on the permission type and the permission role, and a second test matrix is created based on the inheritance type and the inheritance object.
5. The method according to any one of claims 1 to 4, characterized in that: The step of generating a first array based on elements corresponding to the first test matrix and generating a second array based on elements corresponding to the second test matrix includes: Extracting first elements that are not 0 in the first test matrix, and generating a first array based on each of the first elements; Second elements that are not 0 in the second test matrix are extracted, and a second array is generated based on each of the second elements.
6. The method according to claim 5, characterized in that The step of generating a first array based on each of the first elements comprises: Generate a first two-dimensional array based on each of the first elements; Extracting first data which is not 0 in the first two-dimensional array; generating a first array based on each of the first data; The step of generating a second array based on each of the second elements comprises: generating a second two-dimensional array based on each of the second elements; Extracting second data that is not 0 in the second two-dimensional array; A second array is generated based on each of the second data.
7. A testing device for an access control list, characterized in that: The method for testing the access control list according to claim 1 is applied, wherein the device comprises: An acquisition module, used to acquire a first test matrix and a second test matrix, wherein the first test matrix and the second test matrix are generated based on the test conditions corresponding to the operating system, the first test matrix is a test matrix corresponding to the permissions of the parent directory, and the second test matrix is a test matrix corresponding to the permissions of the subdirectories corresponding to the parent directory and / or the files corresponding to the parent directory; A generation module, used to generate a first array based on elements corresponding to the first test matrix, and to generate a second array based on elements corresponding to the second test matrix, wherein the first array and the second array are arrays recognizable by an access control list testing tool, the first array is an array corresponding to permissions of a parent directory, and the second array is an array corresponding to permissions of subdirectories corresponding to the parent directory and / or files corresponding to the parent directory; A testing module is used to create corresponding test cases based on the first array and the second array respectively, and test the access control list based on the test cases.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the access control list testing method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Page authority testing method and device, computer device and storage medium
CN110096431A
Distribution network three-phase power flow calculation method to extract Jacobian elements based on matrix operation
CN110336288A
Airborne product test modeling method based on state machine
CN112486839A