2022-06-07 11:10:11 +02:00
|
|
|
# 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://${ip}
|
|
|
|
${HARBOR_ADMIN} admin
|
|
|
|
|
|
|
|
*** Test Cases ***
|
|
|
|
Test Case - Webhook CRUD
|
|
|
|
[Tags] webhook_crud
|
|
|
|
Init Chrome Driver
|
|
|
|
${d}= Get Current Date result_format=%m%s
|
|
|
|
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
|
|
|
Create An New Project And Go Into Project project${d}
|
|
|
|
Switch To Project Webhooks
|
|
|
|
# create more than one webhooks
|
|
|
|
Create A New Webhook webhook${d} https://test.com
|
|
|
|
Create A New Webhook webhook2${d} https://test2.com
|
|
|
|
Update A Webhook webhook${d} newWebhook${d} https://new-test.com
|
|
|
|
Enable/Deactivate State of Same Webhook newWebhook${d}
|
|
|
|
Delete A Webhook newWebhook${d}
|
|
|
|
Close Browser
|
|
|
|
|
|
|
|
Test Case - Artifact Event Type Webhook Functionality
|
2022-06-21 08:28:43 +02:00
|
|
|
[Tags] artifact_webhook need_webhook_endpoint
|
2022-06-07 11:10:11 +02:00
|
|
|
Init Chrome Driver
|
|
|
|
${image}= Set Variable busybox
|
|
|
|
${tag}= Set Variable latest
|
|
|
|
${d}= Get Current Date result_format=%m%s
|
|
|
|
Go To http://${WEBHOOK_ENDPOINT}
|
|
|
|
${webhook_endpoint_url}= Get Text //p//code
|
|
|
|
New Tab
|
|
|
|
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
|
|
|
Create An New Project And Go Into Project project${d}
|
|
|
|
Switch To Project Webhooks
|
2022-06-21 08:28:43 +02:00
|
|
|
${event_type} Create List Artifact deleted Artifact pulled Artifact pushed
|
|
|
|
Create A New Webhook webhook${d} ${webhook_endpoint_url} ${event_type}
|
2022-06-07 11:10:11 +02:00
|
|
|
${handles}= Get Window Handles
|
|
|
|
${webhook_handle}= Set Variable ${handles}[0]
|
|
|
|
${harbor_handle}= Set Variable ${handles}[1]
|
|
|
|
# Artifact pushed
|
2022-06-21 08:28:43 +02:00
|
|
|
Retry Action Keyword Verify Webhook By Artifact Pushed Event project${d} ${image} ${tag} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${webhook_handle}
|
2022-06-07 11:10:11 +02:00
|
|
|
# Artifact pulled
|
2022-06-21 08:28:43 +02:00
|
|
|
Retry Action Keyword Verify Webhook By Artifact Pulled Event project${d} ${image} ${tag} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${webhook_handle}
|
2022-06-07 11:10:11 +02:00
|
|
|
# Artifact deleted
|
2022-06-21 08:28:43 +02:00
|
|
|
Retry Action Keyword Verify Webhook By Artifact Deleted Event project${d} ${image} ${tag} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle}
|
2022-06-07 11:10:11 +02:00
|
|
|
Close Browser
|
|
|
|
|
|
|
|
Test Case - Scan Event Type Webhook Functionality
|
2022-06-21 08:28:43 +02:00
|
|
|
[Tags] scan_webhook need_webhook_endpoint
|
2022-06-07 11:10:11 +02:00
|
|
|
Init Chrome Driver
|
|
|
|
${image1}= Set Variable busybox
|
|
|
|
${tag1}= Set Variable latest
|
|
|
|
${image2}= Set Variable goharbor/harbor-e2e-engine
|
|
|
|
${tag2}= Set Variable latest-api
|
|
|
|
${d}= Get Current Date result_format=%m%s
|
|
|
|
Go To http://${WEBHOOK_ENDPOINT}
|
|
|
|
${webhook_endpoint_url}= Get Text //p//code
|
|
|
|
New Tab
|
|
|
|
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
|
|
|
Create An New Project And Go Into Project project${d}
|
|
|
|
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image1} ${tag1} ${tag1}
|
|
|
|
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image2} ${tag2} ${tag2}
|
|
|
|
Switch To Project Webhooks
|
2022-06-21 08:28:43 +02:00
|
|
|
${event_type} Create List Scanning finished Scanning stopped
|
|
|
|
Create A New Webhook webhook${d} ${webhook_endpoint_url} ${event_type}
|
2022-06-07 11:10:11 +02:00
|
|
|
${handles}= Get Window Handles
|
|
|
|
${webhook_handle}= Set Variable ${handles}[0]
|
|
|
|
${harbor_handle}= Set Variable ${handles}[1]
|
|
|
|
# Scanning finished
|
2022-06-21 08:28:43 +02:00
|
|
|
Retry Action Keyword Verify Webhook By Scanning Finished Event project${d} ${image1} ${tag1} ${harbor_handle} ${webhook_handle}
|
2022-06-07 11:10:11 +02:00
|
|
|
# Scanning stopped
|
2022-06-21 08:28:43 +02:00
|
|
|
Retry Action Keyword Verify Webhook By Scanning Stopped Event project${d} ${image2} ${tag2} ${harbor_handle} ${webhook_handle}
|
2022-06-07 11:10:11 +02:00
|
|
|
Close Browser
|
|
|
|
|
|
|
|
Test Case - Tag Retention And Replication Event Type Webhook Functionality
|
2022-06-21 08:28:43 +02:00
|
|
|
[Tags] tag_retention_replication_webhook need_webhook_endpoint
|
2022-06-07 11:10:11 +02:00
|
|
|
Init Chrome Driver
|
|
|
|
${image}= Set Variable busybox
|
|
|
|
${tag1}= Set Variable latest
|
|
|
|
${tag2}= Set Variable stable
|
|
|
|
${d}= Get Current Date result_format=%m%s
|
|
|
|
Go To http://${WEBHOOK_ENDPOINT}
|
|
|
|
${webhook_endpoint_url}= Get Text //p//code
|
|
|
|
New Tab
|
|
|
|
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
|
|
|
Create An New Project And Go Into Project project_dest${d}
|
|
|
|
Create An New Project And Go Into Project project${d}
|
|
|
|
Switch To Tag Retention
|
|
|
|
Add A Tag Retention Rule
|
|
|
|
Edit A Tag Retention Rule ** ${tag1}
|
2022-06-21 08:28:43 +02:00
|
|
|
Switch To Project Webhooks
|
2023-04-03 10:01:51 +02:00
|
|
|
${event_type} Create List Tag retention finished Replication status changed
|
2022-06-21 08:28:43 +02:00
|
|
|
Create A New Webhook webhook${d} ${webhook_endpoint_url} ${event_type}
|
2022-06-07 11:10:11 +02:00
|
|
|
Switch To Registries
|
|
|
|
Create A New Endpoint harbor e${d} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
|
|
|
Switch To Replication Manage
|
|
|
|
Create A Rule With Existing Endpoint rule_push_${d} push project${d}/* image e${d} project_push_dest${d}
|
2022-06-21 08:28:43 +02:00
|
|
|
${handles}= Get Window Handles
|
|
|
|
${webhook_handle}= Set Variable ${handles}[0]
|
|
|
|
${harbor_handle}= Set Variable ${handles}[1]
|
|
|
|
# Tag retention finished
|
|
|
|
Retry Action Keyword Verify Webhook By Tag Retention Finished Event project${d} ${image} ${tag1} ${tag2} ${harbor_handle} ${webhook_handle}
|
2023-04-03 10:01:51 +02:00
|
|
|
# Replication status changed
|
|
|
|
Retry Action Keyword Verify Webhook By Replication Status Changed Event project${d} project_push_dest${d} rule_push_${d} ${harbor_handle} ${webhook_handle}
|
2022-06-07 11:10:11 +02:00
|
|
|
Close Browser
|
|
|
|
|
|
|
|
Test Case - Tag Quota Event Type Webhook Functionality
|
2022-06-21 08:28:43 +02:00
|
|
|
[Tags] quota_webhook need_webhook_endpoint
|
2022-06-07 11:10:11 +02:00
|
|
|
Init Chrome Driver
|
|
|
|
Go To http://${WEBHOOK_ENDPOINT}
|
|
|
|
${webhook_endpoint_url}= Get Text //p//code
|
|
|
|
New Tab
|
|
|
|
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
|
|
|
${handles}= Get Window Handles
|
|
|
|
${webhook_handle}= Set Variable ${handles}[0]
|
|
|
|
${harbor_handle}= Set Variable ${handles}[1]
|
2022-06-21 08:28:43 +02:00
|
|
|
Retry Action Keyword Verify Webhook By Quota Near Threshold Event And Quota Exceed Event ${webhook_endpoint_url} ${harbor_handle} ${webhook_handle}
|
2023-04-03 10:01:51 +02:00
|
|
|
Close Browser
|