Update xpath for some UI components (#21817)

Update testcase for audit log enhancement
    Add e2e_setup for e2e testcases

Signed-off-by: stonezdj <stone.zhang@broadcom.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2025-04-02 17:12:22 +08:00 committed by GitHub
parent 280ab5a027
commit b60bd1a69b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 237 additions and 53 deletions

1
.gitignore vendored
View File

@ -50,6 +50,7 @@ src/portal/cypress/screenshots
**/aot **/aot
**/dist **/dist
**/.bin **/.bin
**/robotvars.py
src/core/conf/app.conf src/core/conf/app.conf
src/server/v2.0/models/ src/server/v2.0/models/

View File

@ -9,12 +9,12 @@ class Audit_Log(base.Base):
def __init__(self): def __init__(self):
super(Audit_Log, self).__init__(api_type="audit_log") super(Audit_Log, self).__init__(api_type="audit_log")
def get_latest_audit_log(self): def get_latest_audit_log_ext(self):
return self.list_audit_logs(sort="-creation_time", page_size=1, page=1)[0] return self.list_auditlog_ext(sort="-creation_time", page_size=1, page=1)[0]
def list_audit_logs(self, sort, page_size, page, expect_status_code=200, expect_response_body=None, **kwargs): def list_auditlog_ext(self, sort, page_size, page, expect_status_code=200, expect_response_body=None, **kwargs):
try: try:
return_data, status_code, _ = self._get_client(**kwargs).list_audit_logs_with_http_info(sort=sort, page_size=page_size, page=page) return_data, status_code, _ = self._get_client(**kwargs).list_audit_log_exts_with_http_info(sort=sort, page_size=page_size, page=page)
except ApiException as e: except ApiException as e:
base._assert_status_code(expect_status_code, e.status) base._assert_status_code(expect_status_code, e.status)
if expect_response_body is not None: if expect_response_body is not None:

View File

@ -80,7 +80,7 @@ class TestAuditLogForword(unittest.TestCase, object):
repo_name, tag = push_self_build_image_to_project(project_name, harbor_server, user_name, user_password, self.image, self.tag) repo_name, tag = push_self_build_image_to_project(project_name, harbor_server, user_name, user_password, self.image, self.tag)
# 6. Verify that the Audit Log should be in the log database # 6. Verify that the Audit Log should be in the log database
first_audit_log = self.audit_log.get_latest_audit_log() first_audit_log = self.audit_log.get_latest_audit_log_ext()
self.assertEqual(first_audit_log.operation, "create") self.assertEqual(first_audit_log.operation, "create")
self.assertEqual(first_audit_log.resource, "{}:{}".format(repo_name, tag)) self.assertEqual(first_audit_log.resource, "{}:{}".format(repo_name, tag))
self.assertEqual(first_audit_log.resource_type, "artifact") self.assertEqual(first_audit_log.resource_type, "artifact")
@ -101,7 +101,7 @@ class TestAuditLogForword(unittest.TestCase, object):
self.artifact.create_tag(project_name, self.image, self.tag, self.tag2, **user_client) self.artifact.create_tag(project_name, self.image, self.tag, self.tag2, **user_client)
# 10. Verify that the Audit Log should not be in log database # 10. Verify that the Audit Log should not be in log database
second_audit_log = self.audit_log.get_latest_audit_log() second_audit_log = self.audit_log.get_latest_audit_log_ext()
self.assertEqual(first_audit_log.operation, second_audit_log.operation) self.assertEqual(first_audit_log.operation, second_audit_log.operation)
self.assertEqual(first_audit_log.resource, second_audit_log.resource) self.assertEqual(first_audit_log.resource, second_audit_log.resource)
self.assertEqual(first_audit_log.resource_type,second_audit_log.resource_type) self.assertEqual(first_audit_log.resource_type,second_audit_log.resource_type)

61
tests/e2e_setup/README.md Normal file
View File

@ -0,0 +1,61 @@
## Guide to Harbor E2E testing
### Prerequisites
In order to run e2e testing, you need to install the following tools:
1. Elastic search -- required ES_ENDPOINT
2. Dex -- OIDC testing environment -- required by OIDC login testcase, if not used, just ignore it.
3. LDAP server -- required by LDAP login testcase. if not used, just ignore it.
4. Webhook Server -- required by webhook testcase. WEBHOOK_ENDPOINT
5. Dragonfly -- Required by p2p preheat testcase, DISTRIBUTION_ENDPOINT, DRAGONFLY_AUTH_TOKEN
6. Fake Scanner -- required by scanner testcase, SCANNER_ENDPOINT
7. Install Harbor, need to installed with https enabled. the root ca should be the root ca in harbor repository: https://github.com/goharbor/harbor/blob/main/tests/harbor_ca.crt
#### 1. Git clone the following repositories:
```
git clone https://github.com/goharbor/harbor
```
#### 2. Update the tests/e2e_setup/robotvars.py in e2e_setup, update the environment variable with the prerequest env settings. change the ip to the IP address of the harbor instance
```
cd tests/e2e_setup
cp robotvars.sample.py robotvars.py
# update the environment variable in robotvars.py
```
#### 3. Start e2e container
```
./e2e_container.sh
```
#### 4. Run setup, in the previous container console, run the following command.
```
robot -V /drone/tests/e2e_setup/robotvars.py /drone/tests/robot-cases/Group1-Nightly/Setup_Nightly.robot
```
#### 5. Run robot test
After setup you can select to run single test or full test
##### 5.1 Run single test
```
robot --include sbom_manual_gen -V /drone/tests/e2e_setup/robotvars.py /drone/tests/robot-cases/Group1-Nightly/Trivy.robot
```
##### 5.2 Run full test
```
robot -V /drone/tests/e2e_setup/robotvars.py /drone/tests/robot-cases/Group1-Nightly/Setup_Nightly.robot /drone/tests/robot-cases/Group1-Nightly/Common_GC.robot /drone/tests/robot-cases/Group1-Nightly/Webhook.robot /drone/tests/robot-cases/Group1-Nightly/Routing.robot /drone/tests/robot-cases/Group1-Nightly/P2P_Preheat.robot /drone/tests/robot-cases/Group1-Nightly/Trivy.robot /drone/tests/robot-cases/Group1-Nightly/DB.robot /drone/tests/robot-cases/Group1-Nightly/Common.robot /drone/tests/robot-cases/Group1-Nightly/Teardown.robot
```
#### 6. Check report in the harbor source code directory.
After the test complete, check the test report in the harbor source code directory.

View File

@ -0,0 +1,7 @@
#!/bin/bash
HARBOR_SRC_FOLDER=$(realpath ../../)
echo ${HARBOR_SRC_FOLDER}
docker run -it --privileged -v /var/log/harbor:/var/log/harbor -v /etc/hosts:/etc/hosts -v ${HARBOR_SRC_FOLDER}:/drone -v ${HARBOR_SRC_FOLDER}/tests/harbor_ca.crt:/ca/ca.crt -v /dev/shm:/dev/shm -w /drone registry.goharbor.io/harbor-ci/goharbor/harbor-e2e-engine:latest-ui /bin/bash

View File

@ -0,0 +1,17 @@
# all value should be string
SCANNER_ENDPOINT = "http://<scanner_ip>:8081"
ES_ENDPOINT = "<elastic_search_ip>:9200"
WEBHOOK_ENDPOINT = "<webhook_server_ip>:8084"
DISTRIBUTION_ENDPOINT = "http://<dragonfly_server_ip>:8080"
DOCKER_USER = "<docker_user_name>"
DOCKER_PWD = "<docker_password>"
DRAGONFLY_AUTH_TOKEN = "<dragonfly_auth_token>"
ip = "<harbor ip address or fqdn>"
# fixed value, do not change
LOCAL_REGISTRY = "registry.goharbor.io"
LOCAL_REGISTRY_NAMESPACE = "harbor-ci"
HARBOR_PASSWORD = "Harbor12345"
OIDC_HOSTNAME = "nightly-oidc.harbor.io"
http_get_ca = "true"
ip1 = ""

View File

@ -184,8 +184,6 @@ Prepare Docker Cert In Ubuntu
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip} Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /etc/docker/certs.d/${ip} Wait Unitl Command Success cp ${cert} /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /usr/local/share/ca-certificates/ Wait Unitl Command Success cp ${cert} /usr/local/share/ca-certificates/
#Add pivotal ecs cert for docker manifest push test.
Wait Unitl Command Success cp /ecs_ca/vmwarecert.crt /usr/local/share/ca-certificates/
Wait Unitl Command Success update-ca-certificates Wait Unitl Command Success update-ca-certificates
Prepare Docker Cert In Photon Prepare Docker Cert In Photon

