From 8bfc5d12c327e1fb2a568de66561e6d198881ea9 Mon Sep 17 00:00:00 2001 From: "Danfeng Liu (c)" Date: Thu, 19 Dec 2019 13:43:11 +0800 Subject: [PATCH] Change parameter image to optional 1. Change parameter in Keyword Body Of Admin Push Signed Image to an optional one. 2. Loose the restriction for Quotas error message verification. 3. Get cert for notary from API instead of local file. Signed-off-by: Danfeng Liu (c) --- tests/resources/Harbor-Util.robot | 17 +---------------- tests/resources/TestCaseBody.robot | 2 +- .../Group0-Util/notary-push-image.sh | 4 ++-- .../notary-remove-image-signature.expect | 2 +- tests/robot-cases/Group1-Nightly/Common.robot | 2 +- tests/robot-cases/Group1-Nightly/Notary.robot | 4 ++-- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/tests/resources/Harbor-Util.robot b/tests/resources/Harbor-Util.robot index e6157e5c2..67d60e07a 100644 --- a/tests/resources/Harbor-Util.robot +++ b/tests/resources/Harbor-Util.robot @@ -95,24 +95,9 @@ Switch To LDAP Enable Notary Client ${rc} ${output}= Run And Return Rc And Output rm -rf ~/.docker/ Log ${rc} - Should Be Equal As Integers ${rc} 0 - Log ${ip} - Log To Console ${ip} - ${rc}= Run And Return Rc mkdir -p /etc/docker/certs.d/${ip}/ - Should Be Equal As Integers ${rc} 0 - Log To Console ${notaryServerEndpointNoSubDir} - ${rc}= Run And Return Rc mkdir -p ~/.docker/tls/${notaryServerEndpointNoSubDir}/ - Should Be Equal As Integers ${rc} 0 - ${rc} ${output}= Run And Return Rc And Output cp ./harbor_ca.crt /etc/docker/certs.d/${ip}/ + ${rc} ${output}= Run And Return Rc and Output curl -o /notary_ca.crt -s -k -X GET --header 'Accept: application/json' -u 'admin:Harbor12345' 'https://${ip}/api/systeminfo/getcert' Log ${output} Should Be Equal As Integers ${rc} 0 - ${rc} ${output}= Run And Return Rc And Output cp ./harbor_ca.crt ~/.docker/tls/${notaryServerEndpointNoSubDir}/ - Log ${output} - Should Be Equal As Integers ${rc} 0 - ${rc} ${output}= Run And Return Rc And Output ls -la /etc/docker/certs.d/${ip}/ - Log ${output} - ${rc} ${output}= Run And Return Rc And Output ls -la ~/.docker/tls/${notaryServerEndpointNoSubDir}/ - Log ${output} Remove Notary Signature [Arguments] ${ip} ${image} diff --git a/tests/resources/TestCaseBody.robot b/tests/resources/TestCaseBody.robot index b98ba40d9..954bb813a 100644 --- a/tests/resources/TestCaseBody.robot +++ b/tests/resources/TestCaseBody.robot @@ -98,7 +98,7 @@ Body Of List Helm Charts Close Browser Body Of Admin Push Signed Image - [Arguments] ${image} ${with_remove}=${false} + [Arguments] ${image}=tomcat ${with_remove}=${false} Enable Notary Client ${rc} ${output}= Run And Return Rc And Output docker pull hello-world:latest diff --git a/tests/robot-cases/Group0-Util/notary-push-image.sh b/tests/robot-cases/Group0-Util/notary-push-image.sh index ef8dc9973..eb695b519 100755 --- a/tests/robot-cases/Group0-Util/notary-push-image.sh +++ b/tests/robot-cases/Group0-Util/notary-push-image.sh @@ -10,8 +10,8 @@ echo $IP mkdir -p /etc/docker/certs.d/$IP/ mkdir -p ~/.docker/tls/$IP:4443/ -cp /notary_ca/ca.crt /etc/docker/certs.d/$IP/ -cp /notary_ca/ca.crt ~/.docker/tls/$IP:4443/ +cp /notary_ca.crt /etc/docker/certs.d/$IP/ +cp /notary_ca.crt ~/.docker/tls/$IP:4443/ export DOCKER_CONTENT_TRUST=1 export DOCKER_CONTENT_TRUST_SERVER=https://$IP:4443 diff --git a/tests/robot-cases/Group0-Util/notary-remove-image-signature.expect b/tests/robot-cases/Group0-Util/notary-remove-image-signature.expect index ff77b85ad..18d10bd76 100755 --- a/tests/robot-cases/Group0-Util/notary-remove-image-signature.expect +++ b/tests/robot-cases/Group0-Util/notary-remove-image-signature.expect @@ -5,7 +5,7 @@ set PROJECT [lindex $argv 1] set IMAGE [lindex $argv 2] set timeout 30 -spawn notary -s https://$HOST:4443 --tlscacert /notary_ca/ca.crt -d /root/.docker/trust remove -p $HOST/$PROJECT/$IMAGE latest +spawn notary -s https://$HOST:4443 --tlscacert /notary_ca.crt -d /root/.docker/trust remove -p $HOST/$PROJECT/$IMAGE latest expect { "Enter username:" {send "admin\r";exp_continue} diff --git a/tests/robot-cases/Group1-Nightly/Common.robot b/tests/robot-cases/Group1-Nightly/Common.robot index b73ae5699..350ed23a4 100644 --- a/tests/robot-cases/Group1-Nightly/Common.robot +++ b/tests/robot-cases/Group1-Nightly/Common.robot @@ -547,7 +547,7 @@ Test Case - Project Quotas Control Under GC ${image_a_ver}= Set Variable 6.8.3 Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Create An New Project project${d} storage_quota=${storage_quota} storage_quota_unit=${storage_quota_unit} - Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image_a}:${image_a_ver} err_msg=Quota exceeded when processing the request of adding 82.5 MiB of storage resource, which when updated to current usage of 166.6 MiB will exceed the configured upper limit of 200.0 MiB + Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image_a}:${image_a_ver} err_msg=will exceed the configured upper limit of 200.0 MiB GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} @{param} Create List project${d} Retry Keyword When Return Value Mismatch Get Project Storage Quota Text From Project Quotas List 0Byte of ${storage_quota}${storage_quota_unit} 60 @{param} diff --git a/tests/robot-cases/Group1-Nightly/Notary.robot b/tests/robot-cases/Group1-Nightly/Notary.robot index 87ef5adde..a2b310f7c 100644 --- a/tests/robot-cases/Group1-Nightly/Notary.robot +++ b/tests/robot-cases/Group1-Nightly/Notary.robot @@ -40,7 +40,7 @@ Test Case - Project Level Policy Content Trust Close Browser Test Case - Admin Push Signed Image - Body Of Admin Push Signed Image tomcat + Body Of Admin Push Signed Image Test Case - Admin Push Signed Image And Remove Signature - Body Of Admin Push Signed Image mariadb with_remove=${true} \ No newline at end of file + Body Of Admin Push Signed Image image=mariadb with_remove=${true} \ No newline at end of file