mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-30 22:37:43 +02:00
Add oidc test cases for 1.8.0 1 (#7971)
* OIDC authentication is a new feature in version 1.8.0, so add nightly GUI test cases for OIDC authentication scenario. (#7745) Signed-off-by: danfengliu <danfengl@vmware.com> * Nightly test case user-view-logs failed several times, after debugging, the reason is checking too fast although the operation has not finsished, so I add a checking for end of the operation. (#7858) Signed-off-by: danfengliu <danfengl@vmware.com> * Add test case for oidc auth mode (#7860) * Nightly test case user-view-logs failed several times, after debugging, the reason is checking too fast although the operation has not finsished, so I add a checking for end of the operation. Signed-off-by: danfengliu <danfengl@vmware.com> * Add test case Manage-Project-Member for oidc auth mode Jenkins pipeline, this test case reuse the same test case in common file. Signed-off-by: danfengliu <danfengl@vmware.com> * Jenkin job cd_daily_master failed due to sign image failure, but there're other failure for replicaiton NG, so API for replication NG need to be updated. (#7778) Signed-off-by: danfengliu <danfengl@vmware.com> * Fix bug for manage-project-member, due to keywords changed for oidc-auth-mode, test case manage-project-member should be debug at the same time. (#7888) Signed-off-by: danfengliu <danfengl@vmware.com> * Add test case secret-verify for oidc-auth-mode feature by adding some keywords and one test cases. Signed-off-by: danfengliu <danfengl@vmware.com> * Population data tool - prepare.py has been adapted for the latest version due to API changing, but the old version still was needed in other place, so it should be add it back and give it a new name. (#7943) Signed-off-by: danfengliu <danfengl@vmware.com> * Add 2 UI test cases which is replication rule edit and delete. (#7904) Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
parent
0ff3111224
commit
2b16c8b072
@ -27,7 +27,7 @@ Generate Certificate Authority For Chrome
|
||||
${rc} ${out}= Run And Return Rc And Output certutil -d sql:$HOME/.pki/nssdb -A -t TC -f password${rand}.ca -n "Harbor${rand}" -i ./harbor_ca.crt
|
||||
Log ${out}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
|
||||
|
||||
Generate Certificate Authority
|
||||
# Generates CA (private/ca.key.pem, certs/ca.cert.pem, certs/STARK_ENTERPRISES_ROOT_CA.crt) in OUT_DIR
|
||||
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${OUT_DIR}=/root/ca
|
||||
|
@ -41,7 +41,7 @@ Push image
|
||||
Wait Unitl Command Success docker logout ${ip}
|
||||
|
||||
Push Image With Tag
|
||||
#tag1 is tag of image on docker hub,default latest,use a version existing if you do not want to use latest
|
||||
#tag1 is tag of image on docker hub,default latest,use a version existing if you do not want to use latest
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag} ${tag1}=latest
|
||||
Log To Console \nRunning docker push ${image}...
|
||||
Wait Unitl Command Success docker pull ${image}:${tag1}
|
||||
@ -50,15 +50,19 @@ Push Image With Tag
|
||||
Wait Unitl Command Success docker push ${ip}/${project}/${image}:${tag}
|
||||
Wait Unitl Command Success docker logout ${ip}
|
||||
|
||||
Cannot Docker Login Harbor
|
||||
[Arguments] ${ip} ${user} ${pwd}
|
||||
Command Should be Failed docker login -u ${user} -p ${pwd} ${ip}
|
||||
|
||||
Cannot Pull image
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${image}
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
|
||||
Wait Unitl Command Success docker pull ${ip}/${project}/${image} positive=${false}
|
||||
Command Should be Failed docker pull ${ip}/${project}/${image}
|
||||
|
||||
Cannot Pull Unsigned Image
|
||||
[Arguments] ${ip} ${user} ${pass} ${proj} ${imagewithtag}
|
||||
[Arguments] ${ip} ${user} ${pass} ${proj} ${imagewithtag}
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pass} ${ip}
|
||||
${output}= Wait Unitl Command Success docker pull ${ip}/${proj}/${imagewithtag} positive=${false}
|
||||
${output}= Command Should be Failed docker pull ${ip}/${proj}/${imagewithtag}
|
||||
Should Contain ${output} The image is not signed in Notary
|
||||
|
||||
Cannot Push image
|
||||
@ -67,7 +71,7 @@ Cannot Push image
|
||||
Wait Unitl Command Success docker pull ${image}
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
|
||||
Wait Unitl Command Success docker tag ${image} ${ip}/${project}/${image}
|
||||
Wait Unitl Command Success docker push ${ip}/${project}/${image} positive=${false}
|
||||
Command Should be Failed docker push ${ip}/${project}/${image}
|
||||
Wait Unitl Command Success docker logout ${ip}
|
||||
|
||||
Wait Until Container Stops
|
||||
@ -107,8 +111,8 @@ Start Docker Daemon Locally
|
||||
Prepare Docker Cert
|
||||
[Arguments] ${ip}
|
||||
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
|
||||
Wait Unitl Command Success cp harbor_ca.crt /etc/docker/certs.d/${ip}
|
||||
|
||||
Wait Unitl Command Success cp harbor_ca.crt /etc/docker/certs.d/${ip}
|
||||
|
||||
Kill Local Docker Daemon
|
||||
[Arguments] ${handle} ${dockerd-pid}
|
||||
Terminate Process ${handle}
|
||||
@ -118,7 +122,7 @@ Kill Local Docker Daemon
|
||||
Docker Login Fail
|
||||
[Arguments] ${ip} ${user} ${pwd}
|
||||
Log To Console \nRunning docker login ${ip} ...
|
||||
${output}= Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip} positive=${false}
|
||||
${output}= Command Should be Failed docker login -u ${user} -p ${pwd} ${ip}
|
||||
Should Contain ${output} unauthorized: authentication required
|
||||
Should Not Contain ${output} 500 Internal Server Error
|
||||
|
||||
@ -136,4 +140,4 @@ Docker Tag
|
||||
|
||||
Docker Push
|
||||
[Arguments] ${image}
|
||||
Wait Unitl Command Success docker push ${image}
|
||||
Wait Unitl Command Success docker push ${image}
|
||||
|
59
tests/resources/Harbor-Pages/OIDC_Auth.robot
Normal file
59
tests/resources/Harbor-Pages/OIDC_Auth.robot
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright Project Harbor Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License
|
||||
|
||||
*** Settings ***
|
||||
Documentation This resource provides any keywords related to the Harbor private registry appliance
|
||||
Resource ../../resources/Util.robot
|
||||
|
||||
*** Variables ***
|
||||
|
||||
*** Keywords ***
|
||||
|
||||
Sign In Harbor With OIDC User
|
||||
[Arguments] ${url} ${username}=${OIDC_USERNAME}
|
||||
${head_username}= Set Variable xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header//clr-dropdown//button[contains(.,'${username}')]
|
||||
Init Chrome Driver
|
||||
Go To ${url}
|
||||
Retry Element Click ${log_oidc_provider_btn}
|
||||
Retry Text Input ${dex_login_btn} ${username}@example.com
|
||||
Retry Text Input ${dex_pwd_btn} password
|
||||
Retry Element Click ${submit_login_btn}
|
||||
Retry Element Click ${grant_btn}
|
||||
|
||||
#If input box for harbor user name is visible, it means it's the 1st time login of this user,
|
||||
# but if this user has been logged into harbor successfully, this input box will not show up,
|
||||
# so there is condition branch for this stituation.
|
||||
${isVisible}= Run Keyword And Return Status Element Should Be Visible ${oidc_username_input}
|
||||
Run Keyword If '${isVisible}' == 'True' Run Keywords Retry Text Input ${oidc_username_input} ${username} AND Retry Element Click ${save_btn}
|
||||
Retry Wait Element ${head_username}
|
||||
|
||||
Get Secrete By API
|
||||
[Arguments] ${url} ${username}=${OIDC_USERNAME}
|
||||
${json}= Run Curl And Return Json curl -s -k -X GET --header 'Accept: application/json' -u '${HARBOR_ADMIN}:${HARBOR_PASSWORD}' '${url}/api/users/search?username=${username}'
|
||||
${user_info}= Set Variable ${json[0]}
|
||||
${user_id}= Set Variable ${user_info["user_id"]}
|
||||
${json}= Run Curl And Return Json curl -s -k -X GET --header 'Accept: application/json' -u '${HARBOR_ADMIN}:${HARBOR_PASSWORD}' '${url}/api/users/${user_id}'
|
||||
${secret}= Set Variable ${json["oidc_user_meta"]["secret"]}
|
||||
[Return] ${secret}
|
||||
|
||||
Generate And Return Secret
|
||||
[Arguments] ${url}
|
||||
Retry Element Click ${head_admin_xpath}
|
||||
Retry Element Click ${user_profile_xpath}
|
||||
Retry Element Click ${more_btn}
|
||||
Retry Element Click ${generate_secret_btn}
|
||||
Retry Double Keywords When Error Retry Element Click ${confirm_btn} Retry Wait Until Page Not Contains Element ${confirm_btn}
|
||||
Retry Wait Until Page Contains generate CLI secret success
|
||||
${secret}= Get Secrete By API ${url}
|
||||
[Return] ${secret}
|
28
tests/resources/Harbor-Pages/OIDC_Auth_Elements.robot
Normal file
28
tests/resources/Harbor-Pages/OIDC_Auth_Elements.robot
Normal file
@ -0,0 +1,28 @@
|
||||
# Copyright Project Harbor Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License
|
||||
|
||||
*** Settings ***
|
||||
Documentation This resource provides any keywords related to the Harbor private registry appliance
|
||||
|
||||
*** Variables ***
|
||||
${log_oidc_provider_btn} //*[@id='log_oidc']
|
||||
${dex_login_btn} //*[@id='login']
|
||||
${dex_pwd_btn} //*[@id='password']
|
||||
${submit_login_btn} //*[@id='submit-login']
|
||||
${grant_btn} xpath=/html/body/div[2]/div/div[2]/div[1]/form/button
|
||||
${oidc_username_input} //*[@id='oidcUsername']
|
||||
${save_btn} //*[@id='saveButton']
|
||||
${OIDC_USERNAME} test1
|
||||
${generate_secret_btn} //*[@id='generate-cli-btn']
|
||||
${more_btn} //*[@id='hidden-generate-cli']
|
@ -117,16 +117,20 @@ User Should Be Owner Of Project
|
||||
Logout Harbor
|
||||
|
||||
User Should Not Be A Member Of Project
|
||||
[Arguments] ${user} ${pwd} ${project}
|
||||
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
|
||||
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
|
||||
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
|
||||
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
|
||||
Project Should Not Display ${project}
|
||||
Logout Harbor
|
||||
Cannot Pull image ${ip} ${user} ${pwd} ${project} ${ip}/${project}/hello-world
|
||||
Cannot Push image ${ip} ${user} ${pwd} ${project} hello-world
|
||||
Cannot Pull image ${ip} ${user} ${password} ${project} ${ip}/${project}/hello-world
|
||||
Cannot Push image ${ip} ${user} ${password} ${project} hello-world
|
||||
|
||||
Manage Project Member
|
||||
[Arguments] ${admin} ${pwd} ${project} ${user} ${op} ${has_image}=${true}
|
||||
Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
|
||||
[Arguments] ${admin} ${pwd} ${project} ${user} ${op} ${has_image}=${true} ${is_oidc_mode}=${false}
|
||||
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
|
||||
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin}
|
||||
Go Into Project ${project} ${has_image}
|
||||
Switch To Member
|
||||
Run Keyword If '${op}' == 'Add' Add Guest Member To Project ${user}
|
||||
@ -135,38 +139,48 @@ Manage Project Member
|
||||
Logout Harbor
|
||||
|
||||
Change User Role In Project
|
||||
[Arguments] ${admin} ${pwd} ${project} ${user} ${role}
|
||||
Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
|
||||
[Arguments] ${admin} ${pwd} ${project} ${user} ${role} ${is_oidc_mode}=${false}
|
||||
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
|
||||
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin}
|
||||
Wait Until Element Is Visible //clr-dg-cell//a[contains(.,'${project}')]
|
||||
Change Project Member Role ${project} ${user} ${role}
|
||||
Logout Harbor
|
||||
|
||||
User Should Be Guest
|
||||
[Arguments] ${user} ${pwd} ${project}
|
||||
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
|
||||
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
|
||||
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
|
||||
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
|
||||
Project Should Display ${project}
|
||||
Go Into Project ${project}
|
||||
Switch To Member
|
||||
User Can Not Add Member
|
||||
Page Should Contain Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Guest')]
|
||||
Logout Harbor
|
||||
Pull image ${ip} ${user} ${pwd} ${project} hello-world
|
||||
Cannot Push image ${ip} ${user} ${pwd} ${project} hello-world
|
||||
Pull image ${ip} ${user} ${password} ${project} hello-world
|
||||
Cannot Push image ${ip} ${user} ${password} ${project} hello-world
|
||||
|
||||
User Should Be Developer
|
||||
[Arguments] ${user} ${pwd} ${project}
|
||||
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
|
||||
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
|
||||
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
|
||||
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
|
||||
Project Should Display ${project}
|
||||
Go Into Project ${project}
|
||||
Switch To Member
|
||||
User Can Not Add Member
|
||||
Page Should Contain Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Developer')]
|
||||
Logout Harbor
|
||||
Push Image With Tag ${ip} ${user} ${pwd} ${project} hello-world v1
|
||||
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v1
|
||||
|
||||
User Should Be Admin
|
||||
[Arguments] ${user} ${pwd} ${project} ${guest}
|
||||
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
[Arguments] ${user} ${pwd} ${project} ${guest} ${is_oidc_mode}=${false}
|
||||
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
|
||||
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
|
||||
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
|
||||
Project Should Display ${project}
|
||||
Go Into Project ${project}
|
||||
Switch To Member
|
||||
@ -174,18 +188,21 @@ User Should Be Admin
|
||||
User Can Change Role ${guest}
|
||||
Page Should Contain Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Admin')]
|
||||
Logout Harbor
|
||||
Push Image With Tag ${ip} ${user} ${pwd} ${project} hello-world v2
|
||||
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v2
|
||||
|
||||
User Should Be Master
|
||||
[Arguments] ${user} ${pwd} ${project}
|
||||
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
|
||||
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
|
||||
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
|
||||
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
|
||||
Project Should Display ${project}
|
||||
Go Into Project ${project}
|
||||
Delete Repo ${project}
|
||||
Switch To Member
|
||||
Page Should Contain Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Master')]
|
||||
Logout Harbor
|
||||
Push Image With Tag ${ip} ${user} ${pwd} ${project} hello-world v3
|
||||
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v3
|
||||
|
||||
Project Should Have Member
|
||||
[Arguments] ${project} ${user}
|
||||
|
@ -100,6 +100,7 @@ Delete Repo
|
||||
Retry Double Keywords When Error Retry Element Click ${element_repo_checkbox} Wait Until Element Is Visible And Enabled ${repo_delete_btn}
|
||||
Retry Double Keywords When Error Retry Element Click ${repo_delete_btn} Wait Until Element Is Visible And Enabled ${delete_confirm_btn}
|
||||
Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn}
|
||||
Retry Wait Until Page Not Contains Element ${element_repo_checkbox}
|
||||
|
||||
Delete Repo on CardView
|
||||
[Arguments] ${reponame}
|
||||
|
@ -20,6 +20,21 @@ Resource ../../resources/Util.robot
|
||||
${HARBOR_VERSION} v1.1.1
|
||||
|
||||
*** Keywords ***
|
||||
Select Dest Registry
|
||||
[Arguments] ${endpoint}
|
||||
Retry Element Click ${dest_registry_dropdown_list}
|
||||
Retry Element Click ${dest_registry_dropdown_list}//option[contains(.,'${endpoint}')]
|
||||
|
||||
Select Source Registry
|
||||
[Arguments] ${endpoint}
|
||||
Retry Element Click ${src_registry_dropdown_list}
|
||||
Retry Element Click ${src_registry_dropdown_list}//option[contains(.,'${endpoint}')]
|
||||
|
||||
Select Trigger
|
||||
[Arguments] ${mode}
|
||||
Retry Element Click ${rule_trigger_select}
|
||||
Retry Element Click ${rule_trigger_select}//option[contains(.,'${mode}')]
|
||||
|
||||
Check New Rule UI Without Endpoint
|
||||
Retry Element Click ${new_replication-rule_button}
|
||||
Page Should Contain Please add an endpoint first
|
||||
@ -44,69 +59,26 @@ Create A New Endpoint
|
||||
Run Keyword If '${save}' == 'N' No Operation
|
||||
|
||||
Create A Rule With Existing Endpoint
|
||||
[Arguments] ${name} ${replication_mode} ${project_name} ${resource_type} ${endpoint} ${dest_namespace_input}
|
||||
[Arguments] ${name} ${replication_mode} ${project_name} ${resource_type} ${endpoint} ${dest_namespace}
|
||||
... ${mode}=Manual
|
||||
#click new
|
||||
Retry Element Click ${new_name_xpath}
|
||||
#input name
|
||||
Retry Text Input ${rule_name} ${name}
|
||||
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push}
|
||||
... AND Retry Element Click //select[@id='dest_registry']
|
||||
... AND Retry Element Click //select[@id='dest_registry']//option[contains(.,'${endpoint}')]
|
||||
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull}
|
||||
... AND Retry Element Click //select[@id='src_registry_id']
|
||||
... AND Retry Element Click //select[@id='src_registry_id']//option[contains(.,'${endpoint}')]
|
||||
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push}
|
||||
... AND Select Dest Registry ${endpoint}
|
||||
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull}
|
||||
... AND Select Source Registry ${endpoint}
|
||||
#set filter
|
||||
Retry Text Input ${source_project} ${project_name}
|
||||
Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type}
|
||||
Retry Text Input ${dest_namespace_xpath} ${dest_namespace_input}
|
||||
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
|
||||
#set trigger
|
||||
Retry Element Click //select[@id='ruleTrigger']
|
||||
Retry Element Click //select[@id='ruleTrigger']//option[contains(.,'${mode}')]
|
||||
Select Trigger ${mode}
|
||||
Run Keyword If '${mode}' == 'Scheduled' Log To Console Scheduled
|
||||
#click save
|
||||
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
|
||||
|
||||
Project Create A Rule With Existing Endpoint
|
||||
# day 1=Monday..7=Sunday timeformat 12hour+am/pm
|
||||
[Arguments] ${name} ${project_name} ${endpoint} ${mode} ${plan}=Daily ${weekday}=1 ${time}=0800a
|
||||
#click new
|
||||
Retry Element Click ${new_name_xpath}
|
||||
#input name
|
||||
Retry Text Input ${rule_name} ${name}
|
||||
#input descripiton,here skip, leave it blank
|
||||
#in this keyword, source project is not need to input
|
||||
#set filter
|
||||
Retry Element Click ${source_image_filter_add}
|
||||
Retry Text Input ${source_iamge_repo_filter} *
|
||||
Retry Element Click ${source_image_filter_add}
|
||||
Retry Text Input ${source_image_tag_filter} *
|
||||
#select endpoint
|
||||
Retry Element Click ${rule_target_select}
|
||||
Wait Until Element Is Visible //select[@id='ruleTarget']//option[contains(.,'${endpoint}')]
|
||||
Retry Element Click //select[@id='ruleTarget']//option[contains(.,'${endpoint}')]
|
||||
#set trigger
|
||||
Retry Element Click ${rule_trigger_select}
|
||||
Wait Until Element Is Visible //select[@id='ruleTrigger']//option[contains(.,'${mode}')]
|
||||
Retry Element Click //select[@id='ruleTrigger']//option[contains(.,'${mode}')]
|
||||
Run Keyword If '${mode}' == 'Scheduled' Setting Replication Schedule ${plan} ${weekday} ${time}
|
||||
#click save
|
||||
Retry Element Click ${rule_save_button}
|
||||
|
||||
Setting Replication Schedule
|
||||
[Arguments] ${plan} ${weekday}=1 ${time}=0800a
|
||||
Retry Element Click ${schedule_type_select}
|
||||
Wait Until Element Is Visible //select[@name='scheduleType']/option[@value='${plan}']
|
||||
Retry Element Click //select[@name='scheduleType']/option[@value='${plan}']
|
||||
Run Keyword If '${plan}' == 'Weekly' Setting Replication Weekday ${weekday}
|
||||
Retry Text Input ${shcedule_time} ${time}
|
||||
|
||||
Setting Replication Weekday
|
||||
[arguments] ${day}
|
||||
Retry Element Click ${schedule_day_select}
|
||||
Wait Until Element Is Visible //select[@name='scheduleDay']/option[@value='${day}']
|
||||
Retry Element Click //select[@name='scheduleDay']/option[@value='${day}']
|
||||
|
||||
Endpoint Is Unpingable
|
||||
Retry Element Click ${ping_test_button}
|
||||
Wait Until Page Contains Failed
|
||||
@ -187,11 +159,39 @@ View Job Log
|
||||
Retry Text Input ${job_filter_input} ${job}
|
||||
Retry Link Click //clr-dg-row[contains(.,'${job}')]//a
|
||||
|
||||
Find Item And Click Edit Button
|
||||
[Arguments] ${name}
|
||||
Filter Object ${name}
|
||||
Retry Select Object ${name}
|
||||
Retry Element Click ${action_bar_edit}
|
||||
|
||||
Find Item And Click Delete Button
|
||||
[Arguments] ${name}
|
||||
Filter Object ${name}
|
||||
Retry Select Object ${name}
|
||||
Retry Element Click ${action_bar_delete}
|
||||
|
||||
Edit Replication Rule By Name
|
||||
[Arguments] ${name}
|
||||
Switch To Registries
|
||||
Switch To Replication Manage
|
||||
Find Item And Click Edit Button ${name}
|
||||
|
||||
Delete Replication Rule By Name
|
||||
[Arguments] ${name}
|
||||
Switch To Registries
|
||||
Switch To Replication Manage
|
||||
Find Item And Click Delete Button ${name}
|
||||
|
||||
Ensure Delete Replication Rule By Name
|
||||
[Arguments] ${name}
|
||||
Delete Replication Rule By Name ${name}
|
||||
Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn}
|
||||
Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any replication rules!\")]
|
||||
|
||||
Rename Endpoint
|
||||
[arguments] ${name} ${newname}
|
||||
Filter Object ${name}
|
||||
Select Object ${name}
|
||||
Retry Element Click ${action_bar_edit}
|
||||
Find Item And Click Edit Button ${name}
|
||||
Retry Wait Until Page Contains Element ${destination_name_xpath}
|
||||
Retry Text Input ${destination_name_xpath} ${newname}
|
||||
Retry Element Click ${replication_save_xpath}
|
||||
|
@ -75,6 +75,13 @@ ${filter_tag} //*[@id='filter_tag']
|
||||
${is_overide_xpath} //label[contains(.,'Replace the destination resources if name exists')]
|
||||
${enable_rule_xpath} //label[contains(.,'Enable rule')]
|
||||
${targetCron_id} //*[@id='targetCron']
|
||||
${rule_name_input} //*[@id='ruleName']
|
||||
${src_registry_dropdown_list} //select[@id='src_registry_id']
|
||||
${dest_registry_dropdown_list} //select[@id='dest_registry']
|
||||
${rule_confirm_btn} //*[@id='ruleBtnOk']
|
||||
${rule_cancel_btn} //*[@id='ruleBtnCancel']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ CA Setup
|
||||
[Arguments] ${ip} ${HARBOR_PASSWORD} ${cert}=/ca/ca.crt
|
||||
Run mv ${cert} harbor_ca.crt
|
||||
Generate Certificate Authority For Chrome ${HARBOR_PASSWORD}
|
||||
Prepare Docker Cert ${ip}
|
||||
Prepare Docker Cert ${ip}
|
||||
|
||||
Collect Nightly Logs
|
||||
[Arguments] ${ip} ${SSH_PWD} ${ip1}==${EMPTY}
|
||||
@ -45,11 +45,13 @@ Collect Logs
|
||||
SSHLibrary.Get File /var/log/harbor/ui.log
|
||||
SSHLibrary.Get File /var/log/harbor/registry.log
|
||||
SSHLibrary.Get File /var/log/harbor/proxy.log
|
||||
SSHLibrary.Get File /var/log/harbor/adminserver.log
|
||||
SSHLibrary.Get File /var/log/harbor/clair.log
|
||||
SSHLibrary.Get File /var/log/harbor/jobservice.log
|
||||
SSHLibrary.Get File /var/log/harbor/adminserver.log
|
||||
SSHLibrary.Get File /var/log/harbor/clair.log
|
||||
SSHLibrary.Get File /var/log/harbor/jobservice.log
|
||||
SSHLibrary.Get File /var/log/harbor/postgresql.log
|
||||
SSHLibrary.Get File /var/log/harbor/notary-server.log
|
||||
SSHLibrary.Get File /var/log/harbor/notary-signer.log
|
||||
SSHLibrary.Get File /var/log/harbor/chartmuseum.log
|
||||
SSHLibrary.Get File /var/log/harbor/registryctl.log
|
||||
Run rename 's/^/${ip}/' *.log
|
||||
Close All Connections
|
@ -109,4 +109,36 @@ Body Of Admin Push Signed Image
|
||||
${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/repositories/library/tomcat/signatures"
|
||||
Log To Console ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Should Contain ${output} sha256
|
||||
Should Contain ${output} sha256
|
||||
|
||||
Delete A Project Without Sign In Harbor
|
||||
[Arguments] ${harbor_ip}=${ip} ${username}=${HARBOR_ADMIN} ${password}=${HARBOR_PASSWORD}
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Create An New Project project${d}
|
||||
Push Image ${harbor_ip} ${username} ${password} project${d} hello-world
|
||||
Project Should Not Be Deleted project${d}
|
||||
Go Into Project project${d}
|
||||
Delete Repo project${d}
|
||||
Navigate To Projects
|
||||
Project Should Be Deleted project${d}
|
||||
|
||||
Manage Project Member Without Sign In Harbor
|
||||
[Arguments] ${sign_in_user} ${sign_in_pwd} ${test_user1}=user005 ${test_user2}=user006 ${is_oidc_mode}=${false}
|
||||
${d}= Get current Date result_format=%m%s
|
||||
Create An New Project project${d}
|
||||
Push image ip=${ip} user=${sign_in_user} pwd=${sign_in_pwd} project=project${d} image=hello-world
|
||||
Logout Harbor
|
||||
|
||||
User Should Not Be A Member Of Project ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
|
||||
Manage Project Member ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Add is_oidc_mode=${is_oidc_mode}
|
||||
User Should Be Guest ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
|
||||
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Developer is_oidc_mode=${is_oidc_mode}
|
||||
User Should Be Developer ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
|
||||
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Admin is_oidc_mode=${is_oidc_mode}
|
||||
User Should Be Admin ${test_user1} ${sign_in_pwd} project${d} ${test_user2} is_oidc_mode=${is_oidc_mode}
|
||||
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Master is_oidc_mode=${is_oidc_mode}
|
||||
User Should Be Master ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
|
||||
Manage Project Member ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Remove is_oidc_mode=${is_oidc_mode}
|
||||
User Should Not Be A Member Of Project ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
|
||||
Push image ip=${ip} user=${sign_in_user} pwd=${sign_in_pwd} project=project${d} image=hello-world
|
||||
User Should Be Guest ${test_user2} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
|
@ -54,6 +54,8 @@ Resource Harbor-Pages/ToolKit.robot
|
||||
Resource Harbor-Pages/ToolKit_Elements.robot
|
||||
Resource Harbor-Pages/Vulnerability.robot
|
||||
Resource Harbor-Pages/LDAP-Mode.robot
|
||||
Resource Harbor-Pages/OIDC_Auth.robot
|
||||
Resource Harbor-Pages/OIDC_Auth_Elements.robot
|
||||
Resource Harbor-Pages/Verify.robot
|
||||
Resource Docker-Util.robot
|
||||
Resource Admiral-Util.robot
|
||||
@ -129,9 +131,32 @@ Retry Wait Until Page Not Contains Element
|
||||
@{param} Create List ${element_xpath}
|
||||
Retry Action Keyword Wait Until Page Does Not Contain Element @{param}
|
||||
|
||||
Retry Select Object
|
||||
[Arguments] ${obj_name}
|
||||
@{param} Create List ${obj_name}
|
||||
Retry Action Keyword Select Object @{param}
|
||||
|
||||
Retry Textfield Value Should Be
|
||||
[Arguments] ${element} ${text}
|
||||
@{param} Create List ${element} ${text}
|
||||
Retry Action Keyword Wait And Textfield Value Should Be @{param}
|
||||
|
||||
Retry List Selection Should Be
|
||||
[Arguments] ${element} ${text}
|
||||
@{param} Create List ${element} ${text}
|
||||
Retry Action Keyword Wait And List Selection Should Be @{param}
|
||||
Link Click
|
||||
[Arguments] ${element_xpath}
|
||||
Click Link ${element_xpath}
|
||||
Wait And List Selection Should Be
|
||||
[Arguments] ${element} ${text}
|
||||
Wait Until Element Is Visible And Enabled ${element}
|
||||
List Selection Should Be ${element} ${text}
|
||||
|
||||
Wait And Textfield Value Should Be
|
||||
[Arguments] ${element} ${text}
|
||||
Wait Until Element Is Visible And Enabled ${element}
|
||||
Textfield Value Should Be ${element} ${text}
|
||||
|
||||
Element Click
|
||||
[Arguments] ${element_xpath}
|
||||
@ -148,6 +173,12 @@ Text Input
|
||||
Wait Until Element Is Visible And Enabled ${element_xpath}
|
||||
Input Text ${element_xpath} ${text}
|
||||
|
||||
Clear Field Of Characters
|
||||
[Arguments] ${field} ${character count}
|
||||
[Documentation] This keyword pushes the delete key (ascii: \8) a specified number of times in a specified field.
|
||||
: FOR ${index} IN RANGE ${character count}
|
||||
\ Press Key ${field} \\8
|
||||
|
||||
Wait Unitl Vul Data Ready
|
||||
[Arguments] ${url} ${timeout} ${interval}
|
||||
${n}= Evaluate ${timeout}/${interval}
|
||||
@ -161,16 +192,20 @@ Wait Unitl Vul Data Ready
|
||||
Run Keyword If ${i+1}==${n} Fail The vul data is not ready
|
||||
|
||||
Wait Unitl Command Success
|
||||
[Arguments] ${cmd} ${times}=8 ${positive}=${true}
|
||||
[Arguments] ${cmd} ${times}=8
|
||||
:FOR ${n} IN RANGE 1 ${times}
|
||||
\ Log Trying ${cmd}: ${n} ... console=True
|
||||
\ ${rc} ${output}= Run And Return Rc And Output ${cmd}
|
||||
\ Run Keyword If ${positive} == ${true} Exit For Loop If '${rc}'=='0'
|
||||
\ ... ELSE Exit For Loop If '${rc}'!='0'
|
||||
\ Exit For Loop If '${rc}'=='0'
|
||||
\ Sleep 2
|
||||
Log Command Result is ${output}
|
||||
Run Keyword If ${positive} == ${true} Should Be Equal As Strings '${rc}' '0'
|
||||
... ELSE Should Not Be Equal As Strings '${rc}' '0'
|
||||
Should Be Equal As Strings '${rc}' '0'
|
||||
[Return] ${output}
|
||||
|
||||
Command Should be Failed
|
||||
[Arguments] ${cmd}
|
||||
${rc} ${output}= Run And Return Rc And Output ${cmd}
|
||||
Should Not Be Equal As Strings '${rc}' '0'
|
||||
[Return] ${output}
|
||||
|
||||
Retry Keyword When Error
|
||||
@ -196,4 +231,13 @@ Retry Double Keywords When Error
|
||||
\ Exit For Loop If '${out1[0]}'=='PASS' and '${out2[0]}'=='PASS'
|
||||
\ Sleep 2
|
||||
Should Be Equal As Strings '${out1[0]}' 'PASS'
|
||||
Should Be Equal As Strings '${out2[0]}' 'PASS'
|
||||
Should Be Equal As Strings '${out2[0]}' 'PASS'
|
||||
|
||||
Run Curl And Return Json
|
||||
[Arguments] ${curl_cmd}
|
||||
${json_data_file}= Set Variable ${CURDIR}${/}cur_user_info.json
|
||||
${rc} ${output}= Run And Return Rc And Output ${curl_cmd}
|
||||
Should Be Equal As Integers 0 ${rc}
|
||||
Create File ${json_data_file} ${output}
|
||||
${json}= Load Json From File ${json_data_file}
|
||||
[Return] ${json}
|
@ -76,15 +76,8 @@ Test Case - Create An New Project
|
||||
|
||||
Test Case - Delete A Project
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Create An New Project project${d}
|
||||
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
|
||||
Project Should Not Be Deleted project${d}
|
||||
Go Into Project project${d}
|
||||
Delete Repo project${d}
|
||||
Navigate To Projects
|
||||
Project Should Be Deleted project${d}
|
||||
Delete A Project Without Sign In Harbor
|
||||
Close Browser
|
||||
|
||||
Test Case - Read Only Mode
|
||||
@ -307,30 +300,12 @@ Test Case - User View Logs
|
||||
Do Log Advanced Search
|
||||
Close Browser
|
||||
|
||||
|
||||
Test Case - Manage Project Member
|
||||
Init Chrome Driver
|
||||
${d}= Get current Date result_format=%m%s
|
||||
|
||||
Sign In Harbor ${HARBOR_URL} user004 Test1@34
|
||||
Create An New Project project${d}
|
||||
Push image ip=${ip} user=user004 pwd=Test1@34 project=project${d} image=hello-world
|
||||
Logout Harbor
|
||||
|
||||
User Should Not Be A Member Of Project user005 Test1@34 project${d}
|
||||
Manage Project Member user004 Test1@34 project${d} user005 Add
|
||||
User Should Be Guest user005 Test1@34 project${d}
|
||||
Change User Role In Project user004 Test1@34 project${d} user005 Developer
|
||||
User Should Be Developer user005 Test1@34 project${d}
|
||||
Change User Role In Project user004 Test1@34 project${d} user005 Admin
|
||||
User Should Be Admin user005 Test1@34 project${d} user006
|
||||
Change User Role In Project user004 Test1@34 project${d} user005 Master
|
||||
User Should Be Master user005 Test1@34 project${d}
|
||||
Manage Project Member user004 Test1@34 project${d} user005 Remove
|
||||
User Should Not Be A Member Of Project user005 Test1@34 project${d}
|
||||
Push image ip=${ip} user=user004 pwd=Test1@34 project=project${d} image=hello-world
|
||||
User Should Be Guest user006 Test1@34 project${d}
|
||||
|
||||
${user}= Set Variable user004
|
||||
${pwd}= Set Variable Test1@34
|
||||
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
Manage Project Member Without Sign In Harbor ${user} ${pwd}
|
||||
Close Browser
|
||||
|
||||
Test Case - Manage project publicity
|
||||
|
@ -39,7 +39,7 @@ Test Case - Ldap Sign in and out
|
||||
Sign In Harbor ${HARBOR_URL} mike zhu88jie
|
||||
Close Browser
|
||||
|
||||
Test Case - System Admin On-board New Member
|
||||
Test Case - System Admin On-board New Member
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
@ -53,7 +53,7 @@ Test Case - System Admin On-board New Member
|
||||
Page Should Contain mike02
|
||||
Close Browser
|
||||
|
||||
Test Case - LDAP User On-borad New Member
|
||||
Test Case - LDAP User On-borad New Member
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} mike03 zhu88jie
|
||||
@ -70,7 +70,7 @@ Test Case - Home Page Differences With DB Mode
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Logout Harbor
|
||||
Sleep 2
|
||||
Page Should Not Contain Sign up
|
||||
Page Should Not Contain Sign up
|
||||
Page Should Not Contain Forgot password
|
||||
Close Browser
|
||||
|
||||
@ -101,7 +101,7 @@ Test Case - Ldap User Push An Image
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} mike zhu88jie
|
||||
Create An New Project project${d}
|
||||
|
||||
|
||||
Push Image ${ip} mike zhu88jie project${d} hello-world:latest
|
||||
Go Into Project project${d}
|
||||
Wait Until Page Contains project${d}/hello-world
|
||||
|
85
tests/robot-cases/Group1-Nightly/OIDC.robot
Normal file
85
tests/robot-cases/Group1-Nightly/OIDC.robot
Normal file
@ -0,0 +1,85 @@
|
||||
// Copyright Project Harbor Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
*** Settings ***
|
||||
Documentation Harbor BATs
|
||||
Resource ../../resources/Util.robot
|
||||
Default Tags Nightly
|
||||
|
||||
*** Variables ***
|
||||
${HARBOR_URL} https://${OIDC_HOSTNAME}
|
||||
${HARBOR_ADMIN} admin
|
||||
|
||||
*** Test Cases ***
|
||||
Test Case - Get Harbor Version
|
||||
#Just get harbor version and log it
|
||||
Get Harbor Version
|
||||
|
||||
Test Case - OIDC User Sign In
|
||||
#Sign in with all 9 users is for user population, other test cases might use these users.
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL}
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test2
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test3
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test4
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test5
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test6
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test7
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test8
|
||||
Sleep 2
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL} test9
|
||||
Sleep 2
|
||||
Close Browser
|
||||
|
||||
Test Case - Create An New Project
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL}
|
||||
${d}= Get Current Date result_format=%M%S
|
||||
Create An New Project test${d}
|
||||
Close Browser
|
||||
|
||||
Test Case - Delete A Project
|
||||
Init Chrome Driver
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL}
|
||||
${secret}= Get Secrete By API ${HARBOR_URL}
|
||||
Delete A Project Without Sign In Harbor harbor_ip=${OIDC_HOSTNAME} username=${OIDC_USERNAME} password=${secret}
|
||||
Close Browser
|
||||
|
||||
Test Case - Manage Project Member
|
||||
Init Chrome Driver
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL}
|
||||
${secret}= Get Secrete By API ${HARBOR_URL}
|
||||
Manage Project Member Without Sign In Harbor sign_in_user=${OIDC_USERNAME} sign_in_pwd=${secret} test_user1=test2 test_user2=test3 is_oidc_mode=${true}
|
||||
Close Browser
|
||||
|
||||
Test Case - Generate User CLI Secret
|
||||
Init Chrome Driver
|
||||
${d}= Get current Date result_format=%m%s
|
||||
${image}= Set Variable hello-world
|
||||
Sign In Harbor With OIDC User ${HARBOR_URL}
|
||||
Create An New Project project${d}
|
||||
${secret_old}= Get Secrete By API ${HARBOR_URL}
|
||||
Push image ip=${ip} user=${OIDC_USERNAME} pwd=${secret_old} project=project${d} image=${image}
|
||||
${secret_new}= Generate And Return Secret ${HARBOR_URL}
|
||||
Log To Console ${secret_old}
|
||||
Log To Console ${secret_new}
|
||||
Should Not Be Equal As Strings '${secret_old}' '${secret_new}'
|
||||
Cannot Docker Login Harbor ${ip} ${OIDC_USERNAME} ${secret_old}
|
||||
Pull image ${ip} ${OIDC_USERNAME} ${secret_new} project${d} ${image}
|
||||
Push image ${ip} ${OIDC_USERNAME} ${secret_new} project${d} ${image}
|
@ -90,6 +90,61 @@ Test Case - Harbor Endpoint Delete
|
||||
Delete Success deletea
|
||||
Close Browser
|
||||
|
||||
Test Case - Replication Rule Edit
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%M%S
|
||||
${endpoint1}= Set Variable e1${d}
|
||||
${endpoint2}= Set Variable e2${d}
|
||||
${rule_name_old}= Set Variable rule_testabc${d}
|
||||
${rule_name_new}= Set Variable rule_abctest${d}
|
||||
${resource_type}= Set Variable chart
|
||||
${dest_namespace}= Set Variable dest_namespace${d}
|
||||
${mode}= Set Variable Scheduled
|
||||
${cron_str}= Set Variable 10 10 10 * * *
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Registries
|
||||
Create A New Endpoint docker-hub ${endpoint1} https://hub.docker.com/ danfengliu Aa123456 Y
|
||||
Create A New Endpoint harbor ${endpoint2} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
|
||||
Switch To Replication Manage
|
||||
Create A Rule With Existing Endpoint ${rule_name_old} pull danfengliu/* image ${endpoint1} project${d}
|
||||
Edit Replication Rule By Name ${rule_name_old}
|
||||
# Change rule-name, source-registry, filter, trigger-mode for edition verification
|
||||
Clear Field Of Characters ${rule_name_input} 30
|
||||
Retry Text Input ${rule_name_input} ${rule_name_new}
|
||||
Select Source Registry ${endpoint2}
|
||||
#Source Resource Filter
|
||||
Retry Text Input ${source_project} project${d}
|
||||
Select From List By Value ${rule_resource_selector} ${resource_type}
|
||||
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
|
||||
Select Trigger ${mode}
|
||||
Retry Text Input ${targetCron_id} ${cron_str}
|
||||
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
|
||||
# verify all items were changed as expected
|
||||
Edit Replication Rule By Name ${rule_name_new}
|
||||
Retry Textfield Value Should Be ${rule_name_input} ${rule_name_new}
|
||||
Retry List Selection Should Be ${src_registry_dropdown_list} ${endpoint2}-https://${ip}
|
||||
Retry Textfield Value Should Be ${source_project} project${d}
|
||||
Retry Textfield Value Should Be ${dest_namespace_xpath} ${dest_namespace}
|
||||
Retry List Selection Should Be ${rule_resource_selector} ${resource_type}
|
||||
Retry List Selection Should Be ${rule_trigger_select} ${mode}
|
||||
Retry Textfield Value Should Be ${targetCron_id} ${cron_str}
|
||||
Retry Element Click ${rule_cancel_btn}
|
||||
Ensure Delete Replication Rule By Name ${rule_name_new}
|
||||
Close Browser
|
||||
|
||||
Test Case - Replication Rule Delete
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%M%S
|
||||
${endpoint1}= Set Variable e1${d}
|
||||
${rule_name}= Set Variable rule_testabc${d}
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Registries
|
||||
Create A New Endpoint docker-hub ${endpoint1} https://hub.docker.com/ danfengliu Aa123456 Y
|
||||
Switch To Replication Manage
|
||||
Create A Rule With Existing Endpoint ${rule_name} pull danfengliu/* image ${endpoint1} project${d}
|
||||
Ensure Delete Replication Rule By Name ${rule_name}
|
||||
Close Browser
|
||||
|
||||
Test Case - Replication Of Pull Images from DockerHub To Self
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%M%S
|
||||
@ -192,4 +247,4 @@ Test Case - Replication Of Push Images from Self To Harbor By Push Event
|
||||
Go Into Project project_dest${d}
|
||||
Switch To Project Repo
|
||||
Retry Wait Until Page Contains project_dest${d}/centos
|
||||
Close Browser
|
||||
Close Browser
|
||||
|
@ -1,224 +0,0 @@
|
||||
// Copyright Project Harbor Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
*** Settings ***
|
||||
Documentation Harbor BATs
|
||||
Library ../../apitests/python/library/Harbor.py ${SERVER_CONFIG}
|
||||
Resource ../../resources/Util.robot
|
||||
Default Tags Replication
|
||||
|
||||
*** Variables ***
|
||||
${HARBOR_URL} https://${ip}
|
||||
${SSH_USER} root
|
||||
${HARBOR_ADMIN} admin
|
||||
${SERVER} ${ip}
|
||||
${SERVER_URL} https://${SERVER}
|
||||
${SERVER_API_ENDPOINT} ${SERVER_URL}/api
|
||||
&{SERVER_CONFIG} endpoint=${SERVER_API_ENDPOINT} verify_ssl=False
|
||||
${REMOTE_SERVER} ${ip1}
|
||||
${REMOTE_SERVER_URL} https://${REMOTE_SERVER}
|
||||
${REMOTE_SERVER_API_ENDPOINT} ${REMOTE_SERVER_URL}/api
|
||||
|
||||
*** Test Cases ***
|
||||
Test Case - Get Harbor Version
|
||||
#Just get harbor version and log it
|
||||
Get Harbor Version
|
||||
|
||||
Test Case - Pro Replication Rules Add
|
||||
Init Chrome Driver
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Replication Manage
|
||||
Check New Rule UI Without Endpoint
|
||||
Close Browser
|
||||
|
||||
Test Case - Endpoint Verification
|
||||
#This case need vailid info and selfsign cert
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Registries
|
||||
Create A New Endpoint edp1${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} N
|
||||
Endpoint Is Pingable
|
||||
Enable Certificate Verification
|
||||
Endpoint Is Unpingable
|
||||
Close Browser
|
||||
|
||||
Test Case - Endpoint Add
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Registries
|
||||
Create A New Endpoint testabc https://${d} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Wait Until Page Contains testabc
|
||||
Close Browser
|
||||
|
||||
Test Case - Endpoint Edit
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Registries
|
||||
Rename Endpoint testabc deletea
|
||||
Wait Until Page Contains deletea
|
||||
Close Browser
|
||||
|
||||
Test Case - Endpoint Delete
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Registries
|
||||
Delete Endpoint deletea
|
||||
Delete Success deletea
|
||||
Close Browser
|
||||
|
||||
Test Case - Rule Edit
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Create An New Project project${d}
|
||||
Switch To Registries
|
||||
Create A New Endpoint e${d} https://ip ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Replication Manage
|
||||
Create A Rule With Existing Endpoint rule${d} project${d} e${d} Immediate
|
||||
Rename Rule rule${d} newname
|
||||
Wait Until Page Contains newname
|
||||
Close Browser
|
||||
|
||||
Test Case - Rule Delete
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Replication Manage
|
||||
Delete Rule newname
|
||||
Delete Success newname
|
||||
Close Browser
|
||||
|
||||
|
||||
Test Case - Trigger Immediate
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Create An New Project project${d}
|
||||
Switch To Registries
|
||||
Create A New Endpoint edp${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Replication Manage
|
||||
Create A Rule With Existing Endpoint rule${d} project${d} edp${d} Immediate
|
||||
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
|
||||
Logout Harbor
|
||||
#logout and login target
|
||||
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Go Into Project project${d}
|
||||
Page Should Contain hello-world
|
||||
Go Into Repo hello-world
|
||||
Page Should Contain latest
|
||||
Close Browser
|
||||
|
||||
Test Case - Trigger Manual
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Create An New Project project${d}
|
||||
#using existing endpoint added before for only one replication endpoint
|
||||
Switch To Replication Manage
|
||||
Create A Rule With Existing Endpoint rule${d} project${d} edp Manual
|
||||
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
|
||||
Trigger Replication Manual rule${d}
|
||||
Logout Harbor
|
||||
#logout and login target
|
||||
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Go Into Project project${d}
|
||||
Page Should Contain hello-world
|
||||
Go Into Repo hello-world
|
||||
Page Should Contain latest
|
||||
Close Browser
|
||||
|
||||
Test Case - Large Image Replicate
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Create An New Project project${d}
|
||||
Push Image with tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ubuntu 16.04 16.04
|
||||
Switch To Replication Manage
|
||||
Create A Rule With Existing Endpoint rule${d} project${d} edp Immediate
|
||||
Logout Harbor
|
||||
#logout and login target
|
||||
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Go Into Project project${d}
|
||||
Page Should Contain ubuntu
|
||||
Go Into Repo ubuntu
|
||||
Page Should Contain 16.04
|
||||
Close Browser
|
||||
|
||||
Test Case - Proj Replication Jobs Log View
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Create An New Project project${d}
|
||||
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
|
||||
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox
|
||||
Switch To Registries
|
||||
Create A New Endpoint edp${d} aaa ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Switch To Replication Manage
|
||||
Create A Rule With Existing Endpoint rule${d} project${d} edp${d} Immediate
|
||||
Filter Rule rule${d}
|
||||
Select Rule rule${d}
|
||||
Wait Until Page Contains transfer
|
||||
Wait Until Page Contains error
|
||||
View Job Log busybox
|
||||
Close Browser
|
||||
|
||||
Test Case - Project LeveL Replication Operation
|
||||
Init Chrome Driver
|
||||
${d} = Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Create An New Project proj${d}
|
||||
Go Into Project proj${d} has_image=${false}
|
||||
Switch To Replication
|
||||
Project Create A Rule With Existing Endpoint rule${d} proj${d} edp Manual
|
||||
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} proj${d} hello-world
|
||||
Trigger Replication Manual rule${d}
|
||||
Logout Harbor
|
||||
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Go Into Project proj${d}
|
||||
Page Should Contain hello-world
|
||||
Go Into Repo hello-world
|
||||
Page Should Contain latest
|
||||
Close Browser
|
||||
|
||||
Test Case - Replicate based on label
|
||||
${project_id} ${project_name} = Create Project
|
||||
|
||||
Docker Pull hello-world:latest
|
||||
Docker Login ${SERVER} admin Harbor12345
|
||||
Docker Tag hello-world:latest ${SERVER}/${project_name}/hello-world:1.0
|
||||
Docker Push ${SERVER}/${project_name}/hello-world:1.0
|
||||
Docker Tag hello-world:latest ${SERVER}/${project_name}/hello-world:2.0
|
||||
Docker Push ${SERVER}/${project_name}/hello-world:2.0
|
||||
|
||||
${label_id} ${label_name} = Create Label
|
||||
Add Label To Image ${label_id} ${project_name}/hello-world 1.0
|
||||
|
||||
${registry_id} = Get Registry Id By Endpoint ${REMOTE_SERVER_URL}
|
||||
|
||||
${projects} = Create List ${project_id}
|
||||
${registries} = Create List ${registry_id}
|
||||
${label_filter} = Create Dictionary kind=label value=${label_id}
|
||||
${filters} = Create List ${label_filter}
|
||||
${rule_id} ${rule_name} = Create Replication Rule ${projects} ${registries} filters=${filters}
|
||||
|
||||
Start Replication ${rule_id}
|
||||
Wait Until Jobs Finish ${rule_id}
|
||||
|
||||
Image Should Exist ${project_name}/hello-world 1.0 endpoint=${REMOTE_SERVER_API_ENDPOINT} verify_ssl=False
|
||||
Image Should Not Exist ${project_name}/hello-world 2.0 endpoint=${REMOTE_SERVER_API_ENDPOINT} verify_ssl=False
|
||||
|
@ -30,8 +30,8 @@
|
||||
{
|
||||
"url":"http://url",
|
||||
"name":"endpoint1",
|
||||
"user":"endpointuser",
|
||||
"pass":"endpointpass"
|
||||
"user":"admin",
|
||||
"pass":"Harbor12345"
|
||||
}
|
||||
],
|
||||
"replicationrule":[
|
||||
|
@ -12,6 +12,7 @@ parser.add_argument('--version', '-v', dest='version', required=False, help='The
|
||||
args = parser.parse_args()
|
||||
|
||||
url = "https://"+args.endpoint+"/api/"
|
||||
endpoint_url = "https://"+args.endpoint
|
||||
print url
|
||||
|
||||
class HarborAPI:
|
||||
@ -45,18 +46,27 @@ class HarborAPI:
|
||||
request(url+"projects/"+projectid+"/members", 'post', **body)
|
||||
|
||||
def add_endpoint(self, endpointurl, endpointname, username, password, insecure):
|
||||
payload = {"endpoint": ""+endpointurl+"", "name": ""+endpointname+"", "username": ""+username+"", "password": ""+password+"", "insecure": insecure}
|
||||
payload = {
|
||||
"credential":{
|
||||
"access_key":""+username+"",
|
||||
"access_secret":""+password+"",
|
||||
"type":"basic"
|
||||
},
|
||||
"insecure":insecure,
|
||||
"name":""+endpointname+"",
|
||||
"type":"harbor",
|
||||
"url":""+endpoint_url+""
|
||||
}
|
||||
body=dict(body=payload)
|
||||
request(url+"targets", 'post', **body)
|
||||
print body
|
||||
request(url+"/registries", 'post', **body)
|
||||
|
||||
def add_replication_rule(self, project, target, trigger, rulename):
|
||||
r = request(url+"projects?name="+project+"", 'get')
|
||||
projectid = r.json()[0]['project_id']
|
||||
r = request(url+"targets?name="+target+"", 'get')
|
||||
r = request(url+"registries?name="+target+"", 'get')
|
||||
targetid = r.json()[0]['id']
|
||||
payload = {"name": ""+rulename+"", "description": "string", "projects": [{"project_id": projectid,}], "targets": [{"id": targetid,}], "trigger": {"kind": ""+trigger+"", "schedule_param": {"type": "weekly", "weekday": 1, "offtime": 0}}}
|
||||
payload = {"name": ""+rulename+"", "deletion": False, "enabled": True, "description": "string", "dest_registry": {"id": targetid},"trigger": {"type": "manual"}}
|
||||
body=dict(body=payload)
|
||||
request(url+"policies/replication", 'post', **body)
|
||||
request(url+"replication/policies", 'post', **body)
|
||||
|
||||
def update_project_setting(self, project, contenttrust, preventrunning, preventseverity, scanonpush):
|
||||
r = request(url+"projects?name="+project+"", 'get')
|
||||
@ -171,7 +181,7 @@ def do_data_creation():
|
||||
push_signed_image("alpine", data["projects"][0]["name"], "latest")
|
||||
|
||||
for endpoint in data["endpoint"]:
|
||||
harborAPI.add_endpoint(endpoint["url"], endpoint["name"], endpoint["user"], endpoint["pass"], False)
|
||||
harborAPI.add_endpoint(endpoint["url"], endpoint["name"], endpoint["user"], endpoint["pass"], True)
|
||||
for replicationrule in data["replicationrule"]:
|
||||
harborAPI.add_replication_rule(replicationrule["project"],
|
||||
replicationrule["endpoint"], replicationrule["trigger"],
|
||||
@ -180,7 +190,7 @@ def do_data_creation():
|
||||
harborAPI.update_project_setting(project["name"],
|
||||
project["configuration"]["enable_content_trust"],
|
||||
project["configuration"]["prevent_vulnerable_images_from_running"],
|
||||
project["configuration"]["prevent_vlunerable_images_from_running_severity"],
|
||||
project["configuration"]["prevent_vlunerable_images_from_running_severity"],
|
||||
project["configuration"]["automatically_scan_images_on_push"])
|
||||
harborAPI.update_systemsetting(data["configuration"]["emailsetting"]["emailfrom"],
|
||||
data["configuration"]["emailsetting"]["emailserver"],
|
||||
|
192
tests/robot-cases/Group3-Upgrade/prepare_v17.py
Normal file
192
tests/robot-cases/Group3-Upgrade/prepare_v17.py
Normal file
@ -0,0 +1,192 @@
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import requests
|
||||
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
parser = argparse.ArgumentParser(description='The script to generate data for harbor v1.4.0')
|
||||
parser.add_argument('--endpoint', '-e', dest='endpoint', required=True, help='The endpoint to harbor')
|
||||
parser.add_argument('--version', '-v', dest='version', required=False, help='The version to harbor')
|
||||
args = parser.parse_args()
|
||||
|
||||
url = "https://"+args.endpoint+"/api/"
|
||||
print url
|
||||
|
||||
class HarborAPI:
|
||||
def create_project(self, project_name):
|
||||
body=dict(body={"project_name": ""+project_name+"", "metadata": {"public": "true"}})
|
||||
request(url+"projects", 'post', **body)
|
||||
|
||||
def create_user(self, username):
|
||||
payload = {"username":username, "email":username+"@vmware.com", "password":"Harbor12345", "realname":username, "comment":"string"}
|
||||
body=dict(body=payload)
|
||||
request(url+"users", 'post', **body)
|
||||
|
||||
def set_user_admin(self, user):
|
||||
r = request(url+"users?username="+user+"", 'get')
|
||||
userid = str(r.json()[0]['user_id'])
|
||||
if args.version == "1.6":
|
||||
body=dict(body={"has_admin_role": True})
|
||||
else:
|
||||
body=dict(body={"has_admin_role": 1})
|
||||
request(url+"users/"+userid+"/sysadmin", 'put', **body)
|
||||
|
||||
def add_member(self, project, user, role):
|
||||
r = request(url+"projects?name="+project+"", 'get')
|
||||
projectid = str(r.json()[0]['project_id'])
|
||||
if args.version == "1.6":
|
||||
payload = {"member_user":{ "username": ""+user+""},"role_id": role}
|
||||
else:
|
||||
payload = {"roles": [role], "username":""+user+""}
|
||||
|
||||
body=dict(body=payload)
|
||||
request(url+"projects/"+projectid+"/members", 'post', **body)
|
||||
|
||||
def add_endpoint(self, endpointurl, endpointname, username, password, insecure):
|
||||
payload = {"endpoint": ""+endpointurl+"", "name": ""+endpointname+"", "username": ""+username+"", "password": ""+password+"", "insecure": insecure}
|
||||
body=dict(body=payload)
|
||||
request(url+"targets", 'post', **body)
|
||||
|
||||
def add_replication_rule(self, project, target, trigger, rulename):
|
||||
r = request(url+"projects?name="+project+"", 'get')
|
||||
projectid = r.json()[0]['project_id']
|
||||
r = request(url+"targets?name="+target+"", 'get')
|
||||
targetid = r.json()[0]['id']
|
||||
payload = {"name": ""+rulename+"", "description": "string", "projects": [{"project_id": projectid,}], "targets": [{"id": targetid,}], "trigger": {"kind": ""+trigger+"", "schedule_param": {"type": "weekly", "weekday": 1, "offtime": 0}}}
|
||||
body=dict(body=payload)
|
||||
request(url+"policies/replication", 'post', **body)
|
||||
|
||||
def update_project_setting(self, project, contenttrust, preventrunning, preventseverity, scanonpush):
|
||||
r = request(url+"projects?name="+project+"", 'get')
|
||||
projectid = str(r.json()[0]['project_id'])
|
||||
payload = {
|
||||
"project_name": ""+project+"",
|
||||
"metadata": {
|
||||
"public": "True",
|
||||
"enable_content_trust": contenttrust,
|
||||
"prevent_vulnerable_images_from_running": preventrunning,
|
||||
"prevent_vulnerable_images_from_running_severity": preventseverity,
|
||||
"automatically_scan_images_on_push": scanonpush
|
||||
}
|
||||
}
|
||||
body=dict(body=payload)
|
||||
request(url+"projects/"+projectid+"", 'put', **body)
|
||||
|
||||
def update_systemsetting(self, emailfrom, emailhost, emailport, emailuser, creation, selfreg, token):
|
||||
payload = {
|
||||
"auth_mode": "db_auth",
|
||||
"email_from": emailfrom,
|
||||
"email_host": emailhost,
|
||||
"email_port": emailport,
|
||||
"email_identity": "string",
|
||||
"email_username": emailuser,
|
||||
"email_ssl": True,
|
||||
"email_insecure": True,
|
||||
"project_creation_restriction": creation,
|
||||
"read_only": False,
|
||||
"self_registration": selfreg,
|
||||
"token_expiration": token,
|
||||
"scan_all_policy": {
|
||||
"type": "none",
|
||||
"parameter": {
|
||||
"daily_time": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
body=dict(body=payload)
|
||||
request(url+"configurations", 'put', **body)
|
||||
|
||||
def update_repoinfo(self, reponame):
|
||||
payload = {"description": "testdescription"}
|
||||
body=dict(body=payload)
|
||||
request(url+"repositories/"+reponame+"", 'put', **body)
|
||||
|
||||
def get_ca(self, target='/harbor/ca/ca.crt'):
|
||||
url = "https://" + args.endpoint + "/api/systeminfo/getcert"
|
||||
resp = request(url, 'get')
|
||||
try:
|
||||
ca_content = json.loads(resp.text)
|
||||
except ValueError:
|
||||
ca_content = resp.text
|
||||
ca_path = '/harbor/ca'
|
||||
if not os.path.exists(ca_path):
|
||||
try:
|
||||
os.makedirs(ca_path)
|
||||
except Exception, e:
|
||||
pass
|
||||
open(target, 'wb').write(ca_content)
|
||||
|
||||
|
||||
def request(url, method, user = None, userp = None, **kwargs):
|
||||
if user is None:
|
||||
user = "admin"
|
||||
if userp is None:
|
||||
userp = "Harbor12345"
|
||||
kwargs.setdefault('headers', kwargs.get('headers', {}))
|
||||
kwargs['headers']['Accept'] = 'application/json'
|
||||
if 'body' in kwargs:
|
||||
kwargs['headers']['Content-Type'] = 'application/json'
|
||||
kwargs['data'] = json.dumps(kwargs['body'])
|
||||
del kwargs['body']
|
||||
|
||||
resp = requests.request(method, url, verify=False, auth=(user, userp), **kwargs)
|
||||
if resp.status_code >= 400:
|
||||
raise Exception("[Exception Message] - {}".format(resp.text))
|
||||
return resp
|
||||
|
||||
with open("data.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
def pull_image(*image):
|
||||
for i in image:
|
||||
os.system("docker pull "+i)
|
||||
|
||||
def push_image(image, project):
|
||||
os.system("docker tag "+image+" "+args.endpoint+"/"+project+"/"+image)
|
||||
os.system("docker login "+args.endpoint+" -u Admin"+" -p Harbor12345")
|
||||
os.system("docker push "+args.endpoint+"/"+project+"/"+image)
|
||||
|
||||
def push_signed_image(image, project, tag):
|
||||
os.system("./sign_image.sh" + " " + args.endpoint + " " + project + " " + image + " " + tag)
|
||||
|
||||
def do_data_creation():
|
||||
harborAPI = HarborAPI()
|
||||
harborAPI.get_ca()
|
||||
|
||||
for user in data["users"]:
|
||||
harborAPI.create_user(user["name"])
|
||||
|
||||
for user in data["admin"]:
|
||||
harborAPI.set_user_admin(user["name"])
|
||||
|
||||
for project in data["projects"]:
|
||||
harborAPI.create_project(project["name"])
|
||||
for member in project["member"]:
|
||||
harborAPI.add_member(project["name"], member["name"], member["role"])
|
||||
|
||||
pull_image("busybox", "redis", "haproxy", "alpine", "httpd:2")
|
||||
push_image("busybox", data["projects"][0]["name"])
|
||||
push_signed_image("alpine", data["projects"][0]["name"], "latest")
|
||||
|
||||
for endpoint in data["endpoint"]:
|
||||
harborAPI.add_endpoint(endpoint["url"], endpoint["name"], endpoint["user"], endpoint["pass"], False)
|
||||
for replicationrule in data["replicationrule"]:
|
||||
harborAPI.add_replication_rule(replicationrule["project"],
|
||||
replicationrule["endpoint"], replicationrule["trigger"],
|
||||
replicationrule["rulename"])
|
||||
for project in data["projects"]:
|
||||
harborAPI.update_project_setting(project["name"],
|
||||
project["configuration"]["enable_content_trust"],
|
||||
project["configuration"]["prevent_vulnerable_images_from_running"],
|
||||
project["configuration"]["prevent_vlunerable_images_from_running_severity"],
|
||||
project["configuration"]["automatically_scan_images_on_push"])
|
||||
harborAPI.update_systemsetting(data["configuration"]["emailsetting"]["emailfrom"],
|
||||
data["configuration"]["emailsetting"]["emailserver"],
|
||||
float(data["configuration"]["emailsetting"]["emailport"]),
|
||||
data["configuration"]["emailsetting"]["emailuser"],
|
||||
data["configuration"]["projectcreation"],
|
||||
data["configuration"]["selfreg"],
|
||||
float(data["configuration"]["token"]))
|
||||
do_data_creation()
|
@ -10,8 +10,8 @@ ${HARBOR_ADMIN} admin
|
||||
*** Test Cases ***
|
||||
Test Case - Upgrade Verify
|
||||
${data}= Load Json From File ${CURDIR}${/}data.json
|
||||
Run Keyword Verify User ${data}
|
||||
Run Keyword Verify Project ${data}
|
||||
Run Keyword Verify User ${data}
|
||||
Run Keyword Verify Project ${data}
|
||||
Run Keyword Verify Member Exist ${data}
|
||||
Run Keyword Verify User System Admin Role ${data}
|
||||
Run Keyword Verify Endpoint ${data}
|
||||
|
Loading…
Reference in New Issue
Block a user