View File

@ -69,7 +69,7 @@ ${retain_image_last_pull_time_label} //clr-checkbox-wrapper//label[contains(@cl
${retain_image_last_pull_time_checkbox} //*[@id='scannerSkipUpdatePullTime'] ${retain_image_last_pull_time_checkbox} //*[@id='scannerSkipUpdatePullTime']
${banner_message_input_id} //*[@id='banner-message'] ${banner_message_input_id} //*[@id='banner-message']
${banner_message_type_select_id} //*[@id='banner-message-type'] ${banner_message_type_select_id} //*[@id='banner-message-type']
${banner_message_closable_checkbox} //div[contains(@class,'clr-checkbox-wrapper')]//label[contains(@class,'clr-control-label')] ${banner_message_closable_checkbox} //div[contains(@class,'clr-checkbox-wrapper')]//label[contains(@class,'clr-control-label') and contains(@for, 'banner-message-closable')]
${banner_message_from_date} (//clr-date-container)[1]//button ${banner_message_from_date} (//clr-date-container)[1]//button
${banner_message_to_date} (//clr-date-container)[2]//button ${banner_message_to_date} (//clr-date-container)[2]//button
${banner_message_date_next_month} //button[@aria-label='Next month'] ${banner_message_date_next_month} //button[@aria-label='Next month']

View File

@ -31,7 +31,7 @@ Set LDAP Group Admin DN
Retry Element Click ${config_auth_save_button_xpath} Retry Element Click ${config_auth_save_button_xpath}
Ldap User Should Not See Change Password Ldap User Should Not See Change Password
Retry Element Click //clr-header//clr-dropdown[2]//button Retry Element Click //clr-header//clr-dropdown//button
Sleep 2 Sleep 2
Page Should Not Contain Password Page Should Not Contain Password

View File

@ -24,6 +24,9 @@ Purge Now
[Arguments] ${keep_records} ${keep_records_unit} ${expected_status}=SUCCESS ${exclude_operations}=@{EMPTY} [Arguments] ${keep_records} ${keep_records_unit} ${expected_status}=SUCCESS ${exclude_operations}=@{EMPTY}
Retry Text Input ${keep_records_input} ${keep_records} Retry Text Input ${keep_records_input} ${keep_records}
Retry Double Keywords When Error Retry Element Click ${keep_records_unit_select} Retry Element Click ${keep_records_unit_select}//option[contains(.,'${keep_records_unit}')] Retry Double Keywords When Error Retry Element Click ${keep_records_unit_select} Retry Element Click ${keep_records_unit_select}//option[contains(.,'${keep_records_unit}')]
Retry Element Click ${include_event_type_create_artifact}
Retry Element Click ${include_event_type_pull_artifact}
Retry Element Click ${include_event_type_delete_artifact}
${len}= Get Length ${exclude_operations} ${len}= Get Length ${exclude_operations}
Run Keyword If ${len} > 0 Click Exclude Operation @{exclude_operations} Run Keyword If ${len} > 0 Click Exclude Operation @{exclude_operations}
Retry Double Keywords When Error Retry Button Click ${purge_now_btn} Retry Wait Until Page Contains Element ${latest_purge_job_status_xpath}\[contains(.,'${expected_status}')] Retry Double Keywords When Error Retry Button Click ${purge_now_btn} Retry Wait Until Page Contains Element ${latest_purge_job_status_xpath}\[contains(.,'${expected_status}')]

View File

@ -19,6 +19,9 @@ Documentation This resource provides any keywords related to the Harbor private
${log_rotation_page_xpath} //app-clearing-job//nav//a[contains(.,'Log Rotation')] ${log_rotation_page_xpath} //app-clearing-job//nav//a[contains(.,'Log Rotation')]
${keep_records_input} //*[@id='retentionTime'] ${keep_records_input} //*[@id='retentionTime']
${keep_records_unit_select} //*[@id='expiration-type'] ${keep_records_unit_select} //*[@id='expiration-type']
${include_event_type_create_artifact} //*[@for='create_artifact']
${include_event_type_pull_artifact} //*[@for='pull_artifact']
${include_event_type_delete_artifact} //*[@for='delete_artifact']
${latest_purge_job_status_xpath} //app-purge-history//div//clr-dg-row[1]//clr-dg-cell[4] ${latest_purge_job_status_xpath} //app-purge-history//div//clr-dg-row[1]//clr-dg-cell[4]
${latest_purge_job_update_time_xpath} //app-purge-history//div//clr-dg-row[1]//clr-dg-cell[6] ${latest_purge_job_update_time_xpath} //app-purge-history//div//clr-dg-row[1]//clr-dg-cell[6]
${purge_job_last_completed_time_xpath} //app-set-job//div//span[contains(@class,'mr-3')] ${purge_job_last_completed_time_xpath} //app-set-job//div//span[contains(@class,'mr-3')]

View File

@ -26,10 +26,10 @@ Refresh Logs
Verify Log Verify Log
[Arguments] ${username} ${resource} ${resource_type} ${operation} ${row_num}=1 [Arguments] ${username} ${resource} ${resource_type} ${operation} ${row_num}=1
Refresh Logs Refresh Logs
${real_username}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[1] ${real_username}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[2]
${real_resource}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[2] ${real_resource}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[3]
${real_resource_type}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[3] ${real_resource_type}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[4]
${real_operation}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[4] ${real_operation}= Get Text //clr-datagrid//clr-dg-row[${row_num}]//clr-dg-cell[5]
Should Be Equal ${real_username} ${username} Should Be Equal ${real_username} ${username}
Should Be Equal ${real_resource} ${resource} Should Be Equal ${real_resource} ${resource}
Should Be Equal ${real_resource_type} ${resource_type} Should Be Equal ${real_resource_type} ${resource_type}

View File

@ -17,4 +17,4 @@ Documentation This resource provides any keywords related to the Harbor private
*** Variables *** *** Variables ***
${logs_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,'Logs')] ${logs_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,'Logs')]
${logs_refresh_btn} //hbr-log//span[contains(@class,'refresh-btn')] ${logs_refresh_btn} //hbr-audit-log//span[contains(@class,'refresh-btn')]

