Merge pull request #13128 from danfengliu/fix-a-typo-in-upgrade-prepare-script

Fix typo in upgrade prepare script
This commit is contained in:
danfengliu 2020-09-28 17:54:51 +08:00 committed by GitHub
commit fc5743b355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 716 additions and 622 deletions

View File

@ -24,39 +24,29 @@ Verify User
Close Browser Close Browser
Verify Project Verify Project
[Arguments] ${json} ${check_content_trust}=${true} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Project..." Log To Console "Verify Project..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
Retry Wait Until Page Contains ${project} Retry Wait Until Page Contains ${project}
END END
Verify Project Metadata ${json} ${check_content_trust}
Close Browser Close Browser
Verify Image Tag
[Arguments] ${json}
Log To Console "Verify Image Tag..."
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
@{repo}= Get Value From Json ${json} $.projects[?(@.name=${project})]..repo..name
Run Keyword If ${has_image} == ${true} Loop Image Repo @{repo}
Navigate To Projects
END
Close Browser
Verify Project Metadata Verify Project Metadata
[Arguments] ${json} ${check_content_trust} # check_content_trust has been removed from Harbor since v2.0
# verify_registry_name is for proxy cache project, this feature developed since 2.1
[Arguments] ${json} ${check_content_trust}=${true} ${verify_registry_name}=${false}
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}
@ -72,6 +62,25 @@ Verify Project Metadata
END END
Close Browser Close Browser
Verify Image Tag
[Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Image Tag..."
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
@{repo}= Get Value From Json ${json} $.projects[?(@.name=${project})]..repo..name
Run Keyword If ${has_image} == ${true} Loop Image Repo @{repo}
Navigate To Projects
END
Close Browser
Verify Checkbox Verify Checkbox
[Arguments] ${json} ${key} ${checkbox} ${is_opposite}=${false} [Arguments] ${json} ${key} ${checkbox} ${is_opposite}=${false}
@{out}= Get Value From Json ${json} ${key} @{out}= Get Value From Json ${json} ${key}
@ -87,12 +96,15 @@ Loop Image Repo
END END
Verify Member Exist Verify Member Exist
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Member Exist..." Log To Console "Verify Member Exist..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}
@ -104,12 +116,15 @@ Verify Member Exist
Close Browser Close Browser
Verify Webhook Verify Webhook
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Webhook..." Log To Console "Verify Webhook..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}
@ -131,12 +146,15 @@ Verify Webhook
Close Browser Close Browser
Verify Webhook For 2.0 Verify Webhook For 2.0
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Webhook..." Log To Console "Verify Webhook..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}
@ -162,12 +180,15 @@ Verify Webhook For 2.0
Close Browser Close Browser
Verify Tag Retention Rule Verify Tag Retention Rule
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Tag Retention Rule..." Log To Console "Verify Tag Retention Rule..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
${tag_retention_rule}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule ${tag_retention_rule}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule
Run Keyword If ${tag_retention_rule}[0] == ${null} Continue For Loop Run Keyword If ${tag_retention_rule}[0] == ${null} Continue For Loop
${out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image ${out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
@ -189,12 +210,15 @@ Verify Tag Retention Rule
Close Browser Close Browser
Verify Tag Immutability Rule Verify Tag Immutability Rule
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Tag Immutability Rule..." Log To Console "Verify Tag Immutability Rule..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}
@ -219,12 +243,15 @@ Loop Member
END END
Verify Robot Account Exist Verify Robot Account Exist
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Robot Account Exist..." Log To Console "Verify Robot Account Exist..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}
@ -267,12 +294,15 @@ Verify System Label
Close Browser Close Browser
Verify Project Label Verify Project Label
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Project Label..." Log To Console "Verify Project Label..."
@{project}= Get Value From Json ${json} $.peoject.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}
@ -381,12 +411,15 @@ Verify System Setting
Close Browser Close Browser
Verify Project-level Allowlist Verify Project-level Allowlist
[Arguments] ${json} [Arguments] ${json} ${verify_registry_name}=${false}
Log To Console "Verify Project-level Allowlist..." Log To Console "Verify Project-level Allowlist..."
@{project}= Get Value From Json ${json} $.projects.[*].name @{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project} FOR ${project} IN @{project}
@{registry_name}= Get Value From Json ${json} $.projects[?(@.name=${project})].registry_name
Run Keyword If '${registry_name}[0]' != '${null}' and '${verify_registry_name}' == '${false}' Continue For Loop
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false} ${has_image} Set Variable If ${out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image} Go Into Project ${project} has_image=${has_image}

