Commit 78cc93d
authored
fix TACACS Local Accounting test: fixed a check on presence of accounting log about a command executed by TACACS user (#6354)
TACACS Local Accounting tests check if the commands executed by TACACS users are logged locally in DUT.
The tests execute a grep command using a TACACS user and then check presence of the corresponding accounting log in syslog using sed utility. The code fragment demonstrating it:
ssh_run_command(rw_user_client, "grep")
# Verify syslog have user command record.
check_local_log_exist(rw_user_client, tacacs_creds, "grep")
The issue is that check_local_log_exist calls sed to query for accounting logs and this query command itself is logged too so tests pass even when the initial command is not logged.
Currently the test catches this log:
INFO audisp-tacplus: Audisp-tacplus: Accounting: user: test_rwuser, tty: (none), host: mytestbed-1-dut, command: /usr/bin/bash -c sudo sed -nE '/INFO audisp-tacplus: Accounting: user: test_rwuser,.*, command: .*grep,/P' /var/log/syslog, type: 2, task ID: 29318\n"
instead of:
INFO audisp-tacplus: Audisp-tacplus: Accounting: user: test_rwuser, tty: (none), host: mytestbed-1-dut, command: /usr/bin/grep, type: 2, task ID: 13871
The consequences of the issue are:
the tests do not check accounting log entries to adhere to an expected pattern
Since sed command happens to be logged too, tests match the search pattern used in sed command itself, instead of matching a separate accounting log adheres to an expected pattern. The matched fragment is made bold below:
INFO audisp-tacplus: Audisp-tacplus: Accounting: user: test_rwuser, tty: (none), host: mytestbed-1-dut, command: /usr/bin/bash -c sudo sed -nE '/INFO audisp-tacplus: Accounting: user: test_rwuser,.*, command: .*grep,/P' /var/log/syslog, type: 2, task ID: 29318\n"
tests may fail occasionally when some small logging delays take place
the scenarios documented by test code become confusing since the actual accounting log being matched is different than that's intended by tests. Expected to match an accounting log for grep command but matched a log for log query command itself.1 parent a39bbcf commit 78cc93d
1 file changed
+30
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 62 | | |
70 | | - | |
71 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
77 | 83 | | |
| 84 | + | |
| 85 | + | |
78 | 86 | | |
79 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
80 | 90 | | |
81 | | - | |
82 | | - | |
83 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
84 | 94 | | |
85 | 95 | | |
86 | 96 | | |
| |||
178 | 188 | | |
179 | 189 | | |
180 | 190 | | |
181 | | - | |
| 191 | + | |
| 192 | + | |
182 | 193 | | |
183 | | - | |
| 194 | + | |
184 | 195 | | |
185 | 196 | | |
186 | 197 | | |
| |||
191 | 202 | | |
192 | 203 | | |
193 | 204 | | |
194 | | - | |
| 205 | + | |
195 | 206 | | |
196 | 207 | | |
197 | | - | |
| 208 | + | |
198 | 209 | | |
199 | 210 | | |
200 | 211 | | |
| |||
211 | 222 | | |
212 | 223 | | |
213 | 224 | | |
214 | | - | |
| 225 | + | |
215 | 226 | | |
216 | | - | |
| 227 | + | |
217 | 228 | | |
218 | 229 | | |
219 | 230 | | |
0 commit comments