View File

@ -111,7 +111,7 @@ Execute P2P Preheat
Verify Latest Execution Result Verify Latest Execution Result
[Arguments] ${project_name} ${policy_name} ${contain} ${not_contain}=${null} ${expected_status}=Success [Arguments] ${project_name} ${policy_name} ${contain} ${not_contain}=${null} ${expected_status}=Success
Retry Double Keywords When Error Select P2P Preheat Policy ${policy_name} Wait Until Element Is Visible ${p2p_preheat_executions_refresh_xpath} Retry Double Keywords When Error Select P2P Preheat Policy ${policy_name} Wait Until Element Is Visible ${p2p_preheat_executions_refresh_xpath}
Retry Keyword N Times When Error 5 Retry P2P Preheat Be Successful ${project_name} ${policy_name} ${contain} ${not_contain} Retry Keyword N Times When Error 10 Retry P2P Preheat Be Successful ${project_name} ${policy_name} ${contain} ${not_contain}
Retry P2P Preheat Be Successful Retry P2P Preheat Be Successful
[Arguments] ${project_name} ${policy_name} ${contain} ${not_contain}=${null} ${expected_status}=Success [Arguments] ${project_name} ${policy_name} ${contain} ${not_contain}=${null} ${expected_status}=Success

View File

@ -164,7 +164,7 @@ Project Should Be Deleted
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${projname}')]/../div/clr-icon[@shape='success-standard'] Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${projname}')]/../div/clr-icon[@shape='success-standard']
Advanced Search Should Display Advanced Search Should Display
Retry Wait Until Page Contains Element xpath=//audit-log//div[@class='flex-xs-middle']/button Retry Wait Until Page Contains Element xpath=//project-audit-log//button[contains(., 'Advanced')]
# it's not a common keywords, only used into log case. # it's not a common keywords, only used into log case.
Do Log Advanced Search Do Log Advanced Search
@ -173,24 +173,24 @@ Do Log Advanced Search
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'delete')] Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'delete')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'project') and contains(.,'create')] Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'project') and contains(.,'create')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'repository') and contains(.,'delete')] Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'repository') and contains(.,'delete')]
Retry Element Click xpath=//audit-log//div[@class='flex-xs-middle']/button Retry Element Click xpath=//project-audit-log//button[contains(., 'Advanced')]
Retry Element Click xpath=//project-detail//audit-log//clr-dropdown/button Retry Element Click xpath=//project-audit-log//button[contains(., 'Operations')]
#pull log #pull log
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Pull')] Retry Element Click xpath=//project-audit-log//clr-dropdown//a[contains(.,'Pull')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'pull')] Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'pull')]
#create log #create log
Retry Element Click xpath=//audit-log//clr-dropdown/button Retry Element Click xpath=//project-audit-log//button[contains(., 'Operations')]
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Create')] Retry Element Click xpath=//project-audit-log//clr-dropdown//a[contains(.,'Create')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'create')] Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'create')]
#delete log #delete log
Retry Element Click xpath=//audit-log//clr-dropdown/button Retry Element Click xpath=//project-audit-log//button[contains(., 'Operations')]
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Delete')] Retry Element Click xpath=//project-audit-log//clr-dropdown//a[contains(.,'Delete')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'delete')] Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'delete')]
#others #others
Retry Element Click xpath=//audit-log//clr-dropdown/button Retry Element Click xpath=//project-audit-log//button[contains(., 'Operations')]
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Others')] Retry Element Click xpath=//project-audit-log//clr-dropdown//a[contains(.,'Others')]
Retry Element Click xpath=//audit-log//hbr-filter//clr-icon Retry Element Click xpath=//project-audit-log//hbr-filter//clr-icon
Retry Text Input xpath=//audit-log//hbr-filter//input harbor-jobservice Retry Text Input xpath=//project-audit-log//hbr-filter//input harbor-jobservice
Retry Wait Until Page Not Contains Element //audit-log//clr-dg-row[2] Retry Wait Until Page Not Contains Element //audit-log//clr-dg-row[2]
Retry Click Repo Name Retry Click Repo Name

