Skip to content

Commit

Permalink
Add GUI test script for new feature of master-role, without adding a …
Browse files Browse the repository at this point in the history
…new case for master-role, I add new test steps in old test case named Manage-Project-Members, because master-role is a sub function in project members. (goharbor#6945)

In this PR, I also modify a public action keyword to make it suitble for indefinite numbers of parameters.

Signed-off-by: danfengliu <danfengl@vmware.com>
  • Loading branch information
danfengliu committed Feb 22, 2019
1 parent f19ad5c commit a1063ed
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 57 deletions.
4 changes: 2 additions & 2 deletions tests/resources/APITest-Util.robot
@@ -1,13 +1,13 @@
*** Keywords ***
Make Swagger Client
${rc} ${output}= Run And Return Rc And Output make swagger_client
${rc} ${output}= Run And Return Rc And Output make swagger_client
Log ${output}
[Return] ${rc}

Setup API Test
Retry Keyword When Error Make Swagger Client

Harbor API Test
Harbor API Test
[Arguments] ${testcase_name}
${current_dir}= Run pwd
Log To Console ${current_dir}
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/Harbor-Pages/Project-Helmcharts.robot
Expand Up @@ -47,4 +47,4 @@ Go Back To Versions And Delete
Retry Element Click xpath=${version_checkbox}
Retry Element Click xpath=${version_delete}
Retry Element Click xpath=${version_confirm_delete}
Retry Keyword When Error Wait Until Page Contains Element element=xpath=${helmchart_content}
Retry Wait Until Page Contains Element xpath=${helmchart_content}
45 changes: 27 additions & 18 deletions tests/resources/Harbor-Pages/Project-Members.robot
Expand Up @@ -22,11 +22,10 @@ ${HARBOR_VERSION} v1.1.1
*** Keywords ***
Go Into Project
[Arguments] ${project} ${has_image}=${true}
Wait Until Element Is Visible And Enabled ${search_input}
Retry Wait Element ${search_input}
Input Text ${search_input} ${project}
Wait Until Page Contains ${project}
Wait Until Element Is Visible And Enabled xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a
Click Element xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a
Retry Wait Until Page Contains ${project}
Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a
#To prevent waiting for a fixed-period of time for page loading and failure caused by exception, we add loop to re-run <Wait Until Element Is Visible And Enabled> when
# exception was caught.
:For ${n} IN RANGE 1 5
Expand All @@ -41,35 +40,35 @@ Go Into Project
Add User To Project Admin
[Arguments] ${project} ${user}
Go Into Project
Sleep 2
Sleep 2
Click Element xpath=${project_member_tag_xpath}
Sleep 1
Click Element xpath=${project_member_add_button_xpath}
Sleep 2
Sleep 2
Input Text xpath=${project_member_add_username_xpath} ${user}
Sleep 3
Click Element xpath=${project_member_add_admin_xpath}
Click Element xpath=${project_member_add_save_button_xpath}
Sleep 4

Search Project Member
[Arguments] ${project} ${user}
Go Into Project ${project}
Sleep 2
Sleep 2
Click Element xpath=//clr-dg-cell//a[contains(.,'${project}')]
Sleep 1
Sleep 1
Click Element xpath=${project_member_search_button_xpath}
Sleep 1
Sleep 1
Click Element xpath=${project_member_search_text_xpath}
Sleep 2
Wait Until Page Contains ${user}
Wait Until Page Contains ${user}

Change Project Member Role
[Arguments] ${project} ${user} ${role}
Click Element xpath=//clr-dg-cell//a[contains(.,'${project}')]
Sleep 2
Sleep 2
Click Element xpath=${project_member_tag_xpath}
Sleep 1
Sleep 1
Click Element xpath=//project-detail//clr-dg-row[contains(.,'${user}')]//label
Sleep 1
#change role
Expand Down Expand Up @@ -100,13 +99,12 @@ User Can Not Add Member

Add Guest Member To Project
[arguments] ${member}
Click Element xpath=${project_member_add_button_xpath}
Sleep 1
Input Text xpath=${project_member_add_username_xpath} ${member}
Retry Element Click xpath=${project_member_add_button_xpath}
Retry Text Input xpath=${project_member_add_username_xpath} ${member}
#select guest
Mouse Down xpath=${project_member_guest_radio_checkbox}
Mouse Up xpath=${project_member_guest_radio_checkbox}
Click Button xpath=${project_member_add_confirmation_ok_xpath}
Retry Button Click xpath=${project_member_add_confirmation_ok_xpath}
Sleep 1

Delete Project Member
Expand Down Expand Up @@ -188,6 +186,17 @@ User Should Be Admin
Logout Harbor
Push Image With Tag ${ip} ${user} ${pwd} ${project} hello-world v2

User Should Be Master
[Arguments] ${user} ${pwd} ${project}
Sign In Harbor ${HARBOR_URL} ${user} ${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

Project Should Have Member
[Arguments] ${project} ${user}
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Expand Down
16 changes: 7 additions & 9 deletions tests/resources/Harbor-Pages/Project.robot
Expand Up @@ -44,7 +44,7 @@ Create An New Project With New User
Logout Harbor
Sign In Harbor ${url} ${username} ${newPassword}
Create An New Project ${projectname} ${public}
Sleep 1
Sleep 1

#It's the log of project.
Go To Project Log
Expand All @@ -67,7 +67,7 @@ Switch To Replication
Sleep 1

Navigate To Projects
${element}= Set Variable xpath=${projects_xpath}
${element}= Set Variable xpath=${projects_xpath}
Wait Until Element Is Visible And Enabled ${element}
Click Element ${element}
Sleep 2
Expand All @@ -89,7 +89,7 @@ Search Private Projects

Make Project Private
[Arguments] ${projectname}
Go Into Project ${project name}
Go Into Project ${project name}
Sleep 2
Click Element xpath=//project-detail//a[contains(.,'Configuration')]
Sleep 1
Expand All @@ -102,12 +102,10 @@ Make Project Private
Make Project Public
[Arguments] ${projectname}
Go Into Project ${project name}
Sleep 2
Click Element xpath=//project-detail//a[contains(.,'Configuration')]
Retry Element Click xpath=//project-detail//a[contains(.,'Configuration')]
Checkbox Should Not Be Selected xpath=//input[@name='public']
Click Element //div[@id="clr-wrapper-public"]//label[1]
Wait Until Element Is Enabled //button[contains(.,'SAVE')]
Click Element //button[contains(.,'SAVE')]
Retry Element Click //div[@id="clr-wrapper-public"]//label[1]
Retry Element Click //button[contains(.,'SAVE')]
Wait Until Page Contains Configuration has been successfully saved

Delete Repo
Expand Down Expand Up @@ -151,7 +149,7 @@ Project Should Be Deleted
Advanced Search Should Display
Page Should Contain Element xpath=//audit-log//div[@class='flex-xs-middle']/button

# it's not a common keywords, only used into log case.
# it's not a common keywords, only used into log case.
Do Log Advanced Search
Capture Page Screenshot LogAdvancedSearch.png
Sleep 1
Expand Down
51 changes: 37 additions & 14 deletions tests/resources/Util.robot
Expand Up @@ -68,24 +68,43 @@ Wait Until Element Is Visible And Enabled
Wait Until Element Is Enabled ${element}

Retry Action Keyword
[Arguments] ${keyword} ${element_xpath}
Retry Keyword When Error ${keyword} element=${element_xpath}

Retry Element Click
[Arguments] ${element_xpath}
Retry Action Keyword Element Click ${element_xpath}
[Arguments] ${keyword} @{param}
Retry Keyword When Error ${keyword} @{param}

Retry Wait Element
[Arguments] ${element_xpath}
Retry Action Keyword Wait Until Element Is Visible And Enabled ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Visible And Enabled @{param}

Retry Wait Element Not Visible
[Arguments] ${element_xpath}
Retry Action Keyword Wait Until Element Is Not Visible ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Not Visible @{param}

Retry Element Click
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Element Click @{param}

Retry Button Click
[Arguments] ${element_xpath}
Retry Action Keyword Button Click ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Button Click @{param}

Retry Text Input
[Arguments] ${element_xpath} ${text}
@{param} Create List ${element_xpath} ${text}
Retry Action Keyword Text Input @{param}

Retry Wait Until Page Contains
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Contains @{param}

Retry Wait Until Page Contains Element
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Contains Element @{param}

Element Click
[Arguments] ${element_xpath}
Expand All @@ -97,6 +116,11 @@ Button Click
Wait Until Element Is Visible And Enabled ${element_xpath}
Click button ${element_xpath}

Text Input
[Arguments] ${element_xpath} ${text}
Wait Until Element Is Visible And Enabled ${element_xpath}
Input Text ${element_xpath} ${text}

Wait Unitl Vul Data Ready
[Arguments] ${url} ${timeout} ${interval}
${n}= Evaluate ${timeout}/${interval}
Expand All @@ -119,15 +143,14 @@ Wait Unitl Command Success
\ Sleep 2
Log ${output}
Run Keyword If ${positive} == ${true} Should Be Equal As Strings '${rc}' '0'
... ELSE Should Not Be Equal As Strings '${rc}' '0'
... ELSE Should Not Be Equal As Strings '${rc}' '0'
[Return] ${output}

Retry Keyword When Error
[Arguments] ${keyword} ${element}=${None} ${times}=6
:For ${n} IN RANGE 1 ${times}
[Arguments] ${keyword} @{elements}
:For ${n} IN RANGE 1 6
\ Log To Console Trying ${keyword} ${n} times ...
\ ${out} Run Keyword If "${element}"=="${None}" Run Keyword And Ignore Error ${keyword}
\ ... ELSE Run Keyword And Ignore Error ${keyword} ${element}
\ ${out} Run Keyword And Ignore Error ${keyword} @{elements}
\ Log To Console Return value is ${out[0]}
\ Exit For Loop If '${out[0]}'=='PASS'
\ Sleep 2
Expand Down
29 changes: 16 additions & 13 deletions tests/robot-cases/Group1-Nightly/Common.robot
Expand Up @@ -41,7 +41,7 @@ Test Case - Vulnerability Data Not Ready
Test Case - Garbage Collection
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
Expand All @@ -66,7 +66,7 @@ Test Case - Garbage Collection
Should Contain ${output} success to run gc in job.

Close Browser

Test Case - Create An New Project
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Expand Down Expand Up @@ -294,7 +294,7 @@ Test Case - User View Logs

Sign In Harbor ${HARBOR_URL} user002 Test1@34
Create An New Project project${d}

Push image ${ip} user002 Test1@34 project${d} busybox:latest
Pull image ${ip} user002 Test1@34 project${d} busybox:latest

Expand All @@ -313,7 +313,7 @@ Test Case - User View Logs
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
Expand All @@ -326,8 +326,11 @@ Test Case - Manage Project Member
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}

Close Browser
Expand Down Expand Up @@ -403,7 +406,7 @@ Test Case - Edit Project Creation
Test Case - Edit Repo Info
Init Chrome Driver
${d}= Get Current Date result_format=%m%s

Sign In Harbor ${HARBOR_URL} user011 Test1@34
Create An New Project project${d}
Push Image ${ip} user011 Test1@34 project${d} hello-world
Expand All @@ -415,7 +418,7 @@ Test Case - Edit Repo Info
Test Case - Delete Multi Project
Init Chrome Driver
${d}= Get Current Date result_format=%m%s

Sign In Harbor ${HARBOR_URL} user012 Test1@34
Create An New Project projecta${d}
Create An New Project projectb${d}
Expand All @@ -432,7 +435,7 @@ Test Case - Delete Multi Project
Test Case - Delete Multi Repo
Init Chrome Driver
${d}= Get Current Date result_format=%m%s

Sign In Harbor ${HARBOR_URL} user013 Test1@34
Create An New Project project${d}
Push Image ${ip} user013 Test1@34 project${d} hello-world
Expand All @@ -447,7 +450,7 @@ Test Case - Delete Multi Repo
Test Case - Delete Multi Tag
Init Chrome Driver
${d}= Get Current Date result_format=%m%s

Sign In Harbor ${HARBOR_URL} user014 Test1@34
Create An New Project project${d}
Push Image With Tag ${ip} user014 Test1@34 project${d} redis 3.2.10-alpine 3.2.10-alpine
Expand Down Expand Up @@ -476,7 +479,7 @@ Test Case - Delete Repo on CardView
Test Case - Delete Multi Member
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user016 Test1@34
Sign In Harbor ${HARBOR_URL} user016 Test1@34
Create An New Project project${d}
Go Into Project project${d} has_image=${false}
Switch To Member
Expand Down Expand Up @@ -530,7 +533,7 @@ Test Case - Developer Operate Labels
Sign In Harbor ${HARBOR_URL} user021 Test1@34
Create An New Project project${d}
Logout Harbor

Manage Project Member user021 Test1@34 project${d} user022 Add ${false}
Change User Role In Project user021 Test1@34 project${d} user022 Developer

Expand All @@ -546,7 +549,7 @@ Test Case - Scan A Tag In The Repo

Sign In Harbor ${HARBOR_URL} user023 Test1@34
Create An New Project project${d}
Go Into Project project${d} has_image=${false}
Go Into Project project${d} has_image=${false}
Push Image ${ip} user023 Test1@34 project${d} hello-world
Go Into Project project${d}
Go Into Repo project${d}/hello-world
Expand All @@ -560,7 +563,7 @@ Test Case - Scan As An Unprivileged User
Init Chrome Driver
${d}= get current date result_format=%m%s
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library hello-world

Sign In Harbor ${HARBOR_URL} user024 Test1@34
Go Into Project library
Go Into Repo hello-world
Expand Down Expand Up @@ -697,7 +700,7 @@ Test Case - View Scan Results
${d}= get current date result_format=%m%s

Sign In Harbor ${HARBOR_URL} user025 Test1@34
Create An New Project project${d}
Create An New Project project${d}
Push Image ${ip} user025 Test1@34 project${d} tomcat
Go Into Project project${d}
Go Into Repo project${d}/tomcat
Expand Down

0 comments on commit a1063ed

Please sign in to comment.