2017-08-07 08:02:38 +02:00
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
//
// 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
Suite Setup Install Harbor to Test Server
Default Tags BAT
*** Variables ***
2017-10-30 07:55:03 +01:00
${HARBOR_URL} https://${ip}
2017-08-07 08:02:38 +02:00
*** Test Cases ***
Test Case - Create An New User
Init Chrome Driver
2017-09-07 12:29:05 +02:00
${d}= Get Current Date result_format=%m%s
2017-08-07 08:02:38 +02:00
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Close Browser
Test Case - Sign With Admin
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Close Browser
Test Case - Update User Comment
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Update User Comment Test12#4
Logout Harbor
Test Case - Update Password
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Change Password Test1@34 Test12#4
Logout Harbor
Sign In Harbor ${HARBOR_URL} tester${d} Test12#4
Close Browser
Test Case - Create An New Project
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Create An New Project test${d}
Close Browser
Test Case - User View Projects
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Create An New Project test${d}1
Create An New Project test${d}2
Create An New Project test${d}3
Switch To Log
2017-09-07 12:29:05 +02:00
Capture Page Screenshot UserViewProjects.png
2017-08-07 08:02:38 +02:00
Wait Until Page Contains test${d}1
Wait Until Page Contains test${d}2
Wait Until Page Contains test${d}3
Close Browser
Test Case - Push Image
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Create An New Project test${d}
2017-09-07 12:29:05 +02:00
Push image ${ip} tester${d} Test1@34 test${d} hello-world:latest
2017-08-07 08:02:38 +02:00
Go Into Project test${d}
Wait Until Page Contains test${d}/hello-world
Test Case - User View Logs
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
2017-10-30 07:55:03 +01:00
Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=true
2017-08-07 08:02:38 +02:00
2017-09-07 12:29:05 +02:00
Push image ${ip} tester${d} Test1@34 project${d} busybox:latest
2017-08-07 08:02:38 +02:00
Pull image ${ip} tester${d} Test1@34 project${d} busybox:latest
2017-09-07 12:29:05 +02:00
Go Into Project project${d}
Delete Repo project${d}
2017-08-07 08:02:38 +02:00
2017-09-07 12:29:05 +02:00
Go To Project Log
Advanced Search Should Display
2017-08-07 08:02:38 +02:00
2017-09-07 12:29:05 +02:00
Do Log Advanced Search
2017-08-07 08:02:38 +02:00
Close Browser
Test Case - Manage project publicity
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=usera${d} email=usera${d}@vmware.com realname=usera${d} newPassword=Test1@34 comment=harbor
Logout Harbor
Create An New User url=${HARBOR_URL} username=userb${d} email=userb${d}@vmware.com realname=userb${d} newPassword=Test1@34 comment=harbor
Logout Harbor
Sign In Harbor ${HARBOR_URL} usera${d} Test1@34
Create An New Project project${d} public=true
Push image ${ip} usera${d} Test1@34 project${d} hello-world:latest
Pull image ${ip} userb${d} Test1@34 project${d} hello-world:latest
Logout Harbor
Sign In Harbor ${HARBOR_URL} userb${d} Test1@34
Project Should Display project${d}
Search Private Projects
Project Should Not Display project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} usera${d} Test1@34
Make Project Private project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} userb${d} Test1@34
Project Should Not Display project${d}
Cannot Pull image ${ip} userb${d} Test1@34 project${d} hello-world:latest
Logout Harbor
Sign In Harbor ${HARBOR_URL} usera${d} Test1@34
Make Project Public project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} userb${d} Test1@34
Project Should Display project${d}
2017-09-07 12:29:05 +02:00
Close Browser
2017-08-07 08:02:38 +02:00
2017-11-03 07:36:40 +01:00
Test Case - Project Level Policy Public
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}
Go Into Project project${d}
Goto Project Config
Click Project Public
Save Project Config
#verify
Public Should Be Selected
Back To Projects
#project${d} default should be private
Project Should Be Public project${d}
Close Browser
Test Case - Project Level Policy Content Trust
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:latest
Go Into Project project${d}
Goto Project Config
Click Content Trust
Save Project Config
#verify
Content Trust Should Be Selected
Cannot Pull Unsigned Image ${ip} %{HARBOR_ADMIN} %{HARBOR_PASSWORD} project${d} hello-world:latest
Close Browser
2017-08-07 08:02:38 +02:00
Test Case - Edit Project Creation
2017-09-07 12:29:05 +02:00
# create normal user and login
2017-08-07 08:02:38 +02:00
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
2017-09-07 12:29:05 +02:00
Project Creation Should Display
2017-08-07 08:02:38 +02:00
Logout Harbor
2017-09-07 12:29:05 +02:00
Sleep 3
2017-08-07 08:02:38 +02:00
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
2017-09-07 12:29:05 +02:00
Set Pro Create Admin Only
2017-08-07 08:02:38 +02:00
Logout Harbor
2017-09-07 12:29:05 +02:00
Sign In Harbor ${HARBOR_URL} tester${d} Test1@34
Project Creation Should Not Display
Logout Harbor
2017-08-07 08:02:38 +02:00
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Set Pro Create Every One
Close browser
Test Case - Edit Self-Registration
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Disable Self Reg
2017-09-07 12:29:05 +02:00
Logout Harbor
2017-08-07 08:02:38 +02:00
Sign Up Should Not Display
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
2017-09-07 12:29:05 +02:00
Switch To Configure
2017-08-07 08:02:38 +02:00
Self Reg Should Be Disabled
Sleep 1
2017-09-07 12:29:05 +02:00
#restore setting
2017-08-07 08:02:38 +02:00
Enable Self Reg
Close Browser
Test Case - Edit Email Settings
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
2017-09-07 12:29:05 +02:00
Switch To Email
2017-08-07 08:02:38 +02:00
Config Email
Logout Harbor
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
2017-09-07 12:29:05 +02:00
Switch To Email
2017-08-07 08:02:38 +02:00
Verify Email
Close Browser
Test Case - Edit Token Expire
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
2017-09-07 12:29:05 +02:00
Switch To System Settings
Modify Token Expiration 20
2017-08-07 08:02:38 +02:00
Logout Harbor
2017-09-07 12:29:05 +02:00
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Switch To System Settings
2017-08-07 08:02:38 +02:00
Token Must Be Match 20
2017-09-07 12:29:05 +02:00
#reset to default
2017-08-07 08:02:38 +02:00
Modify Token Expiration 30
Close Browser
2018-01-05 07:32:16 +01:00
# Test Case - Create An Replication Rule New Endpoint
# 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}
# Go Into Project project${d}
# Switch To Replication
# Create An New Rule With New Endpoint policy_name=test_policy_${d} policy_description=test_description destination_name=test_destination_name_${d} destination_url=test_destination_url_${d} destination_username=test_destination_username destination_password=test_destination_password
# Close Browser
2017-08-07 08:02:38 +02:00
2017-12-08 08:05:52 +01:00
Test Case - Scan A Tag In The Repo
2017-08-07 08:02:38 +02:00
Init Chrome Driver
${d}= get current date result_format=%m%s
Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=false
Push Image ${ip} tester${d} Test1@34 project${d} hello-world
2017-12-21 04:00:12 +01:00
Go Into Project project${d}
2017-12-08 08:05:52 +01:00
Go Into Repo project${d}/hello-world
2017-10-12 05:31:44 +02:00
Scan Repo latest
Summary Chart Should Display latest
2017-12-21 04:00:12 +01:00
#Edit Repo Info
2017-09-07 12:29:05 +02:00
Close Browser
2017-10-30 07:55:03 +01:00
Test Case - Manage Project Member
2017-09-07 12:29:05 +02:00
Init Chrome Driver
${d}= Get current Date result_format=%m%s
Create An New Project With New User url=${HARBOR_URL} username=alice${d} email=alice${d}@vmware.com realname=alice${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=false
Push image ip=${ip} user=alice${d} pwd=Test1@34 project=project${d} image=hello-world
Logout Harbor
Create An New User url=${HARBOR_URL} username=bob${d} email=bob${d}@vmware.com realname=bob${d} newPassword=Test1@34 comment=habor
Logout Harbor
Create An New User url=${HARBOR_URL} username=carol${d} email=carol${d}@vmware.com realname=carol${d} newPassword=Test1@34 comment=harbor
Logout Harbor
User Should Not Be A Member Of Project bob${d} Test1@34 project${d}
Manage Project Member alice${d} Test1@34 project${d} bob${d} Add
User Should Be Guest bob${d} Test1@34 project${d}
Change User Role In Project alice${d} Test1@34 project${d} bob${d} Developer
User Should Be Developer bob${d} Test1@34 project${d}
Change User Role In Project alice${d} Test1@34 project${d} bob${d} Admin
User Should Be Admin bob${d} Test1@34 project${d} carol${d}
Manage Project Member alice${d} Test1@34 project${d} bob${d} Remove
User Should Not Be A Member Of Project bob${d} Test1@34 project${d}
User Should Be Guest carol${d} Test1@34 project${d}
Close Browser
2017-08-07 08:02:38 +02:00
2017-10-27 11:20:20 +02:00
Test Case - Delete A Project
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New Project With New User ${HARBOR_URL} tester${d} tester${d}@vmware.com tester${d} Test1@34 harobr project${d} false
Push Image ${ip} tester${d} Test1@34 project${d} hello-world
Project Should Not Be Deleted project${d}
Go Into Project project${d}
Delete Repo project${d}
Back To projects
Project Should Be Deleted project${d}
Close Browser
2018-01-12 03:42:17 +01:00
Test Case - Delete Multi Project
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor
Create An New Project projecta${d}
Create An New Project projectb${d}
Push Image ${ip} test${d} Test1@34 projecta${d} hello-world
Filter Object project
Multi-delete Object projecta projectb
#verify delete project with image should not be deleted directly
Partly Success
Page Should Contain projecta${d}
Page Should Not Contain projectb${d}
Close Browser
Test Case - Delete Multi User
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User ${HARBOR_URL} deletea${d} testa${d}@vmware.com test${d} Test1@34 harbor
Logout Harbor
Create An New User ${HARBOR_URL} deleteb${d} testb${d}@vmware.com test${d} Test1@34 harbor
Logout Harbor
Create An New User ${HARBOR_URL} deletec${d} testc${d}@vmware.com test${d} Test1@34 harbor
Logout Harbor
Sign In Harbor ${HARBOR_URL} admin Harbor12345
Switch To User Tag
Filter Object delete
Multi-delete Object deletea deleteb deletec
#assert delete
2018-01-12 06:06:24 +01:00
Delete Success
2018-01-12 03:42:17 +01:00
Sleep 1
#filter object delete
Page Should Not Contain deletea
Close Browser
Test Case - Delete Multi Repo
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor
Create An New Project project${d}
Push Image ${ip} test${d} Test1@34 project${d} hello-world
Push Image ${ip} test${d} Test1@34 project${d} busybox
Sleep 2
Go Into Project project${d}
Multi-delete Object hello-world busybox
#verify
Delete Success
Close Browser
Test Case - Delete Multi Tag
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor
Create An New Project project${d}
Push Image With Tag ${ip} test${d} Test1@34 project${d} hello-world latest
Push Image With Tag ${ip} test${d} Test1@34 project${d} hello-world v1
Sleep 2
Go Into Project project${d}
Go Into Repo hello-world
Multi-delete object latest v1
#verify
Delete Success
Close Browser
Test Case - Delete Multi Member
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User ${HARBOR_URL} testa${d} testa${d}@vmware.com test${d} Test1@34 harbor
Logout Harbor
Create An New User ${HARBOR_URL} testb${d} testb${d}@vmware.com test${d} Test1@34 harbor
Logout Harbor
Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor
Create An New Project project${d}
Go Into Project project${d}
Switch To Member
Add Guest Member to project testa${d}
Add Guest Member to project testb${d}
Multi-delete Object testa${d} testb${d}
Delete Success
Page Should Not Contain testa${d}
Close Browser
2017-08-07 08:02:38 +02:00
Test Case - Assign Sys Admin
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Logout Harbor
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Switch to User Tag
Assign User Admin tester${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} tester${d} Test1@34
Administration Tag Should Display
Close Browser
2017-10-30 07:55:03 +01:00
Test Case - Admin Push Signed Image
Enabe Notary Client
${rc} ${output}= Run And Return Rc And Output docker pull hello-world:latest
Log ${output}
Push image ${ip} %{HARBOR_ADMIN} %{HARBOR_PASSWORD} library hello-world:latest
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group9-Content-trust/notary-push-image.sh
Log ${output}
Should Be Equal As Integers ${rc} 0
${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
Test Case - Admin Push Un-Signed Image
${rc} ${output}= Run And Return Rc And Output docker push ${ip}/library/hello-world:latest
Log To Console ${output}
2017-11-01 11:19:58 +01:00
Test Case - Ldap Verify Cert
2017-08-07 08:02:38 +02:00
Switch To LDAP
2017-11-01 11:19:58 +01:00
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Switch To Configure
Test Ldap Connection
Close Browser
Test Case - Ldap Sign in and out
2017-08-07 08:02:38 +02:00
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Switch To Configure
Init LDAP
Logout Harbor
2017-11-29 12:29:51 +01:00
Sign In Harbor ${HARBOR_URL} mike zhu88jie
2017-08-07 08:02:38 +02:00
Close Browser
2017-10-17 09:05:16 +02:00
Test Case - Ldap User Create Project
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
2017-11-29 12:29:51 +01:00
Sign In Harbor ${HARBOR_URL} mike zhu88jie
2017-10-17 09:05:16 +02:00
Create An New Project project${d}
2017-12-01 06:47:21 +01:00
Logout Harbor
Manage Project Member %{HARBOR_ADMIN} %{HARBOR_PASSWORD} project${d} mike02 Add
2018-01-02 11:28:48 +01:00
Project Should Have Member project${d} mike02
User Email Should Exist mike02@example.com
2017-10-17 09:05:16 +02:00
Close Browser
Test Case - Ldap User Push An Image
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
2017-11-29 12:29:51 +01:00
Sign In Harbor ${HARBOR_URL} mike zhu88jie
2017-10-17 09:05:16 +02:00
Create An New Project project${d}
2017-11-01 11:19:58 +01:00
2017-11-29 12:29:51 +01:00
Push Image ${ip} mike zhu88jie project${d} hello-world:latest
2017-10-17 09:05:16 +02:00
Go Into Project project${d}
Wait Until Page Contains project${d}/hello-world
2017-10-18 03:48:14 +02:00
Close Browser
2017-10-17 09:05:16 +02:00
2017-11-29 12:29:51 +01:00
Test Case - Ldap User Can Not login
Docker Login Fail ${ip} test 123456
2017-09-01 04:47:04 +02:00
Test Case - Clean Harbor Images
2017-10-30 07:55:03 +01:00
Down Harbor
2017-11-29 12:29:51 +01:00