View File

@ -101,6 +101,7 @@ Create A New Endpoint
Run Keyword If '${provider}' == 'harbor' or '${provider}' == 'gitlab' Run keyword Retry Text Input xpath=${destination_url_xpath} ${url} Run Keyword If '${provider}' == 'harbor' or '${provider}' == 'gitlab' Run keyword Retry Text Input xpath=${destination_url_xpath} ${url}
Run Keyword If '${provider}' == 'aws-ecr' or '${provider}' == 'google-gcr' Run keyword Select Destination URL ${url} Run Keyword If '${provider}' == 'aws-ecr' or '${provider}' == 'google-gcr' Run keyword Select Destination URL ${url}
Run Keyword If '${provider}' != 'google-gcr' and '${username}' != '${null}' Retry Password Input xpath=${destination_username_xpath} ${username} Run Keyword If '${provider}' != 'google-gcr' and '${username}' != '${null}' Retry Password Input xpath=${destination_username_xpath} ${username}
Run Keyword If '${username}' != '${null}' Retry Text Input xpath=${destination_username_xpath} ${username}
Run Keyword If '${pwd}' != '${null}' Retry Password Input xpath=${destination_password_xpath} ${pwd} Run Keyword If '${pwd}' != '${null}' Retry Password Input xpath=${destination_password_xpath} ${pwd}
#cancel verify cert since we use a selfsigned cert #cancel verify cert since we use a selfsigned cert
Retry Element Click ${destination_insecure_xpath} Retry Element Click ${destination_insecure_xpath}

