[cherry-pick]Update Robot Account Test Case (#19711)

Update Robot Account Test Case

Update project and system robot account testcase
Update system robot account do replication testcase

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
Yang Jiao 2023-12-14 11:26:30 +08:00 committed by GitHub
parent ee793bf25b
commit 4f19f84dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 177 additions and 73 deletions

View File

@ -192,12 +192,12 @@ if "tag-retention" in resources or "all" == resources:
create_tag_retention_rule = Permission("{}/retentions".format(harbor_base_url), "POST", 201, tag_retention_rule_payload, "id", id_from_header=True)
read_tag_retention = Permission("{}/retentions/{}".format(harbor_base_url, ID_PLACEHOLDER), "GET", 200, tag_retention_rule_payload, payload_id_field="id")
update_tag_retention = Permission("{}/retentions/{}".format(harbor_base_url, ID_PLACEHOLDER), "PUT", 200, tag_retention_rule_payload, payload_id_field="id")
execute_tag_retention = Permission("{}/retentions/888/executions".format(harbor_base_url), "POST", 400, tag_retention_rule_payload, payload_id_field="id")
execute_tag_retention = Permission("{}/retentions/88888888/executions".format(harbor_base_url), "POST", 400, tag_retention_rule_payload, payload_id_field="id")
list_tag_retention_execution = Permission("{}/retentions/{}/executions".format(harbor_base_url, ID_PLACEHOLDER), "GET", 200, tag_retention_rule_payload, payload_id_field="id")
tag_retention_rule_payload["action"] = "stop"
stop_tag_retention = Permission("{}/retentions/{}/executions/888".format(harbor_base_url, ID_PLACEHOLDER), "PATCH", 404, tag_retention_rule_payload, payload_id_field="id")
list_tag_retention_tasks = Permission("{}/retentions/{}/executions/888/tasks".format(harbor_base_url, ID_PLACEHOLDER), "GET", 404, tag_retention_rule_payload, payload_id_field="id")
read_tag_retention_tasks = Permission("{}/retentions/{}/executions/888/tasks/888".format(harbor_base_url, ID_PLACEHOLDER), "GET", 404, tag_retention_rule_payload, payload_id_field="id")
stop_tag_retention = Permission("{}/retentions/{}/executions/88888888".format(harbor_base_url, ID_PLACEHOLDER), "PATCH", 404, tag_retention_rule_payload, payload_id_field="id")
list_tag_retention_tasks = Permission("{}/retentions/{}/executions/88888888/tasks".format(harbor_base_url, ID_PLACEHOLDER), "GET", 404, tag_retention_rule_payload, payload_id_field="id")
read_tag_retention_tasks = Permission("{}/retentions/{}/executions/88888888/tasks/88888888".format(harbor_base_url, ID_PLACEHOLDER), "GET", 404, tag_retention_rule_payload, payload_id_field="id")
delete_tag_retention = Permission("{}/retentions/{}".format(harbor_base_url, ID_PLACEHOLDER), "DELETE", 200, tag_retention_rule_payload, payload_id_field="id")
# 16. Resource log actions: ['list']
@ -226,8 +226,8 @@ list_webhook = Permission("{}/projects/{}/webhook/policies".format(harbor_base_u
read_webhook = Permission("{}/projects/{}/webhook/policies/{}".format(harbor_base_url, project_id, ID_PLACEHOLDER), "GET", 200, webhook_payload, payload_id_field="id")
update_webhook = Permission("{}/projects/{}/webhook/policies/{}".format(harbor_base_url, project_id, ID_PLACEHOLDER), "PUT", 200, webhook_payload, payload_id_field="id")
list_webhook_executions = Permission("{}/projects/{}/webhook/policies/{}/executions".format(harbor_base_url, project_id, ID_PLACEHOLDER), "GET", 200, webhook_payload, payload_id_field="id")
list_webhook_executions_tasks = Permission("{}/projects/{}/webhook/policies/{}/executions/888/tasks".format(harbor_base_url, project_id, ID_PLACEHOLDER), "GET", 404, webhook_payload, payload_id_field="id")
read_webhook_executions_tasks = Permission("{}/projects/{}/webhook/policies/{}/executions/888/tasks/888/log".format(harbor_base_url, project_id, ID_PLACEHOLDER), "GET", 404, webhook_payload, payload_id_field="id")
list_webhook_executions_tasks = Permission("{}/projects/{}/webhook/policies/{}/executions/88888888/tasks".format(harbor_base_url, project_id, ID_PLACEHOLDER), "GET", 404, webhook_payload, payload_id_field="id")
read_webhook_executions_tasks = Permission("{}/projects/{}/webhook/policies/{}/executions/88888888/tasks/88888888/log".format(harbor_base_url, project_id, ID_PLACEHOLDER), "GET", 404, webhook_payload, payload_id_field="id")
list_webhook_events = Permission("{}/projects/{}/webhook/events".format(harbor_base_url, project_id), "GET", 200)
delete_webhook = Permission("{}/projects/{}/webhook/policies/{}".format(harbor_base_url, project_id, ID_PLACEHOLDER), "DELETE", 200, webhook_payload, payload_id_field="id")

View File

@ -288,6 +288,47 @@ list_vul = Permission("{}/security/vul".format(harbor_base_url), "GET", 200)
read_catalog = Permission("{}/v2/_catalog".format(endpoint_URL), "GET", 200)
# catalog permissions end
# garbage-collection permissions start
gc_payload = {
"parameters": {
"delete_untagged": True,
"workers": 1,
"dry_run": True
},
"schedule": {
"type": "Manual"
}
}
create_gc = Permission("{}/system/gc/schedule".format(harbor_base_url), "POST", 201, gc_payload, "id", id_from_header=True)
list_gc = Permission("{}/system/gc".format(harbor_base_url), "GET", 200)
read_gc = Permission("{}/system/gc/{}".format(harbor_base_url, ID_PLACEHOLDER), "GET", 200, payload=gc_payload, payload_id_field="id")
stop_gc = Permission("{}/system/gc/{}".format(harbor_base_url, ID_PLACEHOLDER), "PUT", 200, payload=gc_payload, payload_id_field="id")
read_gc_log = Permission("{}/system/gc/{}/log".format(harbor_base_url, "88888888"), "GET", 404)
read_gc_schedule = Permission("{}/system/gc/schedule".format(harbor_base_url), "GET", 200)
update_gc_schedule = Permission("{}/system/gc/schedule".format(harbor_base_url), "PUT", 200, gc_payload)
# garbage-collection permissions end
# purge-audit permissions start
purge_audit_payload = {
"parameters": {
"audit_retention_hour": 24,
"include_operations": "create,delete,pull",
"dry_run": True
},
"schedule": {
"type": "Manual"
}
}
create_purge_audit = Permission("{}/system/purgeaudit/schedule".format(harbor_base_url), "POST", 201, purge_audit_payload, "id", id_from_header=True)
list_purge_audit = Permission("{}/system/purgeaudit".format(harbor_base_url), "GET", 200)
read_purge_audit = Permission("{}/system/purgeaudit/{}".format(harbor_base_url, ID_PLACEHOLDER), "GET", 200, payload=purge_audit_payload, payload_id_field="id")
stop_purge_audit = Permission("{}/system/purgeaudit/{}".format(harbor_base_url, ID_PLACEHOLDER), "PUT", 200, payload=purge_audit_payload, payload_id_field="id")
read_purge_audit_log = Permission("{}/system/purgeaudit/{}/log".format(harbor_base_url, "88888888"), "GET", 404)
read_purge_audit_schedule = Permission("{}/system/purgeaudit/schedule".format(harbor_base_url), "GET", 200)
update_purge_audit_schedule = Permission("{}/system/purgeaudit/schedule".format(harbor_base_url), "PUT", 200, purge_audit_payload)
# purge-audit permissions end
resource_permissions = {
"audit-log": [list_audit_logs],
"preheat-instance": [create_preheat_instance, list_preheat_instance, read_preheat_instance, update_preheat_instance, delete_preheat_instance],
@ -302,7 +343,9 @@ resource_permissions = {
"scanner": [list_scanner, create_scanner, ping_scanner, read_scanner, update_scanner, delete_scanner, set_default_scanner, get_scanner_metadata],
"label": [create_label, read_label, update_label, delete_label],
"security-hub": [read_summary, list_vul],
"catalog": [read_catalog]
"catalog": [read_catalog],
"garbage-collection": [create_gc, list_gc, read_gc, stop_gc, read_gc_log, read_gc_schedule, update_gc_schedule],
"purge-audit": [create_purge_audit, list_purge_audit, read_purge_audit, stop_purge_audit, read_purge_audit_log, read_purge_audit_schedule, update_purge_audit_schedule]
}
resource_permissions["all"] = [item for sublist in resource_permissions.values() for item in sublist]

View File

@ -10,16 +10,56 @@ Switch To Project Robot Account
Retry Element Click ${project_robot_account_tabpage}
Retry Wait Until Page Contains Element ${project_robot_account_create_btn}
Create A Robot Account And Return Token
[Arguments] ${projectname} ${robot_account_name} ${project_has_image}=${false}
Go Into Project ${projectname} has_image=${project_has_image}
Switch To Project Robot Account
Retry Element Click ${project_robot_account_create_btn}
Retry Text Input ${project_robot_account_create_name_input} ${robot_account_name}
Retry Element Click xpath=//select[@id='expiration-type']
Retry Element Click xpath=//select[@id='expiration-type']//option[@value='never']
Retry Double Keywords When Error Retry Element Click ${project_robot_account_create_save_btn} Retry Wait Until Page Not Contains Element ${project_robot_account_create_save_btn}
${token}= Get Value ${project_robot_account_token_input}
[Return] ${token}
Create A Project Robot Account
[Arguments] ${robot_account_name} ${expiration_type} ${description}=${null} ${days}=${null} ${resources}=${null}
Retry Element Click ${project_robot_account_create_btn}
Retry Wait Element Should Be Disabled //button[text()='Next']
Retry Text Input ${project_robot_account_create_name_input} ${robot_account_name}
Run Keyword If '${description}' != '${null}' Retry Text Input //textarea ${description}
Select From List By Value ${project_robot_account_create_sexpiration_type_btn} ${expiration_type}
Run Keyword If '${expiration_type}' == 'days' Retry Text Input ${project_robot_account_token_expiration_days} ${days}
Retry Double Keywords When Error Retry Button Click //button[text()='Next'] Retry Wait Element Not Visible //button[text()='Next']
Retry Wait Element Should Be Disabled ${project_robot_account_create_finish_btn}
${first_resource}= Set Variable ${resources}[0]
${permission_count}= Create Dictionary
${total}= Set Variable 0
IF '${first_resource}' == 'all'
Set To Dictionary ${permission_count} all=55
${total}= Set Variable 55
Retry Element Click //span[text()='Select all']
ELSE
FOR ${item} IN @{resources}
${elements}= Get WebElements //table//tr[./td[text()='${item}']]//label
${elements_count}= Get Length ${elements}
Set To Dictionary ${permission_count} ${item}=${elements_count}
${total}= Evaluate ${total} + ${elements_count}
FOR ${element} IN @{elements}
Retry Element Click ${element}
END
END
END
Retry Double Keywords When Error Retry Element Click ${project_robot_account_create_finish_btn} Retry Wait Until Page Not Contains Element ${project_robot_account_create_finish_btn}
${robot_account_name}= Get Text ${project_robot_account_name_xpath}
${token}= Get Value ${project_robot_account_token_input}
Retry Element Click //hbr-copy-input//clr-icon
IF '${days}' == '${null}'
${expires}= Set Variable Never Expires
ELSE
${days}= Evaluate ${days} - 1
${expires}= Set Variable ${days}d 23h
END
Retry Wait Element Visible //clr-dg-row[.//clr-dg-cell[contains(.,'${robot_account_name}')] and .//clr-icon[contains(@class, 'color-green')] and .//button[text()=' ${total} PERMISSION(S) '] and .//span[contains(.,'${expires}')] and .//clr-dg-cell[text()='${description}'] ]
[Return] ${robot_account_name} ${token} ${permission_count}
Check Project Robot Account Permission
[Arguments] ${robot_account_name} ${permission_count}
Retry Button Click //clr-dg-row[.//clr-dg-cell[contains(., '${robot_account_name}')]]//button
FOR ${key} IN @{permission_count.keys()}
Retry Wait Element Count //table//tr[./td[text()=' ${key} ']]//label ${permission_count['${key}']}
END
Retry Double Keywords When Error Retry Button Click //button[@aria-label='Close'] Retry Wait Until Page Not Contains Element //button[@aria-label='Close']
Check Project Robot Account API Permission
[Arguments] ${robot_account_name} ${token} ${admin_user_name} ${admin_password} ${project_id} ${project_name} ${source_artifact_name} ${source_artifact_tag} ${resources} ${expected_status}=0
${rc} ${output}= Run And Return Rc And Output USER_NAME='${robot_account_name}' PASSWORD='${token}' ADMIN_USER_NAME=${admin_user_name} ADMIN_PASSWORD=${admin_password} HARBOR_BASE_URL=https://${ip}/api/v2.0 PROJECT_ID=${project_id} PROJECT_NAME=${project_name} SOURCE_ARTIFACT_NAME=${source_artifact_name} SOURCE_ARTIFACT_TAG=${source_artifact_tag} RESOURCES=${resources} python ./tests/apitests/python/test_project_permission.py
Should Be Equal As Integers ${rc} ${expected_status}

View File

@ -5,5 +5,8 @@ Documentation This resource provides any keywords related to the Harbor robot-a
${project_robot_account_tabpage} xpath=//project-detail//a[contains(.,'Robot Accounts')]
${project_robot_account_create_btn} xpath=//project-detail/app-robot-account//button
${project_robot_account_token_input} xpath=//app-robot-account//hbr-copy-input//input
${project_robot_account_name_xpath} //view-token//div[contains(@class,'robot-name')]//span
${project_robot_account_create_name_input} //input[@id='name']
${project_robot_account_create_save_btn} //button[@id='system-robot-save']
${project_robot_account_create_finish_btn} //button[text()='Finish']
${project_robot_account_create_sexpiration_type_btn} //select[@id='expiration-type']
${project_robot_account_token_expiration_days} //*[@id='robotTokenExpiration']

View File

@ -86,40 +86,29 @@ Select Project Permission
Capture Page Screenshot
END
Create A New System Robot Account
[Arguments] ${name}=${null} ${expiration_type}=default ${expiration_value}=${null} ${description}=${null} ${is_cover_all}=${false} ${cover_all_permission_list}=@{EMPTY} ${project_permission_list}=@{EMPTY}
${d}= Get Current Date result_format=%m%s
${name}= Set Variable If '${name}'=='${null}' robot_name${d} ${name}
Switch To Robot Account
Retry Double Keywords When Error Retry Element Click ${new_sys_robot_account_btn} Retry Wait Until Page Contains Element ${sys_robot_account_name_input}
Retry Text Input ${sys_robot_account_name_input} ${name}
Run Keyword If '${expiration_type}' != 'default' Run Keywords Retry Element Click xpath=${sys_robot_account_expiration_type_select} AND
... Retry Element Click xpath=${sys_robot_account_expiration_type_select}//option[@value='${expiration_type}']
Create A System Robot Account
[Arguments] ${robot_account_name} ${expiration_type} ${description}=${null} ${days}=${null} ${cover_all_system_resources}=${null} ${cover_all_project_resources}=${null}
Retry Element Click ${new_sys_robot_account_btn}
Retry Wait Element Should Be Disabled //button[text()='Next']
Retry Text Input ${sys_robot_account_name_input} ${robot_account_name}
Run Keyword If '${description}' != '${null}' Retry Text Input ${sys_robot_account_description_textarea} ${description}
Run Keyword If '${is_cover_all}' == '${true}' Retry Double Keywords When Error Retry Element Click ${sys_robot_account_coverall_chb} Retry Checkbox Should Be Selected ${sys_robot_account_coverall_chb_input}
... ELSE Clear Global Permissions By JavaScript
Select From List By Value ${sys_robot_account_expiration_type_select} ${expiration_type}
Run Keyword If '${expiration_type}' == 'days' Retry Text Input ${sys_robot_account_expiration_input} ${days}
Retry Button Click //button[text()='Next']
Retry Wait Element Should Be Disabled ${project_robot_account_create_finish_btn}
Run Keyword If '${cover_all_system_resources}' == '${true}' Retry Element Click //*[@id='clr-wizard-page-1']//span[text()='Select all']
Retry Double Keywords When Error Retry Button Click //button[text()='Next'] Retry Wait Element Not Visible //button[text()='Next']
Run Keyword If '${cover_all_project_resources}' == '${true}' Run Keywords Retry Element Click ${sys_robot_account_coverall_chb} AND Retry Element Click //*[@id='clr-wizard-page-2']//span[text()='Select all']
Retry Double Keywords When Error Retry Element Click ${project_robot_account_create_finish_btn} Retry Wait Element Not Visible ${project_robot_account_create_finish_btn}
${robot_account_name}= Get Text ${project_robot_account_name_xpath}
${token}= Get Value //hbr-copy-input//input
Retry Element Click //hbr-copy-input//clr-icon
[Return] ${robot_account_name} ${token}
# Select project
FOR ${project} IN @{project_permission_list}
Log To Console project: ${project}
Should Be True type($project) is not dict
${tmp} = Convert To Dictionary ${project}
Should Be True type($tmp) is dict
${project_name}= Get From Dictionary ${tmp} project_name
Log To Console project_name: ${project_name}
${permission_item_list}= Get From Dictionary ${tmp} permission_item_list
Log To Console permission_item_list: ${permission_item_list}
Filter Project In Project Permisstion List ${project_name}
Retry Element Click //clr-dg-row[contains(.,'${project_name}')]//div[contains(@class,'clr-checkbox-wrapper')]/label[contains(@class,'clr-control-label')]
Retry Element Click //clr-dg-row[contains(., '${project_name}')]//clr-dropdown/button
Select Project Permission ${project_name} ${permission_item_list}
END
# Save it
Retry Double Keywords When Error Retry Element Click ${save_sys_robot_account_btn} Retry Wait Until Page Not Contains Element ${save_sys_robot_account_btn}
Retry Double Keywords When Error Retry Element Click ${save_sys_robot_export_to_file_btn} Retry Wait Until Page Not Contains Element ${save_sys_robot_export_to_file_btn}
# Get Robot Account Info
${id} ${name} ${secret} ${creation_time} ${expires_at}= Get Robot Account Info By File ${download_directory}/robot$${name}.json
[Return] ${name} ${secret}
Check System Robot Account API Permission
[Arguments] ${robot_account_name} ${token} ${admin_user_name} ${admin_password} ${resources} ${expected_status}=0
${rc} ${output}= Run And Return Rc And Output USER_NAME='${robot_account_name}' PASSWORD='${token}' ADMIN_USER_NAME=${admin_user_name} ADMIN_PASSWORD=${admin_password} HARBOR_BASE_URL=https://${ip}/api/v2.0 RESOURCES=${resources} python ./tests/apitests/python/test_system_permission.py
Should Be Equal As Integers ${rc} ${expected_status}
System Robot Account Exist
[Arguments] ${name} ${project_count}

View File

@ -21,7 +21,7 @@ ${sys_robot_account_name_input} //*[@id='name']
${sys_robot_account_expiration_type_select} //*[@id='expiration-type']
${sys_robot_account_expiration_input} //*[@id='robotTokenExpiration']
${sys_robot_account_description_textarea} //*[@id='description']
${sys_robot_account_coverall_chb_input} xpath=//input[@id='coverAll']
${sys_robot_account_coverall_chb_input} //input[@id='coverAll']
${sys_robot_account_coverall_chb} //clr-checkbox-wrapper[contains(@class, 'clr-checkbox-wrapper')]/label[contains(@class,'clr-control-label') and contains(@for, 'coverAll')]
${sys_robot_account_permission_list_btn} //form/section//clr-dropdown/button
${save_sys_robot_account_btn} //*[@id='system-robot-save']

View File

@ -621,17 +621,27 @@ Test Case - Tag Immutability
Delete Success busybox
Close Browser
Test Case - Robot Account
[tags] robot_account
Test Case - Project Level Robot Account
[tags] project_robot
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
${token}= Create A Robot Account And Return Token project${d} robot${d}
Log To Console ${token}
Log ${token}
Push image ${ip} robot${d} ${token} project${d} hello-world:latest is_robot=${true}
Pull image ${ip} robot${d} ${token} project${d} hello-world:latest is_robot=${true}
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
${current_url}= Get Location
${words}= Split String ${current_url} /
${project_id}= Set Variable ${words}[-2]
Switch To Project Robot Account
${resources}= Create List Repository
${robot_account_name} ${token} ${permission_count}= Create A Project Robot Account robot1${d} never description=For testing resources=${resources}
Push image ${ip} robot1${d} ${token} project${d} hello-world:latest is_robot=${true}
Pull image ${ip} robot1${d} ${token} project${d} hello-world:latest is_robot=${true}
Check Project Robot Account Permission robot1${d} ${permission_count}
Check Project Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project_id} project${d} hello-world latest repository
Check System Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} all 1
${resources}= Create List all
${robot_account_name} ${token} ${permission_count}= Create A Project Robot Account robot2${d} days days=10 description=For testing resources=${resources}
Check Project Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project_id} project${d} hello-world latest all
Check System Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} all 1
Close Browser
Test Case - Push Docker Manifest Index and Display
@ -700,26 +710,44 @@ Test Case - Read Only Mode
Test Case - System Robot Account Cover All Projects
[Tags] sys_robot_account_cover
${d}= Get Current Date result_format=%m%s
${pro_name}= Set Variable project_${d}
${project_name}= Set Variable project${d}
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project ${pro_name}
${name} ${secret}= Create A New System Robot Account is_cover_all=${true}
Navigate To Projects
Create An New Project And Go Into Project ${project_name}
${current_url}= Get Location
${words}= Split String ${current_url} /
${project_id}= Set Variable ${words}[-2]
Switch To Robot Account
System Robot Account Exist ${name} all
${robot_account_name} ${token}= Create A System Robot Account sys${d} never description=For testing cover_all_system_resources=${true} cover_all_project_resources=${true}
Push image ${ip} '${robot_account_name}' ${token} project${d} hello-world:latest
Pull image ${ip} '${robot_account_name}' ${token} project${d} hello-world:latest
Check System Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} all
Check Project Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project_id} ${project_name} hello-world latest all
Retry Wait Element Visible //clr-dg-row[.//clr-dg-cell[contains(.,'${robot_account_name}')] and .//clr-icon[contains(@class, 'color-green')] and .//button[text()=' 51 PERMISSION(S) '] and .//span[contains(.,'Never Expires')] and .//clr-dg-cell[text()='For testing'] ]
System Robot Account Exist ${robot_account_name} all
Close Browser
Test Case - System Robot Account
[Tags] sys_robot_account
${d}= Get Current Date result_format=%m%s
${project_count}= Evaluate random.randint(3, 5)
${pro_name}= Set Variable project_${d}
${project_name}= Set Variable project${d}
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
${project_permission_list}= Create A Random Project Permission List ${project_count}
${name} ${secret}= Create A New System Robot Account project_permission_list=${project_permission_list}
System Robot Account Exist ${name} ${project_count}
Create An New Project And Go Into Project ${project_name}
${current_url}= Get Location
${words}= Split String ${current_url} /
${project_id}= Set Variable ${words}[-2]
Switch To Robot Account
${robot_account_name} ${token}= Create A System Robot Account sys1${d} days days=100 description=For testing cover_all_system_resources=${true}
Retry Wait Element Visible //clr-dg-row[.//clr-dg-cell[contains(.,'${robot_account_name}')] and .//clr-icon[contains(@class, 'color-green')] and .//button[text()=' 51 PERMISSION(S) '] and .//span[contains(.,'99d 23h')] and .//clr-dg-cell[text()='For testing'] and .//clr-dg-cell//span[text()=' None ']]
Check System Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} all
Check Project Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project_id} ${project_name} hello-world latest all 1
${robot_account_name} ${token}= Create A System Robot Account sys2${d} days days=2 description=For testing cover_all_project_resources=${true}
Push image ${ip} '${robot_account_name}' ${token} project${d} hello-world:latest
Retry Wait Element Visible //clr-dg-row[.//clr-dg-cell[contains(.,'${robot_account_name}')] and .//clr-icon[contains(@class, 'color-green')] and .//span[text()='All projects with'] and .//button[text()=' 55 PERMISSION(S) '] and .//span[contains(.,'1d 23h')] and .//clr-dg-cell[text()='For testing'] and .//clr-dg-cell//span[text()=' None ']]
Check System Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} all 1
Check Project Robot Account API Permission ${robot_account_name} ${token} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project_id} ${project_name} hello-world latest all
Close Browser
Test Case - Go To Harbor Api Page

View File

@ -363,7 +363,8 @@ Test Case - Robot Account Do Replication
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project_dest${d}
# create system Robot Account
${robot_account_name} ${robot_account_secret}= Create A New System Robot Account is_cover_all=${true}
Switch To Robot Account
${robot_account_name} ${robot_account_secret}= Create A System Robot Account replication${d} days days=2 description=For testing cover_all_project_resources=${true}
# logout and login source
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}