View File

@ -514,13 +514,13 @@
"auth_header":"bbb", "auth_header":"bbb",
"enabled":true, "enabled":true,
"notify_type":"slack", "notify_type":"slack",
"name":"webhook28" "name":"webhook3.3"
}, },
"configuration":{ "configuration":{
"public":"true", "public":"true",
"enable_content_trust":"true", "enable_content_trust":"false",
"auto_scan":"true", "auto_scan":"true",
"prevent_vul":"true", "prevent_vul":"false",
"severity":"high", "severity":"high",
"reuse_sys_cve_allowlist":"false", "reuse_sys_cve_allowlist":"false",
"deployment_security":{ "deployment_security":{

View File

@ -1,456 +1,494 @@
{ {
"create_project":[ "create_project":[
{ {
"branch":1, "branch":1,
"version":"1.4" "version":"1.4"
}, },
{ {
"branch":1, "branch":1,
"version":"1.6" "version":"1.6"
}, },
{ {
"branch":1, "branch":1,
"version":"1.7" "version":"1.7"
}, },
{ {
"branch":1, "branch":1,
"version":"1.8" "version":"1.8"
}, },
{ {
"branch":2, "branch":2,
"version":"1.9" "version":"1.9"
}, },
{ {
"branch":2, "branch":2,
"version":"1.10" "version":"1.10"
}, },
{ {
"branch":2, "branch":2,
"version":"2.0" "version":"2.0"
}, },
{ {
"branch":3, "branch":3,
"version":"2.1" "version":"2.1"
}, },
{ {
"branch":3, "branch":3,
"version":"2.2" "version":"2.2"
} }
], ],
"add_member":[ "populate_projects":[
{ {
"branch":1, "branch":1,
"version":"1.4" "version":"1.4"
}, },
{ {
"branch":2, "branch":1,
"version":"1.6" "version":"1.6"
}, },
{ {
"branch":2, "branch":1,
"version":"1.7" "version":"1.7"
}, },
{ {
"branch":2, "branch":1,
"version":"1.8" "version":"1.8"
}, },
{ {
"branch":2, "branch":2,
"version":"1.9" "version":"1.9"
}, },
{ {
"branch":2, "branch":2,
"version":"1.10" "version":"1.10"
}, },
{ {
"branch":2, "branch":2,
"version":"2.0" "version":"2.0"
}, },
{ {
"branch":2, "branch":3,
"version":"2.1" "version":"2.1"
}, },
{ {
"branch":2, "branch":3,
"version":"2.2" "version":"2.2"
} }
], ],
"set_user_admin":[ "add_member":[
{ {
"branch":1, "branch":1,
"version":"1.4" "version":"1.4"
}, },
{ {
"branch":2, "branch":2,
"version":"1.6" "version":"1.6"
}, },
{ {
"branch":2, "branch":2,
"version":"1.7" "version":"1.7"
}, },
{ {
"branch":2, "branch":2,
"version":"1.8" "version":"1.8"
}, },
{ {
"branch":2, "branch":2,
"version":"1.9" "version":"1.9"
}, },
{ {
"branch":2, "branch":2,
"version":"1.10" "version":"1.10"
}, },
{ {
"branch":3, "branch":2,
"version":"2.0" "version":"2.0"
}, },
{ {
"branch":3, "branch":2,
"version":"2.1" "version":"2.1"
}, },
{ {
"branch":3, "branch":2,
"version":"2.2" "version":"2.2"
} }
], ],
"add_endpoint":[ "set_user_admin":[
{ {
"branch":1, "branch":1,
"version":"1.4" "version":"1.4"
}, },
{ {
"branch":1, "branch":2,
"version":"1.6" "version":"1.6"
}, },
{ {
"branch":1, "branch":2,
"version":"1.7" "version":"1.7"
}, },
{ {
"branch":2, "branch":2,
"version":"1.8" "version":"1.8"
}, },
{ {
"branch":2, "branch":2,
"version":"1.9" "version":"1.9"
}, },
{ {
"branch":2, "branch":2,
"version":"1.10" "version":"1.10"
}, },
{ {
"branch":2, "branch":3,
"version":"2.0" "version":"2.0"
}, },
{ {
"branch":2, "branch":3,
"version":"2.1" "version":"2.1"
}, },
{ {
"branch":2, "branch":3,
"version":"2.2" "version":"2.2"
} }
], ],
"add_replication_rule":[ "add_endpoint":[
{ {
"branch":1, "branch":1,
"version":"1.4" "version":"1.4"
}, },
{ {
"branch":1, "branch":1,
"version":"1.6" "version":"1.6"
}, },
{ {
"branch":1, "branch":1,
"version":"1.7" "version":"1.7"
}, },
{ {
"branch":2, "branch":2,
"version":"1.8" "version":"1.8"
}, },
{ {
"branch":2, "branch":2,
"version":"1.9" "version":"1.9"
}, },
{ {
"branch":2, "branch":2,
"version":"1.10" "version":"1.10"
}, },
{ {
"branch":2, "branch":2,
"version":"2.0" "version":"2.0"
}, },
{ {
"branch":2, "branch":2,
"version":"2.1" "version":"2.1"
}, },
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
} }
], ],
"add_sys_allowlist":[ "add_replication_rule":[
{ {
"branch":1, "branch":1,
"version":"1.9" "version":"1.4"
}, },
{ {
"branch":1, "branch":1,
"version":"1.10" "version":"1.6"
}, },
{ {
"branch":1, "branch":1,
"version":"2.0" "version":"1.7"
}, },
{ {
"branch":2, "branch":2,
"version":"2.1" "version":"1.8"
}, },
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"1.9"
} },
], {
"update_project_setting_allowlist":[ "branch":2,
{ "version":"1.10"
"branch":1, },
"version":"1.9" {
}, "branch":2,
{ "version":"2.0"
"branch":1, },
"version":"1.10" {
}, "branch":2,
{ "version":"2.1"
"branch":1, },
"version":"2.0" {
}, "branch":2,
{ "version":"2.2"
"branch":2, }
"version":"2.1" ],
}, "add_sys_allowlist":[
{ {
"branch":2, "branch":1,
"version":"2.2" "version":"1.9"
} },
], {
"add_project_robot_account":[ "branch":1,
{ "version":"1.10"
"branch":1, },
"version":"1.8" {
}, "branch":1,
{ "version":"2.0"
"branch":1, },
"version":"1.9" {
}, "branch":2,
{ "version":"2.1"
"branch":1, },
"version":"1.10" {
}, "branch":2,
{ "version":"2.2"
"branch":1, }
"version":"2.0" ],
}, "update_project_setting_allowlist":[
{ {
"branch":1, "branch":1,
"version":"2.1" "version":"1.9"
}, },
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"1.10"
} },
], {
"add_tag_retention_rule":[ "branch":1,
{ "version":"2.0"
"branch":1, },
"version":"1.9" {
}, "branch":2,
{ "version":"2.1"
"branch":1, },
"version":"1.10" {
}, "branch":2,
{ "version":"2.2"
"branch":1, }
"version":"2.0" ],
}, "add_project_robot_account":[
{ {
"branch":1, "branch":1,
"version":"2.1" "version":"1.8"
}, },
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"1.9"
} },
], {
"add_tag_immutability_rule":[ "branch":1,
{ "version":"1.10"
"branch":1, },
"version":"1.10" {
}, "branch":1,
{ "version":"2.0"
"branch":1, },
"version":"2.0" {
}, "branch":1,
{ "version":"2.1"
"branch":1, },
"version":"2.1" {
}, "branch":1,
{ "version":"2.2"
"branch":1, }
"version":"2.2" ],
} "add_tag_retention_rule":[
], {
"add_webhook":[ "branch":1,
{ "version":"1.9"
"branch":1, },
"version":"1.9" {
}, "branch":1,
{ "version":"1.10"
"branch":1, },
"version":"1.10" {
}, "branch":1,
{ "version":"2.0"
"branch":2, },
"version":"2.0" {
}, "branch":1,
{ "version":"2.1"
"branch":2, },
"version":"2.1" {
}, "branch":1,
{ "version":"2.2"
"branch":2, }
"version":"2.2" ],
} "add_tag_immutability_rule":[
], {
"update_interrogation_services":[ "branch":1,
{ "version":"1.10"
"branch":1, },
"version":"1.9" {
}, "branch":1,
{ "version":"2.0"
"branch":1, },
"version":"1.10" {
}, "branch":1,
{ "version":"2.1"
"branch":1, },
"version":"2.0" {
}, "branch":1,
{ "version":"2.2"
"branch":1, }
"version":"2.1" ],
}, "add_webhook":[
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"1.9"
} },
], {
"push_artifact_index":[ "branch":1,
{ "version":"1.10"
"branch":1, },
"version":"2.0" {
}, "branch":2,
{ "version":"2.0"
"branch":1, },
"version":"2.1" {
}, "branch":2,
{ "version":"2.1"
"branch":1, },
"version":"2.2" {
} "branch":2,
], "version":"2.2"
"add_distribution":[ }
{ ],
"branch":1, "update_interrogation_services":[
"version":"2.1" {
}, "branch":1,
{ "version":"1.9"
"branch":1, },
"version":"2.2" {
} "branch":1,
], "version":"1.10"
"add_p2p_preheat_policy":[ },
{ {
"branch":1, "branch":1,
"version":"2.1" "version":"2.0"
}, },
{ {
"branch":1, "branch":1,
"version":"2.2" "version":"2.1"
} },
], {
"get_ca":[ "branch":1,
{ "version":"2.2"
"branch":1, }
"version":"1.4" ],
}, "push_artifact_index":[
{ {
"branch":1, "branch":1,
"version":"1.6" "version":"2.0"
}, },
{ {
"branch":1, "branch":1,
"version":"1.7" "version":"2.1"
}, },
{ {
"branch":1, "branch":1,
"version":"1.8" "version":"2.2"
}, }
{ ],
"branch":1, "add_distribution":[
"version":"1.9" {
}, "branch":1,
{ "version":"2.1"
"branch":1, },
"version":"1.10" {
}, "branch":1,
{ "version":"2.2"
"branch":2, }
"version":"2.0" ],
}, "add_p2p_preheat_policy":[
{ {
"branch":2, "branch":1,
"version":"2.1" "version":"2.1"
}, },
{ {
"branch":2, "branch":1,
"version":"2.2" "version":"2.2"
} }
], ],
"set_url":[ "get_ca":[
{ {
"branch":1, "branch":1,
"version":"1.4" "version":"1.4"
}, },
{ {
"branch":1, "branch":1,
"version":"1.6" "version":"1.6"
}, },
{ {
"branch":1, "branch":1,
"version":"1.7" "version":"1.7"
}, },
{ {
"branch":1, "branch":1,
"version":"1.8" "version":"1.8"
}, },
{ {
"branch":1, "branch":1,
"version":"1.9" "version":"1.9"
}, },
{ {
"branch":1, "branch":1,
"version":"1.10" "version":"1.10"
}, },
{ {
"branch":2, "branch":2,
"version":"2.0" "version":"2.0"
}, },
{ {
"branch":2, "branch":2,
"version":"2.1" "version":"2.1"
}, },
{ {
"branch":2, "branch":2,
"version":"2.2" "version":"2.2"
} }
] ],
} "set_url":[
{
"branch":1,
"version":"1.4"
},
{
"branch":1,
"version":"1.6"
},
{
"branch":1,
"version":"1.7"
},
{
"branch":1,
"version":"1.8"
},
{
"branch":1,
"version":"1.9"
},
{
"branch":1,
"version":"1.10"
},
{
"branch":2,
"version":"2.0"
},
{
"branch":2,
"version":"2.1"
},
{
"branch":2,
"version":"2.2"
}
]
}