View File

@ -17,7 +17,7 @@ Documentation This resource provides any keywords related to the Harbor private
*** Variables *** *** Variables ***
${head_admin_xpath} xpath=//clr-dropdown//button//clr-icon[@shape='user'] ${head_admin_xpath} xpath=//clr-dropdown//button//clr-icon[@shape='user']
${change_password_xpath} xpath=//clr-main-container//clr-dropdown//a[2] ${change_password_xpath} xpath=//clr-main-container//clr-dropdown//a[contains(.,'Change Password')]
${user_profile_xpath} xpath=//clr-main-container//clr-dropdown//a[1] ${user_profile_xpath} xpath=//clr-main-container//clr-dropdown//a[1]
${old_password_xpath} xpath=//*[@id='oldPassword'] ${old_password_xpath} xpath=//*[@id='oldPassword']
${new_password_xpath} xpath=//*[@id='newPassword'] ${new_password_xpath} xpath=//*[@id='newPassword']

View File

@ -444,18 +444,6 @@ Body Of Generate Image SBOM On Push
Checkout And Review SBOM Details latest Checkout And Review SBOM Details latest
Close Browser Close Browser
Body Of Stop SBOM Manual Generation
Init Chrome Driver
${d}= get current date result_format=%m%s
${repo}= Set Variable goharbor/harbor-e2e-engine
${tag}= Set Variable test-ui
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${repo} ${tag} ${tag}
# stop generate sbom of an artifact
Retry Action Keyword Stop SBOM Generation project${d} ${repo}
Close Browser
Stop SBOM Generation Stop SBOM Generation
[Arguments] ${project_name} ${repo} [Arguments] ${project_name} ${repo}
Generate Artifact SBOM ${project_name} ${repo} Generate Artifact SBOM ${project_name} ${repo}
@ -676,7 +664,7 @@ Create Schedules For Job Service Dashboard Schedules
Create An New P2P Preheat Policy ${p2p_policy_name} ${distribution_name} ** ** Scheduled ${schedule_type} ${schedule_cron} Create An New P2P Preheat Policy ${p2p_policy_name} ${distribution_name} ** ** Scheduled ${schedule_type} ${schedule_cron}
# Create a replication policy triggered by schedule # Create a replication policy triggered by schedule
Switch to Registries Switch to Registries
Create A New Endpoint harbor goharbor${d} ${null} ${null} ${null} Y Create A New Endpoint harbor goharbor${d} https://${LOCAL_REGISTRY} ${null} ${null} Y
Switch To Replication Manage Switch To Replication Manage
Create A Rule With Existing Endpoint ${replication_policy_name} pull harbor-ci/goharbor/harbor-core image goharbor${d} ${project_name} filter_tag=dev mode=Scheduled cron=${schedule_cron} Create A Rule With Existing Endpoint ${replication_policy_name} pull harbor-ci/goharbor/harbor-core image goharbor${d} ${project_name} filter_tag=dev mode=Scheduled cron=${schedule_cron}
# Set up a schedule to scan all # Set up a schedule to scan all

