Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions tests/tacacs/test_accounting.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ def check_tacacs_server_no_other_user_log(ptfhost, tacacs_creds):

def check_local_log_exist(duthost, tacacs_creds, command):
"""
Remove all ansible command log with /D command,
which will match following format:
"ansible.legacy.command Invoked"

Find logs run by tacacs_rw_user from syslog:
Find logs match following format:
"INFO audisp-tacplus: Accounting: user: tacacs_rw_user,.*, command: .*command,"
Print matched logs with /P command.
"""
username = tacacs_creds['tacacs_rw_user']
log_pattern = "/INFO audisp-tacplus.+Accounting: user: {0},.*, command: .*{1},/P" \
log_pattern = "/ansible.legacy.command Invoked/D;\
/INFO audisp-tacplus.+Accounting: user: {0},.*, command: .*{1},/P" \
.format(username, command)
logs = wait_for_log(duthost, "/var/log/syslog", log_pattern)

Expand All @@ -128,6 +133,9 @@ def check_local_log_exist(duthost, tacacs_creds, command):
def check_local_no_other_user_log(duthost, tacacs_creds):
"""
Find logs not run by tacacs_rw_user from syslog:
Remove all ansible command log with /D command,
which will match following format:
"ansible.legacy.command Invoked"

Remove all tacacs_rw_user's log with /D command,
which will match following format:
Expand All @@ -139,7 +147,9 @@ def check_local_no_other_user_log(duthost, tacacs_creds):
Print matched logs with /P command, which are not run by tacacs_rw_user.
"""
username = tacacs_creds['tacacs_rw_user']
log_pattern = "/INFO audisp-tacplus: Accounting: user: {0},/D;/INFO audisp-tacplus: Accounting: user:/P" \
log_pattern = "/ansible.legacy.command Invoked/D;\
/INFO audisp-tacplus: Accounting: user: {0},/D;\
/INFO audisp-tacplus: Accounting: user:/P" \
.format(username)
logs = wait_for_log(duthost, "/var/log/syslog", log_pattern)

Expand Down