mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
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>
This commit is contained in:
parent
1ceb7a2fb9
commit
a503944110
39
tests/resources/Harbor-Pages/OIDC_Auth.robot
Normal file
39
tests/resources/Harbor-Pages/OIDC_Auth.robot
Normal file
@ -0,0 +1,39 @@
|
||||
# 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}
|
26
tests/resources/Harbor-Pages/OIDC_Auth_Elements.robot
Normal file
26
tests/resources/Harbor-Pages/OIDC_Auth_Elements.robot
Normal file
@ -0,0 +1,26 @@
|
||||
# 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
|
@ -51,5 +51,7 @@ Collect Logs
|
||||
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
|
@ -110,3 +110,14 @@ Body Of Admin Push Signed Image
|
||||
Log To Console ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
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}
|
@ -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
|
||||
@ -197,3 +199,12 @@ Retry Double Keywords When Error
|
||||
\ Sleep 2
|
||||
Should Be Equal As Strings '${out1[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
|
||||
|
65
tests/robot-cases/Group1-Nightly/OIDC.robot
Normal file
65
tests/robot-cases/Group1-Nightly/OIDC.robot
Normal file
@ -0,0 +1,65 @@
|
||||
// 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 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}
|
||||
${json}= Run Curl And Return Json curl -s -k -X GET --header 'Accept: application/json' -u '${HARBOR_ADMIN}:${HARBOR_PASSWORD}' 'https://${ip}/api/users/search?username=${OIDC_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}' 'https://${ip}/api/users/${user_id}'
|
||||
${secret}= Set Variable ${json["oidc_user_meta"]["secret"]}
|
||||
Delete A Project Without Sign In Harbor harbor_ip=${OIDC_HOSTNAME} username=${OIDC_USERNAME} password=${secret}
|
||||
Close Browser
|
Loading…
Reference in New Issue
Block a user