View File

@ -902,7 +902,7 @@ Test Case - Audit Log And Purge
Logout Harbor Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Logs Switch To Logs
Verify Log ${user} project${d} project delete Verify Log ${user} project${d} project delete 3
Switch To Log Rotation Switch To Log Rotation
Purge Now 1 Hours Purge Now 1 Hours
Close Browser Close Browser

View File

@ -110,6 +110,7 @@ Test Case - Project Quotas Control Under GC
Close Browser Close Browser
Test Case - Garbage Collection Accessory Test Case - Garbage Collection Accessory
[Tags] garbage_collection_accessory
Init Chrome Driver Init Chrome Driver
${d}= Get Current Date result_format=%m%s ${d}= Get Current Date result_format=%m%s
${image}= Set Variable hello-world ${image}= Set Variable hello-world

View File

@ -144,7 +144,7 @@ Test Case - Replication Of Pull Images from DockerHub To Self
Log All image1:${image1} Log All image1:${image1}
${image2}= Get From Dictionary ${image2_with_tag} image ${image2}= Get From Dictionary ${image2_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' @{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}'
Body Of Replication Of Pull Images from Registry To Self docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}/{${image1}*,${image2}} ${null} N Flatten 1 Level @{target_images} Body Of Replication Of Pull Images from Registry To Self docker-hub ${null} ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}/{${image1}*,${image2}} ${null} N Flatten 1 Level @{target_images}
Test Case - Replication Of Push Images from Self To Harbor Test Case - Replication Of Push Images from Self To Harbor
Init Chrome Driver Init Chrome Driver

View File