View File

@ -55,20 +55,58 @@ def get_feature_branch(func):
return inner_func return inner_func
class HarborAPI: class HarborAPI:
@get_feature_branch
def populate_projects(self, **kwargs):
for project in data["projects"]:
if kwargs["branch"] == 1:
if project["registry_name"] is not None:
continue
elif kwargs["branch"] == 2:
if project["registry_name"] is not None:
continue
elif kwargs["branch"] == 3:
print("Populate all projects")
else:
raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch))
self.create_project(project, version=args.version)
for member in project["member"]:
self.add_member(project["name"], member["name"], member["role"], version=args.version)
for robot_account in project["robot_account"]:
self.add_project_robot_account(project["name"], robot_account, version=args.version)
self.add_p2p_preheat_policy(project, version=args.version)
self.add_webhook(project["name"], project["webhook"], version=args.version)
if project["tag_retention_rule"] is not None:
self.add_tag_retention_rule(project["name"], project["tag_retention_rule"], version=args.version)
self.add_tag_immutability_rule(project["name"], project["tag_immutability_rule"], version=args.version)
self.update_project_setting_metadata(project["name"],
project["configuration"]["public"],
project["configuration"]["enable_content_trust"],
project["configuration"]["prevent_vul"],
project["configuration"]["severity"],
project["configuration"]["auto_scan"])
self.update_project_setting_allowlist(project["name"],
project["configuration"]["reuse_sys_cve_allowlist"],
project["configuration"]["deployment_security"], version=args.version)
time.sleep(30)
@get_feature_branch @get_feature_branch
def create_project(self, project, **kwargs): def create_project(self, project, **kwargs):
if kwargs["branch"] == 1: if kwargs["branch"] == 1:
body=dict(body={"project_name": project["name"], "metadata": {"public": "true"}}) body=dict(body={"project_name": project["name"], "metadata": {"public": "true"}})
request(url+"projects", 'post', **body)
elif kwargs["branch"] == 2: elif kwargs["branch"] == 2:
body=dict(body={"project_name": project["name"], "metadata": {"public": "true"},"count_limit":project["count_limit"],"storage_limit":project["storage_limit"]}) body=dict(body={"project_name": project["name"], "metadata": {"public": "true"},"count_limit":project["count_limit"],"storage_limit":project["storage_limit"]})
request(url+"projects", 'post', **body)
elif kwargs["branch"] == 3: elif kwargs["branch"] == 3:
if project["registry_name"] is not None: if project["registry_name"] is not None:
r = request(url+"registries?name="+project["registry_name"]+"", 'get') r = request(url+"registries?name="+project["registry_name"]+"", 'get')
registry_id = int(str(r.json()[0]['id'])) registry_id = int(str(r.json()[0]['id']))
else: else:
registry_id=None registry_id = None
body=dict(body={"project_name": project["name"], "registry_id":registry_id, "metadata": {"public": "true"},"storage_limit":project["storage_limit"]}) body=dict(body={"project_name": project["name"], "registry_id":registry_id, "metadata": {"public": "true"},"storage_limit":project["storage_limit"]})
request(url+"projects", 'post', **body) request(url+"projects", 'post', **body)
#Project with registry_name must have repo and to verify repo can be pulled.
if project["registry_name"] is not None: if project["registry_name"] is not None:
USER_ADMIN=dict(endpoint = "https://"+args.endpoint+"/api/v2.0" , username = "admin", password = "Harbor12345") USER_ADMIN=dict(endpoint = "https://"+args.endpoint+"/api/v2.0" , username = "admin", password = "Harbor12345")
repo = Repository() repo = Repository()
@ -77,11 +115,9 @@ class HarborAPI:
time.sleep(180) time.sleep(180)
repo_name = urllib.parse.quote(_repo["cache_image_namespace"]+"/"+_repo["cache_image"],'utf-8') repo_name = urllib.parse.quote(_repo["cache_image_namespace"]+"/"+_repo["cache_image"],'utf-8')
repo_data = repo.get_repository(project["name"], repo_name, **USER_ADMIN) repo_data = repo.get_repository(project["name"], repo_name, **USER_ADMIN)
print("=========repo_data:",repo_data)
return return
else: else:
raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch)) raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch))
request(url+"projects", 'post', **body)
def create_user(self, username): def create_user(self, username):
payload = {"username":username, "email":username+"@vmware.com", "password":"Harbor12345", "realname":username, "comment":"string"} payload = {"username":username, "email":username+"@vmware.com", "password":"Harbor12345", "realname":username, "comment":"string"}
@ -546,7 +582,7 @@ class HarborAPI:
repo_name_b, tag_b = push_image_to_project(project, args.endpoint, 'admin', 'Harbor12345', image_b, "latest") repo_name_b, tag_b = push_image_to_project(project, args.endpoint, 'admin', 'Harbor12345', image_b, "latest")
manifests = [args.endpoint+"/"+repo_name_a+":"+tag_a, args.endpoint+"/"+repo_name_b+":"+tag_b] manifests = [args.endpoint+"/"+repo_name_a+":"+tag_a, args.endpoint+"/"+repo_name_b+":"+tag_b]
index = args.endpoint+"/"+project+"/"+name+":"+tag index = args.endpoint+"/"+project+"/"+name+":"+tag
docker_manifest_push_to_harbor(index, manifests, args.endpoint, 'admin', 'Harbor12345', cfg_file = args.libpath + "/update_docker_cfg.sh" docker_manifest_push_to_harbor(index, manifests, args.endpoint, 'admin', 'Harbor12345', cfg_file = args.libpath + "/update_docker_cfg.sh")
def request(url, method, user = None, userp = None, **kwargs): def request(url, method, user = None, userp = None, **kwargs):
if user is None: if user is None:
@ -607,18 +643,7 @@ def do_data_creation():
for distribution in data["distributions"]: for distribution in data["distributions"]:
harborAPI.add_distribution(distribution, version=args.version) harborAPI.add_distribution(distribution, version=args.version)
for project in data["projects"]: harborAPI.populate_projects(version=args.version)
harborAPI.create_project(project, version=args.version)
for member in project["member"]:
harborAPI.add_member(project["name"], member["name"], member["role"], version=args.version)
for robot_account in project["robot_account"]:
harborAPI.add_project_robot_account(project["name"], robot_account, version=args.version)
harborAPI.add_p2p_preheat_policy(project, version=args.version)
harborAPI.add_webhook(project["name"], project["webhook"], version=args.version)
if project["tag_retention_rule"] in not None:
harborAPI.add_tag_retention_rule(project["name"], project["tag_retention_rule"], version=args.version)
harborAPI.add_tag_immutability_rule(project["name"], project["tag_immutability_rule"], version=args.version)
time.sleep(30)
harborAPI.push_artifact_index(data["projects"][0]["name"], data["projects"][0]["artifact_index"]["name"], data["projects"][0]["artifact_index"]["tag"], version=args.version) harborAPI.push_artifact_index(data["projects"][0]["name"], data["projects"][0]["artifact_index"]["name"], data["projects"][0]["artifact_index"]["tag"], version=args.version)
pull_image("busybox", "redis", "haproxy", "alpine", "httpd:2") pull_image("busybox", "redis", "haproxy", "alpine", "httpd:2")
@ -628,18 +653,6 @@ def do_data_creation():
for replicationrule in data["replicationrule"]: for replicationrule in data["replicationrule"]:
harborAPI.add_replication_rule(replicationrule, version=args.version) harborAPI.add_replication_rule(replicationrule, version=args.version)
for project in data["projects"]:
harborAPI.update_project_setting_metadata(project["name"],
project["configuration"]["public"],
project["configuration"]["enable_content_trust"],
project["configuration"]["prevent_vul"],
project["configuration"]["severity"],
project["configuration"]["auto_scan"])
for project in data["projects"]:
harborAPI.update_project_setting_allowlist(project["name"],
project["configuration"]["reuse_sys_cve_allowlist"],
project["configuration"]["deployment_security"], version=args.version)
harborAPI.update_interrogation_services(data["interrogation_services"]["cron"], version=args.version) harborAPI.update_interrogation_services(data["interrogation_services"]["cron"], version=args.version)

View File

@ -1,106 +1,116 @@
*** Settings *** *** Settings ***
Documentation Harbor BATs Documentation Harbor BATs
Resource ../../resources/Util.robot Resource ../../resources/Util.robot
Default Tags Nightly Default Tags Nightly
*** Variables *** *** Variables ***
${HARBOR_URL} https://${ip} ${HARBOR_URL} https://${ip}
${HARBOR_ADMIN} admin ${HARBOR_ADMIN} admin
*** Test Cases *** *** Test Cases ***
Test Case - Upgrade Verify Test Case - Upgrade Verify
[Tags] 1.8-latest [Tags] 1.8-latest
${data}= Load Json From File ${CURDIR}${/}data.json ${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data} Run Keyword Verify User ${data}
Run Keyword Verify Project ${data} Run Keyword Verify Project ${data}
Run Keyword Verify Member Exist ${data} Run Keyword Verify Project Label ${data}
Run Keyword Verify Robot Account Exist ${data} Run Keyword Verify Project Metadata ${data}
Run Keyword Verify User System Admin Role ${data} Run Keyword Verify Member Exist ${data}
Run Keyword Verify Endpoint ${data} Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Replicationrule ${data} Run Keyword Verify User System Admin Role ${data}
Run Keyword Verify System Setting ${data} Run Keyword Verify Endpoint ${data}
Run Keyword Verify Image Tag ${data} Run Keyword Verify Replicationrule ${data}
Run Keyword Verify System Setting ${data}
Test Case - Upgrade Verify Run Keyword Verify Image Tag ${data}
[Tags] 1.9-latest
${data}= Load Json From File ${CURDIR}${/}data.json Test Case - Upgrade Verify
Run Keyword Verify User ${data} [Tags] 1.9-latest
Run Keyword Verify Project ${data} ${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify Member Exist ${data} Run Keyword Verify User ${data}
Run Keyword Verify Robot Account Exist ${data} Run Keyword Verify Project ${data}
Run Keyword Verify Project-level Allowlist ${data} Run Keyword Verify Project Label ${data}
Run Keyword Verify Webhook ${data} Run Keyword Verify Project Metadata ${data}
Run Keyword Verify Tag Retention Rule ${data} Run Keyword Verify Member Exist ${data}
Run Keyword Verify User System Admin Role ${data} Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Endpoint ${data} Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Replicationrule ${data} Run Keyword Verify Webhook ${data}
Run Keyword Verify Interrogation Services ${data} Run Keyword Verify Tag Retention Rule ${data}
Run Keyword Verify System Setting ${data} Run Keyword Verify User System Admin Role ${data}
Run Keyword Verify System Setting Allowlist ${data} Run Keyword Verify Endpoint ${data}
Run Keyword Verify Image Tag ${data} Run Keyword Verify Replicationrule ${data}
Run Keyword Verify Trivy Is Default Scanner Run Keyword Verify Interrogation Services ${data}
Run Keyword Verify System Setting ${data}
Test Case - Upgrade Verify Run Keyword Verify System Setting Allowlist ${data}
[Tags] 1.10-latest Run Keyword Verify Image Tag ${data}
${data}= Load Json From File ${CURDIR}${/}data.json Run Keyword Verify Trivy Is Default Scanner
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data} Test Case - Upgrade Verify
Run Keyword Verify Member Exist ${data} [Tags] 1.10-latest
Run Keyword Verify Robot Account Exist ${data} ${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify Project-level Allowlist ${data} Run Keyword Verify User ${data}
Run Keyword Verify Webhook ${data} Run Keyword Verify Project ${data}
Run Keyword Verify Tag Retention Rule ${data} Run Keyword Verify Project Label ${data}
Run Keyword Verify Tag Immutability Rule ${data} Run Keyword Verify Project Metadata ${data}
Run Keyword Verify User System Admin Role ${data} Run Keyword Verify Member Exist ${data}
Run Keyword Verify Endpoint ${data} Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Replicationrule ${data} Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Interrogation Services ${data} Run Keyword Verify Webhook ${data}
Run Keyword Verify System Setting ${data} Run Keyword Verify Tag Retention Rule ${data}
Run Keyword Verify System Setting Allowlist ${data} Run Keyword Verify Tag Immutability Rule ${data}
Run Keyword Verify Image Tag ${data} Run Keyword Verify User System Admin Role ${data}
Run Keyword Verify Clair Is Default Scanner Run Keyword Verify Endpoint ${data}
Run Keyword Verify Replicationrule ${data}
Test Case - Upgrade Verify Run Keyword Verify Interrogation Services ${data}
[Tags] 2.0-latest Run Keyword Verify System Setting ${data}
${data}= Load Json From File ${CURDIR}${/}data.json Run Keyword Verify System Setting Allowlist ${data}
Run Keyword Verify User ${data} Run Keyword Verify Image Tag ${data}
Run Keyword Verify Project ${data} Run Keyword Verify Clair Is Default Scanner
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data} Test Case - Upgrade Verify
Run Keyword Verify Project-level Allowlist ${data} [Tags] 2.0-latest
Run Keyword Verify Webhook For 2.0 ${data} ${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify Tag Retention Rule ${data} Run Keyword Verify User ${data}
Run Keyword Verify Tag Immutability Rule ${data} Run Keyword Verify Project ${data}
Run Keyword Verify User System Admin Role ${data} Run Keyword Verify Project Metadata ${data} check_content_trust=${false}
Run Keyword Verify Endpoint ${data} #Run Keyword Verify Project Label ${data}
Run Keyword Verify Replicationrule ${data} Run Keyword Verify Member Exist ${data}
Run Keyword Verify Interrogation Services ${data} Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify System Setting ${data} Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify System Setting Allowlist ${data} Run Keyword Verify Webhook For 2.0 ${data}
Run Keyword Verify Image Tag ${data} Run Keyword Verify Tag Retention Rule ${data}
Run Keyword Verify Trivy Is Default Scanner Run Keyword Verify Tag Immutability Rule ${data}
Run Keyword Verify Artifact Index ${data} Run Keyword Verify User System Admin Role ${data}
Run Keyword Verify Endpoint ${data}
Test Case - Upgrade Verify Run Keyword Verify Replicationrule ${data}
[Tags] 2.1-latest Run Keyword Verify Interrogation Services ${data}
${data}= Load Json From File ${CURDIR}${/}data.json Run Keyword Verify System Setting ${data}
Run Keyword Verify User ${data} Run Keyword Verify System Setting Allowlist ${data}
Run Keyword Verify Project ${data} check_content_trust=${false} Run Keyword Verify Image Tag ${data}
Run Keyword Verify Member Exist ${data} Run Keyword Verify Trivy Is Default Scanner
Run Keyword Verify Robot Account Exist ${data} Run Keyword Verify Artifact Index ${data}
Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Webhook For 2.0 ${data} Test Case - Upgrade Verify
Run Keyword Verify Tag Retention Rule ${data} [Tags] 2.1-latest
Run Keyword Verify Tag Immutability Rule ${data} ${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User System Admin Role ${data} Run Keyword Verify User ${data}
Run Keyword Verify Endpoint ${data} Run Keyword Verify Project ${data} verify_registry_name=${true}
Run Keyword Verify Replicationrule ${data} Run Keyword Verify Project Metadata ${data} check_content_trust=${false} verify_registry_name=${true}
Run Keyword Verify Interrogation Services ${data} #Run Keyword Verify Project Label ${data} verify_registry_name=${true}
Run Keyword Verify System Setting ${data} Run Keyword Verify Member Exist ${data} verify_registry_name=${true}
Run Keyword Verify System Setting Allowlist ${data} Run Keyword Verify Robot Account Exist ${data} verify_registry_name=${true}
Run Keyword Verify Image Tag ${data} Run Keyword Verify Project-level Allowlist ${data} verify_registry_name=${true}
Run Keyword Verify Trivy Is Default Scanner Run Keyword Verify Webhook For 2.0 ${data} verify_registry_name=${true}
Run Keyword Verify Artifact Index ${data} Run Keyword Verify Tag Retention Rule ${data} verify_registry_name=${true}
Run Keyword Verify Proxy Cache Image Existence ${data} Run Keyword Verify Tag Immutability Rule ${data} verify_registry_name=${true}
Run Keyword Verify Distributions ${data} Run Keyword Verify Image Tag ${data} verify_registry_name=${true}
Run Keyword Verify P2P Preheat Policy ${data} Run Keyword Verify User System Admin Role ${data}
Run Keyword Verify Endpoint ${data}
Run Keyword Verify Replicationrule ${data}
Run Keyword Verify Interrogation Services ${data}
Run Keyword Verify System Setting ${data}
Run Keyword Verify System Setting Allowlist ${data}
Run Keyword Verify Trivy Is Default Scanner
Run Keyword Verify Artifact Index ${data}
Run Keyword Verify Proxy Cache Image Existence ${data}
Run Keyword Verify Distributions ${data}
Run Keyword Verify P2P Preheat Policy ${data}