[cherry-pick]Add audit log forward UI testcase (#17592)

Add audit log forward UI testcase

Verify that the audit log forward function is correct.

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
Yang Jiao 2022-09-27 10:46:44 +08:00 committed by GitHub
parent f33ba83d84
commit 2004154893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 7 deletions

View File

@ -43,7 +43,6 @@ Init LDAP
Switch To Configure
Retry Element Click xpath=${configuration_xpath}
Sleep 2
Test Ldap Connection
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
@ -137,12 +136,9 @@ Project Creation Should Display
Project Creation Should Not Display
Retry Wait Until Page Not Contains Element xpath=${project_create_xpath}
## System settings
Switch To System Settings
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Retry Element Click xpath=${configuration_system_tabsheet_id}
Sleep 1
Switch To Project Quotas
Sleep 1
@ -391,3 +387,15 @@ Edit A Distribution
Retry Double Keywords When Error Retry Element Click ${distribution_add_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${distribution_add_save_btn_id}
Filter Distribution List ${name} ${new_endpoint}
Distribution Exist ${name} ${new_endpoint}
Set Audit Log Forward
[Arguments] ${syslog_endpoint} ${expected_msg}
Switch To System Settings
Run Keyword If '${syslog_endpoint}' == '${null}' Retry Clear Element Text By Press Keys ${audit_log_forward_syslog_endpoint_input_id}
... ELSE Retry Text Input ${audit_log_forward_syslog_endpoint_input_id} ${syslog_endpoint}
Retry Double Keywords When Error Retry Element Click ${config_save_button_xpath} Retry Wait Until Page Contains ${expected_msg}
Enable Skip Audit Log Database
Switch To System Settings
Retry Double Keywords When Error Click Element ${skip_audit_log_database_label} Checkbox Should Be Selected ${skip_audit_log_database_checkbox}
Retry Double Keywords When Error Retry Element Click ${config_save_button_xpath} Retry Wait Until Page Contains Configuration has been successfully saved.

View File

@ -57,3 +57,7 @@ ${distribution_del_btn_id} //*[@id='distribution-delete']
${distribution_edit_btn_id} //*[@id='distribution-edit']
${filter_dist_btn} //hbr-filter//clr-icon[contains(@class,'search-btn')]
${filter_dist_input} //hbr-filter//input
${audit_log_forward_syslog_endpoint_input_id} //*[@id='auditLogForwardEndpoint']
${skip_audit_log_database_checkbox} //*[@id='skipAuditLogDatabase']
${skip_audit_log_database_label} //clr-checkbox-wrapper//label[contains(@for,'skipAuditLogDatabase')]

View File

@ -34,3 +34,11 @@ Verify Log
Should Be Equal ${real_resource} ${resource}
Should Be Equal ${real_resource_type} ${resource_type}
Should Be Equal ${real_operation} ${operation}
Verify Log In File
[Arguments] ${username} ${resource} ${resource_type} ${operation} ${audit_log_path}=${log_path}/audit.log
${contents}= OperatingSystem.Get File ${audit_log_path}
@{lines}= Split to lines ${contents}
Log ${lines}[-1]
@{items} Create List operator="${username}" resource:${resource} resourceType="${resource_type}" action:${operation} time="20
Should Contain Any ${lines}[-1] @{items}

View File

@ -19,6 +19,7 @@ Resource Util.robot
*** Variables ***
${download_directory} /drone/download
${files_directory} ${EXECDIR}/tests/files
${log_path} /var/log/harbor/
*** Keywords ***
Start Selenium Standalone Server Locally

View File

@ -134,6 +134,16 @@ Retry Clear Element Text
@{param} Create List ${element_xpath}
Retry Action Keyword Clear Element Text @{param}
Retry Clear Element Text By Press Keys
[Arguments] ${element_xpath}
${value}= Get Value ${element_xpath}
${value_length}= Get length ${value}
${keys}= Create List
FOR ${idx} IN RANGE ${value_length}
Append To List ${keys} BACK_SPACE
END
Press Keys ${element_xpath} @{keys}
Retry Link Click
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}

View File

@ -904,7 +904,6 @@ Test Case - Audit Log And Purge
# create artifact
Push Image With Tag ${ip} ${user} ${pwd} project${d} ${image} ${tag1} ${tag1}
Clean All Local Images
Refresh Logs
Verify Log ${user} project${d}/${image}:${tag1} artifact create
Go Into Project project${d}
Go Into Repo ${image}
@ -942,3 +941,51 @@ Test Case - Audit Log And Purge
Switch To Log Rotation
Purge Now 1 Hours
Close Browser
Test Case - Audit Log Forward
[Tags] audit_log_forward
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${audit_log_path}= Set Variable ${log_path}/audit.log
${syslog_endpoint}= Set Variable harbor-log:10514
${test_endpoint}= Set Variable test.endpoint
${image}= Set Variable alpine
${tag1}= Set Variable 3.10
${tag2}= Set Variable test
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Logs
Verify Log ${HARBOR_ADMIN} project${d} project create
Switch To System Settings
Retry Wait Element Should Be Disabled ${skip_audit_log_database_checkbox}
Set Audit Log Forward ${test_endpoint} bad request: could not connect to the audit endpoint: ${test_endpoint}
# Set Audit Log Forward
Set Audit Log Forward ${syslog_endpoint} Configuration has been successfully saved.
Wait Until Element Is Enabled ${skip_audit_log_database_checkbox}
# create artifact
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image} ${tag1} ${tag1}
Switch To Logs
Verify Log ${HARBOR_ADMIN} project${d}/${image}:${tag1} artifact create
Verify Log In File ${HARBOR_ADMIN} project${d}/${image}:${tag1} artifact create
# Enable Skip Audit Log Database
Enable Skip Audit Log Database
Go Into Project project${d}
Go Into Repo ${image}
Go Into Artifact ${tag1}
# create tag
Add A New Tag ${tag2}
Switch To Logs
Verify Log ${HARBOR_ADMIN} project${d}/${image}:${tag1} artifact create
Verify Log In File ${HARBOR_ADMIN} project${d}/${image}:${tag2} artifact create
Set Audit Log Forward ${null} Configuration has been successfully saved.
Retry Wait Element Should Be Disabled ${skip_audit_log_database_checkbox}
Checkbox Should Not Be Selected ${skip_audit_log_database_checkbox}
Go Into Project project${d}
Go Into Repo ${image}
Go Into Artifact ${tag1}
# delete tag
Delete A Tag ${tag2}
Switch To Logs
Verify Log ${HARBOR_ADMIN} project${d}/${image}:${tag2} tag delete
Verify Log In File ${HARBOR_ADMIN} project${d}/${image}:${tag2} artifact create
Close Browser