@ -27,7 +27,7 @@ Test Case - Main Menu Routing
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
&{routing}= Create Dictionary harbor/projects=//projects//div//h2[contains(.,'Projects')] &{routing}= Create Dictionary harbor/projects=//projects//div//h2[contains(.,'Projects')]
... harbor/logs=//hbr-log//div//h2[contains(.,'Logs')] ... harbor/logs=//app-logs/h2[contains(.,'Logs')]
... harbor/users=//harbor-user//div//h2[contains(.,'Users')] ... harbor/users=//harbor-user//div//h2[contains(.,'Users')]
... harbor/robot-accounts=//system-robot-accounts//h2[contains(.,'Robot Accounts')] ... harbor/robot-accounts=//system-robot-accounts//h2[contains(.,'Robot Accounts')]
... harbor/registries=//hbr-endpoint//h2[contains(.,'Registries')] ... harbor/registries=//hbr-endpoint//h2[contains(.,'Registries')]
@ -65,7 +65,7 @@ Test Case - Project Tab Routing
... harbor/projects/1/tag-strategy/immutable-tag=//project-detail//app-tag-feature-integration//app-immutable-tag ... harbor/projects/1/tag-strategy/immutable-tag=//project-detail//app-tag-feature-integration//app-immutable-tag
... harbor/projects/1/robot-account=//project-detail//app-robot-account ... harbor/projects/1/robot-account=//project-detail//app-robot-account
... harbor/projects/1/webhook=//project-detail//ng-component//button//span[contains(.,'New Webhook')] ... harbor/projects/1/webhook=//project-detail//ng-component//button//span[contains(.,'New Webhook')]
... harbor/projects/1/logs=//project-detail//audit-log ... harbor/projects/1/logs=//project-detail/project-logs
... harbor/projects/1/configs=//project-detail//app-project-config//hbr-project-policy-config ... harbor/projects/1/configs=//project-detail//app-project-config//hbr-project-policy-config
FOR ${key} IN @{routing.keys()} FOR ${key} IN @{routing.keys()}
Retry Double Keywords When Error Go To ${HARBOR_URL}/${key} Retry Wait Element ${routing['${key}']} Retry Double Keywords When Error Go To ${HARBOR_URL}/${key} Retry Wait Element ${routing['${key}']}

View File

@ -230,7 +230,7 @@ Test Case - Log Rotation Schedule Job
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Log Rotation Switch To Log Rotation
${exclude_operations} Create List Pull ${exclude_operations} Create List Pull artifact
Set Log Rotation Schedule 2 Days Custom 0 */2 * * * * ${exclude_operations} Set Log Rotation Schedule 2 Days Custom 0 */2 * * * * ${exclude_operations}
Sleep 480 Sleep 480
Set Log Rotation Schedule 2 Days None Set Log Rotation Schedule 2 Days None

View File

@ -172,10 +172,6 @@ Test Case - Generate Image SBOM On Push
[Tags] run-once [Tags] run-once
Body Of Generate Image SBOM On Push Body Of Generate Image SBOM On Push
Test Case - Stop SBOM Manual Generation
[Tags] stop_sbom_gen
Body Of Stop SBOM Manual Generation
Test Case - External Scanner CRUD Test Case - External Scanner CRUD
[Tags] external_scanner_crud need_scanner_endpoint [Tags] external_scanner_crud need_scanner_endpoint
${SCANNER_ENDPOINT_VALUE}= Get Variable Value ${SCANNER_ENDPOINT} ${EMPTY} ${SCANNER_ENDPOINT_VALUE}= Get Variable Value ${SCANNER_ENDPOINT} ${EMPTY}

View File

@ -35,6 +35,10 @@
{ {
"branch":3, "branch":3,
"version":"2.2" "version":"2.2"
},
{
"branch":3,
"version":"2.12"
} }
], ],
"populate_projects":[ "populate_projects":[
@ -73,6 +77,10 @@
{ {
"branch":3, "branch":3,
"version":"2.2" "version":"2.2"
},
{
"branch":3,
"version":"2.12"
} }
], ],
"add_member":[ "add_member":[
@ -111,6 +119,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"set_user_admin":[ "set_user_admin":[
@ -149,6 +161,10 @@
{ {
"branch":3, "branch":3,
"version":"2.2" "version":"2.2"
},
{
"branch":3,
"version":"2.12"
} }
], ],
"add_endpoint":[ "add_endpoint":[
@ -187,6 +203,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"add_replication_rule":[ "add_replication_rule":[
@ -225,6 +245,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"add_sys_allowlist":[ "add_sys_allowlist":[
@ -247,6 +271,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"update_project_setting_allowlist":[ "update_project_setting_allowlist":[
@ -269,6 +297,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"add_project_robot_account":[ "add_project_robot_account":[
@ -295,6 +327,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"add_tag_retention_rule":[ "add_tag_retention_rule":[
@ -317,6 +353,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":1,
"version":"2.12"
} }
], ],
"add_tag_immutability_rule":[ "add_tag_immutability_rule":[
@ -335,6 +375,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":1,
"version":"2.12"
} }
], ],
"add_webhook":[ "add_webhook":[
@ -357,6 +401,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"update_interrogation_services":[ "update_interrogation_services":[
@ -379,6 +427,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":1,
"version":"2.12"
} }
], ],
"push_artifact_index":[ "push_artifact_index":[
@ -393,6 +445,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":1,
"version":"2.12"
} }
], ],
"add_distribution":[ "add_distribution":[
@ -403,6 +459,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":1,
"version":"2.12"
} }
], ],
"add_p2p_preheat_policy":[ "add_p2p_preheat_policy":[
@ -413,6 +473,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":1,
"version":"2.12"
} }
], ],
"get_ca":[ "get_ca":[
@ -451,6 +515,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"set_url":[ "set_url":[
@ -489,6 +557,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"update_systemsetting":[ "update_systemsetting":[
@ -515,6 +587,10 @@
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
},
{
"branch":2,
"version":"2.12"
} }
], ],
"populate_quotas":[ "populate_quotas":[
@ -533,6 +609,10 @@
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.2"
},
{
"branch":1,
"version":"2.12"
} }
] ]
} }

View File

@ -354,8 +354,12 @@ class HarborAPI:
def add_project_robot_account(self, project, robot_account, **kwargs): def add_project_robot_account(self, project, robot_account, **kwargs):
r = request(url+"projects?name="+project+"", 'get') r = request(url+"projects?name="+project+"", 'get')
projectid = str(r.json()[0]['project_id']) projectid = str(r.json()[0]['project_id'])
create_url = url
print("robot_account:", robot_account)
print("branch:", kwargs["branch"])
print("version:", kwargs["version"])
if kwargs["branch"] == 1: if kwargs["branch"] == 1:
create_url = url+"projects/"+projectid+"/robots"
if len(robot_account["access"]) == 1: if len(robot_account["access"]) == 1:
robot_account_ac = robot_account["access"][0] robot_account_ac = robot_account["access"][0]
payload = { payload = {
@ -383,10 +387,34 @@ class HarborAPI:
} }
else: else:
raise Exception(r"Error: Robot account count {} is not legal!".format(len(robot_account["access"]))) raise Exception(r"Error: Robot account count {} is not legal!".format(len(robot_account["access"])))
elif kwargs["branch"] == 2:
create_url = url+"/robots"
if len(robot_account["access"]) == 1:
robot_account_ac = robot_account["access"][0]
payload = {
"name":robot_account["name"],
"level":"project",
"duration": -1,
"permissions":[
{"access":[{"resource":"repository","action":robot_account_ac["action"]}],
"kind":"project","namespace":project}]
}
elif len(robot_account["access"]) == 2:
payload = {
"name":robot_account["name"],
"level":"project",
"duration": -1,
"permissions":[
{"access":[{"resource":"repository","action":"pull"},
{"resource":"repository","action":"push"}],
"kind":"project","namespace":project}]
}
else:
raise Exception(r"Error: Robot account count {} is not legal!".format(len(robot_account["access"])))
else: else:
raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch)) raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch))
body=dict(body=payload) body=dict(body=payload)
request(url+"projects/"+projectid+"/robots", 'post', **body) request(create_url, 'post', **body)
@get_feature_branch @get_feature_branch
def add_tag_retention_rule(self, project, tag_retention_rule, **kwargs): def add_tag_retention_rule(self, project, tag_retention_rule, **kwargs):