Add build base image step in build package git action workflow

Build base image step should be in build package workflow, and local base images build by new step should be removed since images have been pushed to docker hub.

Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
danfengliu 2021-04-08 15:32:31 +08:00
parent 5f0e7cfd62
commit f0ebd17994
86 changed files with 9825 additions and 9793 deletions

View File

@ -1,350 +1,350 @@
name: CI
env:
POSTGRESQL_HOST: localhost
POSTGRESQL_PORT: 5432
POSTGRESQL_USR: postgres
POSTGRESQL_PWD: root123
POSTGRESQL_DATABASE: registry
DOCKER_COMPOSE_VERSION: 1.23.0
HARBOR_ADMIN: admin
HARBOR_ADMIN_PASSWD: Harbor12345
CORE_SECRET: tempString
KEY_PATH: "/data/secret/keys/secretkey"
REDIS_HOST: localhost
REG_VERSION: v2.7.1-patch-2819-2553
UI_BUILDER_VERSION: 1.6.0
on:
pull_request:
push:
paths-ignore:
- 'docs/**'
jobs:
UTTEST:
env:
UTTEST: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
IP=`hostname -I | awk '{print $1}'`
echo '{"insecure-registries" : ["'$IP':5000"]}' | sudo tee /etc/docker/daemon.json
echo "IP=$IP" >> $GITHUB_ENV
sudo cp ./tests/harbor_ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
sudo service docker restart
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
bash ./tests/showtime.sh ./tests/ci/ut_install.sh
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/ut_run.sh $IP
df -h
- name: Codecov For BackEnd
uses: codecov/codecov-action@v1
with:
file: ./src/github.com/goharbor/harbor/profile.cov
flags: unittests
APITEST_DB:
env:
APITEST_DB: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
IP=`hostname -I | awk '{print $1}'`
echo "IP=$IP" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
docker system prune -a -f
bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP DB
- name: script
run: |
cd src/github.com/goharbor/harbor
echo IP: $IP
df -h
bash ./tests/showtime.sh ./tests/ci/api_run.sh DB $IP
df -h
APITEST_DB_PROXY_CACHE:
env:
APITEST_DB: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
IP=`hostname -I | awk '{print $1}'`
echo "IP=$IP" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
docker system prune -a -f
bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP DB
- name: script
run: |
cd src/github.com/goharbor/harbor
echo IP: $IP
df -h
bash ./tests/showtime.sh ./tests/ci/api_run.sh PROXY_CACHE $IP
df -h
APITEST_LDAP:
env:
APITEST_LDAP: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
IP=`hostname -I | awk '{print $1}'`
echo "IP=$IP" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP LDAP
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/api_run.sh LDAP $IP
df -h
OFFLINE:
env:
OFFLINE: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
docker version
go env
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
IP=`hostname -I | awk '{print $1}'`
echo '{"insecure-registries" : ["'$IP':5000"]}' | sudo tee /etc/docker/daemon.json
echo "IP=$IP" >> $GITHUB_ENV
sudo cp ./tests/harbor_ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
sudo service docker restart
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/distro_installer.sh
df -h
UI_UT:
env:
UI_UT: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- uses: actions/setup-node@v1
with:
node-version: '10.16.2'
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/ui_ut_run.sh
df -h
- name: Codecov For UI
uses: codecov/codecov-action@v1
with:
file: ./src/github.com/goharbor/harbor/src/portal/coverage/lcov.info
flags: unittests
name: CI
env:
POSTGRESQL_HOST: localhost
POSTGRESQL_PORT: 5432
POSTGRESQL_USR: postgres
POSTGRESQL_PWD: root123
POSTGRESQL_DATABASE: registry
DOCKER_COMPOSE_VERSION: 1.23.0
HARBOR_ADMIN: admin
HARBOR_ADMIN_PASSWD: Harbor12345
CORE_SECRET: tempString
KEY_PATH: "/data/secret/keys/secretkey"
REDIS_HOST: localhost
REG_VERSION: v2.7.1-patch-2819-2553
UI_BUILDER_VERSION: 1.6.0
on:
pull_request:
push:
paths-ignore:
- 'docs/**'
jobs:
UTTEST:
env:
UTTEST: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
IP=`hostname -I | awk '{print $1}'`
echo '{"insecure-registries" : ["'$IP':5000"]}' | sudo tee /etc/docker/daemon.json
echo "IP=$IP" >> $GITHUB_ENV
sudo cp ./tests/harbor_ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
sudo service docker restart
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
bash ./tests/showtime.sh ./tests/ci/ut_install.sh
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/ut_run.sh $IP
df -h
- name: Codecov For BackEnd
uses: codecov/codecov-action@v1
with:
file: ./src/github.com/goharbor/harbor/profile.cov
flags: unittests
APITEST_DB:
env:
APITEST_DB: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
IP=`hostname -I | awk '{print $1}'`
echo "IP=$IP" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
docker system prune -a -f
bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP DB
- name: script
run: |
cd src/github.com/goharbor/harbor
echo IP: $IP
df -h
bash ./tests/showtime.sh ./tests/ci/api_run.sh DB $IP
df -h
APITEST_DB_PROXY_CACHE:
env:
APITEST_DB: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
IP=`hostname -I | awk '{print $1}'`
echo "IP=$IP" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
docker system prune -a -f
bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP DB
- name: script
run: |
cd src/github.com/goharbor/harbor
echo IP: $IP
df -h
bash ./tests/showtime.sh ./tests/ci/api_run.sh PROXY_CACHE $IP
df -h
APITEST_LDAP:
env:
APITEST_LDAP: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
go env
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
IP=`hostname -I | awk '{print $1}'`
echo "IP=$IP" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- name: install
run: |
cd src/github.com/goharbor/harbor
env
df -h
bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP LDAP
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/api_run.sh LDAP $IP
df -h
OFFLINE:
env:
OFFLINE: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: setup env
run: |
cd src/github.com/goharbor/harbor
pwd
docker version
go env
echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV
shell: bash
- name: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
#sudo apt install -y xvfb
#xvfb-run ls
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
IP=`hostname -I | awk '{print $1}'`
echo '{"insecure-registries" : ["'$IP':5000"]}' | sudo tee /etc/docker/daemon.json
echo "IP=$IP" >> $GITHUB_ENV
sudo cp ./tests/harbor_ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
sudo service docker restart
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/distro_installer.sh
df -h
UI_UT:
env:
UI_UT: true
runs-on:
#- self-hosted
- ubuntu-latest
timeout-minutes: 100
steps:
- uses: actions/setup-node@v1
with:
node-version: '10.16.2'
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/ui_ut_run.sh
df -h
- name: Codecov For UI
uses: codecov/codecov-action@v1
with:
file: ./src/github.com/goharbor/harbor/src/portal/coverage/lcov.info
flags: unittests

View File

@ -1,111 +1,128 @@
name: "Build Package Workflow"
env:
DOCKER_COMPOSE_VERSION: 1.23.0
on:
push:
branches:
- master
- release-*
tags:
- v*
jobs:
BUILD_PACKAGE:
env:
BUILD_PACKAGE: true
runs-on:
#- self-hosted
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '285.0.0'
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- run: gcloud info
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: Build Package
run: |
set -x
env
df -h
harbor_target_bucket=""
target_branch="$(echo ${GITHUB_REF#refs/heads/})"
harbor_offline_build_bundle=""
harbor_online_build_bundle=""
harbor_logs_bucket="harbor-ci-logs"
harbor_builds_bucket="harbor-builds"
harbor_releases_bucket="harbor-releases"
harbor_ci_pipeline_store_bucket="harbor-ci-pipeline-store/latest"
# the target release version is the version of next release(RC or GA). It needs to be updated on creating new release branch.
target_release_version=$(cat ./VERSION)
Harbor_Package_Version=$target_release_version-'build.'$GITHUB_RUN_NUMBER
if [[ $target_branch == "master" ]]; then
Harbor_Assets_Version=$Harbor_Package_Version
else
Harbor_Assets_Version=$target_release_version
fi
if [[ $target_branch == "release-"* ]]; then
Harbor_Build_Base_Tag=$target_release_version
else
Harbor_Build_Base_Tag=dev
fi
if [[ $target_branch == "master" ]]; then
harbor_target_bucket=$harbor_builds_bucket
else
harbor_target_bucket=$harbor_releases_bucket/$target_branch
fi
cd src/github.com/goharbor/harbor
sudo make package_offline GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} BUILDBIN=true NOTARYFLAG=true CHARTFLAG=true TRIVYFLAG=true HTTPPROXY=
sudo make package_online GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} BUILDBIN=true NOTARYFLAG=true CHARTFLAG=true TRIVYFLAG=true HTTPPROXY=
harbor_offline_build_bundle=$(basename harbor-offline-installer-*.tgz)
harbor_online_build_bundle=$(basename harbor-online-installer-*.tgz)
echo "Package name is: $harbor_offline_build_bundle"
echo "Package name is: $harbor_online_build_bundle"
echo -en "${{ secrets.HARBOR_SIGN_KEY }}" | gpg --import
gpg -v -ab -u ${{ secrets.HARBOR_SIGN_KEY_ID }} $harbor_offline_build_bundle
gpg -v -ab -u ${{ secrets.HARBOR_SIGN_KEY_ID }} $harbor_online_build_bundle
source tests/ci/build_util.sh
cp ${harbor_offline_build_bundle} harbor-offline-installer-latest.tgz
cp ${harbor_offline_build_bundle}.asc harbor-offline-installer-latest.tgz.asc
uploader ${harbor_offline_build_bundle} $harbor_target_bucket
uploader ${harbor_offline_build_bundle}.asc $harbor_target_bucket
uploader ${harbor_online_build_bundle} $harbor_target_bucket
uploader ${harbor_online_build_bundle}.asc $harbor_target_bucket
uploader harbor-offline-installer-latest.tgz $harbor_target_bucket
uploader harbor-offline-installer-latest.tgz.asc $harbor_target_bucket
echo "BUILD_BUNDLE=$harbor_offline_build_bundle" >> $GITHUB_ENV
publishImage $target_branch $Harbor_Assets_Version "${{ secrets.DOCKER_HUB_USERNAME }}" "${{ secrets.DOCKER_HUB_PASSWORD }}"
- name: Slack Notification
uses: sonots/slack-notice-action@v3
with:
status: ${{ job.status }}
title: Build Package - ${{ env.BUILD_BUNDLE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()
name: "Build Package Workflow"
env:
DOCKER_COMPOSE_VERSION: 1.23.0
on:
push:
branches:
- master
- release-*
tags:
- v*
jobs:
BUILD_PACKAGE:
env:
BUILD_PACKAGE: true
runs-on:
#- self-hosted
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '285.0.0'
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- run: gcloud info
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.15.6
id: go
- name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1
with:
docker_version: 18.09
docker_channel: stable
- uses: actions/checkout@v2.1.0
- uses: jitterbit/get-changed-files@v1
id: changed-files
with:
format: space-delimited
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor
- name: Build Dev Base Image
if: contains(steps.changed-files.outputs.modified, 'Dockerfile.base') && contains(github.ref, 'master')
run: |
set -x
base_image_tag=$(cat ./VERSION)
echo "Start to build base image for dev ......"
cd src/github.com/goharbor/harbor
sudo make build_base_docker -e BASEIMAGETAG=$base_image_tag -e REGISTRYUSER="${{ secrets.DOCKER_HUB_USERNAME }}" -e REGISTRYPASSWORD="${{ secrets.DOCKER_HUB_PASSWORD }}" -e PUSHBASEIMAGE=yes
- name: Build Release Base Image
if: contains(steps.changed-files.outputs.modified, 'VERSION')
run: |
set -x
base_image_tag=$(cat ./VERSION)
echo "Start to build base image for release $(base_image_tag) ......"
cd src/github.com/goharbor/harbor
sudo make build_base_docker -e BASEIMAGETAG=$base_image_tag -e REGISTRYUSER="${{ secrets.DOCKER_HUB_USERNAME }}" -e REGISTRYPASSWORD="${{ secrets.DOCKER_HUB_PASSWORD }}" -e PUSHBASEIMAGE=yes
- name: Build Package
run: |
set -x
env
df -h
harbor_target_bucket=""
target_branch="$(echo ${GITHUB_REF#refs/heads/})"
harbor_offline_build_bundle=""
harbor_online_build_bundle=""
harbor_logs_bucket="harbor-ci-logs"
harbor_builds_bucket="harbor-builds"
harbor_releases_bucket="harbor-releases"
harbor_ci_pipeline_store_bucket="harbor-ci-pipeline-store/latest"
# the target release version is the version of next release(RC or GA). It needs to be updated on creating new release branch.
target_release_version=$(cat ./VERSION)
Harbor_Package_Version=$target_release_version-'build.'$GITHUB_RUN_NUMBER
if [[ $target_branch == "master" ]]; then
Harbor_Assets_Version=$Harbor_Package_Version
harbor_target_bucket=$harbor_builds_bucket
else
Harbor_Assets_Version=$target_release_version
harbor_target_bucket=$harbor_releases_bucket/$target_branch
fi
if [[ $target_branch == "release-"* ]]; then
Harbor_Build_Base_Tag=$target_release_version
else
Harbor_Build_Base_Tag=dev
fi
cd src/github.com/goharbor/harbor
sudo make package_offline GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} BUILDBIN=true NOTARYFLAG=true CHARTFLAG=true TRIVYFLAG=true HTTPPROXY=
sudo make package_online GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} BUILDBIN=true NOTARYFLAG=true CHARTFLAG=true TRIVYFLAG=true HTTPPROXY=
harbor_offline_build_bundle=$(basename harbor-offline-installer-*.tgz)
harbor_online_build_bundle=$(basename harbor-online-installer-*.tgz)
echo "Package name is: $harbor_offline_build_bundle"
echo "Package name is: $harbor_online_build_bundle"
echo -en "${{ secrets.HARBOR_SIGN_KEY }}" | gpg --import
gpg -v -ab -u ${{ secrets.HARBOR_SIGN_KEY_ID }} $harbor_offline_build_bundle
gpg -v -ab -u ${{ secrets.HARBOR_SIGN_KEY_ID }} $harbor_online_build_bundle
source tests/ci/build_util.sh
cp ${harbor_offline_build_bundle} harbor-offline-installer-latest.tgz
cp ${harbor_offline_build_bundle}.asc harbor-offline-installer-latest.tgz.asc
uploader ${harbor_offline_build_bundle} $harbor_target_bucket
uploader ${harbor_offline_build_bundle}.asc $harbor_target_bucket
uploader ${harbor_online_build_bundle} $harbor_target_bucket
uploader ${harbor_online_build_bundle}.asc $harbor_target_bucket
uploader harbor-offline-installer-latest.tgz $harbor_target_bucket
uploader harbor-offline-installer-latest.tgz.asc $harbor_target_bucket
echo "BUILD_BUNDLE=$harbor_offline_build_bundle" >> $GITHUB_ENV
publishImage $target_branch $Harbor_Assets_Version "${{ secrets.DOCKER_HUB_USERNAME }}" "${{ secrets.DOCKER_HUB_PASSWORD }}"
- name: Slack Notification
uses: sonots/slack-notice-action@v3
with:
status: ${{ job.status }}
title: Build Package - ${{ env.BUILD_BUNDLE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()

2
.gitignore vendored
View File

@ -48,3 +48,5 @@ src/core/conf/app.conf
src/server/v2.0/models/
src/server/v2.0/restapi/
.editorconfig

View File

@ -112,3 +112,16 @@ if [ $? -ne 0 ];then
else
success "Pushing image $IMAGE succeeded";
fi
h2 "Remove local goharbor images"
DOCKER_RMI="docker rmi -f $(docker images | grep "goharbor" | awk '{print $3}')"
info "$DOCKER_RMI"
DOCKER_RMI_OUTPUT=$($DOCKER_RMI)
if [ $? -ne 0 ];then
warn $DOCKER_RMI_OUTPUT
error "Clean local goharbor images failed";
else
success "Clean local goharbor images succeeded";
fi

View File

@ -1,250 +1,250 @@
# -*- coding: utf-8 -*-
import base
import subprocess
import json
from testutils import DOCKER_USER, DOCKER_PWD, BASE_IMAGE, BASE_IMAGE_ABS_PATH_NAME
try:
import docker
except ImportError:
import pip
pip.main(['install', 'docker'])
import docker
def docker_info_display():
command = ["docker", "info", "-f", "'{{.OSType}}/{{.Architecture}}'"]
print("Docker Info: ", command)
ret = base.run_command(command)
print("Command return: ", ret)
def docker_login_cmd(harbor_host, username, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh", enable_manifest = True):
if username == "" or password == "":
print("[Warnig]: No docker credential was provided.")
return
command = ["docker", "login", harbor_host, "-u", username, "-p", password]
print( "Docker Login Command: ", command)
base.run_command(command)
if enable_manifest == True:
try:
ret = subprocess.check_output([cfg_file], shell=False)
print("docker login cmd ret:", ret)
except subprocess.CalledProcessError as exc:
raise Exception("Failed to update docker config, error is {} {}.".format(exc.returncode, exc.output))
def docker_manifest_create(index, manifests):
command = ["docker","manifest","create", "--amend", index]
command.extend(manifests)
print( "Docker Manifest Command: ", command)
base.run_command(command)
def docker_images_all_list():
command = ["docker","images","-a"]
base.run_command(command)
def docker_load_image(image):
command = ["docker","load","-i", image]
base.run_command(command)
def docker_image_clean_all():
docker_images_all_list()
command = ["docker rmi -f $(docker images -a -q)"]
base.run_command_with_popen(command)
command = ["docker","system", "prune", "-a", "-f"]
base.run_command(command)
docker_images_all_list()
def docker_manifest_push(index):
command = ["docker","manifest","push",index]
print( "Docker Manifest Command: ", command)
ret = base.run_command(command)
index_sha256=""
manifest_list=[]
for line in ret.split("\n"):
if line[:7] == "sha256:":
index_sha256 = line
if line.find('Pushed ref') == 0:
manifest_list.append(line[-71:])
return index_sha256, manifest_list
def docker_manifest_push_to_harbor(index, manifests, harbor_server, username, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh"):
docker_login_cmd(harbor_server, username, password, cfg_file=cfg_file)
docker_manifest_create(index, manifests)
return docker_manifest_push(index)
def list_repositories(harbor_host, username, password, n = None, last = None):
if n is not None and last is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n+"&last="+last, "--insecure"]
elif n is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog", "--insecure"]
print( "List Repositories Command: ", command)
ret = base.run_command(command)
repos = json.loads(ret).get("repositories","")
return repos
def list_image_tags(harbor_host, repository, username, password, n = None, last = None):
if n is not None and last is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n+"&last="+last, "--insecure"]
elif n is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list", "--insecure"]
print( "List Image Tags Command: ", command)
ret = base.run_command(command)
tags = json.loads(ret).get("tags","")
return tags
class DockerAPI(object):
def __init__(self):
self.DCLIENT = docker.APIClient(base_url='unix://var/run/docker.sock',version='auto',timeout=30)
self.DCLIENT2 = docker.from_env()
def docker_login(self, registry, username, password, expected_error_message = None):
ret = ""
err_message = ""
if username == "" or password == "":
print("[Warnig]: No docker credential was provided.")
return
if expected_error_message == "":
expected_error_message = None
if registry == "docker":
registry = None
try:
print("Docker login: {}:{}:{}".format(registry,username,password))
ret = self.DCLIENT.login(registry = registry, username=username, password=password)
except Exception as err:
print( "Docker image pull catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, str(err)))
else:
print("Docker image login did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when login registry {}, return message: {}".format (expected_error_message, registry, err_message))
else:
print(r"Docker image login got expected error message:{}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when login registry {}, return message is [{}]".format (registry, err_message))
def docker_image_pull(self, image, tag = None, expected_error_message = None, is_clean_all_img = True):
ret = ""
err_message = ""
if tag is not None:
_tag = tag
else:
_tag = "latest"
if expected_error_message == "":
expected_error_message = None
try:
ret = self.DCLIENT.pull(r'{}:{}'.format(image, _tag))
except Exception as err:
print( "Docker image pull catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, str(err)))
else:
print("Docker image pull did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when pull image {}, return message: {}".format (expected_error_message, image, err_message))
else:
print(r"Docker image pull got expected error message:{}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when pull image {}, return message is [{}]".format (image, err_message))
if is_clean_all_img:
docker_image_clean_all()
def docker_image_tag(self, image, harbor_registry, tag = None):
_tag = base._random_name("tag")
if tag is not None:
_tag = tag
ret = ""
try:
ret = self.DCLIENT.tag(image, harbor_registry, _tag, force=True)
print("Docker image tag commond return:", ret)
return harbor_registry, _tag
except docker.errors.APIError as err:
raise Exception(r" Docker tag image {} failed, error is [{}]".format (image, str(err)))
def docker_image_push(self, harbor_registry, tag, expected_error_message = None):
ret = ""
err_message = ""
docker_images_all_list()
if expected_error_message == "":
expected_error_message = None
try:
ret = self.DCLIENT.push(harbor_registry, tag)
except Exception as err:
print( "Docker image push catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker push image {} failed, error is [{}]".format (image, str(err)))
else:
print("Docker image push did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when push image {}, return message: {}".format (expected_error_message, harbor_registry, err_message))
else:
print(r"Docker image push got expected error message:{}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when push image {}, return message is [{}]".format (harbor_registry, err_message))
docker_images_all_list()
def docker_image_build(self, harbor_registry, tags=None, size=1, expected_error_message = None):
ret = ""
err_message = ""
docker_images_all_list()
try:
baseimage = BASE_IMAGE['name'] + ":" + BASE_IMAGE['tag']
if not self.DCLIENT.images(name=baseimage):
print( "Docker load is triggered when building {}".format(harbor_registry))
docker_load_image(BASE_IMAGE_ABS_PATH_NAME)
docker_images_all_list()
c = self.DCLIENT.create_container(image=baseimage,
command='dd if=/dev/urandom of=test bs=1M count={}'.format(size))
self.DCLIENT.start(c)
self.DCLIENT.wait(c)
if not tags:
tags=['latest']
firstrepo="{}:{}".format(harbor_registry, tags[0])
#self.DCLIENT.commit(c, firstrepo)
self.DCLIENT2.containers.get(c).commit(harbor_registry, tags[0])
for tag in tags[1:]:
repo="{}:{}".format(harbor_registry, tag)
self.DCLIENT.tag(firstrepo, repo)
for tag in tags:
repo="{}:{}".format(harbor_registry, tag)
ret = self.DCLIENT.push(repo)
print("docker_image_push ret:", ret)
print("build image {} with size {}".format(repo, size))
self.DCLIENT.remove_container(c)
except Exception as err:
print( "Docker image build catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker push image {} failed, error is [{}]".format (harbor_registry, str(err)))
else:
print("Docker image build did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when build image {}, return message: {}".format (expected_error_message, harbor_registry, err_message))
else:
print(r"Docker image build got expected error message: {}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when build image {}, return message is [{}]".format (harbor_registry, err_message))
docker_image_clean_all()
# -*- coding: utf-8 -*-
import base
import subprocess
import json
from testutils import DOCKER_USER, DOCKER_PWD, BASE_IMAGE, BASE_IMAGE_ABS_PATH_NAME
try:
import docker
except ImportError:
import pip
pip.main(['install', 'docker'])
import docker
def docker_info_display():
command = ["docker", "info", "-f", "'{{.OSType}}/{{.Architecture}}'"]
print("Docker Info: ", command)
ret = base.run_command(command)
print("Command return: ", ret)
def docker_login_cmd(harbor_host, username, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh", enable_manifest = True):
if username == "" or password == "":
print("[Warnig]: No docker credential was provided.")
return
command = ["docker", "login", harbor_host, "-u", username, "-p", password]
print( "Docker Login Command: ", command)
base.run_command(command)
if enable_manifest == True:
try:
ret = subprocess.check_output([cfg_file], shell=False)
print("docker login cmd ret:", ret)
except subprocess.CalledProcessError as exc:
raise Exception("Failed to update docker config, error is {} {}.".format(exc.returncode, exc.output))
def docker_manifest_create(index, manifests):
command = ["docker","manifest","create", "--amend", index]
command.extend(manifests)
print( "Docker Manifest Command: ", command)
base.run_command(command)
def docker_images_all_list():
command = ["docker","images","-a"]
base.run_command(command)
def docker_load_image(image):
command = ["docker","load","-i", image]
base.run_command(command)
def docker_image_clean_all():
docker_images_all_list()
command = ["docker rmi -f $(docker images -a -q)"]
base.run_command_with_popen(command)
command = ["docker","system", "prune", "-a", "-f"]
base.run_command(command)
docker_images_all_list()
def docker_manifest_push(index):
command = ["docker","manifest","push",index]
print( "Docker Manifest Command: ", command)
ret = base.run_command(command)
index_sha256=""
manifest_list=[]
for line in ret.split("\n"):
if line[:7] == "sha256:":
index_sha256 = line
if line.find('Pushed ref') == 0:
manifest_list.append(line[-71:])
return index_sha256, manifest_list
def docker_manifest_push_to_harbor(index, manifests, harbor_server, username, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh"):
docker_login_cmd(harbor_server, username, password, cfg_file=cfg_file)
docker_manifest_create(index, manifests)
return docker_manifest_push(index)
def list_repositories(harbor_host, username, password, n = None, last = None):
if n is not None and last is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n+"&last="+last, "--insecure"]
elif n is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog", "--insecure"]
print( "List Repositories Command: ", command)
ret = base.run_command(command)
repos = json.loads(ret).get("repositories","")
return repos
def list_image_tags(harbor_host, repository, username, password, n = None, last = None):
if n is not None and last is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n+"&last="+last, "--insecure"]
elif n is not None:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list", "--insecure"]
print( "List Image Tags Command: ", command)
ret = base.run_command(command)
tags = json.loads(ret).get("tags","")
return tags
class DockerAPI(object):
def __init__(self):
self.DCLIENT = docker.APIClient(base_url='unix://var/run/docker.sock',version='auto',timeout=30)
self.DCLIENT2 = docker.from_env()
def docker_login(self, registry, username, password, expected_error_message = None):
ret = ""
err_message = ""
if username == "" or password == "":
print("[Warnig]: No docker credential was provided.")
return
if expected_error_message == "":
expected_error_message = None
if registry == "docker":
registry = None
try:
print("Docker login: {}:{}:{}".format(registry,username,password))
ret = self.DCLIENT.login(registry = registry, username=username, password=password)
except Exception as err:
print( "Docker image pull catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, str(err)))
else:
print("Docker image login did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when login registry {}, return message: {}".format (expected_error_message, registry, err_message))
else:
print(r"Docker image login got expected error message:{}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when login registry {}, return message is [{}]".format (registry, err_message))
def docker_image_pull(self, image, tag = None, expected_error_message = None, is_clean_all_img = True):
ret = ""
err_message = ""
if tag is not None:
_tag = tag
else:
_tag = "latest"
if expected_error_message == "":
expected_error_message = None
try:
ret = self.DCLIENT.pull(r'{}:{}'.format(image, _tag))
except Exception as err:
print( "Docker image pull catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, str(err)))
else:
print("Docker image pull did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when pull image {}, return message: {}".format (expected_error_message, image, err_message))
else:
print(r"Docker image pull got expected error message:{}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when pull image {}, return message is [{}]".format (image, err_message))
if is_clean_all_img:
docker_image_clean_all()
def docker_image_tag(self, image, harbor_registry, tag = None):
_tag = base._random_name("tag")
if tag is not None:
_tag = tag
ret = ""
try:
ret = self.DCLIENT.tag(image, harbor_registry, _tag, force=True)
print("Docker image tag commond return:", ret)
return harbor_registry, _tag
except docker.errors.APIError as err:
raise Exception(r" Docker tag image {} failed, error is [{}]".format (image, str(err)))
def docker_image_push(self, harbor_registry, tag, expected_error_message = None):
ret = ""
err_message = ""
docker_images_all_list()
if expected_error_message == "":
expected_error_message = None
try:
ret = self.DCLIENT.push(harbor_registry, tag)
except Exception as err:
print( "Docker image push catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker push image {} failed, error is [{}]".format (image, str(err)))
else:
print("Docker image push did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when push image {}, return message: {}".format (expected_error_message, harbor_registry, err_message))
else:
print(r"Docker image push got expected error message:{}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when push image {}, return message is [{}]".format (harbor_registry, err_message))
docker_images_all_list()
def docker_image_build(self, harbor_registry, tags=None, size=1, expected_error_message = None):
ret = ""
err_message = ""
docker_images_all_list()
try:
baseimage = BASE_IMAGE['name'] + ":" + BASE_IMAGE['tag']
if not self.DCLIENT.images(name=baseimage):
print( "Docker load is triggered when building {}".format(harbor_registry))
docker_load_image(BASE_IMAGE_ABS_PATH_NAME)
docker_images_all_list()
c = self.DCLIENT.create_container(image=baseimage,
command='dd if=/dev/urandom of=test bs=1M count={}'.format(size))
self.DCLIENT.start(c)
self.DCLIENT.wait(c)
if not tags:
tags=['latest']
firstrepo="{}:{}".format(harbor_registry, tags[0])
#self.DCLIENT.commit(c, firstrepo)
self.DCLIENT2.containers.get(c).commit(harbor_registry, tags[0])
for tag in tags[1:]:
repo="{}:{}".format(harbor_registry, tag)
self.DCLIENT.tag(firstrepo, repo)
for tag in tags:
repo="{}:{}".format(harbor_registry, tag)
ret = self.DCLIENT.push(repo)
print("docker_image_push ret:", ret)
print("build image {} with size {}".format(repo, size))
self.DCLIENT.remove_container(c)
except Exception as err:
print( "Docker image build catch exception:", str(err))
err_message = str(err)
if expected_error_message is None:
raise Exception(r" Docker push image {} failed, error is [{}]".format (harbor_registry, str(err)))
else:
print("Docker image build did not catch exception and return message is:", ret)
err_message = ret
finally:
if expected_error_message is not None:
if str(err_message).lower().find(expected_error_message.lower()) < 0:
raise Exception(r" Failed to catch error [{}] when build image {}, return message: {}".format (expected_error_message, harbor_registry, err_message))
else:
print(r"Docker image build got expected error message: {}".format(expected_error_message))
else:
if str(err_message).lower().find("error".lower()) >= 0:
raise Exception(r" It's was not suppose to catch error when build image {}, return message is [{}]".format (harbor_registry, err_message))
docker_image_clean_all()

View File

@ -1,95 +1,95 @@
# -*- coding: utf-8 -*-
import base
import v2_swagger_client
from v2_swagger_client.rest import ApiException
class Tag_Immutability(base.Base, object):
def __init__(self):
super(Tag_Immutability,self).__init__(api_type = "immutable")
def create_tag_immutability_policy_rule(self, project_id, selector_repository_decoration = "repoMatches",
selector_repository="**", selector_tag_decoration = "matches",
selector_tag="**", expect_status_code = 201, **kwargs):
#repoExcludes,excludes
immutable_rule = v2_swagger_client.ImmutableRule(
action="immutable",
template="immutable_template",
priority = 0,
scope_selectors={
"repository": [
{
"kind": "doublestar",
"decoration": selector_repository_decoration,
"pattern": selector_repository
}
]
},
tag_selectors=[
{
"kind": "doublestar",
"decoration": selector_tag_decoration,
"pattern": selector_tag
}
]
)
try:
_, status_code, header = self._get_client(**kwargs).create_immu_rule_with_http_info(project_id, immutable_rule)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
else:
base._assert_status_code(expect_status_code, status_code)
base._assert_status_code(201, status_code)
return base._get_id_from_header(header)
def list_tag_immutability_policy_rules(self, project_id, **kwargs):
return self._get_client(**kwargs).list_immu_rules_with_http_info(project_id)
def get_rule(self, project_id, rule_id, **kwargs):
rules = self.list_tag_immutability_policy_rules(project_id, **kwargs)
if len(rules) <= 0:
return None
for r in rules[0]:
if r.id == rule_id:
return r
return None
def update_tag_immutability_policy_rule(self, project_id, rule_id, selector_repository_decoration = None,
selector_repository=None, selector_tag_decoration = None,
selector_tag=None, disabled = None, expect_status_code = 200, **kwargs):
rule = self.get_rule( project_id, rule_id,**kwargs)
if selector_repository_decoration:
rule.scope_selectors["repository"][0].decoration = selector_repository_decoration
if selector_repository:
rule.scope_selectors["repository"][0].pattern = selector_repository
if selector_tag_decoration:
rule.tag_selectors[0].decoration = selector_tag_decoration
if selector_tag:
rule.tag_selectors[0].pattern = selector_tag
if disabled is not None:
rule.disabled = disabled
try:
_, status_code, header = self._get_client(**kwargs).update_immu_rule_with_http_info(project_id, rule_id, rule)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
if expect_response_body is not None:
base._assert_status_body(expect_response_body, e.body)
else:
base._assert_status_code(expect_status_code, status_code)
base._assert_status_code(200, status_code)
return base._get_id_from_header(header)
def create_rule(self, project_id, selector_repository_decoration = "repoMatches", selector_repository="**",
selector_tag_decoration = "matches", selector_tag="**",
expect_status_code = 201, disabled = False, **kwargs):
rule_id = self.create_tag_immutability_policy_rule(project_id, selector_repository_decoration = selector_repository_decoration,
selector_repository = selector_repository,
selector_tag_decoration = selector_tag_decoration,
selector_tag = selector_tag, expect_status_code = expect_status_code, **kwargs)
if expect_status_code != 201:
return
self.update_tag_immutability_policy_rule(project_id, rule_id, selector_repository_decoration = selector_repository_decoration,
selector_repository = selector_repository, selector_tag_decoration = selector_tag_decoration,
selector_tag = selector_tag, disabled = disabled, expect_status_code = 200, **kwargs)
return rule_id
# -*- coding: utf-8 -*-
import base
import v2_swagger_client
from v2_swagger_client.rest import ApiException
class Tag_Immutability(base.Base, object):
def __init__(self):
super(Tag_Immutability,self).__init__(api_type = "immutable")
def create_tag_immutability_policy_rule(self, project_id, selector_repository_decoration = "repoMatches",
selector_repository="**", selector_tag_decoration = "matches",
selector_tag="**", expect_status_code = 201, **kwargs):
#repoExcludes,excludes
immutable_rule = v2_swagger_client.ImmutableRule(
action="immutable",
template="immutable_template",
priority = 0,
scope_selectors={
"repository": [
{
"kind": "doublestar",
"decoration": selector_repository_decoration,
"pattern": selector_repository
}
]
},
tag_selectors=[
{
"kind": "doublestar",
"decoration": selector_tag_decoration,
"pattern": selector_tag
}
]
)
try:
_, status_code, header = self._get_client(**kwargs).create_immu_rule_with_http_info(project_id, immutable_rule)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
else:
base._assert_status_code(expect_status_code, status_code)
base._assert_status_code(201, status_code)
return base._get_id_from_header(header)
def list_tag_immutability_policy_rules(self, project_id, **kwargs):
return self._get_client(**kwargs).list_immu_rules_with_http_info(project_id)
def get_rule(self, project_id, rule_id, **kwargs):
rules = self.list_tag_immutability_policy_rules(project_id, **kwargs)
if len(rules) <= 0:
return None
for r in rules[0]:
if r.id == rule_id:
return r
return None
def update_tag_immutability_policy_rule(self, project_id, rule_id, selector_repository_decoration = None,
selector_repository=None, selector_tag_decoration = None,
selector_tag=None, disabled = None, expect_status_code = 200, **kwargs):
rule = self.get_rule( project_id, rule_id,**kwargs)
if selector_repository_decoration:
rule.scope_selectors["repository"][0].decoration = selector_repository_decoration
if selector_repository:
rule.scope_selectors["repository"][0].pattern = selector_repository
if selector_tag_decoration:
rule.tag_selectors[0].decoration = selector_tag_decoration
if selector_tag:
rule.tag_selectors[0].pattern = selector_tag
if disabled is not None:
rule.disabled = disabled
try:
_, status_code, header = self._get_client(**kwargs).update_immu_rule_with_http_info(project_id, rule_id, rule)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
if expect_response_body is not None:
base._assert_status_body(expect_response_body, e.body)
else:
base._assert_status_code(expect_status_code, status_code)
base._assert_status_code(200, status_code)
return base._get_id_from_header(header)
def create_rule(self, project_id, selector_repository_decoration = "repoMatches", selector_repository="**",
selector_tag_decoration = "matches", selector_tag="**",
expect_status_code = 201, disabled = False, **kwargs):
rule_id = self.create_tag_immutability_policy_rule(project_id, selector_repository_decoration = selector_repository_decoration,
selector_repository = selector_repository,
selector_tag_decoration = selector_tag_decoration,
selector_tag = selector_tag, expect_status_code = expect_status_code, **kwargs)
if expect_status_code != 201:
return
self.update_tag_immutability_policy_rule(project_id, rule_id, selector_repository_decoration = selector_repository_decoration,
selector_repository = selector_repository, selector_tag_decoration = selector_tag_decoration,
selector_tag = selector_tag, disabled = disabled, expect_status_code = 200, **kwargs)
return rule_id

View File

@ -1,94 +1,94 @@
# -*- coding: utf-8 -*-
import base
import v2_swagger_client
from v2_swagger_client.rest import ApiException
class User(base.Base, object):
def __init__(self):
super(User, self).__init__(api_type = "user")
def create_user(self, name=None,
email=None, user_password=None, realname=None, expect_status_code=201, **kwargs):
if name is None:
name = base._random_name("user")
if realname is None:
realname = base._random_name("realname")
if email is None:
email = '%s@%s.com' % (realname, "vmware")
if user_password is None:
user_password = "Harbor12345678"
user_req = v2_swagger_client.UserCreationReq(username=name, email=email, password=user_password, realname=realname)
try:
_, status_code, header = self._get_client(**kwargs).create_user_with_http_info(user_req)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
else:
base._assert_status_code(expect_status_code, status_code)
return base._get_id_from_header(header), name
def get_users(self, user_name=None, email=None, page=None, page_size=None, expect_status_code=200, **kwargs):
query = []
if user_name is not None:
query.append("username=" + user_name)
if email is not None:
query.append("email=" + email)
params = {}
if len(query) > 0:
params["q"] = ",".join(query)
if page is not None:
params["page"] = page
if page_size is not None:
params["page_size"] = page_size
try:
data, status_code, _ = self._get_client(**kwargs).list_users_with_http_info(**params)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
else:
base._assert_status_code(expect_status_code, status_code)
return data
def get_user_by_id(self, user_id, **kwargs):
data, status_code, _ = self._get_client(**kwargs).get_user_with_http_info(user_id)
base._assert_status_code(200, status_code)
return data
def get_user_by_name(self, name, expect_status_code=200, **kwargs):
users = self.get_users(user_name=name, expect_status_code=expect_status_code, **kwargs)
for user in users:
if user.username == name:
return user
return None
def get_user_current(self, **kwargs):
data, status_code, _ = self._get_client(**kwargs).get_current_user_info_with_http_info()
base._assert_status_code(200, status_code)
return data
def delete_user(self, user_id, expect_status_code=200, **kwargs):
_, status_code, _ = self._get_client(**kwargs).delete_user_with_http_info(user_id)
base._assert_status_code(expect_status_code, status_code)
return user_id
def update_user_pwd(self, user_id, new_password=None, old_password=None, **kwargs):
if old_password is None:
old_password = ""
password = v2_swagger_client.PasswordReq(old_password=old_password, new_password=new_password)
_, status_code, _ = self._get_client(**kwargs).update_user_password_with_http_info(user_id, password)
base._assert_status_code(200, status_code)
return user_id
def update_user_profile(self, user_id, email=None, realname=None, comment=None, **kwargs):
user_profile = v2_swagger_client.UserProfile(email=email, realname=realname, comment=comment)
_, status_code, _ = self._get_client(**kwargs).update_user_profile_with_http_info(user_id, user_profile)
base._assert_status_code(200, status_code)
return user_id
def update_user_role_as_sysadmin(self, user_id, IsAdmin, **kwargs):
sysadmin_flag = v2_swagger_client.UserSysAdminFlag(sysadmin_flag=IsAdmin)
_, status_code, _ = self._get_client(**kwargs).set_user_sys_admin_with_http_info(user_id, sysadmin_flag)
base._assert_status_code(200, status_code)
return user_id
# -*- coding: utf-8 -*-
import base
import v2_swagger_client
from v2_swagger_client.rest import ApiException
class User(base.Base, object):
def __init__(self):
super(User, self).__init__(api_type = "user")
def create_user(self, name=None,
email=None, user_password=None, realname=None, expect_status_code=201, **kwargs):
if name is None:
name = base._random_name("user")
if realname is None:
realname = base._random_name("realname")
if email is None:
email = '%s@%s.com' % (realname, "vmware")
if user_password is None:
user_password = "Harbor12345678"
user_req = v2_swagger_client.UserCreationReq(username=name, email=email, password=user_password, realname=realname)
try:
_, status_code, header = self._get_client(**kwargs).create_user_with_http_info(user_req)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
else:
base._assert_status_code(expect_status_code, status_code)
return base._get_id_from_header(header), name
def get_users(self, user_name=None, email=None, page=None, page_size=None, expect_status_code=200, **kwargs):
query = []
if user_name is not None:
query.append("username=" + user_name)
if email is not None:
query.append("email=" + email)
params = {}
if len(query) > 0:
params["q"] = ",".join(query)
if page is not None:
params["page"] = page
if page_size is not None:
params["page_size"] = page_size
try:
data, status_code, _ = self._get_client(**kwargs).list_users_with_http_info(**params)
except ApiException as e:
base._assert_status_code(expect_status_code, e.status)
else:
base._assert_status_code(expect_status_code, status_code)
return data
def get_user_by_id(self, user_id, **kwargs):
data, status_code, _ = self._get_client(**kwargs).get_user_with_http_info(user_id)
base._assert_status_code(200, status_code)
return data
def get_user_by_name(self, name, expect_status_code=200, **kwargs):
users = self.get_users(user_name=name, expect_status_code=expect_status_code, **kwargs)
for user in users:
if user.username == name:
return user
return None
def get_user_current(self, **kwargs):
data, status_code, _ = self._get_client(**kwargs).get_current_user_info_with_http_info()
base._assert_status_code(200, status_code)
return data
def delete_user(self, user_id, expect_status_code=200, **kwargs):
_, status_code, _ = self._get_client(**kwargs).delete_user_with_http_info(user_id)
base._assert_status_code(expect_status_code, status_code)
return user_id
def update_user_pwd(self, user_id, new_password=None, old_password=None, **kwargs):
if old_password is None:
old_password = ""
password = v2_swagger_client.PasswordReq(old_password=old_password, new_password=new_password)
_, status_code, _ = self._get_client(**kwargs).update_user_password_with_http_info(user_id, password)
base._assert_status_code(200, status_code)
return user_id
def update_user_profile(self, user_id, email=None, realname=None, comment=None, **kwargs):
user_profile = v2_swagger_client.UserProfile(email=email, realname=realname, comment=comment)
_, status_code, _ = self._get_client(**kwargs).update_user_profile_with_http_info(user_id, user_profile)
base._assert_status_code(200, status_code)
return user_id
def update_user_role_as_sysadmin(self, user_id, IsAdmin, **kwargs):
sysadmin_flag = v2_swagger_client.UserSysAdminFlag(sysadmin_flag=IsAdmin)
_, status_code, _ = self._get_client(**kwargs).set_user_sys_admin_with_http_info(user_id, sysadmin_flag)
base._assert_status_code(200, status_code)
return user_id

View File

@ -1,84 +1,84 @@
from __future__ import absolute_import
import unittest
from testutils import harbor_server, suppress_urllib3_warning
from testutils import TEARDOWN
from testutils import ADMIN_CLIENT
from library.artifact import Artifact
from library.project import Project
from library.user import User
from library.repository import Repository
from library.repository import push_self_build_image_to_project
from library.label import Label
class TestProjects(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.project = Project()
self.user = User()
self.artifact = Artifact()
self.repo = Repository()
self.label = Label()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
#1. Delete repository(RA) by user(UA);
self.repo.delete_repository(TestProjects.project_add_g_lbl_name, TestProjects.repo_name.split('/')[1], **TestProjects.USER_add_g_lbl_CLIENT)
#2. Delete project(PA);
self.project.delete_project(TestProjects.project_add_g_lbl_id, **TestProjects.USER_add_g_lbl_CLIENT)
#3. Delete user(UA);
self.user.delete_user(TestProjects.user_add_g_lbl_id, **ADMIN_CLIENT)
#4. Delete label(LA).
self.label.delete_label(TestProjects.label_id, **ADMIN_CLIENT)
def testAddSysLabelToRepo(self):
"""
Test case:
Add Global Label To Tag
Test step and expected result:
1. Create a new user(UA);
2. Create a new private project(PA) by user(UA);
3. Add user(UA) as a member of project(PA) with project-admin role;
4. Get private project of user(UA), user(UA) can see only one private project which is project(PA);
5. Create a new repository(RA) and tag(TA) in project(PA) by user(UA);
6. Create a new label(LA) in project(PA) by admin;;
7. Add this system global label to repository(RA)/tag(TA);
Tear down:
1. Delete repository(RA) by user(UA);
2. Delete project(PA);
3. Delete user(UA);
4. Delete label(LA).
"""
url = ADMIN_CLIENT["endpoint"]
user_001_password = "Aa123456"
#1. Create user-001
TestProjects.user_add_g_lbl_id, user_add_g_lbl_name = self.user.create_user(user_password = user_001_password, **ADMIN_CLIENT)
TestProjects.USER_add_g_lbl_CLIENT=dict(endpoint = url, username = user_add_g_lbl_name, password = user_001_password)
#2. Create private project-001
TestProjects.project_add_g_lbl_id, TestProjects.project_add_g_lbl_name = self.project.create_project(metadata = {"public": "false"}, **ADMIN_CLIENT)
#3. Add user-001 as a member of project-001 with project-admin role
self.project.add_project_members(TestProjects.project_add_g_lbl_id, user_id=TestProjects.user_add_g_lbl_id, **ADMIN_CLIENT)
#4. Get private project of user(UA), user(UA) can see only one private project which is project(PA);
self.project.projects_should_exist(dict(public=False), expected_count = 1,
expected_project_id = TestProjects.project_add_g_lbl_id, **TestProjects.USER_add_g_lbl_CLIENT)
#5. Create a new repository(RA) and tag(TA) in project(PA) by user(UA);
TestProjects.repo_name, tag = push_self_build_image_to_project(TestProjects.project_add_g_lbl_name, harbor_server, user_add_g_lbl_name, user_001_password, "test_sys_label", "latest")
#6. Create a new label(LA) in project(PA) by admin;
TestProjects.label_id, _ = self.label.create_label(**ADMIN_CLIENT)
#7. Add this system global label to repository(RA)/tag(TA).
self.artifact.add_label_to_reference(TestProjects.project_add_g_lbl_name, TestProjects.repo_name.split('/')[1], tag, int(TestProjects.label_id), **TestProjects.USER_add_g_lbl_CLIENT)
if __name__ == '__main__':
unittest.main()
from __future__ import absolute_import
import unittest
from testutils import harbor_server, suppress_urllib3_warning
from testutils import TEARDOWN
from testutils import ADMIN_CLIENT
from library.artifact import Artifact
from library.project import Project
from library.user import User
from library.repository import Repository
from library.repository import push_self_build_image_to_project
from library.label import Label
class TestProjects(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.project = Project()
self.user = User()
self.artifact = Artifact()
self.repo = Repository()
self.label = Label()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
#1. Delete repository(RA) by user(UA);
self.repo.delete_repository(TestProjects.project_add_g_lbl_name, TestProjects.repo_name.split('/')[1], **TestProjects.USER_add_g_lbl_CLIENT)
#2. Delete project(PA);
self.project.delete_project(TestProjects.project_add_g_lbl_id, **TestProjects.USER_add_g_lbl_CLIENT)
#3. Delete user(UA);
self.user.delete_user(TestProjects.user_add_g_lbl_id, **ADMIN_CLIENT)
#4. Delete label(LA).
self.label.delete_label(TestProjects.label_id, **ADMIN_CLIENT)
def testAddSysLabelToRepo(self):
"""
Test case:
Add Global Label To Tag
Test step and expected result:
1. Create a new user(UA);
2. Create a new private project(PA) by user(UA);
3. Add user(UA) as a member of project(PA) with project-admin role;
4. Get private project of user(UA), user(UA) can see only one private project which is project(PA);
5. Create a new repository(RA) and tag(TA) in project(PA) by user(UA);
6. Create a new label(LA) in project(PA) by admin;;
7. Add this system global label to repository(RA)/tag(TA);
Tear down:
1. Delete repository(RA) by user(UA);
2. Delete project(PA);
3. Delete user(UA);
4. Delete label(LA).
"""
url = ADMIN_CLIENT["endpoint"]
user_001_password = "Aa123456"
#1. Create user-001
TestProjects.user_add_g_lbl_id, user_add_g_lbl_name = self.user.create_user(user_password = user_001_password, **ADMIN_CLIENT)
TestProjects.USER_add_g_lbl_CLIENT=dict(endpoint = url, username = user_add_g_lbl_name, password = user_001_password)
#2. Create private project-001
TestProjects.project_add_g_lbl_id, TestProjects.project_add_g_lbl_name = self.project.create_project(metadata = {"public": "false"}, **ADMIN_CLIENT)
#3. Add user-001 as a member of project-001 with project-admin role
self.project.add_project_members(TestProjects.project_add_g_lbl_id, user_id=TestProjects.user_add_g_lbl_id, **ADMIN_CLIENT)
#4. Get private project of user(UA), user(UA) can see only one private project which is project(PA);
self.project.projects_should_exist(dict(public=False), expected_count = 1,
expected_project_id = TestProjects.project_add_g_lbl_id, **TestProjects.USER_add_g_lbl_CLIENT)
#5. Create a new repository(RA) and tag(TA) in project(PA) by user(UA);
TestProjects.repo_name, tag = push_self_build_image_to_project(TestProjects.project_add_g_lbl_name, harbor_server, user_add_g_lbl_name, user_001_password, "test_sys_label", "latest")
#6. Create a new label(LA) in project(PA) by admin;
TestProjects.label_id, _ = self.label.create_label(**ADMIN_CLIENT)
#7. Add this system global label to repository(RA)/tag(TA).
self.artifact.add_label_to_reference(TestProjects.project_add_g_lbl_name, TestProjects.repo_name.split('/')[1], tag, int(TestProjects.label_id), **TestProjects.USER_add_g_lbl_CLIENT)
if __name__ == '__main__':
unittest.main()

View File

@ -1,91 +1,91 @@
from __future__ import absolute_import
import unittest
from testutils import harbor_server, suppress_urllib3_warning
from testutils import TEARDOWN
from testutils import ADMIN_CLIENT
from testutils import created_user, created_project
from library.project import Project
from library.user import User
from library.repository import Repository
from library.artifact import Artifact
from library.configurations import Configurations
from library.projectV2 import ProjectV2
from library.repository import push_self_build_image_to_project
class TestAssignRoleToLdapGroup(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.conf= Configurations()
self.project = Project()
self.artifact = Artifact()
self.repo = Repository()
self.user= User()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
print("Case completed")
def testAssignRoleToLdapGroup(self):
"""
Test case:
Assign Role To Ldap Group
Test step and expected result:
1. Set LDAP Auth configurations;
2. Create a new public project(PA) by Admin;
3. Add 3 member groups to project(PA);
4. Push image by each member role;
5. Verfify that admin_user can add project member, dev_user and guest_user can not add project member;
6. Verfify that admin_user and dev_user can push image, guest_user can not push image;
7. Verfify that admin_user, dev_user and guest_user can view logs, test user can not view logs.
8. Delete repository(RA) by user(UA);
9. Delete project(PA);
"""
url = ADMIN_CLIENT["endpoint"]
USER_ADMIN=dict(endpoint = url, username = "admin_user", password = "zhu88jie", repo = "haproxy")
USER_DEV=dict(endpoint = url, username = "dev_user", password = "zhu88jie", repo = "alpine")
USER_GUEST=dict(endpoint = url, username = "guest_user", password = "zhu88jie", repo = "busybox")
USER_TEST=dict(endpoint = url, username = "test", password = "123456")
USER_MIKE=dict(endpoint = url, username = "mike", password = "zhu88jie")
#USER001 is in group harbor_group3
self.conf.set_configurations_of_ldap(ldap_filter="", ldap_group_attribute_name="cn", ldap_group_base_dn="ou=groups,dc=example,dc=com",
ldap_group_search_filter="objectclass=groupOfNames", ldap_group_search_scope=2, **ADMIN_CLIENT)
with created_project(metadata={"public": "false"}) as (project_id, project_name):
self.project.add_project_members(project_id, member_role_id = 1, _ldap_group_dn = "cn=harbor_admin,ou=groups,dc=example,dc=com", **ADMIN_CLIENT)
self.project.add_project_members(project_id, member_role_id = 2, _ldap_group_dn = "cn=harbor_dev,ou=groups,dc=example,dc=com", **ADMIN_CLIENT)
self.project.add_project_members(project_id, member_role_id = 3, _ldap_group_dn = "cn=harbor_guest,ou=groups,dc=example,dc=com", **ADMIN_CLIENT)
projects = self.project.get_projects(dict(name=project_name), **USER_ADMIN)
self.assertTrue(len(projects) == 1)
self.assertEqual(1, projects[0].current_user_role_id)
#Mike has logged in harbor in previous test.
mike = self.user.get_user_by_name(USER_MIKE["username"], **ADMIN_CLIENT)
#Verify role difference in add project member feature, to distinguish between admin and dev role
self.project.add_project_members(project_id, user_id=mike.user_id, member_role_id = 3, **USER_ADMIN)
self.project.add_project_members(project_id, user_id=mike.user_id, member_role_id = 3, expect_status_code=403, **USER_DEV)
self.project.add_project_members(project_id, user_id=mike.user_id, member_role_id = 3, expect_status_code=403, **USER_GUEST)
repo_name_admin, _ = push_self_build_image_to_project(project_name, harbor_server, USER_ADMIN["username"], USER_ADMIN["password"], USER_ADMIN["repo"], "latest")
artifacts = self.artifact.list_artifacts(project_name, USER_ADMIN["repo"], **USER_ADMIN)
self.assertTrue(len(artifacts) == 1)
repo_name_dev, _ = push_self_build_image_to_project(project_name, harbor_server, USER_DEV["username"], USER_DEV["password"], USER_DEV["repo"], "latest")
artifacts = self.artifact.list_artifacts(project_name, USER_DEV["repo"], **USER_DEV)
self.assertTrue(len(artifacts) == 1)
push_self_build_image_to_project(project_name, harbor_server, USER_GUEST["username"], USER_GUEST["password"], USER_GUEST["repo"], "latest", expected_error_message = "unauthorized to access repository")
artifacts = self.artifact.list_artifacts(project_name, USER_GUEST["repo"], **USER_GUEST)
self.assertTrue(len(artifacts) == 0)
self.assertTrue(self.project.query_user_logs(project_name, **USER_ADMIN)>0, "admin user can see logs")
self.assertTrue(self.project.query_user_logs(project_name, **USER_DEV)>0, "dev user can see logs")
self.assertTrue(self.project.query_user_logs(project_name, **USER_GUEST)>0, "guest user can see logs")
self.assertTrue(self.project.query_user_logs(project_name, status_code=403, **USER_TEST)==0, "test user can not see any logs")
self.repo.delete_repository(project_name, repo_name_admin.split('/')[1], **USER_ADMIN)
self.repo.delete_repository(project_name, repo_name_dev.split('/')[1], **USER_ADMIN)
if __name__ == '__main__':
unittest.main()
from __future__ import absolute_import
import unittest
from testutils import harbor_server, suppress_urllib3_warning
from testutils import TEARDOWN
from testutils import ADMIN_CLIENT
from testutils import created_user, created_project
from library.project import Project
from library.user import User
from library.repository import Repository
from library.artifact import Artifact
from library.configurations import Configurations
from library.projectV2 import ProjectV2
from library.repository import push_self_build_image_to_project
class TestAssignRoleToLdapGroup(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.conf= Configurations()
self.project = Project()
self.artifact = Artifact()
self.repo = Repository()
self.user= User()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
print("Case completed")
def testAssignRoleToLdapGroup(self):
"""
Test case:
Assign Role To Ldap Group
Test step and expected result:
1. Set LDAP Auth configurations;
2. Create a new public project(PA) by Admin;
3. Add 3 member groups to project(PA);
4. Push image by each member role;
5. Verfify that admin_user can add project member, dev_user and guest_user can not add project member;
6. Verfify that admin_user and dev_user can push image, guest_user can not push image;
7. Verfify that admin_user, dev_user and guest_user can view logs, test user can not view logs.
8. Delete repository(RA) by user(UA);
9. Delete project(PA);
"""
url = ADMIN_CLIENT["endpoint"]
USER_ADMIN=dict(endpoint = url, username = "admin_user", password = "zhu88jie", repo = "haproxy")
USER_DEV=dict(endpoint = url, username = "dev_user", password = "zhu88jie", repo = "alpine")
USER_GUEST=dict(endpoint = url, username = "guest_user", password = "zhu88jie", repo = "busybox")
USER_TEST=dict(endpoint = url, username = "test", password = "123456")
USER_MIKE=dict(endpoint = url, username = "mike", password = "zhu88jie")
#USER001 is in group harbor_group3
self.conf.set_configurations_of_ldap(ldap_filter="", ldap_group_attribute_name="cn", ldap_group_base_dn="ou=groups,dc=example,dc=com",
ldap_group_search_filter="objectclass=groupOfNames", ldap_group_search_scope=2, **ADMIN_CLIENT)
with created_project(metadata={"public": "false"}) as (project_id, project_name):
self.project.add_project_members(project_id, member_role_id = 1, _ldap_group_dn = "cn=harbor_admin,ou=groups,dc=example,dc=com", **ADMIN_CLIENT)
self.project.add_project_members(project_id, member_role_id = 2, _ldap_group_dn = "cn=harbor_dev,ou=groups,dc=example,dc=com", **ADMIN_CLIENT)
self.project.add_project_members(project_id, member_role_id = 3, _ldap_group_dn = "cn=harbor_guest,ou=groups,dc=example,dc=com", **ADMIN_CLIENT)
projects = self.project.get_projects(dict(name=project_name), **USER_ADMIN)
self.assertTrue(len(projects) == 1)
self.assertEqual(1, projects[0].current_user_role_id)
#Mike has logged in harbor in previous test.
mike = self.user.get_user_by_name(USER_MIKE["username"], **ADMIN_CLIENT)
#Verify role difference in add project member feature, to distinguish between admin and dev role
self.project.add_project_members(project_id, user_id=mike.user_id, member_role_id = 3, **USER_ADMIN)
self.project.add_project_members(project_id, user_id=mike.user_id, member_role_id = 3, expect_status_code=403, **USER_DEV)
self.project.add_project_members(project_id, user_id=mike.user_id, member_role_id = 3, expect_status_code=403, **USER_GUEST)
repo_name_admin, _ = push_self_build_image_to_project(project_name, harbor_server, USER_ADMIN["username"], USER_ADMIN["password"], USER_ADMIN["repo"], "latest")
artifacts = self.artifact.list_artifacts(project_name, USER_ADMIN["repo"], **USER_ADMIN)
self.assertTrue(len(artifacts) == 1)
repo_name_dev, _ = push_self_build_image_to_project(project_name, harbor_server, USER_DEV["username"], USER_DEV["password"], USER_DEV["repo"], "latest")
artifacts = self.artifact.list_artifacts(project_name, USER_DEV["repo"], **USER_DEV)
self.assertTrue(len(artifacts) == 1)
push_self_build_image_to_project(project_name, harbor_server, USER_GUEST["username"], USER_GUEST["password"], USER_GUEST["repo"], "latest", expected_error_message = "unauthorized to access repository")
artifacts = self.artifact.list_artifacts(project_name, USER_GUEST["repo"], **USER_GUEST)
self.assertTrue(len(artifacts) == 0)
self.assertTrue(self.project.query_user_logs(project_name, **USER_ADMIN)>0, "admin user can see logs")
self.assertTrue(self.project.query_user_logs(project_name, **USER_DEV)>0, "dev user can see logs")
self.assertTrue(self.project.query_user_logs(project_name, **USER_GUEST)>0, "guest user can see logs")
self.assertTrue(self.project.query_user_logs(project_name, status_code=403, **USER_TEST)==0, "test user can not see any logs")
self.repo.delete_repository(project_name, repo_name_admin.split('/')[1], **USER_ADMIN)
self.repo.delete_repository(project_name, repo_name_dev.split('/')[1], **USER_ADMIN)
if __name__ == '__main__':
unittest.main()

View File

@ -1,72 +1,72 @@
from __future__ import absolute_import
import unittest
from testutils import ADMIN_CLIENT, suppress_urllib3_warning
from testutils import harbor_server
from testutils import TEARDOWN
from library.base import _assert_status_code
from library.project import Project
from library.user import User
from library.repository import Repository
from library.repository import push_self_build_image_to_project
class TestProjects(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.project= Project()
self.user= User()
self.repo= Repository()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
#1. Delete project(PA);
self.project.delete_project(TestProjects.project_del_repo_id, **TestProjects.USER_del_repo_CLIENT)
#2. Delete user(UA).
self.user.delete_user(TestProjects.user_del_repo_id, **ADMIN_CLIENT)
def testDelRepo(self):
"""
Test case:
Delete a repository
Test step and expected result:
1. Create a new user(UA);
2. Create a new project(PA) by user(UA);
3. Create a new repository(RA) in project(PA) by user(UA);
4. Get repository in project(PA), there should be one repository which was created by user(UA);
5. Delete repository(RA) by user(UA);
6. Get repository by user(UA), it should get nothing;
Tear down:
1. Delete project(PA);
2. Delete user(UA).
"""
url = ADMIN_CLIENT["endpoint"]
user_del_repo_password = "Aa123456"
#1. Create a new user(UA);
TestProjects.user_del_repo_id, user_del_repo_name = self.user.create_user(user_password = user_del_repo_password, **ADMIN_CLIENT)
TestProjects.USER_del_repo_CLIENT=dict(endpoint = url, username = user_del_repo_name, password = user_del_repo_password)
#2. Create a new project(PA) by user(UA);
TestProjects.project_del_repo_id, TestProjects.project_del_repo_name = self.project.create_project(metadata = {"public": "false"}, **TestProjects.USER_del_repo_CLIENT)
#3. Create a new repository(RA) in project(PA) by user(UA);
repo_name, _ = push_self_build_image_to_project(TestProjects.project_del_repo_name, harbor_server, 'admin', 'Harbor12345', "test_del_repo", "latest", size=512)
#4. Get repository in project(PA), there should be one repository which was created by user(UA);
repo_data = self.repo.list_repositories(TestProjects.project_del_repo_name, **TestProjects.USER_del_repo_CLIENT)
_assert_status_code(repo_name, repo_data[0].name)
#5. Delete repository(RA) by user(UA);
self.repo.delete_repository(TestProjects.project_del_repo_name, repo_name.split('/')[1], **TestProjects.USER_del_repo_CLIENT)
#6. Get repository by user(UA), it should get nothing;
repo_data = self.repo.list_repositories(TestProjects.project_del_repo_name, **TestProjects.USER_del_repo_CLIENT)
_assert_status_code(len(repo_data), 0)
if __name__ == '__main__':
unittest.main()
from __future__ import absolute_import
import unittest
from testutils import ADMIN_CLIENT, suppress_urllib3_warning
from testutils import harbor_server
from testutils import TEARDOWN
from library.base import _assert_status_code
from library.project import Project
from library.user import User
from library.repository import Repository
from library.repository import push_self_build_image_to_project
class TestProjects(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.project= Project()
self.user= User()
self.repo= Repository()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
#1. Delete project(PA);
self.project.delete_project(TestProjects.project_del_repo_id, **TestProjects.USER_del_repo_CLIENT)
#2. Delete user(UA).
self.user.delete_user(TestProjects.user_del_repo_id, **ADMIN_CLIENT)
def testDelRepo(self):
"""
Test case:
Delete a repository
Test step and expected result:
1. Create a new user(UA);
2. Create a new project(PA) by user(UA);
3. Create a new repository(RA) in project(PA) by user(UA);
4. Get repository in project(PA), there should be one repository which was created by user(UA);
5. Delete repository(RA) by user(UA);
6. Get repository by user(UA), it should get nothing;
Tear down:
1. Delete project(PA);
2. Delete user(UA).
"""
url = ADMIN_CLIENT["endpoint"]
user_del_repo_password = "Aa123456"
#1. Create a new user(UA);
TestProjects.user_del_repo_id, user_del_repo_name = self.user.create_user(user_password = user_del_repo_password, **ADMIN_CLIENT)
TestProjects.USER_del_repo_CLIENT=dict(endpoint = url, username = user_del_repo_name, password = user_del_repo_password)
#2. Create a new project(PA) by user(UA);
TestProjects.project_del_repo_id, TestProjects.project_del_repo_name = self.project.create_project(metadata = {"public": "false"}, **TestProjects.USER_del_repo_CLIENT)
#3. Create a new repository(RA) in project(PA) by user(UA);
repo_name, _ = push_self_build_image_to_project(TestProjects.project_del_repo_name, harbor_server, 'admin', 'Harbor12345', "test_del_repo", "latest", size=512)
#4. Get repository in project(PA), there should be one repository which was created by user(UA);
repo_data = self.repo.list_repositories(TestProjects.project_del_repo_name, **TestProjects.USER_del_repo_CLIENT)
_assert_status_code(repo_name, repo_data[0].name)
#5. Delete repository(RA) by user(UA);
self.repo.delete_repository(TestProjects.project_del_repo_name, repo_name.split('/')[1], **TestProjects.USER_del_repo_CLIENT)
#6. Get repository by user(UA), it should get nothing;
repo_data = self.repo.list_repositories(TestProjects.project_del_repo_name, **TestProjects.USER_del_repo_CLIENT)
_assert_status_code(len(repo_data), 0)
if __name__ == '__main__':
unittest.main()

View File

@ -1,135 +1,135 @@
from __future__ import absolute_import
import unittest
import urllib
import sys
from testutils import ADMIN_CLIENT, suppress_urllib3_warning, DOCKER_USER, DOCKER_PWD
from testutils import harbor_server
from testutils import TEARDOWN
from library.base import _random_name
from library.base import _assert_status_code
from library.project import Project
from library.user import User
from library.repository import Repository
from library.registry import Registry
from library.repository import pull_harbor_image
from library.artifact import Artifact
import library.containerd
class TestProxyCache(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.url = ADMIN_CLIENT["endpoint"]
self.user_password = "Aa123456"
self.project= Project()
self.user= User()
self.repo= Repository()
self.registry = Registry()
self.artifact = Artifact()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
print("Case completed")
def do_validate(self, registry_type):
"""
Test case:
Proxy Cache Image From Harbor
Test step and expected result:
1. Create a new registry;
2. Create a new project;
3. Add a new user as a member of project;
4. Pull image from this project by docker CLI;
5. Pull image from this project by ctr CLI;
6. Pull manifest index from this project by docker CLI;
7. Pull manifest from this project by ctr CLI;
8. Image pulled by docker CLI should be cached;
9. Image pulled by ctr CLI should be cached;
10. Manifest index pulled by docker CLI should be cached;
11. Manifest index pulled by ctr CLI should be cached;
Tear down:
1. Delete project(PA);
2. Delete user(UA).
"""
user_id, user_name = self.user.create_user(user_password = self.user_password, **ADMIN_CLIENT)
USER_CLIENT=dict(with_signature = True, endpoint = self.url, username = user_name, password = self.user_password)
image_for_docker = dict(image = "for_proxy", tag = "1.0")
image_for_ctr = dict(image = "redis", tag = "latest")
index_for_docker = dict(image = "index081597864867", tag = "index_tag081597864867")
access_key = ""
access_secret = ""
#1. Create a new registry;
if registry_type == "docker-hub":
user_namespace = DOCKER_USER
access_key = user_namespace
access_secret = DOCKER_PWD
registry = "https://hub.docker.com"
# Memo: ctr will not send image pull request if manifest list already exist, so we pull different manifest list for different registry;
index_for_ctr = dict(image = "alpine", tag = "3.12.0")
else:
user_namespace = "nightly"
registry = "https://cicd.harbor.vmwarecna.net"
index_for_ctr = dict(image = "busybox", tag = "1.32.0")
registry_id, _ = self.registry.create_registry(registry, name=_random_name(registry_type), registry_type=registry_type, access_key = access_key, access_secret = access_secret, insecure=False, **ADMIN_CLIENT)
print("registry_id:", registry_id)
#2. Create a new project;
project_id, project_name = self.project.create_project(registry_id = registry_id, metadata = {"public": "false"}, **ADMIN_CLIENT)
print("project_id:",project_id)
print("project_name:",project_name)
#3. Add a new user as a member of project;
self.project.add_project_members(project_id, user_id=user_id, **ADMIN_CLIENT)
#4. Pull image from this project by docker CLI;
pull_harbor_image(harbor_server, USER_CLIENT["username"], USER_CLIENT["password"], project_name + "/" + user_namespace + "/" + image_for_docker["image"], image_for_docker["tag"])
#5. Pull image from this project by ctr CLI;
oci_ref = harbor_server + "/" + project_name + "/" + user_namespace + "/" + image_for_ctr["image"] + ":" + image_for_ctr["tag"]
library.containerd.ctr_images_pull(user_name, self.user_password, oci_ref)
library.containerd.ctr_images_list(oci_ref = oci_ref)
#6. Pull manifest index from this project by docker CLI;
index_repo_name = user_namespace + "/" + index_for_docker["image"]
pull_harbor_image(harbor_server, user_name, self.user_password, project_name + "/" + index_repo_name, index_for_docker["tag"])
#7. Pull manifest from this project by ctr CLI;
index_repo_name_for_ctr = user_namespace + "/" + index_for_ctr["image"]
oci_ref = harbor_server + "/" + project_name + "/" + index_repo_name_for_ctr + ":" + index_for_ctr["tag"]
library.containerd.ctr_images_pull(user_name, self.user_password, oci_ref)
library.containerd.ctr_images_list(oci_ref = oci_ref)
#8. Image pulled by docker CLI should be cached;
self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(user_namespace + "/" + image_for_docker["image"],'utf-8'), image_for_docker["tag"], **USER_CLIENT)
#9. Image pulled by ctr CLI should be cached;
self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(user_namespace + "/" + image_for_ctr["image"],'utf-8'), image_for_ctr["tag"], **USER_CLIENT)
#10. Manifest index pulled by docker CLI should be cached;
ret_index_by_d = self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(index_repo_name,'utf-8'), index_for_docker["tag"], **USER_CLIENT)
print("Index's reference by docker CLI:", ret_index_by_d.references)
self.assertTrue(len(ret_index_by_d.references) == 1)
#11. Manifest index pulled by ctr CLI should be cached;
ret_index_by_c = self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(index_repo_name_for_ctr,'utf-8'), index_for_ctr["tag"], **USER_CLIENT)
print("Index's reference by ctr CLI:", ret_index_by_c.references)
self.assertTrue(len(ret_index_by_c.references) == 1)
def test_proxy_cache_from_harbor(self):
self.do_validate("harbor")
#def test_proxy_cache_from_dockerhub(self):
# self.do_validate("docker-hub")
if __name__ == '__main__':
suite = unittest.TestSuite(unittest.makeSuite(TestProxyCache))
result = unittest.TextTestRunner(sys.stdout, verbosity=2, failfast=True).run(suite)
if not result.wasSuccessful():
raise Exception(r"Proxy cache test failed: ".format(result))
from __future__ import absolute_import
import unittest
import urllib
import sys
from testutils import ADMIN_CLIENT, suppress_urllib3_warning, DOCKER_USER, DOCKER_PWD
from testutils import harbor_server
from testutils import TEARDOWN
from library.base import _random_name
from library.base import _assert_status_code
from library.project import Project
from library.user import User
from library.repository import Repository
from library.registry import Registry
from library.repository import pull_harbor_image
from library.artifact import Artifact
import library.containerd
class TestProxyCache(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.url = ADMIN_CLIENT["endpoint"]
self.user_password = "Aa123456"
self.project= Project()
self.user= User()
self.repo= Repository()
self.registry = Registry()
self.artifact = Artifact()
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
print("Case completed")
def do_validate(self, registry_type):
"""
Test case:
Proxy Cache Image From Harbor
Test step and expected result:
1. Create a new registry;
2. Create a new project;
3. Add a new user as a member of project;
4. Pull image from this project by docker CLI;
5. Pull image from this project by ctr CLI;
6. Pull manifest index from this project by docker CLI;
7. Pull manifest from this project by ctr CLI;
8. Image pulled by docker CLI should be cached;
9. Image pulled by ctr CLI should be cached;
10. Manifest index pulled by docker CLI should be cached;
11. Manifest index pulled by ctr CLI should be cached;
Tear down:
1. Delete project(PA);
2. Delete user(UA).
"""
user_id, user_name = self.user.create_user(user_password = self.user_password, **ADMIN_CLIENT)
USER_CLIENT=dict(with_signature = True, endpoint = self.url, username = user_name, password = self.user_password)
image_for_docker = dict(image = "for_proxy", tag = "1.0")
image_for_ctr = dict(image = "redis", tag = "latest")
index_for_docker = dict(image = "index081597864867", tag = "index_tag081597864867")
access_key = ""
access_secret = ""
#1. Create a new registry;
if registry_type == "docker-hub":
user_namespace = DOCKER_USER
access_key = user_namespace
access_secret = DOCKER_PWD
registry = "https://hub.docker.com"
# Memo: ctr will not send image pull request if manifest list already exist, so we pull different manifest list for different registry;
index_for_ctr = dict(image = "alpine", tag = "3.12.0")
else:
user_namespace = "nightly"
registry = "https://cicd.harbor.vmwarecna.net"
index_for_ctr = dict(image = "busybox", tag = "1.32.0")
registry_id, _ = self.registry.create_registry(registry, name=_random_name(registry_type), registry_type=registry_type, access_key = access_key, access_secret = access_secret, insecure=False, **ADMIN_CLIENT)
print("registry_id:", registry_id)
#2. Create a new project;
project_id, project_name = self.project.create_project(registry_id = registry_id, metadata = {"public": "false"}, **ADMIN_CLIENT)
print("project_id:",project_id)
print("project_name:",project_name)
#3. Add a new user as a member of project;
self.project.add_project_members(project_id, user_id=user_id, **ADMIN_CLIENT)
#4. Pull image from this project by docker CLI;
pull_harbor_image(harbor_server, USER_CLIENT["username"], USER_CLIENT["password"], project_name + "/" + user_namespace + "/" + image_for_docker["image"], image_for_docker["tag"])
#5. Pull image from this project by ctr CLI;
oci_ref = harbor_server + "/" + project_name + "/" + user_namespace + "/" + image_for_ctr["image"] + ":" + image_for_ctr["tag"]
library.containerd.ctr_images_pull(user_name, self.user_password, oci_ref)
library.containerd.ctr_images_list(oci_ref = oci_ref)
#6. Pull manifest index from this project by docker CLI;
index_repo_name = user_namespace + "/" + index_for_docker["image"]
pull_harbor_image(harbor_server, user_name, self.user_password, project_name + "/" + index_repo_name, index_for_docker["tag"])
#7. Pull manifest from this project by ctr CLI;
index_repo_name_for_ctr = user_namespace + "/" + index_for_ctr["image"]
oci_ref = harbor_server + "/" + project_name + "/" + index_repo_name_for_ctr + ":" + index_for_ctr["tag"]
library.containerd.ctr_images_pull(user_name, self.user_password, oci_ref)
library.containerd.ctr_images_list(oci_ref = oci_ref)
#8. Image pulled by docker CLI should be cached;
self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(user_namespace + "/" + image_for_docker["image"],'utf-8'), image_for_docker["tag"], **USER_CLIENT)
#9. Image pulled by ctr CLI should be cached;
self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(user_namespace + "/" + image_for_ctr["image"],'utf-8'), image_for_ctr["tag"], **USER_CLIENT)
#10. Manifest index pulled by docker CLI should be cached;
ret_index_by_d = self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(index_repo_name,'utf-8'), index_for_docker["tag"], **USER_CLIENT)
print("Index's reference by docker CLI:", ret_index_by_d.references)
self.assertTrue(len(ret_index_by_d.references) == 1)
#11. Manifest index pulled by ctr CLI should be cached;
ret_index_by_c = self.artifact.waiting_for_reference_exist(project_name, urllib.parse.quote(index_repo_name_for_ctr,'utf-8'), index_for_ctr["tag"], **USER_CLIENT)
print("Index's reference by ctr CLI:", ret_index_by_c.references)
self.assertTrue(len(ret_index_by_c.references) == 1)
def test_proxy_cache_from_harbor(self):
self.do_validate("harbor")
#def test_proxy_cache_from_dockerhub(self):
# self.do_validate("docker-hub")
if __name__ == '__main__':
suite = unittest.TestSuite(unittest.makeSuite(TestProxyCache))
result = unittest.TextTestRunner(sys.stdout, verbosity=2, failfast=True).run(suite)
if not result.wasSuccessful():
raise Exception(r"Proxy cache test failed: ".format(result))

View File

@ -1,299 +1,299 @@
from __future__ import absolute_import
import unittest
import sys
from testutils import ADMIN_CLIENT, TEARDOWN, suppress_urllib3_warning
from testutils import harbor_server
from library.project import Project
from library.user import User
from library.repository import Repository
from library.registry import Registry
from library.artifact import Artifact
from library.tag_immutability import Tag_Immutability
from library.repository import push_special_image_to_project
class TestTagImmutability(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.url = ADMIN_CLIENT["endpoint"]
self.user_password = "Aa123456"
self.project= Project()
self.user= User()
self.repo= Repository()
self.registry = Registry()
self.artifact = Artifact()
self.tag_immutability = Tag_Immutability()
self.project_id, self.project_name, self.user_id, self.user_name = [None] * 4
self.user_id, self.user_name = self.user.create_user(user_password = self.user_password, **ADMIN_CLIENT)
self.USER_CLIENT = dict(with_signature = True, with_immutable_status = True, endpoint = self.url, username = self.user_name, password = self.user_password)
self.exsiting_rule = dict(selector_repository="rel*", selector_tag="v2.*")
self.project_id, self.project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
print("Case completed")
def check_tag_immutability(self, artifact, tag_name, status = True):
for tag in artifact.tags:
if tag.name == tag_name:
self.assertTrue(tag.immutable == status)
return
raise Exception("No tag {} found in artifact {}".format(tag, artifact))
def test_disability_of_rules(self):
"""
Test case:
Test Disability Of Rules
Test step and expected result:
1. Create a new project;
2. Push image A to the project with 2 tags A and B;
3. Create a disabled rule matched image A with tag A;
4. Both tags of image A should not be immutable;
5. Enable this rule;
6. image A with tag A should be immutable.
"""
image_a = dict(name="image_disability_a", tag1="latest", tag2="6.2.2")
#1. Create a new project;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A to the project with 2 tags;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a disabled rule matched image A;
rule_id = self.tag_immutability.create_rule(project_id, disabled = True, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Both tags of image A should not be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_disability_of_rules] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = False)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Enable this rule;
self.tag_immutability.update_tag_immutability_policy_rule(project_id, rule_id, disabled = False, **self.USER_CLIENT)
#6. image A with tag A should be immutable.
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_disability_of_rules] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
def test_artifact_and_repo_is_undeletable(self):
"""
Test case:
Test Artifact And Repo is Undeleteable
Test step and expected result:
1. Create a new project;
2. Push image A to the project with 2 tags A and B;
3. Create a enabled rule matched image A with tag A;
4. Tag A should be immutable;
5. Artifact is undeletable;
6. Repository is undeletable.
"""
image_a = dict(name="image_repo_undeletable_a", tag1="latest", tag2="1.3.2")
#1. Create a new project;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A to the project with 2 tags A and B;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_artifact_and_repo_is_undeletable] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Artifact is undeletable;
self.artifact.delete_artifact(project_name, image_a["name"], image_a["tag1"], expect_status_code = 412,expect_response_body = "configured as immutable, cannot be deleted", **self.USER_CLIENT)
#6. Repository is undeletable.
self.repo.delete_repository(project_name, image_a["name"], expect_status_code = 412, expect_response_body = "configured as immutable, cannot be deleted", **self.USER_CLIENT)
def test_tag_is_undeletable(self):
"""
Test case:
Test Tag is Undeleteable
Test step and expected result:
1. Push image A to the project with 2 tags A and B;
2. Create a enabled rule matched image A with tag A;
3. Tag A should be immutable;
4. Tag A is undeletable;
5. Tag B is deletable.
"""
image_a = dict(name="image_undeletable_a", tag1="latest", tag2="9.3.2")
#1. Push image A to the project with 2 tags A and B;
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#2. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(self.project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag2"])[0:2] + "*", **self.USER_CLIENT)
#3. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(self.project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_tag_is_undeletable] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = True)
#4. Tag A is undeletable;
self.artifact.delete_tag(self.project_name, image_a["name"], image_a["tag1"], image_a["tag2"], expect_status_code = 412, **self.USER_CLIENT)
#5. Tag B is deletable.
self.artifact.delete_tag(self.project_name, image_a["name"], image_a["tag1"], image_a["tag1"], **self.USER_CLIENT)
def test_image_is_unpushable(self):
"""
Test case:
Test Image is Unpushable
Test step and expected result:
1. Create a new project;
2. Push image A to the project with 2 tags A and B;
3. Create a enabled rule matched image A with tag A;
4. Tag A should be immutable;
5. Can not push image with the same image name and with the same tag name.
"""
image_a = dict(name="image_unpushable_a", tag1="latest", tag2="1.3.2")
#1. Create a new project;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A to the project with 2 tags A and B;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_image_is_unpushable] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Can not push image with the same image name and with the same tag name.
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"]], size=10
, expected_error_message = "configured as immutable")
def test_copy_disability(self):
"""
Test case:
Test Copy Disability
Test step and expected result:
1. Create 2 projects;
2. Push image A with tag A and B to project A, push image B which has the same image name and tag name to project B;
3. Create a enabled rule matched image A with tag A;
4. Tag A should be immutable;
5. Can not copy artifact from project A to project B with the same repository name.
"""
image_a = dict(name="image_copy_disability_a", tag1="latest", tag2="1.3.2")
#1. Create 2 projects;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
_, project_name_src = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A with tag A and B to project A, push image B which has the same image name and tag name to project B;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
push_special_image_to_project(project_name_src, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_copy_disability] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Can not copy artifact from project A to project B with the same repository name.
artifact_a_src = self.artifact.get_reference_info(project_name_src, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_copy_disability] - artifact_a_src:{}".format(artifact_a_src))
self.artifact.copy_artifact(project_name, image_a["name"], project_name_src+"/"+ image_a["name"] + "@" + artifact_a_src.digest, expect_status_code=412, expect_response_body = "configured as immutable, cannot be updated", **self.USER_CLIENT)
#def test_replication_disability(self):
# pass
def test_priority_of_rules(self):
"""
Test case:
Test Priority Of Rules(excluding rule will not affect matching rule)
Test step and expected result:
1. Push image A, B and C, image A has only 1 tag named tag1;
2. Create a matching rule that matches image A and tag named tag2 which is not exist;
3. Create a excluding rule to exlude image A and B;
4. Add a tag named tag2 to image A, tag2 should be immutable;
5. Tag2 should be immutable;
6. All tags in image B should be immutable;
7. All tags in image C should not be immutable;
8. Disable all rules.
"""
image_a = dict(name="image_priority_a", tag1="latest", tag2="6.3.2")
image_b = dict(name="image_priority_b", tag1="latest", tag2="0.12.0")
image_c = dict(name="image_priority_c", tag1="latest", tag2="3.12.0")
#1. Push image A, B and C, image A has only 1 tag named tag1;
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"]])
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_b["name"], [image_b["tag1"],image_b["tag2"]])
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_c["name"], [image_c["tag1"],image_c["tag2"]])
#2. Create a matching rule that matches image A and tag named tag2 which is not exist;
rule_id_1 = self.tag_immutability.create_rule(self.project_id, selector_repository=image_a["name"], selector_tag=image_a["tag2"], **self.USER_CLIENT)
#3. Create a excluding rule to exlude image A and B;
rule_id_2 = self.tag_immutability.create_rule(self.project_id, selector_repository_decoration = "repoExcludes",
selector_repository="{image_priority_a,image_priority_b}", selector_tag="**", **self.USER_CLIENT)
#4. Add a tag named tag2 to image A, tag2 should be immutable;
self.artifact.create_tag(self.project_name, image_a["name"], image_a["tag1"], image_a["tag2"], **self.USER_CLIENT)
#5. Tag2 should be immutable;
artifact_a = self.artifact.get_reference_info(self.project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_priority_of_rules] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = False)
#6. All tags in image B should be immutable;
artifact_b = self.artifact.get_reference_info(self.project_name, image_b["name"], image_b["tag2"], **self.USER_CLIENT)
print("[test_priority_of_rules] - artifact:{}".format(artifact_b))
self.assertTrue(artifact_b)
self.check_tag_immutability(artifact_b, image_b["tag2"], status = False)
self.check_tag_immutability(artifact_b, image_b["tag1"], status = False)
#7. All tags in image C should not be immutable;
artifact_c = self.artifact.get_reference_info(self.project_name, image_c["name"], image_c["tag2"], **self.USER_CLIENT)
print("[test_priority_of_rules] - artifact:{}".format(artifact_c))
self.assertTrue(artifact_c)
self.check_tag_immutability(artifact_c, image_c["tag2"], status = True)
self.check_tag_immutability(artifact_c, image_c["tag1"], status = True)
#8. Disable all rules.
self.tag_immutability.update_tag_immutability_policy_rule(self.project_id, rule_id_1, disabled = True, **self.USER_CLIENT)
self.tag_immutability.update_tag_immutability_policy_rule(self.project_id, rule_id_2, disabled = True, **self.USER_CLIENT)
def test_add_exsiting_rule(self):
"""
Test case:
Test Priority Of Rules(excluding rule will not affect matching rule)
Test step and expected result:
1. Push image A and B with no tag;
2. Create a immutability policy rule A;
3. Fail to create rule B which has the same config as rule A;
"""
self.tag_immutability.create_tag_immutability_policy_rule(self.project_id, **self.exsiting_rule, **self.USER_CLIENT)
self.tag_immutability.create_tag_immutability_policy_rule(self.project_id, **self.exsiting_rule, expect_status_code = 409, **self.USER_CLIENT)
if __name__ == '__main__':
suite = unittest.TestSuite(unittest.makeSuite(TestTagImmutability))
result = unittest.TextTestRunner(sys.stdout, verbosity=2, failfast=True).run(suite)
if not result.wasSuccessful():
raise Exception(r"Tag immutability test failed: {}".format(result))
from __future__ import absolute_import
import unittest
import sys
from testutils import ADMIN_CLIENT, TEARDOWN, suppress_urllib3_warning
from testutils import harbor_server
from library.project import Project
from library.user import User
from library.repository import Repository
from library.registry import Registry
from library.artifact import Artifact
from library.tag_immutability import Tag_Immutability
from library.repository import push_special_image_to_project
class TestTagImmutability(unittest.TestCase):
@suppress_urllib3_warning
def setUp(self):
self.url = ADMIN_CLIENT["endpoint"]
self.user_password = "Aa123456"
self.project= Project()
self.user= User()
self.repo= Repository()
self.registry = Registry()
self.artifact = Artifact()
self.tag_immutability = Tag_Immutability()
self.project_id, self.project_name, self.user_id, self.user_name = [None] * 4
self.user_id, self.user_name = self.user.create_user(user_password = self.user_password, **ADMIN_CLIENT)
self.USER_CLIENT = dict(with_signature = True, with_immutable_status = True, endpoint = self.url, username = self.user_name, password = self.user_password)
self.exsiting_rule = dict(selector_repository="rel*", selector_tag="v2.*")
self.project_id, self.project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def tearDown(self):
print("Case completed")
def check_tag_immutability(self, artifact, tag_name, status = True):
for tag in artifact.tags:
if tag.name == tag_name:
self.assertTrue(tag.immutable == status)
return
raise Exception("No tag {} found in artifact {}".format(tag, artifact))
def test_disability_of_rules(self):
"""
Test case:
Test Disability Of Rules
Test step and expected result:
1. Create a new project;
2. Push image A to the project with 2 tags A and B;
3. Create a disabled rule matched image A with tag A;
4. Both tags of image A should not be immutable;
5. Enable this rule;
6. image A with tag A should be immutable.
"""
image_a = dict(name="image_disability_a", tag1="latest", tag2="6.2.2")
#1. Create a new project;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A to the project with 2 tags;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a disabled rule matched image A;
rule_id = self.tag_immutability.create_rule(project_id, disabled = True, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Both tags of image A should not be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_disability_of_rules] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = False)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Enable this rule;
self.tag_immutability.update_tag_immutability_policy_rule(project_id, rule_id, disabled = False, **self.USER_CLIENT)
#6. image A with tag A should be immutable.
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_disability_of_rules] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
def test_artifact_and_repo_is_undeletable(self):
"""
Test case:
Test Artifact And Repo is Undeleteable
Test step and expected result:
1. Create a new project;
2. Push image A to the project with 2 tags A and B;
3. Create a enabled rule matched image A with tag A;
4. Tag A should be immutable;
5. Artifact is undeletable;
6. Repository is undeletable.
"""
image_a = dict(name="image_repo_undeletable_a", tag1="latest", tag2="1.3.2")
#1. Create a new project;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A to the project with 2 tags A and B;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_artifact_and_repo_is_undeletable] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Artifact is undeletable;
self.artifact.delete_artifact(project_name, image_a["name"], image_a["tag1"], expect_status_code = 412,expect_response_body = "configured as immutable, cannot be deleted", **self.USER_CLIENT)
#6. Repository is undeletable.
self.repo.delete_repository(project_name, image_a["name"], expect_status_code = 412, expect_response_body = "configured as immutable, cannot be deleted", **self.USER_CLIENT)
def test_tag_is_undeletable(self):
"""
Test case:
Test Tag is Undeleteable
Test step and expected result:
1. Push image A to the project with 2 tags A and B;
2. Create a enabled rule matched image A with tag A;
3. Tag A should be immutable;
4. Tag A is undeletable;
5. Tag B is deletable.
"""
image_a = dict(name="image_undeletable_a", tag1="latest", tag2="9.3.2")
#1. Push image A to the project with 2 tags A and B;
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#2. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(self.project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag2"])[0:2] + "*", **self.USER_CLIENT)
#3. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(self.project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_tag_is_undeletable] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = True)
#4. Tag A is undeletable;
self.artifact.delete_tag(self.project_name, image_a["name"], image_a["tag1"], image_a["tag2"], expect_status_code = 412, **self.USER_CLIENT)
#5. Tag B is deletable.
self.artifact.delete_tag(self.project_name, image_a["name"], image_a["tag1"], image_a["tag1"], **self.USER_CLIENT)
def test_image_is_unpushable(self):
"""
Test case:
Test Image is Unpushable
Test step and expected result:
1. Create a new project;
2. Push image A to the project with 2 tags A and B;
3. Create a enabled rule matched image A with tag A;
4. Tag A should be immutable;
5. Can not push image with the same image name and with the same tag name.
"""
image_a = dict(name="image_unpushable_a", tag1="latest", tag2="1.3.2")
#1. Create a new project;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A to the project with 2 tags A and B;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_image_is_unpushable] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Can not push image with the same image name and with the same tag name.
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"]], size=10
, expected_error_message = "configured as immutable")
def test_copy_disability(self):
"""
Test case:
Test Copy Disability
Test step and expected result:
1. Create 2 projects;
2. Push image A with tag A and B to project A, push image B which has the same image name and tag name to project B;
3. Create a enabled rule matched image A with tag A;
4. Tag A should be immutable;
5. Can not copy artifact from project A to project B with the same repository name.
"""
image_a = dict(name="image_copy_disability_a", tag1="latest", tag2="1.3.2")
#1. Create 2 projects;
project_id, project_name = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
_, project_name_src = self.project.create_project(metadata = {"public": "false"}, **self.USER_CLIENT)
#2. Push image A with tag A and B to project A, push image B which has the same image name and tag name to project B;
push_special_image_to_project(project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
push_special_image_to_project(project_name_src, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"], image_a["tag2"]])
#3. Create a enabled rule matched image A with tag A;
self.tag_immutability.create_rule(project_id, selector_repository=image_a["name"], selector_tag=str(image_a["tag1"])[0:2] + "*", **self.USER_CLIENT)
#4. Tag A should be immutable;
artifact_a = self.artifact.get_reference_info(project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_copy_disability] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = False)
#5. Can not copy artifact from project A to project B with the same repository name.
artifact_a_src = self.artifact.get_reference_info(project_name_src, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_copy_disability] - artifact_a_src:{}".format(artifact_a_src))
self.artifact.copy_artifact(project_name, image_a["name"], project_name_src+"/"+ image_a["name"] + "@" + artifact_a_src.digest, expect_status_code=412, expect_response_body = "configured as immutable, cannot be updated", **self.USER_CLIENT)
#def test_replication_disability(self):
# pass
def test_priority_of_rules(self):
"""
Test case:
Test Priority Of Rules(excluding rule will not affect matching rule)
Test step and expected result:
1. Push image A, B and C, image A has only 1 tag named tag1;
2. Create a matching rule that matches image A and tag named tag2 which is not exist;
3. Create a excluding rule to exlude image A and B;
4. Add a tag named tag2 to image A, tag2 should be immutable;
5. Tag2 should be immutable;
6. All tags in image B should be immutable;
7. All tags in image C should not be immutable;
8. Disable all rules.
"""
image_a = dict(name="image_priority_a", tag1="latest", tag2="6.3.2")
image_b = dict(name="image_priority_b", tag1="latest", tag2="0.12.0")
image_c = dict(name="image_priority_c", tag1="latest", tag2="3.12.0")
#1. Push image A, B and C, image A has only 1 tag named tag1;
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_a["name"], [image_a["tag1"]])
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_b["name"], [image_b["tag1"],image_b["tag2"]])
push_special_image_to_project(self.project_name, harbor_server, self.user_name, self.user_password, image_c["name"], [image_c["tag1"],image_c["tag2"]])
#2. Create a matching rule that matches image A and tag named tag2 which is not exist;
rule_id_1 = self.tag_immutability.create_rule(self.project_id, selector_repository=image_a["name"], selector_tag=image_a["tag2"], **self.USER_CLIENT)
#3. Create a excluding rule to exlude image A and B;
rule_id_2 = self.tag_immutability.create_rule(self.project_id, selector_repository_decoration = "repoExcludes",
selector_repository="{image_priority_a,image_priority_b}", selector_tag="**", **self.USER_CLIENT)
#4. Add a tag named tag2 to image A, tag2 should be immutable;
self.artifact.create_tag(self.project_name, image_a["name"], image_a["tag1"], image_a["tag2"], **self.USER_CLIENT)
#5. Tag2 should be immutable;
artifact_a = self.artifact.get_reference_info(self.project_name, image_a["name"], image_a["tag2"], **self.USER_CLIENT)
print("[test_priority_of_rules] - artifact:{}".format(artifact_a))
self.assertTrue(artifact_a)
self.check_tag_immutability(artifact_a, image_a["tag2"], status = True)
self.check_tag_immutability(artifact_a, image_a["tag1"], status = False)
#6. All tags in image B should be immutable;
artifact_b = self.artifact.get_reference_info(self.project_name, image_b["name"], image_b["tag2"], **self.USER_CLIENT)
print("[test_priority_of_rules] - artifact:{}".format(artifact_b))
self.assertTrue(artifact_b)
self.check_tag_immutability(artifact_b, image_b["tag2"], status = False)
self.check_tag_immutability(artifact_b, image_b["tag1"], status = False)
#7. All tags in image C should not be immutable;
artifact_c = self.artifact.get_reference_info(self.project_name, image_c["name"], image_c["tag2"], **self.USER_CLIENT)
print("[test_priority_of_rules] - artifact:{}".format(artifact_c))
self.assertTrue(artifact_c)
self.check_tag_immutability(artifact_c, image_c["tag2"], status = True)
self.check_tag_immutability(artifact_c, image_c["tag1"], status = True)
#8. Disable all rules.
self.tag_immutability.update_tag_immutability_policy_rule(self.project_id, rule_id_1, disabled = True, **self.USER_CLIENT)
self.tag_immutability.update_tag_immutability_policy_rule(self.project_id, rule_id_2, disabled = True, **self.USER_CLIENT)
def test_add_exsiting_rule(self):
"""
Test case:
Test Priority Of Rules(excluding rule will not affect matching rule)
Test step and expected result:
1. Push image A and B with no tag;
2. Create a immutability policy rule A;
3. Fail to create rule B which has the same config as rule A;
"""
self.tag_immutability.create_tag_immutability_policy_rule(self.project_id, **self.exsiting_rule, **self.USER_CLIENT)
self.tag_immutability.create_tag_immutability_policy_rule(self.project_id, **self.exsiting_rule, expect_status_code = 409, **self.USER_CLIENT)
if __name__ == '__main__':
suite = unittest.TestSuite(unittest.makeSuite(TestTagImmutability))
result = unittest.TextTestRunner(sys.stdout, verbosity=2, failfast=True).run(suite)
if not result.wasSuccessful():
raise Exception(r"Tag immutability test failed: {}".format(result))

View File

@ -1,18 +1,18 @@
*** Keywords ***
Make Swagger Client
${rc} ${output}= Run And Return Rc And Output make swagger_client
Log ${output}
[Return] ${rc}
Setup API Test
Retry Keyword N Times When Error 10 Make Swagger Client
Harbor API Test
[Arguments] ${testcase_name}
${current_dir}= Run pwd
Log To Console ${current_dir}
Log To Console ${ip}
${rc} ${output}= Run And Return Rc And Output SWAGGER_CLIENT_PATH=${current_dir}/harborclient HARBOR_HOST=${ip} DOCKER_USER=${DOCKER_USER} DOCKER_PWD=${DOCKER_PWD} python ${testcase_name}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
*** Keywords ***
Make Swagger Client
${rc} ${output}= Run And Return Rc And Output make swagger_client
Log ${output}
[Return] ${rc}
Setup API Test
Retry Keyword N Times When Error 10 Make Swagger Client
Harbor API Test
[Arguments] ${testcase_name}
${current_dir}= Run pwd
Log To Console ${current_dir}
Log To Console ${ip}
${rc} ${output}= Run And Return Rc And Output SWAGGER_CLIENT_PATH=${current_dir}/harborclient HARBOR_HOST=${ip} DOCKER_USER=${DOCKER_USER} DOCKER_PWD=${DOCKER_PWD} python ${testcase_name}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0

View File

@ -1,26 +1,26 @@
# 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 This resource provides helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
CNAB Push Bundle
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
# 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 This resource provides helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
CNAB Push Bundle
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0

View File

@ -1,116 +1,116 @@
# 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 This resource contains keywords related to creating and using certificates. Requires scripts in infra/integration-image/scripts be available in PATH
*** Keywords ***
Generate Certificate Authority For Chrome
# add the ca to chrome trust list to enable https testing.
[Arguments] ${password}=%{HARBOR_PASSWORD} ${cert}=harbor_ca.crt
${rand}= Evaluate random.randint(0, 100000) modules=random
Log To Console Generate Certificate Authority For Chrome
${rc} ${out}= Run And Return Rc And Output echo ${password} > password${rand}.ca
Log ALL ${out}
Should Be Equal As Integers ${rc} 0
${rc} ${out}= Run And Return Rc And Output certutil -d sql:$HOME/.pki/nssdb -A -t TC -f password${rand}.ca -n "Harbor${rand}" -i ./harbor_ca.crt
Log ALL ${out}
Should Be Equal As Integers ${rc} 0
Generate Certificate Authority
# Generates CA (private/ca.key.pem, certs/ca.cert.pem, certs/STARK_ENTERPRISES_ROOT_CA.crt) in OUT_DIR
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${OUT_DIR}=/root/ca
Log To Console Generating Certificate Authority
${rc} ${out}= Run And Return Rc And Output generate-ca.sh -c ${CA_NAME} -d ${OUT_DIR}
Log ${out}
Should Be Equal As Integers ${rc} 0
Generate Wildcard Server Certificate
# Generates key and signs with CA for *.DOMAIN (csr/*.DOMAIN.csr.pem,
# private/*.DOMAIN.key.pem, certs/*.DOMAIN.cert.pem) in OUT_DIR
[Arguments] ${DOMAIN}=%{DOMAIN} ${OUT_DIR}=/root/ca ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA
Log To Console Generating Wildcard Server Certificate
Run Keyword Generate Server Key And CSR *.${DOMAIN} ${OUT_DIR}
Run Keyword Sign Server CSR ${CA_NAME} *.${DOMAIN} ${OUT_DIR}
Run Keyword Create Certificate Bundle CA_NAME=${CA_NAME} SRC_DIR=${OUT_DIR} CN=*.${DOMAIN}
${out}= Run ls -al ${OUT_DIR}/csr
Log ${out}
${out}= Run ls -al ${OUT_DIR}/private
Log ${out}
${out}= Run ls -al ${OUT_DIR}/certs
Log ${out}
Generate Server Key And CSR
# Generates key and CSR (private/DOMAIN.key.pem, csr/DOMAIN.csr.pem) in OUT_DIR
[Arguments] ${CN}=%{DOMAIN} ${OUT_DIR}=/root/ca
Log To Console Generating Server Key And CSR
${out}= Run generate-server-key-csr.sh -d ${OUT_DIR} -n ${CN}
Log ${out}
Sign Server CSR
# Generates certificate signed by CA (certs/DOMAIN.cert.pem) in OUT_DIR
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${CN}=%{DOMAIN} ${OUT_DIR}=/root/ca
Log To Console Signing Server CSR
${out}= Run sign-csr.sh -c ${CA_NAME} -d ${OUT_DIR} -n ${CN}
Log ${out}
Trust Certificate Authority
# Installs root certificate into trust store on Debian based distro
[Arguments] ${CRT_FILE}=/root/ca/certs/STARK_ENTERPRISES_ROOT_CA.crt
Log To Console Installing CA
${rc} ${out}= Run And Return Rc And Output ubuntu-install-ca.sh -f ${CRT_FILE}
Should Be Equal As Integers ${rc} 0
Log ${out}
Reload Default Certificate Authorities
# Reloads default certificates into trust store on Debian based distro
# Removes all user provided CAs
Log To Console Reloading Default CAs
${rc} ${out}= Run And Return Rc And Output ubuntu-reload-cas.sh
Should Be Equal As Integers ${rc} 0
Log ${out}
Create Certificate Bundle
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${SRC_DIR}=/root/ca ${OUT_FILE}=/root/ca/cert-bundle.tgz ${CN}=%{DOMAIN} ${TMP_DIR}=/root/ca/bundle
${rc} ${out}= Run And Return Rc And Output bundle-certs.sh -c ${CA_NAME} -d ${SRC_DIR} -f ${OUT_FILE} -n ${CN} -o ${TMP_DIR}
Should Be Equal As Integers ${rc} 0
Log ${out}
Get Certificate Authority CRT
# Return ascii armored certificate from file e.g. `-----BEGIN CERTIFICATE-----`
[Arguments] ${CA_CRT}=STARK_ENTERPRISES_ROOT_CA.crt ${DIR}=/root/ca/certs
${out}= Run cat ${DIR}/${CA_CRT}
[Return] ${out}
Get Server Certificate
# Return ascii armored certificate from file e.g. `-----BEGIN CERTIFICATE-----`
# PEM must be provided if using a wildcard cert not specified by DOMAIN
[Arguments] ${PEM}=%{DOMAIN}.cert.pem ${DIR}=/root/ca/certs
${out}= Run cat ${DIR}/${PEM}
[Return] ${out}
Get Server Key
# Return ascii armored key from file e.g. `-----BEGIN RSA PRIVATE KEY-----`
# PEM must be provided if using a wildcard cert not specified by DOMAIN
[Arguments] ${PEM}=%{DOMAIN}.key.pem ${DIR}=/root/ca/private
${out}= Run cat ${DIR}/${PEM}
[Return] ${out}
# 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 This resource contains keywords related to creating and using certificates. Requires scripts in infra/integration-image/scripts be available in PATH
*** Keywords ***
Generate Certificate Authority For Chrome
# add the ca to chrome trust list to enable https testing.
[Arguments] ${password}=%{HARBOR_PASSWORD} ${cert}=harbor_ca.crt
${rand}= Evaluate random.randint(0, 100000) modules=random
Log To Console Generate Certificate Authority For Chrome
${rc} ${out}= Run And Return Rc And Output echo ${password} > password${rand}.ca
Log ALL ${out}
Should Be Equal As Integers ${rc} 0
${rc} ${out}= Run And Return Rc And Output certutil -d sql:$HOME/.pki/nssdb -A -t TC -f password${rand}.ca -n "Harbor${rand}" -i ./harbor_ca.crt
Log ALL ${out}
Should Be Equal As Integers ${rc} 0
Generate Certificate Authority
# Generates CA (private/ca.key.pem, certs/ca.cert.pem, certs/STARK_ENTERPRISES_ROOT_CA.crt) in OUT_DIR
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${OUT_DIR}=/root/ca
Log To Console Generating Certificate Authority
${rc} ${out}= Run And Return Rc And Output generate-ca.sh -c ${CA_NAME} -d ${OUT_DIR}
Log ${out}
Should Be Equal As Integers ${rc} 0
Generate Wildcard Server Certificate
# Generates key and signs with CA for *.DOMAIN (csr/*.DOMAIN.csr.pem,
# private/*.DOMAIN.key.pem, certs/*.DOMAIN.cert.pem) in OUT_DIR
[Arguments] ${DOMAIN}=%{DOMAIN} ${OUT_DIR}=/root/ca ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA
Log To Console Generating Wildcard Server Certificate
Run Keyword Generate Server Key And CSR *.${DOMAIN} ${OUT_DIR}
Run Keyword Sign Server CSR ${CA_NAME} *.${DOMAIN} ${OUT_DIR}
Run Keyword Create Certificate Bundle CA_NAME=${CA_NAME} SRC_DIR=${OUT_DIR} CN=*.${DOMAIN}
${out}= Run ls -al ${OUT_DIR}/csr
Log ${out}
${out}= Run ls -al ${OUT_DIR}/private
Log ${out}
${out}= Run ls -al ${OUT_DIR}/certs
Log ${out}
Generate Server Key And CSR
# Generates key and CSR (private/DOMAIN.key.pem, csr/DOMAIN.csr.pem) in OUT_DIR
[Arguments] ${CN}=%{DOMAIN} ${OUT_DIR}=/root/ca
Log To Console Generating Server Key And CSR
${out}= Run generate-server-key-csr.sh -d ${OUT_DIR} -n ${CN}
Log ${out}
Sign Server CSR
# Generates certificate signed by CA (certs/DOMAIN.cert.pem) in OUT_DIR
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${CN}=%{DOMAIN} ${OUT_DIR}=/root/ca
Log To Console Signing Server CSR
${out}= Run sign-csr.sh -c ${CA_NAME} -d ${OUT_DIR} -n ${CN}
Log ${out}
Trust Certificate Authority
# Installs root certificate into trust store on Debian based distro
[Arguments] ${CRT_FILE}=/root/ca/certs/STARK_ENTERPRISES_ROOT_CA.crt
Log To Console Installing CA
${rc} ${out}= Run And Return Rc And Output ubuntu-install-ca.sh -f ${CRT_FILE}
Should Be Equal As Integers ${rc} 0
Log ${out}
Reload Default Certificate Authorities
# Reloads default certificates into trust store on Debian based distro
# Removes all user provided CAs
Log To Console Reloading Default CAs
${rc} ${out}= Run And Return Rc And Output ubuntu-reload-cas.sh
Should Be Equal As Integers ${rc} 0
Log ${out}
Create Certificate Bundle
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${SRC_DIR}=/root/ca ${OUT_FILE}=/root/ca/cert-bundle.tgz ${CN}=%{DOMAIN} ${TMP_DIR}=/root/ca/bundle
${rc} ${out}= Run And Return Rc And Output bundle-certs.sh -c ${CA_NAME} -d ${SRC_DIR} -f ${OUT_FILE} -n ${CN} -o ${TMP_DIR}
Should Be Equal As Integers ${rc} 0
Log ${out}
Get Certificate Authority CRT
# Return ascii armored certificate from file e.g. `-----BEGIN CERTIFICATE-----`
[Arguments] ${CA_CRT}=STARK_ENTERPRISES_ROOT_CA.crt ${DIR}=/root/ca/certs
${out}= Run cat ${DIR}/${CA_CRT}
[Return] ${out}
Get Server Certificate
# Return ascii armored certificate from file e.g. `-----BEGIN CERTIFICATE-----`
# PEM must be provided if using a wildcard cert not specified by DOMAIN
[Arguments] ${PEM}=%{DOMAIN}.cert.pem ${DIR}=/root/ca/certs
${out}= Run cat ${DIR}/${PEM}
[Return] ${out}
Get Server Key
# Return ascii armored key from file e.g. `-----BEGIN RSA PRIVATE KEY-----`
# PEM must be provided if using a wildcard cert not specified by DOMAIN
[Arguments] ${PEM}=%{DOMAIN}.key.pem ${DIR}=/root/ca/private
${out}= Run cat ${DIR}/${PEM}
[Return] ${out}

View File

@ -1,279 +1,279 @@
# 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 This resource provides helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
Run Docker Info
[Arguments] ${docker-params}
Wait Unitl Command Success docker ${docker-params} info
Pull image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}=${null} ${is_robot}=${false}
Log To Console \nRunning docker pull ${image}...
${image_with_tag}= Set Variable If '${tag}'=='${null}' ${image} ${image}:${tag}
Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
... ELSE Wait Unitl Command Success docker login -u robot\\\$${project}+${user} -p ${pwd} ${ip}
${output}= Docker Pull ${ip}/${project}/${image_with_tag}
Log ${output}
Log To Console ${output}
Should Contain ${output} Digest:
Should Contain ${output} Status:
Should Not Contain ${output} No such image:
#Remove image for docker 20
Clean All Local Images
Push image
# If no tag provided in $(image_with_or_without_tag}, latest will be the tag pulled from docker-hub or read from local
[Arguments] ${ip} ${user} ${pwd} ${project} ${image_with_or_without_tag} ${need_pull_first}=${true} ${sha256}=${null} ${is_robot}=${false}
${d}= Get Current Date result_format=%m%s
${image_in_use}= Set Variable If '${sha256}'=='${null}' ${image_with_or_without_tag} ${image_with_or_without_tag}@sha256:${sha256}
${image_in_use_with_tag}= Set Variable If '${sha256}'=='${null}' ${image_with_or_without_tag} ${image_with_or_without_tag}:${sha256}
Sleep 3
Log To Console \nRunning docker push ${image_with_or_without_tag}...
${image_in_use}= Set Variable If ${need_pull_first}==${true} ${image_in_use} ${image_with_or_without_tag}
Run Keyword If ${need_pull_first}==${true} Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image_in_use}
Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
... ELSE Wait Unitl Command Success docker login -u robot\\\$${project}+${user} -p ${pwd} ${ip}
Run Keyword If ${need_pull_first}==${true} Wait Unitl Command Success docker tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image_in_use} ${ip}/${project}/${image_in_use_with_tag}
... ELSE Wait Unitl Command Success docker tag ${image_in_use} ${ip}/${project}/${image_in_use_with_tag}
Wait Unitl Command Success docker push ${ip}/${project}/${image_in_use_with_tag}
Wait Unitl Command Success docker logout ${ip}
#Remove image for docker 20
Clean All Local Images
Sleep 1
Push Image With Tag
#tag1 is tag of image on docker hub,default latest,use a existed version if you do not want to use latest
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag} ${tag1}=latest
Log To Console \nRunning docker push ${image}...
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${tag1}
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${tag1} ${ip}/${project}/${image}:${tag}
Wait Unitl Command Success docker push ${ip}/${project}/${image}:${tag}
Wait Unitl Command Success docker logout ${ip}
#Remove image for docker 20
Clean All Local Images
Clean All Local Images
${rc} ${out}= Run Keyword And Ignore Error Run docker rmi -f $(docker images -a -q)
Log All ${out}
${rc} ${out}= Run Keyword And Ignore Error Run docker system prune -a -f
Log All ${out}
Cannot Docker Login Harbor
[Arguments] ${ip} ${user} ${pwd}
Command Should be Failed docker login -u ${user} -p ${pwd} ${ip}
Cannot Pull Image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}=${null} ${err_msg}=${null}
Restart Process Locally containerd
Restart Process Locally dockerd
${image_with_tag}= Set Variable If '${tag}'=='${null}' ${image} ${image}:${tag}
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
FOR ${idx} IN RANGE 0 30
${out} Run Keyword And Ignore Error Command Should be Failed docker pull ${ip}/${project}/${image_with_tag}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 3
END
Clean All Local Images
Log To Console Cannot Pull Image - Pull Log: ${out[1]}
Should Be Equal As Strings '${out[0]}' 'PASS'
Run Keyword If '${err_msg}' != '${null}' Should Contain ${out[1]} ${err_msg}
Cannot Push image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${err_msg}=${null} ${err_msg_2}=${null}
Log To Console \nRunning docker push ${image}...
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image} ${ip}/${project}/${image}
${output}= Command Should be Failed docker push ${ip}/${project}/${image}
Log To Console ${output}
Run Keyword If '${err_msg}' != '${null}' Should Contain ${output} ${err_msg}
Run Keyword If '${err_msg_2}' != '${null}' Should Contain ${output} ${err_msg_2}
Wait Unitl Command Success docker logout ${ip}
Clean All Local Images
Wait Until Container Stops
[Arguments] ${container}
FOR ${idx} IN RANGE 0 60
${out}= Run docker %{VCH-PARAMS} inspect ${container} | grep Status
${status}= Run Keyword And Return Status Should Contain ${out} exited
Return From Keyword If ${status}
Sleep 1
END
Fail Container did not stop within 60 seconds
Hit Nginx Endpoint
[Arguments] ${vch-ip} ${port}
Wait Unitl Command Success wget ${vch-ip}:${port}
Get Container IP
[Arguments] ${docker-params} ${id} ${network}=default ${dockercmd}=docker
${ip}= Wait Unitl Command Success ${dockercmd} ${docker-params} network inspect ${network} | jq '.[0].Containers."${id}".IPv4Address' | cut -d \\" -f 2 | cut -d \\/ -f 1
[Return] ${ip}
# The local dind version is embedded in Dockerfile
# docker:1.13-dind
# If you are running this keyword in a container, make sure it is run with --privileged turned on
Start Docker Daemon Locally
${pid}= Run pidof dockerd
#${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_config.sh
#Log ${output}
#Should Be Equal As Integers ${rc} 0
Return From Keyword If '${pid}' != '${EMPTY}'
OperatingSystem.File Should Exist /usr/local/bin/dockerd-entrypoint.sh
${handle}= Start Process /usr/local/bin/dockerd-entrypoint.sh dockerd>./daemon-local.log 2>&1 shell=True
Process Should Be Running ${handle}
FOR ${IDX} IN RANGE 5
${pid}= Run pidof dockerd
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
[Return] ${handle}
Start Containerd Daemon Locally
${handle}= Start Process /usr/local/bin/containerd > ./daemon-local.log 2>&1 & shell=True
FOR ${IDX} IN RANGE 5
${pid}= Run pidof /usr/local/bin/containerd
Log To Console pid: ${pid}
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
[Return] ${handle}
Restart Process Locally
[Arguments] ${process}
${full_process}= Set Variable If
... '${process}'=='containerd' /usr/local/bin/containerd dockerd
${start_process_cmd}= Set Variable If
... '${process}'=='dockerd' /usr/local/bin/dockerd-entrypoint.sh dockerd>./daemon-local.log 2>&1
... '${process}'=='containerd' ${full_process} > ./daemon-local.log 2>&1 &
Should Be True '${start_process_cmd}' != '${EMPTY}'
Run Keyword If '${process}'=='dockerd' OperatingSystem.File Should Exist /usr/local/bin/dockerd-entrypoint.sh
FOR ${IDX} IN RANGE 5
${pid}= Run pidof ${full_process}
Exit For Loop If '${pid}' == '${EMPTY}'
${result}= Run kill ${pid}
Log To Console Kill docker process: ${result}
Sleep 2s
END
${pid}= Run pidof ${full_process}
Should Be Equal As Strings '${pid}' '${EMPTY}'
${result}= Run rm -rf /var/lib/${process}/*
Log All Clear /var/lib/${process}: ${result}
${handle}= Start Process ${start_process_cmd} shell=True
Log All handle : ${handle}
FOR ${IDX} IN RANGE 5
${pid}= Run pidof ${full_process}
Log All pid : ${pid}
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
#Process Should Be Running ${handle}
${result}= Run ps aux |grep ${full_process}
Log All result : ${result}
[Return] ${handle}
Prepare Docker Cert In Ubuntu
[Arguments] ${ip} ${cert}
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /usr/local/share/ca-certificates/
#Add pivotal ecs cert for docker manifest push test.
Wait Unitl Command Success cp /ecs_ca/vmwarecert.crt /usr/local/share/ca-certificates/
Wait Unitl Command Success update-ca-certificates
Prepare Docker Cert In Photon
[Arguments] ${ip} ${cert}
Log All Prepare Docker Cert In Photon ${cert}
${rc} ${output}= Run And Return Rc and Output cat ${cert}
Log All CA output: ${output}
Wait Unitl Command Success cat ${cert} >> /etc/pki/tls/certs/ca-bundle.crt
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /etc/docker/certs.d/${ip}
Kill Local Docker Daemon
[Arguments] ${handle} ${dockerd-pid}
Terminate Process ${handle}
Process Should Be Stopped ${handle}
Wait Unitl Command Success kill -9 ${dockerd-pid}
Docker Login Fail
[Arguments] ${ip} ${user} ${pwd}
Log To Console \nRunning docker login ${ip} ...
${output}= Command Should be Failed docker login -u ${user} -p ${pwd} ${ip}
Should Contain ${output} unauthorized
Should Not Contain ${output} 500 Internal Server Error
Docker Login
[Arguments] ${server} ${username} ${password}
Wait Unitl Command Success docker login -u ${username} -p ${password} ${server}
Docker Pull
[Arguments] ${image}
${output}= Retry Keyword N Times When Error 6 Wait Unitl Command Success docker pull ${image}
Log All Docker Pull: ${output}
[Return] ${output}
Docker Tag
[Arguments] ${src_image} ${dst_image}
Wait Unitl Command Success docker tag ${src_image} ${dst_image}
Docker Push
[Arguments] ${image}
Wait Unitl Command Success docker push ${image}
Docker Push Index
[Arguments] ${ip} ${user} ${pwd} ${index} ${image1} ${image2}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_push_manifest_list.sh ${ip} ${user} ${pwd} ${index} ${image1} ${image2}
Log ${output}
Should Be Equal As Integers ${rc} 0
Docker Image Can Not Be Pulled
[Arguments] ${image}
FOR ${idx} IN RANGE 0 30
${out}= Run Keyword And Ignore Error Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
Log To Console Return value is ${out}
${out}= Run Keyword And Ignore Error Command Should be Failed docker pull ${image}
Exit For Loop If '${out[0]}'=='PASS'
Log To Console Docker pull return value is ${out}
Sleep 3
END
Clean All Local Images
Log To Console Cannot Pull Image From Docker - Pull Log: ${out[1]}
Should Be Equal As Strings '${out[0]}' 'PASS'
Docker Image Can Be Pulled
[Arguments] ${image} ${period}=60 ${times}=2
FOR ${n} IN RANGE 1 ${times}
Sleep ${period}
${out}= Run Keyword And Ignore Error Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
Log To Console Return value is ${out}
${out}= Run Keyword And Ignore Error Docker Pull ${image}
Log To Console Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 5
END
Clean All Local Images
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
# 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 This resource provides helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
Run Docker Info
[Arguments] ${docker-params}
Wait Unitl Command Success docker ${docker-params} info
Pull image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}=${null} ${is_robot}=${false}
Log To Console \nRunning docker pull ${image}...
${image_with_tag}= Set Variable If '${tag}'=='${null}' ${image} ${image}:${tag}
Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
... ELSE Wait Unitl Command Success docker login -u robot\\\$${project}+${user} -p ${pwd} ${ip}
${output}= Docker Pull ${ip}/${project}/${image_with_tag}
Log ${output}
Log To Console ${output}
Should Contain ${output} Digest:
Should Contain ${output} Status:
Should Not Contain ${output} No such image:
#Remove image for docker 20
Clean All Local Images
Push image
# If no tag provided in $(image_with_or_without_tag}, latest will be the tag pulled from docker-hub or read from local
[Arguments] ${ip} ${user} ${pwd} ${project} ${image_with_or_without_tag} ${need_pull_first}=${true} ${sha256}=${null} ${is_robot}=${false}
${d}= Get Current Date result_format=%m%s
${image_in_use}= Set Variable If '${sha256}'=='${null}' ${image_with_or_without_tag} ${image_with_or_without_tag}@sha256:${sha256}
${image_in_use_with_tag}= Set Variable If '${sha256}'=='${null}' ${image_with_or_without_tag} ${image_with_or_without_tag}:${sha256}
Sleep 3
Log To Console \nRunning docker push ${image_with_or_without_tag}...
${image_in_use}= Set Variable If ${need_pull_first}==${true} ${image_in_use} ${image_with_or_without_tag}
Run Keyword If ${need_pull_first}==${true} Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image_in_use}
Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
... ELSE Wait Unitl Command Success docker login -u robot\\\$${project}+${user} -p ${pwd} ${ip}
Run Keyword If ${need_pull_first}==${true} Wait Unitl Command Success docker tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image_in_use} ${ip}/${project}/${image_in_use_with_tag}
... ELSE Wait Unitl Command Success docker tag ${image_in_use} ${ip}/${project}/${image_in_use_with_tag}
Wait Unitl Command Success docker push ${ip}/${project}/${image_in_use_with_tag}
Wait Unitl Command Success docker logout ${ip}
#Remove image for docker 20
Clean All Local Images
Sleep 1
Push Image With Tag
#tag1 is tag of image on docker hub,default latest,use a existed version if you do not want to use latest
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag} ${tag1}=latest
Log To Console \nRunning docker push ${image}...
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${tag1}
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${tag1} ${ip}/${project}/${image}:${tag}
Wait Unitl Command Success docker push ${ip}/${project}/${image}:${tag}
Wait Unitl Command Success docker logout ${ip}
#Remove image for docker 20
Clean All Local Images
Clean All Local Images
${rc} ${out}= Run Keyword And Ignore Error Run docker rmi -f $(docker images -a -q)
Log All ${out}
${rc} ${out}= Run Keyword And Ignore Error Run docker system prune -a -f
Log All ${out}
Cannot Docker Login Harbor
[Arguments] ${ip} ${user} ${pwd}
Command Should be Failed docker login -u ${user} -p ${pwd} ${ip}
Cannot Pull Image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}=${null} ${err_msg}=${null}
Restart Process Locally containerd
Restart Process Locally dockerd
${image_with_tag}= Set Variable If '${tag}'=='${null}' ${image} ${image}:${tag}
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
FOR ${idx} IN RANGE 0 30
${out} Run Keyword And Ignore Error Command Should be Failed docker pull ${ip}/${project}/${image_with_tag}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 3
END
Clean All Local Images
Log To Console Cannot Pull Image - Pull Log: ${out[1]}
Should Be Equal As Strings '${out[0]}' 'PASS'
Run Keyword If '${err_msg}' != '${null}' Should Contain ${out[1]} ${err_msg}
Cannot Push image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${err_msg}=${null} ${err_msg_2}=${null}
Log To Console \nRunning docker push ${image}...
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image} ${ip}/${project}/${image}
${output}= Command Should be Failed docker push ${ip}/${project}/${image}
Log To Console ${output}
Run Keyword If '${err_msg}' != '${null}' Should Contain ${output} ${err_msg}
Run Keyword If '${err_msg_2}' != '${null}' Should Contain ${output} ${err_msg_2}
Wait Unitl Command Success docker logout ${ip}
Clean All Local Images
Wait Until Container Stops
[Arguments] ${container}
FOR ${idx} IN RANGE 0 60
${out}= Run docker %{VCH-PARAMS} inspect ${container} | grep Status
${status}= Run Keyword And Return Status Should Contain ${out} exited
Return From Keyword If ${status}
Sleep 1
END
Fail Container did not stop within 60 seconds
Hit Nginx Endpoint
[Arguments] ${vch-ip} ${port}
Wait Unitl Command Success wget ${vch-ip}:${port}
Get Container IP
[Arguments] ${docker-params} ${id} ${network}=default ${dockercmd}=docker
${ip}= Wait Unitl Command Success ${dockercmd} ${docker-params} network inspect ${network} | jq '.[0].Containers."${id}".IPv4Address' | cut -d \\" -f 2 | cut -d \\/ -f 1
[Return] ${ip}
# The local dind version is embedded in Dockerfile
# docker:1.13-dind
# If you are running this keyword in a container, make sure it is run with --privileged turned on
Start Docker Daemon Locally
${pid}= Run pidof dockerd
#${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_config.sh
#Log ${output}
#Should Be Equal As Integers ${rc} 0
Return From Keyword If '${pid}' != '${EMPTY}'
OperatingSystem.File Should Exist /usr/local/bin/dockerd-entrypoint.sh
${handle}= Start Process /usr/local/bin/dockerd-entrypoint.sh dockerd>./daemon-local.log 2>&1 shell=True
Process Should Be Running ${handle}
FOR ${IDX} IN RANGE 5
${pid}= Run pidof dockerd
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
[Return] ${handle}
Start Containerd Daemon Locally
${handle}= Start Process /usr/local/bin/containerd > ./daemon-local.log 2>&1 & shell=True
FOR ${IDX} IN RANGE 5
${pid}= Run pidof /usr/local/bin/containerd
Log To Console pid: ${pid}
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
[Return] ${handle}
Restart Process Locally
[Arguments] ${process}
${full_process}= Set Variable If
... '${process}'=='containerd' /usr/local/bin/containerd dockerd
${start_process_cmd}= Set Variable If
... '${process}'=='dockerd' /usr/local/bin/dockerd-entrypoint.sh dockerd>./daemon-local.log 2>&1
... '${process}'=='containerd' ${full_process} > ./daemon-local.log 2>&1 &
Should Be True '${start_process_cmd}' != '${EMPTY}'
Run Keyword If '${process}'=='dockerd' OperatingSystem.File Should Exist /usr/local/bin/dockerd-entrypoint.sh
FOR ${IDX} IN RANGE 5
${pid}= Run pidof ${full_process}
Exit For Loop If '${pid}' == '${EMPTY}'
${result}= Run kill ${pid}
Log To Console Kill docker process: ${result}
Sleep 2s
END
${pid}= Run pidof ${full_process}
Should Be Equal As Strings '${pid}' '${EMPTY}'
${result}= Run rm -rf /var/lib/${process}/*
Log All Clear /var/lib/${process}: ${result}
${handle}= Start Process ${start_process_cmd} shell=True
Log All handle : ${handle}
FOR ${IDX} IN RANGE 5
${pid}= Run pidof ${full_process}
Log All pid : ${pid}
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
#Process Should Be Running ${handle}
${result}= Run ps aux |grep ${full_process}
Log All result : ${result}
[Return] ${handle}
Prepare Docker Cert In Ubuntu
[Arguments] ${ip} ${cert}
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /usr/local/share/ca-certificates/
#Add pivotal ecs cert for docker manifest push test.
Wait Unitl Command Success cp /ecs_ca/vmwarecert.crt /usr/local/share/ca-certificates/
Wait Unitl Command Success update-ca-certificates
Prepare Docker Cert In Photon
[Arguments] ${ip} ${cert}
Log All Prepare Docker Cert In Photon ${cert}
${rc} ${output}= Run And Return Rc and Output cat ${cert}
Log All CA output: ${output}
Wait Unitl Command Success cat ${cert} >> /etc/pki/tls/certs/ca-bundle.crt
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp ${cert} /etc/docker/certs.d/${ip}
Kill Local Docker Daemon
[Arguments] ${handle} ${dockerd-pid}
Terminate Process ${handle}
Process Should Be Stopped ${handle}
Wait Unitl Command Success kill -9 ${dockerd-pid}
Docker Login Fail
[Arguments] ${ip} ${user} ${pwd}
Log To Console \nRunning docker login ${ip} ...
${output}= Command Should be Failed docker login -u ${user} -p ${pwd} ${ip}
Should Contain ${output} unauthorized
Should Not Contain ${output} 500 Internal Server Error
Docker Login
[Arguments] ${server} ${username} ${password}
Wait Unitl Command Success docker login -u ${username} -p ${password} ${server}
Docker Pull
[Arguments] ${image}
${output}= Retry Keyword N Times When Error 6 Wait Unitl Command Success docker pull ${image}
Log All Docker Pull: ${output}
[Return] ${output}
Docker Tag
[Arguments] ${src_image} ${dst_image}
Wait Unitl Command Success docker tag ${src_image} ${dst_image}
Docker Push
[Arguments] ${image}
Wait Unitl Command Success docker push ${image}
Docker Push Index
[Arguments] ${ip} ${user} ${pwd} ${index} ${image1} ${image2}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_push_manifest_list.sh ${ip} ${user} ${pwd} ${index} ${image1} ${image2}
Log ${output}
Should Be Equal As Integers ${rc} 0
Docker Image Can Not Be Pulled
[Arguments] ${image}
FOR ${idx} IN RANGE 0 30
${out}= Run Keyword And Ignore Error Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
Log To Console Return value is ${out}
${out}= Run Keyword And Ignore Error Command Should be Failed docker pull ${image}
Exit For Loop If '${out[0]}'=='PASS'
Log To Console Docker pull return value is ${out}
Sleep 3
END
Clean All Local Images
Log To Console Cannot Pull Image From Docker - Pull Log: ${out[1]}
Should Be Equal As Strings '${out[0]}' 'PASS'
Docker Image Can Be Pulled
[Arguments] ${image} ${period}=60 ${times}=2
FOR ${n} IN RANGE 1 ${times}
Sleep ${period}
${out}= Run Keyword And Ignore Error Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
Log To Console Return value is ${out}
${out}= Run Keyword And Ignore Error Docker Pull ${image}
Log To Console Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 5
END
Clean All Local Images
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'

View File

@ -1,31 +1,31 @@
# 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 This resource contains any keywords related to using the Drone CI Build System
*** Keywords ***
Get State Of Drone Build
[Arguments] ${num}
Return From Keyword If '${num}' == '0' local
${out}= Run drone build info vmware/vic ${num}
${lines}= Split To Lines ${out}
[Return] @{lines}[2]
Get Title of Drone Build
[Arguments] ${num}
Return From Keyword If '${num}' == '0' local
${out}= Run drone build info vmware/vic ${num}
${lines}= Split To Lines ${out}
[Return] @{lines}[-1]
# 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 This resource contains any keywords related to using the Drone CI Build System
*** Keywords ***
Get State Of Drone Build
[Arguments] ${num}
Return From Keyword If '${num}' == '0' local
${out}= Run drone build info vmware/vic ${num}
${lines}= Split To Lines ${out}
[Return] @{lines}[2]
Get Title of Drone Build
[Arguments] ${num}
Return From Keyword If '${num}' == '0' local
${out}= Run drone build info vmware/vic ${num}
${lines}= Split To Lines ${out}
[Return] @{lines}[-1]

View File

@ -1,29 +1,29 @@
# 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 This resource provides keywords to interact with Github
*** Keywords ***
Get State Of Github Issue
[Arguments] ${num}
[Tags] secret
FOR ${idx} IN RANGE 0 5
${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/repos/vmware/vic/issues/${num}?access_token\=%{GITHUB_AUTOMATION_API_KEY}
Exit For Loop If '${status}'
Sleep 1
END
Should Be Equal ${result.status_code} ${200}
${status}= Get From Dictionary ${result.json()} state
[Return] ${status}
# 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 This resource provides keywords to interact with Github
*** Keywords ***
Get State Of Github Issue
[Arguments] ${num}
[Tags] secret
FOR ${idx} IN RANGE 0 5
${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/repos/vmware/vic/issues/${num}?access_token\=%{GITHUB_AUTOMATION_API_KEY}
Exit For Loop If '${status}'
Sleep 1
END
Should Be Equal ${result.status_code} ${200}
${status}= Get From Dictionary ${result.json()} state
[Return] ${status}

View File

@ -1,60 +1,60 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Assign User Admin
[Arguments] ${user}
Retry Element Click xpath=//harbor-user//hbr-filter//clr-icon
Input Text xpath=//harbor-user//hbr-filter//input ${user}
Sleep 2
#select checkbox
Retry Element Click //clr-dg-row[contains(.,'${user}')]//label
#click assign admin
Retry Element Click //*[@id='set-admin']
Sleep 1
Switch to User Tag
Retry Element Click xpath=${administration_user_tag_xpath}
Sleep 1
Administration Tag Should Display
Retry Wait Until Page Contains Element xpath=${administration_tag_xpath}
User Email Should Exist
[Arguments] ${email}
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Switch to User Tag
Retry Wait Until Page Contains Element xpath=//clr-dg-cell[contains(., '${email}')]
Add User Button Should Be Disabled
Sleep 1
Retry Wait Until Page Contains Element //button[contains(.,'New') and @disabled='']
Add A New User
[Arguments] ${username} ${email} ${realname} ${newPassword} ${comment}
Retry Element Click xpath=${add_new_user_button}
Retry Text Input xpath=${username_xpath} ${username}
Retry Text Input xpath=${email_xpath} ${email}
Retry Text Input xpath=${realname_xpath} ${realname}
Retry Text Input xpath=${newPassword_xpath} ${newPassword}
Retry Text Input xpath=${confirmPassword_xpath} ${newPassword}
Retry Text Input xpath=${comment_xpath} ${comment}
Retry Double Keywords When Error Retry Element Click xpath=${save_new_user_button} Retry Wait Until Page Not Contains Element xpath=${save_new_user_button}
Retry Wait Until Page Contains Element xpath=//harbor-user//clr-dg-row//clr-dg-cell[contains(., '${username}')]
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Assign User Admin
[Arguments] ${user}
Retry Element Click xpath=//harbor-user//hbr-filter//clr-icon
Input Text xpath=//harbor-user//hbr-filter//input ${user}
Sleep 2
#select checkbox
Retry Element Click //clr-dg-row[contains(.,'${user}')]//label
#click assign admin
Retry Element Click //*[@id='set-admin']
Sleep 1
Switch to User Tag
Retry Element Click xpath=${administration_user_tag_xpath}
Sleep 1
Administration Tag Should Display
Retry Wait Until Page Contains Element xpath=${administration_tag_xpath}
User Email Should Exist
[Arguments] ${email}
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Switch to User Tag
Retry Wait Until Page Contains Element xpath=//clr-dg-cell[contains(., '${email}')]
Add User Button Should Be Disabled
Sleep 1
Retry Wait Until Page Contains Element //button[contains(.,'New') and @disabled='']
Add A New User
[Arguments] ${username} ${email} ${realname} ${newPassword} ${comment}
Retry Element Click xpath=${add_new_user_button}
Retry Text Input xpath=${username_xpath} ${username}
Retry Text Input xpath=${email_xpath} ${email}
Retry Text Input xpath=${realname_xpath} ${realname}
Retry Text Input xpath=${newPassword_xpath} ${newPassword}
Retry Text Input xpath=${confirmPassword_xpath} ${newPassword}
Retry Text Input xpath=${comment_xpath} ${comment}
Retry Double Keywords When Error Retry Element Click xpath=${save_new_user_button} Retry Wait Until Page Not Contains Element xpath=${save_new_user_button}
Retry Wait Until Page Contains Element xpath=//harbor-user//clr-dg-row//clr-dg-cell[contains(., '${username}')]

View File

@ -1,22 +1,22 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${administration_user_tag_xpath} //clr-vertical-nav-group-children/a[contains(.,'Users')]
${administration_tag_xpath} //clr-vertical-nav-group[contains(.,'Admin')]
${add_new_user_button} //*[@id='add-new-user']
${save_new_user_button} //*[@id='save-button']
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${administration_user_tag_xpath} //clr-vertical-nav-group-children/a[contains(.,'Users')]
${administration_tag_xpath} //clr-vertical-nav-group[contains(.,'Admin')]
${add_new_user_button} //*[@id='add-new-user']
${save_new_user_button} //*[@id='save-button']

View File

@ -1,424 +1,424 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Init LDAP
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
Log ${output}
Sleep 2
Input Text xpath=//*[@id='ldapUrl'] ldaps://${output}
Sleep 1
Input Text xpath=//*[@id='ldapSearchDN'] cn=admin,dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapSearchPwd'] admin
Sleep 1
Input Text xpath=//*[@id='ldapBaseDN'] dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapFilter'] (&(objectclass=inetorgperson)(memberof=cn=harbor_users,ou=groups,dc=example,dc=com))
Sleep 1
Input Text xpath=//*[@id='ldapUid'] cn
Sleep 1
Disable Ldap Verify Cert Checkbox
Retry Element Click xpath=${config_auth_save_button_xpath}
Sleep 2
Retry Element Click xpath=/html/body/harbor-app/harbor-shell/clr-main-container/div/div/config/div/div/div/button[3]
Sleep 1
Switch To Configure
Retry Element Click xpath=${configuration_xpath}
Sleep 2
Test Ldap Connection
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
Log ${output}
Sleep 2
Input Text xpath=//*[@id='ldapUrl'] ldaps://${output}
Sleep 1
Input Text xpath=//*[@id='ldapSearchDN'] cn=admin,dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapSearchPwd'] admin
Sleep 1
Input Text xpath=//*[@id='ldapBaseDN'] dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapUid'] cn
Sleep 1
# default is checked, click test connection to verify fail as no cert.
Retry Element Click xpath=${test_ldap_xpath}
Sleep 1
Wait Until Page Contains Failed to verify LDAP server with error
Sleep 5
Disable Ldap Verify Cert Checkbox
# ldap checkbox unchecked, click test connection to verify success.
Sleep 1
Retry Element Click xpath=${test_ldap_xpath}
Wait Until Page Contains Connection to LDAP server is verified timeout=15
Test LDAP Server Success
Retry Element Click xpath=${test_ldap_xpath}
Wait Until Page Contains Connection to LDAP server is verified timeout=15
Disable Ldap Verify Cert Checkbox
Mouse Down xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Mouse Up xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Sleep 2
Ldap Verify Cert Checkbox Should Be Disabled
Ldap Verify Cert Checkbox Should Be Disabled
Checkbox Should Not Be Selected xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Set Pro Create Admin Only
#set limit to admin only
Retry Element Click xpath=${configuration_xpath}
Sleep 2
Retry Element Click xpath=${configuration_system_tabsheet_id}
Sleep 1
Retry Element Click xpath=//select[@id='proCreation']
Retry Element Click xpath=//select[@id='proCreation']//option[@value='adminonly']
Sleep 1
Retry Element Click xpath=${config_system_save_button_xpath}
Set Pro Create Every One
Retry Element Click xpath=${configuration_xpath}
sleep 1
#set limit to Every One
Retry Element Click xpath=${configuration_system_tabsheet_id}
Sleep 1
Retry Element Click xpath=//select[@id='proCreation']
Retry Element Click xpath=//select[@id='proCreation']//option[@value='everyone']
Sleep 1
Retry Element Click xpath=${config_system_save_button_xpath}
Sleep 2
Disable Self Reg
Retry Element Click xpath=${configuration_xpath}
Mouse Down xpath=${self_reg_xpath}
Mouse Up xpath=${self_reg_xpath}
Sleep 1
Self Reg Should Be Disabled
Retry Element Click xpath=${config_auth_save_button_xpath}
Sleep 1
Enable Self Reg
Mouse Down xpath=${self_reg_xpath}
Mouse Up xpath=${self_reg_xpath}
Sleep 1
Self Reg Should Be Enabled
Retry Element Click xpath=${config_auth_save_button_xpath}
Sleep 1
Self Reg Should Be Disabled
Checkbox Should Not Be Selected xpath=${self_reg_xpath}
Self Reg Should Be Enabled
Checkbox Should Be Selected xpath=${self_reg_xpath}
Project Creation Should Display
Retry Wait Until Page Contains Element xpath=${project_create_xpath}
Project Creation Should Not Display
Retry Wait Until Page Not Contains Element xpath=${project_create_xpath}
## System settings
Switch To System Settings
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Retry Element Click xpath=${configuration_system_tabsheet_id}
Sleep 1
Switch To Project Quotas
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Project Quotas')]
Sleep 1
Switch To Distribution
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav-group//span[contains(.,'Distributions')]
Sleep 1
Switch To Robot Account
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav-group//span[contains(.,'Robot Accounts')]
Sleep 1
Modify Token Expiration
[Arguments] ${minutes}
Input Text xpath=//*[@id='tokenExpiration'] ${minutes}
Click Button xpath=${config_system_save_button_xpath}
Sleep 1
Token Must Be Match
[Arguments] ${minutes}
Textfield Value Should Be xpath=//*[@id='tokenExpiration'] ${minutes}
Robot Account Token Must Be Match
[Arguments] ${days}
Textfield Value Should Be xpath=//*[@id='robotTokenExpiration'] ${days}
## Replication
Check Verify Remote Cert
Mouse Down xpath=//*[@id='clr-checkbox-verifyRemoteCert']
Mouse Up xpath=//*[@id='clr-checkbox-verifyRemoteCert']
Retry Element Click xpath=${config_save_button_xpath}
Sleep 1
Switch To System Replication
Sleep 1
Switch To Configure
Retry Element Click xpath=//*[@id='config-replication']
Sleep 1
Should Verify Remote Cert Be Enabled
Checkbox Should Not Be Selected xpath=//*[@id='clr-checkbox-verifyRemoteCert']
## Email
Switch To Email
Switch To Configure
Retry Element Click xpath=//*[@id='config-email']
Sleep 1
Config Email
Input Text xpath=//*[@id='mailServer'] smtp.vmware.com
Input Text xpath=//*[@id='emailPort'] 25
Input Text xpath=//*[@id='emailUsername'] example@vmware.com
Input Text xpath=//*[@id='emailPassword'] example
Input Text xpath=//*[@id='emailFrom'] example<example@vmware.com>
Sleep 1
Retry Element Click xpath=//*[@id='emailSSL-wrapper']/label
Sleep 1
Retry Element Click xpath=//*[@id='emailInsecure-wrapper']/label
Sleep 1
Retry Element Click xpath=${config_email_save_button_xpath}
Sleep 6
Verify Email
Textfield Value Should Be xpath=//*[@id='mailServer'] smtp.vmware.com
Textfield Value Should Be xpath=//*[@id='emailPort'] 25
Textfield Value Should Be xpath=//*[@id='emailUsername'] example@vmware.com
Textfield Value Should Be xpath=//*[@id='emailFrom'] example<example@vmware.com>
Checkbox Should Be Selected xpath=//*[@id='emailSSL']
Checkbox Should Not Be Selected xpath=//*[@id='emailInsecure']
Set Scan All To None
Retry Element Click //vulnerability-config//select
Retry Element Click //vulnerability-config//select/option[@value='none']
sleep 1
Retry Element Click ${vulnerbility_save_button_xpath}
Set Scan All To Daily
Retry Element Click //vulnerability-config//select
Retry Element Click //vulnerability-config//select/option[@value='daily']
sleep 1
Retry Element Click ${vulnerbility_save_button_xpath}
Click Scan Now
Retry Element Click //vulnerability-config//button[contains(.,'SCAN')]
Enable Read Only
${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X PUT -d '{"read_only":true}' "https://${ip}/api/v2.0/configurations"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Disable Read Only
${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X PUT -d '{"read_only":false}' "https://${ip}/api/v2.0/configurations"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
## System labels
Switch To System Labels
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Labels')]
## System labels
Switch To Configuration System Setting
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Retry Element Click xpath=${configuration_system_tabsheet_id}
Switch To Configuration Project Quotas
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Project Quotas')]
Create New Labels
[Arguments] ${labelname}
Retry Element Click xpath=//button[contains(.,'New Label')]
Sleep 1
Input Text xpath=//*[@id='name'] ${labelname}
Sleep 1
Retry Element Click xpath=//hbr-create-edit-label//clr-dropdown/clr-icon
Sleep 1
Retry Element Click xpath=//hbr-create-edit-label//clr-dropdown-menu/label[1]
Sleep 1
Input Text xpath=//*[@id='description'] global
Retry Element Click xpath=//div/form/section/label[4]/button[2]
Wait Until Page Contains ${labelname}
Update A Label
[Arguments] ${labelname}
Retry Element Click xpath=//clr-dg-row[contains(.,'${labelname}')]//clr-checkbox-wrapper
Sleep 1
Retry Element Click xpath=//button[contains(.,'Edit')]
Sleep 1
Input Text xpath=//*[@id='name'] ${labelname}1
Sleep 1
Retry Element Click xpath=//hbr-create-edit-label//form/section//button[2]
Wait Until Page Contains ${labelname}1
Delete A Label
[Arguments] ${labelname}
Retry Element Click xpath=//clr-dg-row[contains(.,'${labelname}')]//clr-checkbox-wrapper
Sleep 1
Retry Element Click xpath=//button[contains(.,'Delete')]
Sleep 3
Retry Element Click xpath=//clr-modal//div//button[contains(.,'DELETE')]
Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${labelname}')]/../div/clr-icon[@shape='success-standard']
## Garbage Collection
Switch To Garbage Collection
Switch To Configure
Sleep 1
Retry Element Click xpath=${gc_config_page}
Wait Until Page Contains Element ${garbage_collection_xpath}
Retry Element Click xpath=${garbage_collection_xpath}
Set GC Schedule
[Arguments] ${type} ${value}=${null}
Switch To Garbage Collection
Retry Double Keywords When Error Retry Element Click ${GC_schedule_edit_btn} Retry Wait Until Page Not Contains Element ${GC_schedule_edit_btn}
Retry Element Click ${GC_schedule_select}
Run Keyword If '${type}'=='custom' Run Keywords Retry Element Click ${vulnerability_dropdown_list_item_custom} AND Retry Text Input ${targetCron_id} ${value}
... ELSE Retry Element Click ${vulnerability_dropdown_list_item_none}
Retry Double Keywords When Error Retry Element Click ${GC_schedule_save_btn} Retry Wait Until Page Not Contains Element ${GC_schedule_save_btn}
Capture Page Screenshot
Click GC Now
Sleep 1
Retry Element Click xpath=${gc_now_xpath}
Sleep 2
View GC Details
Retry Element Click xpath=${gc_log_details_xpath}
Sleep 2
Switch To GC History
Retry Element Click xpath=${gc_log_xpath}
Retry Wait Until Page Contains Job
Add Items To System CVE Allowlist
[Arguments] ${cve_id}
Retry Element Click ${configuration_system_wl_add_btn}
Retry Text Input ${configuration_system_wl_textarea} ${cve_id}
Retry Element Click ${configuration_system_wl_add_confirm_btn}
Retry Element Click ${config_system_save_button_xpath}
Delete Top Item In System CVE Allowlist
[Arguments] ${count}=1
FOR ${idx} IN RANGE 1 ${count}
Retry Element Click ${configuration_system_wl_delete_a_cve_id_icon}
END
Retry Element Click ${config_system_save_button_xpath}
Get Project Count Quota Text From Project Quotas List
[Arguments] ${project_name}
Switch To Project Quotas
${count_quota}= Get Text xpath=//project-quotas//clr-datagrid//clr-dg-row[contains(.,'${project_name}')]//clr-dg-cell[3]//label
[Return] ${count_quota}
Get Project Storage Quota Text From Project Quotas List
[Arguments] ${project_name}
Switch To Configure
Switch To Project Quotas
${storage_quota}= Get Text xpath=//project-quotas//clr-datagrid//clr-dg-row[contains(.,'${project_name}')]//clr-dg-cell[3]//label
[Return] ${storage_quota}
Check Automatic Onboarding And Save
Switch To Configure
Retry Element Click ${cfg_auth_automatic_onboarding_checkbox}
Retry Element Click xpath=${config_auth_save_button_xpath}
Set User Name Claim And Save
[Arguments] ${type}
Switch To Configure
Retry Clear Element Text ${cfg_auth_user_name_claim_input}
Run Keyword If '${type}'=='${null}' Retry Text Input ${cfg_auth_user_name_claim_input} anytext
... ELSE Retry Text Input ${cfg_auth_user_name_claim_input} ${type}
Retry Element Click xpath=${config_auth_save_button_xpath}
Select Distribution
[Arguments] ${name}
Retry Element Click //clr-dg-row[contains(.,'${name}')]//clr-checkbox-wrapper/label
Distribution Exist
[Arguments] ${name} ${endpoint}
Retry Wait Until Page Contains Element //clr-dg-row[contains(.,'${name}') and contains(.,'${endpoint}')]
Distribution Not Exist
[Arguments] ${name} ${endpoint}
Retry Wait Until Page Not Contains Element //clr-dg-row[contains(.,'${name}') and contains(.,'${endpoint}')]
Filter Distribution List
[Arguments] ${name} ${endpoint} ${exsit}=${true}
Retry Double Keywords When Error Retry Element Click ${filter_dist_btn} Wait Until Element Is Visible And Enabled ${filter_dist_input}
Retry Text Input ${filter_dist_input} ${name}
Run Keyword If ${exsit}==${true} Distribution Exist ${name} ${endpoint}
... ELSE Distribution Not Exist ${name} ${endpoint}
Select Provider
[Arguments] ${provider}
Retry Element Click ${distribution_provider_select_id}
Retry Element Click ${distribution_provider_select_id}//option[contains(.,'${provider}')]
Create An New Distribution
[Arguments] ${provider} ${name} ${endpoint}
Switch To Distribution
Retry Element Click ${distribution_add_btn_id}
Select Provider ${provider}
Retry Text Input ${distribution_name_input_id} ${name}
Retry Text Input ${distribution_endpoint_id} ${endpoint}
Retry Double Keywords When Error Retry Element Click ${distribution_add_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${distribution_add_save_btn_id}
Distribution Exist ${name} ${endpoint}
Delete A Distribution
[Arguments] ${name} ${endpoint} ${deletable}=${true}
${is_exsit} evaluate not ${deletable}
Switch To Distribution
Filter Distribution List ${name} ${endpoint}
Retry Double Keywords When Error Select Distribution ${name} Wait Until Element Is Visible //clr-datagrid//clr-dg-footer//clr-checkbox-wrapper/label
Retry Double Keywords When Error Retry Element Click ${distribution_action_btn_id} Wait Until Element Is Visible And Enabled ${distribution_del_btn_id}
Retry Double Keywords When Error Retry Element Click ${distribution_del_btn_id} Wait Until Element Is Visible And Enabled ${delete_confirm_btn}
Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn}
Sleep 10
Filter Distribution List ${name} ${endpoint} exsit=${is_exsit}
Edit A Distribution
[Arguments] ${name} ${endpoint} ${new_endpoint}=${null}
Switch To Distribution
Filter Distribution List ${name} ${endpoint}
Retry Double Keywords When Error Select Distribution ${name} Wait Until Element Is Visible //clr-datagrid//clr-dg-footer//clr-checkbox-wrapper/label times=9
Retry Double Keywords When Error Retry Element Click ${distribution_action_btn_id} Wait Until Element Is Visible And Enabled ${distribution_edit_btn_id}
Retry Double Keywords When Error Retry Element Click ${distribution_edit_btn_id} Wait Until Element Is Visible And Enabled ${distribution_name_input_id}
Retry Text Input ${distribution_endpoint_id} ${new_endpoint}
Retry Double Keywords When Error Retry Element Click ${distribution_add_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${distribution_add_save_btn_id}
Filter Distribution List ${name} ${new_endpoint}
Distribution Exist ${name} ${new_endpoint}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Init LDAP
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
Log ${output}
Sleep 2
Input Text xpath=//*[@id='ldapUrl'] ldaps://${output}
Sleep 1
Input Text xpath=//*[@id='ldapSearchDN'] cn=admin,dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapSearchPwd'] admin
Sleep 1
Input Text xpath=//*[@id='ldapBaseDN'] dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapFilter'] (&(objectclass=inetorgperson)(memberof=cn=harbor_users,ou=groups,dc=example,dc=com))
Sleep 1
Input Text xpath=//*[@id='ldapUid'] cn
Sleep 1
Disable Ldap Verify Cert Checkbox
Retry Element Click xpath=${config_auth_save_button_xpath}
Sleep 2
Retry Element Click xpath=/html/body/harbor-app/harbor-shell/clr-main-container/div/div/config/div/div/div/button[3]
Sleep 1
Switch To Configure
Retry Element Click xpath=${configuration_xpath}
Sleep 2
Test Ldap Connection
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
Log ${output}
Sleep 2
Input Text xpath=//*[@id='ldapUrl'] ldaps://${output}
Sleep 1
Input Text xpath=//*[@id='ldapSearchDN'] cn=admin,dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapSearchPwd'] admin
Sleep 1
Input Text xpath=//*[@id='ldapBaseDN'] dc=example,dc=com
Sleep 1
Input Text xpath=//*[@id='ldapUid'] cn
Sleep 1
# default is checked, click test connection to verify fail as no cert.
Retry Element Click xpath=${test_ldap_xpath}
Sleep 1
Wait Until Page Contains Failed to verify LDAP server with error
Sleep 5
Disable Ldap Verify Cert Checkbox
# ldap checkbox unchecked, click test connection to verify success.
Sleep 1
Retry Element Click xpath=${test_ldap_xpath}
Wait Until Page Contains Connection to LDAP server is verified timeout=15
Test LDAP Server Success
Retry Element Click xpath=${test_ldap_xpath}
Wait Until Page Contains Connection to LDAP server is verified timeout=15
Disable Ldap Verify Cert Checkbox
Mouse Down xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Mouse Up xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Sleep 2
Ldap Verify Cert Checkbox Should Be Disabled
Ldap Verify Cert Checkbox Should Be Disabled
Checkbox Should Not Be Selected xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Set Pro Create Admin Only
#set limit to admin only
Retry Element Click xpath=${configuration_xpath}
Sleep 2
Retry Element Click xpath=${configuration_system_tabsheet_id}
Sleep 1
Retry Element Click xpath=//select[@id='proCreation']
Retry Element Click xpath=//select[@id='proCreation']//option[@value='adminonly']
Sleep 1
Retry Element Click xpath=${config_system_save_button_xpath}
Set Pro Create Every One
Retry Element Click xpath=${configuration_xpath}
sleep 1
#set limit to Every One
Retry Element Click xpath=${configuration_system_tabsheet_id}
Sleep 1
Retry Element Click xpath=//select[@id='proCreation']
Retry Element Click xpath=//select[@id='proCreation']//option[@value='everyone']
Sleep 1
Retry Element Click xpath=${config_system_save_button_xpath}
Sleep 2
Disable Self Reg
Retry Element Click xpath=${configuration_xpath}
Mouse Down xpath=${self_reg_xpath}
Mouse Up xpath=${self_reg_xpath}
Sleep 1
Self Reg Should Be Disabled
Retry Element Click xpath=${config_auth_save_button_xpath}
Sleep 1
Enable Self Reg
Mouse Down xpath=${self_reg_xpath}
Mouse Up xpath=${self_reg_xpath}
Sleep 1
Self Reg Should Be Enabled
Retry Element Click xpath=${config_auth_save_button_xpath}
Sleep 1
Self Reg Should Be Disabled
Checkbox Should Not Be Selected xpath=${self_reg_xpath}
Self Reg Should Be Enabled
Checkbox Should Be Selected xpath=${self_reg_xpath}
Project Creation Should Display
Retry Wait Until Page Contains Element xpath=${project_create_xpath}
Project Creation Should Not Display
Retry Wait Until Page Not Contains Element xpath=${project_create_xpath}
## System settings
Switch To System Settings
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Retry Element Click xpath=${configuration_system_tabsheet_id}
Sleep 1
Switch To Project Quotas
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Project Quotas')]
Sleep 1
Switch To Distribution
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav-group//span[contains(.,'Distributions')]
Sleep 1
Switch To Robot Account
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav-group//span[contains(.,'Robot Accounts')]
Sleep 1
Modify Token Expiration
[Arguments] ${minutes}
Input Text xpath=//*[@id='tokenExpiration'] ${minutes}
Click Button xpath=${config_system_save_button_xpath}
Sleep 1
Token Must Be Match
[Arguments] ${minutes}
Textfield Value Should Be xpath=//*[@id='tokenExpiration'] ${minutes}
Robot Account Token Must Be Match
[Arguments] ${days}
Textfield Value Should Be xpath=//*[@id='robotTokenExpiration'] ${days}
## Replication
Check Verify Remote Cert
Mouse Down xpath=//*[@id='clr-checkbox-verifyRemoteCert']
Mouse Up xpath=//*[@id='clr-checkbox-verifyRemoteCert']
Retry Element Click xpath=${config_save_button_xpath}
Sleep 1
Switch To System Replication
Sleep 1
Switch To Configure
Retry Element Click xpath=//*[@id='config-replication']
Sleep 1
Should Verify Remote Cert Be Enabled
Checkbox Should Not Be Selected xpath=//*[@id='clr-checkbox-verifyRemoteCert']
## Email
Switch To Email
Switch To Configure
Retry Element Click xpath=//*[@id='config-email']
Sleep 1
Config Email
Input Text xpath=//*[@id='mailServer'] smtp.vmware.com
Input Text xpath=//*[@id='emailPort'] 25
Input Text xpath=//*[@id='emailUsername'] example@vmware.com
Input Text xpath=//*[@id='emailPassword'] example
Input Text xpath=//*[@id='emailFrom'] example<example@vmware.com>
Sleep 1
Retry Element Click xpath=//*[@id='emailSSL-wrapper']/label
Sleep 1
Retry Element Click xpath=//*[@id='emailInsecure-wrapper']/label
Sleep 1
Retry Element Click xpath=${config_email_save_button_xpath}
Sleep 6
Verify Email
Textfield Value Should Be xpath=//*[@id='mailServer'] smtp.vmware.com
Textfield Value Should Be xpath=//*[@id='emailPort'] 25
Textfield Value Should Be xpath=//*[@id='emailUsername'] example@vmware.com
Textfield Value Should Be xpath=//*[@id='emailFrom'] example<example@vmware.com>
Checkbox Should Be Selected xpath=//*[@id='emailSSL']
Checkbox Should Not Be Selected xpath=//*[@id='emailInsecure']
Set Scan All To None
Retry Element Click //vulnerability-config//select
Retry Element Click //vulnerability-config//select/option[@value='none']
sleep 1
Retry Element Click ${vulnerbility_save_button_xpath}
Set Scan All To Daily
Retry Element Click //vulnerability-config//select
Retry Element Click //vulnerability-config//select/option[@value='daily']
sleep 1
Retry Element Click ${vulnerbility_save_button_xpath}
Click Scan Now
Retry Element Click //vulnerability-config//button[contains(.,'SCAN')]
Enable Read Only
${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X PUT -d '{"read_only":true}' "https://${ip}/api/v2.0/configurations"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Disable Read Only
${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X PUT -d '{"read_only":false}' "https://${ip}/api/v2.0/configurations"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
## System labels
Switch To System Labels
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Labels')]
## System labels
Switch To Configuration System Setting
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Retry Element Click xpath=${configuration_system_tabsheet_id}
Switch To Configuration Project Quotas
Sleep 1
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Project Quotas')]
Create New Labels
[Arguments] ${labelname}
Retry Element Click xpath=//button[contains(.,'New Label')]
Sleep 1
Input Text xpath=//*[@id='name'] ${labelname}
Sleep 1
Retry Element Click xpath=//hbr-create-edit-label//clr-dropdown/clr-icon
Sleep 1
Retry Element Click xpath=//hbr-create-edit-label//clr-dropdown-menu/label[1]
Sleep 1
Input Text xpath=//*[@id='description'] global
Retry Element Click xpath=//div/form/section/label[4]/button[2]
Wait Until Page Contains ${labelname}
Update A Label
[Arguments] ${labelname}
Retry Element Click xpath=//clr-dg-row[contains(.,'${labelname}')]//clr-checkbox-wrapper
Sleep 1
Retry Element Click xpath=//button[contains(.,'Edit')]
Sleep 1
Input Text xpath=//*[@id='name'] ${labelname}1
Sleep 1
Retry Element Click xpath=//hbr-create-edit-label//form/section//button[2]
Wait Until Page Contains ${labelname}1
Delete A Label
[Arguments] ${labelname}
Retry Element Click xpath=//clr-dg-row[contains(.,'${labelname}')]//clr-checkbox-wrapper
Sleep 1
Retry Element Click xpath=//button[contains(.,'Delete')]
Sleep 3
Retry Element Click xpath=//clr-modal//div//button[contains(.,'DELETE')]
Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${labelname}')]/../div/clr-icon[@shape='success-standard']
## Garbage Collection
Switch To Garbage Collection
Switch To Configure
Sleep 1
Retry Element Click xpath=${gc_config_page}
Wait Until Page Contains Element ${garbage_collection_xpath}
Retry Element Click xpath=${garbage_collection_xpath}
Set GC Schedule
[Arguments] ${type} ${value}=${null}
Switch To Garbage Collection
Retry Double Keywords When Error Retry Element Click ${GC_schedule_edit_btn} Retry Wait Until Page Not Contains Element ${GC_schedule_edit_btn}
Retry Element Click ${GC_schedule_select}
Run Keyword If '${type}'=='custom' Run Keywords Retry Element Click ${vulnerability_dropdown_list_item_custom} AND Retry Text Input ${targetCron_id} ${value}
... ELSE Retry Element Click ${vulnerability_dropdown_list_item_none}
Retry Double Keywords When Error Retry Element Click ${GC_schedule_save_btn} Retry Wait Until Page Not Contains Element ${GC_schedule_save_btn}
Capture Page Screenshot
Click GC Now
Sleep 1
Retry Element Click xpath=${gc_now_xpath}
Sleep 2
View GC Details
Retry Element Click xpath=${gc_log_details_xpath}
Sleep 2
Switch To GC History
Retry Element Click xpath=${gc_log_xpath}
Retry Wait Until Page Contains Job
Add Items To System CVE Allowlist
[Arguments] ${cve_id}
Retry Element Click ${configuration_system_wl_add_btn}
Retry Text Input ${configuration_system_wl_textarea} ${cve_id}
Retry Element Click ${configuration_system_wl_add_confirm_btn}
Retry Element Click ${config_system_save_button_xpath}
Delete Top Item In System CVE Allowlist
[Arguments] ${count}=1
FOR ${idx} IN RANGE 1 ${count}
Retry Element Click ${configuration_system_wl_delete_a_cve_id_icon}
END
Retry Element Click ${config_system_save_button_xpath}
Get Project Count Quota Text From Project Quotas List
[Arguments] ${project_name}
Switch To Project Quotas
${count_quota}= Get Text xpath=//project-quotas//clr-datagrid//clr-dg-row[contains(.,'${project_name}')]//clr-dg-cell[3]//label
[Return] ${count_quota}
Get Project Storage Quota Text From Project Quotas List
[Arguments] ${project_name}
Switch To Configure
Switch To Project Quotas
${storage_quota}= Get Text xpath=//project-quotas//clr-datagrid//clr-dg-row[contains(.,'${project_name}')]//clr-dg-cell[3]//label
[Return] ${storage_quota}
Check Automatic Onboarding And Save
Switch To Configure
Retry Element Click ${cfg_auth_automatic_onboarding_checkbox}
Retry Element Click xpath=${config_auth_save_button_xpath}
Set User Name Claim And Save
[Arguments] ${type}
Switch To Configure
Retry Clear Element Text ${cfg_auth_user_name_claim_input}
Run Keyword If '${type}'=='${null}' Retry Text Input ${cfg_auth_user_name_claim_input} anytext
... ELSE Retry Text Input ${cfg_auth_user_name_claim_input} ${type}
Retry Element Click xpath=${config_auth_save_button_xpath}
Select Distribution
[Arguments] ${name}
Retry Element Click //clr-dg-row[contains(.,'${name}')]//clr-checkbox-wrapper/label
Distribution Exist
[Arguments] ${name} ${endpoint}
Retry Wait Until Page Contains Element //clr-dg-row[contains(.,'${name}') and contains(.,'${endpoint}')]
Distribution Not Exist
[Arguments] ${name} ${endpoint}
Retry Wait Until Page Not Contains Element //clr-dg-row[contains(.,'${name}') and contains(.,'${endpoint}')]
Filter Distribution List
[Arguments] ${name} ${endpoint} ${exsit}=${true}
Retry Double Keywords When Error Retry Element Click ${filter_dist_btn} Wait Until Element Is Visible And Enabled ${filter_dist_input}
Retry Text Input ${filter_dist_input} ${name}
Run Keyword If ${exsit}==${true} Distribution Exist ${name} ${endpoint}
... ELSE Distribution Not Exist ${name} ${endpoint}
Select Provider
[Arguments] ${provider}
Retry Element Click ${distribution_provider_select_id}
Retry Element Click ${distribution_provider_select_id}//option[contains(.,'${provider}')]
Create An New Distribution
[Arguments] ${provider} ${name} ${endpoint}
Switch To Distribution
Retry Element Click ${distribution_add_btn_id}
Select Provider ${provider}
Retry Text Input ${distribution_name_input_id} ${name}
Retry Text Input ${distribution_endpoint_id} ${endpoint}
Retry Double Keywords When Error Retry Element Click ${distribution_add_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${distribution_add_save_btn_id}
Distribution Exist ${name} ${endpoint}
Delete A Distribution
[Arguments] ${name} ${endpoint} ${deletable}=${true}
${is_exsit} evaluate not ${deletable}
Switch To Distribution
Filter Distribution List ${name} ${endpoint}
Retry Double Keywords When Error Select Distribution ${name} Wait Until Element Is Visible //clr-datagrid//clr-dg-footer//clr-checkbox-wrapper/label
Retry Double Keywords When Error Retry Element Click ${distribution_action_btn_id} Wait Until Element Is Visible And Enabled ${distribution_del_btn_id}
Retry Double Keywords When Error Retry Element Click ${distribution_del_btn_id} Wait Until Element Is Visible And Enabled ${delete_confirm_btn}
Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn}
Sleep 10
Filter Distribution List ${name} ${endpoint} exsit=${is_exsit}
Edit A Distribution
[Arguments] ${name} ${endpoint} ${new_endpoint}=${null}
Switch To Distribution
Filter Distribution List ${name} ${endpoint}
Retry Double Keywords When Error Select Distribution ${name} Wait Until Element Is Visible //clr-datagrid//clr-dg-footer//clr-checkbox-wrapper/label times=9
Retry Double Keywords When Error Retry Element Click ${distribution_action_btn_id} Wait Until Element Is Visible And Enabled ${distribution_edit_btn_id}
Retry Double Keywords When Error Retry Element Click ${distribution_edit_btn_id} Wait Until Element Is Visible And Enabled ${distribution_name_input_id}
Retry Text Input ${distribution_endpoint_id} ${new_endpoint}
Retry Double Keywords When Error Retry Element Click ${distribution_add_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${distribution_add_save_btn_id}
Filter Distribution List ${name} ${new_endpoint}
Distribution Exist ${name} ${new_endpoint}

View File

@ -1,69 +1,69 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_create_xpath} //clr-dg-action-bar//button[contains(.,'New')]
${self_reg_xpath} //input[@id='selfReg']
${test_ldap_xpath} //*[@id='authentication']/config-auth/div/button[3]
${config_save_button_xpath} //config//div/button[contains(.,'SAVE')]
${config_email_save_button_xpath} //*[@id='config_email_save']
${config_auth_save_button_xpath} //*[@id='config_auth_save']
${config_system_save_button_xpath} //*[@id='config_system_save']
${vulnerbility_save_button_xpath} //*[@id='config-save']
${configuration_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,' Configuration ')]
${garbage_collection_xpath} //*[@id='config-gc']
${gc_log_xpath} //*[@id='gc-log']
${gc_config_page} //clr-vertical-nav-group-children/a[contains(.,'Garbage')]
${gc_now_xpath} //*[@id='gc']/gc-config//button[contains(.,'GC')]
${gc_log_details_xpath} //*[@id='clr-dg-row26']/clr-dg-cell[6]/a
${configuration_system_tabsheet_id} //*[@id='config-system']
${configuration_authentication_tabsheet_id} //*[@id="config-auth"]
${configuration_project_quotas_tabsheet_id} //*[@id='config-quotas']
${configuration_system_wl_add_btn} //*[@id='show-add-modal-button']
${configuration_system_wl_textarea} //*[@id='allowlist-textarea']
${configuration_system_wl_add_confirm_btn} //*[@id='add-to-system']
${configuration_system_wl_delete_a_cve_id_icon} //system-settings/form/section//ul/li[1]/a[2]/clr-icon
${configuration_sys_repo_readonly_chb_id} //*[@id='repo_read_only_lbl']
${checkbox_delete_untagged_artifacts} //gc-config//clr-toggle-wrapper/label[contains(@for,'delete_untagged')]
${cfg_auth_automatic_onboarding_checkbox} //clr-checkbox-wrapper//label[contains(@for,'oidcAutoOnboard')]
${cfg_auth_user_name_claim_input} //*[@id='oidcUserClaim']
${cfg_auth_ldap_group_admin_dn} //*[@id='ldapGroupAdminDN']
${distribution_add_btn_id} //*[@id='new-instance']
${distribution_provider_select_id} //*[@id='provider']
${distribution_name_input_id} //*[@id='name']
${distribution_endpoint_id} //*[@id='endpoint']
${distribution_description_id} //*[@id='description']
${distribution_auth_none_mode_ratio_id} //*[@id='none_mode']
${distribution_auth_basic_mode_ratio_id} //*[@id='basic_mode']
${distribution_auth_oauth_mode_ratio_id} //*[@id='token_mode']
${distribution_enable_checkbox_id} //*[@id='enabled']
${distribution_insecure_checkbox_id} //*[@id='insecure']
${distribution_add_save_btn_id} //*[@id='instance-ok']
${distribution_action_btn_id} //*[@id='member-action']
${distribution_del_btn_id} //*[@id='distribution-delete']
${distribution_edit_btn_id} //*[@id='distribution-edit']
${filter_dist_btn} //hbr-filter//clr-icon[contains(@class,'search-btn')]
${filter_dist_input} //hbr-filter//input
${GC_schedule_edit_btn} //*[@id='editSchedule']
${GC_schedule_select} //*[@id='selectPolicy']
${GC_schedule_save_btn} //*[@id='config-save']
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_create_xpath} //clr-dg-action-bar//button[contains(.,'New')]
${self_reg_xpath} //input[@id='selfReg']
${test_ldap_xpath} //*[@id='authentication']/config-auth/div/button[3]
${config_save_button_xpath} //config//div/button[contains(.,'SAVE')]
${config_email_save_button_xpath} //*[@id='config_email_save']
${config_auth_save_button_xpath} //*[@id='config_auth_save']
${config_system_save_button_xpath} //*[@id='config_system_save']
${vulnerbility_save_button_xpath} //*[@id='config-save']
${configuration_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,' Configuration ')]
${garbage_collection_xpath} //*[@id='config-gc']
${gc_log_xpath} //*[@id='gc-log']
${gc_config_page} //clr-vertical-nav-group-children/a[contains(.,'Garbage')]
${gc_now_xpath} //*[@id='gc']/gc-config//button[contains(.,'GC')]
${gc_log_details_xpath} //*[@id='clr-dg-row26']/clr-dg-cell[6]/a
${configuration_system_tabsheet_id} //*[@id='config-system']
${configuration_authentication_tabsheet_id} //*[@id="config-auth"]
${configuration_project_quotas_tabsheet_id} //*[@id='config-quotas']
${configuration_system_wl_add_btn} //*[@id='show-add-modal-button']
${configuration_system_wl_textarea} //*[@id='allowlist-textarea']
${configuration_system_wl_add_confirm_btn} //*[@id='add-to-system']
${configuration_system_wl_delete_a_cve_id_icon} //system-settings/form/section//ul/li[1]/a[2]/clr-icon
${configuration_sys_repo_readonly_chb_id} //*[@id='repo_read_only_lbl']
${checkbox_delete_untagged_artifacts} //gc-config//clr-toggle-wrapper/label[contains(@for,'delete_untagged')]
${cfg_auth_automatic_onboarding_checkbox} //clr-checkbox-wrapper//label[contains(@for,'oidcAutoOnboard')]
${cfg_auth_user_name_claim_input} //*[@id='oidcUserClaim']
${cfg_auth_ldap_group_admin_dn} //*[@id='ldapGroupAdminDN']
${distribution_add_btn_id} //*[@id='new-instance']
${distribution_provider_select_id} //*[@id='provider']
${distribution_name_input_id} //*[@id='name']
${distribution_endpoint_id} //*[@id='endpoint']
${distribution_description_id} //*[@id='description']
${distribution_auth_none_mode_ratio_id} //*[@id='none_mode']
${distribution_auth_basic_mode_ratio_id} //*[@id='basic_mode']
${distribution_auth_oauth_mode_ratio_id} //*[@id='token_mode']
${distribution_enable_checkbox_id} //*[@id='enabled']
${distribution_insecure_checkbox_id} //*[@id='insecure']
${distribution_add_save_btn_id} //*[@id='instance-ok']
${distribution_action_btn_id} //*[@id='member-action']
${distribution_del_btn_id} //*[@id='distribution-delete']
${distribution_edit_btn_id} //*[@id='distribution-edit']
${filter_dist_btn} //hbr-filter//clr-icon[contains(@class,'search-btn')]
${filter_dist_input} //hbr-filter//input
${GC_schedule_edit_btn} //*[@id='editSchedule']
${GC_schedule_select} //*[@id='selectPolicy']
${GC_schedule_save_btn} //*[@id='config-save']

View File

@ -1,53 +1,53 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
GC Now
[Arguments] ${harbor_url} ${login_user} ${login_pwd} ${untag}=${false}
Switch To Garbage Collection
Run Keyword If '${untag}' == '${true}' Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
Click GC Now
Logout Harbor
Sleep 2
Sign In Harbor ${harbor_url} ${login_user} ${login_pwd}
Switch To Garbage Collection
Sleep 1
#Switch To GC History
#Retry Keyword N Times When Error 60 Retry Wait Until Page Contains Finished
Retry GC Should Be Successful
[Arguments] ${history_id} ${expected_msg}
Retry Keyword N Times When Error 15 GC Should Be Successful ${history_id} ${expected_msg}
GC Should Be Successful
[Arguments] ${history_id} ${expected_msg}
${rc} ${output}= Run And Return Rc And Output curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -i --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/gc/${history_id}/log"
Log All ${output}
Should Be Equal As Integers ${rc} 0
Run Keyword If '${expected_msg}' != '${null}' Should Contain ${output} ${expected_msg}
Should Contain ${output} success to run gc in job.
Get GC Logs
[Arguments]
${cmd}= Set Variable curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/gc"
Log All cmd:${cmd}
${rc} ${output}= Run And Return Rc And Output ${cmd}
Log All ${output}
[Return] ${output}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
GC Now
[Arguments] ${harbor_url} ${login_user} ${login_pwd} ${untag}=${false}
Switch To Garbage Collection
Run Keyword If '${untag}' == '${true}' Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
Click GC Now
Logout Harbor
Sleep 2
Sign In Harbor ${harbor_url} ${login_user} ${login_pwd}
Switch To Garbage Collection
Sleep 1
#Switch To GC History
#Retry Keyword N Times When Error 60 Retry Wait Until Page Contains Finished
Retry GC Should Be Successful
[Arguments] ${history_id} ${expected_msg}
Retry Keyword N Times When Error 15 GC Should Be Successful ${history_id} ${expected_msg}
GC Should Be Successful
[Arguments] ${history_id} ${expected_msg}
${rc} ${output}= Run And Return Rc And Output curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -i --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/gc/${history_id}/log"
Log All ${output}
Should Be Equal As Integers ${rc} 0
Run Keyword If '${expected_msg}' != '${null}' Should Contain ${output} ${expected_msg}
Should Contain ${output} success to run gc in job.
Get GC Logs
[Arguments]
${cmd}= Set Variable curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/gc"
Log All cmd:${cmd}
${rc} ${output}= Run And Return Rc And Output ${cmd}
Log All ${output}
[Return] ${output}

View File

@ -1,57 +1,57 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Sign In Harbor
[Arguments] ${url} ${user} ${pw}
Go To ${url}
Retry Wait Element ${harbor_span_title}
Retry Wait Element ${login_name}
Retry Wait Element ${login_pwd}
Input Text ${login_name} ${user}
Input Text ${login_pwd} ${pw}
Retry Wait Element ${login_btn}
Retry Button Click ${login_btn}
Log To Console ${user}
Retry Wait Element xpath=//span[contains(., '${user}')]
Capture Screenshot And Source
Capture Page Screenshot
Log Source
Sign Up Should Not Display
Retry Wait Until Page Not Contains Element xpath=${sign_up_button_xpath}
Create An New User
[Arguments] ${url} ${username} ${email} ${realname} ${newPassword} ${comment}
Go To ${url}
Retry Wait Element ${harbor_span_title}
Retry Element Click xpath=${sign_up_for_an_account_xpath}
Retry Text Input xpath=${username_xpath} ${username}
Retry Text Input xpath=${email_xpath} ${email}
Retry Text Input xpath=${realname_xpath} ${realname}
Retry Text Input xpath=${newPassword_xpath} ${newPassword}
Retry Text Input xpath=${confirmPassword_xpath} ${newPassword}
Retry Text Input xpath=${comment_xpath} ${comment}
Retry Double Keywords When Error Retry Element Click ${signup_xpath} Retry Wait Until Page Not Contains Element ${signup_xpath}
Retry Text Input ${login_name} ${username}
Retry Text Input ${login_pwd} ${newPassword}
Retry Double Keywords When Error Retry Element Click ${login_btn} Retry Wait Until Page Not Contains Element ${login_btn}
Retry Wait Element xpath=//span[contains(., '${username}')]
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Sign In Harbor
[Arguments] ${url} ${user} ${pw}
Go To ${url}
Retry Wait Element ${harbor_span_title}
Retry Wait Element ${login_name}
Retry Wait Element ${login_pwd}
Input Text ${login_name} ${user}
Input Text ${login_pwd} ${pw}
Retry Wait Element ${login_btn}
Retry Button Click ${login_btn}
Log To Console ${user}
Retry Wait Element xpath=//span[contains(., '${user}')]
Capture Screenshot And Source
Capture Page Screenshot
Log Source
Sign Up Should Not Display
Retry Wait Until Page Not Contains Element xpath=${sign_up_button_xpath}
Create An New User
[Arguments] ${url} ${username} ${email} ${realname} ${newPassword} ${comment}
Go To ${url}
Retry Wait Element ${harbor_span_title}
Retry Element Click xpath=${sign_up_for_an_account_xpath}
Retry Text Input xpath=${username_xpath} ${username}
Retry Text Input xpath=${email_xpath} ${email}
Retry Text Input xpath=${realname_xpath} ${realname}
Retry Text Input xpath=${newPassword_xpath} ${newPassword}
Retry Text Input xpath=${confirmPassword_xpath} ${newPassword}
Retry Text Input xpath=${comment_xpath} ${comment}
Retry Double Keywords When Error Retry Element Click ${signup_xpath} Retry Wait Until Page Not Contains Element ${signup_xpath}
Retry Text Input ${login_name} ${username}
Retry Text Input ${login_pwd} ${newPassword}
Retry Double Keywords When Error Retry Element Click ${login_btn} Retry Wait Until Page Not Contains Element ${login_btn}
Retry Wait Element xpath=//span[contains(., '${username}')]

View File

@ -1,33 +1,33 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${sign_up_for_an_account_xpath} /html/body/harbor-app/sign-in/clr-main-container/div/form/div[1]/a
${sign_up_button_xpath} //a[@class='signup']
${username_xpath} //*[@id='username']
${email_xpath} //*[@id='email']
${realname_xpath} //*[@id='realname']
${newPassword_xpath} //*[@id='newPassword']
${confirmPassword_xpath} //*[@id='confirmPassword']
${comment_xpath} //*[@id='comment']
${signup_xpath} //*[@id='sign-up']
${search_input} //*[@id='search_input']
${login_btn} //*[@id='log_in']
${harbor_span_title} //span[contains(., 'Harbor')]
${login_name} //*[@id='login_username']
${login_pwd} //*[@id='login_password']
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${sign_up_for_an_account_xpath} /html/body/harbor-app/sign-in/clr-main-container/div/form/div[1]/a
${sign_up_button_xpath} //a[@class='signup']
${username_xpath} //*[@id='username']
${email_xpath} //*[@id='email']
${realname_xpath} //*[@id='realname']
${newPassword_xpath} //*[@id='newPassword']
${confirmPassword_xpath} //*[@id='confirmPassword']
${comment_xpath} //*[@id='comment']
${signup_xpath} //*[@id='sign-up']
${search_input} //*[@id='search_input']
${login_btn} //*[@id='log_in']
${harbor_span_title} //span[contains(., 'Harbor')]
${login_name} //*[@id='login_username']
${login_pwd} //*[@id='login_password']

View File

@ -1,38 +1,38 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Switch To Configuration Authentication
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Retry Element Click xpath=${configuration_authentication_tabsheet_id}
Set LDAP Group Admin DN
[Arguments] ${group_dn}
Switch To Configuration Authentication
Retry Text Input ${cfg_auth_ldap_group_admin_dn} ${group_dn}
Retry Element Click ${config_auth_save_button_xpath}
Ldap User Should Not See Change Password
Retry Element Click //clr-header//clr-dropdown[2]//button
Sleep 2
Page Should Not Contain Password
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Switch To Configuration Authentication
Sleep 1
Retry Element Click xpath=${configuration_xpath}
Retry Element Click xpath=${configuration_authentication_tabsheet_id}
Set LDAP Group Admin DN
[Arguments] ${group_dn}
Switch To Configuration Authentication
Retry Text Input ${cfg_auth_ldap_group_admin_dn} ${group_dn}
Retry Element Click ${config_auth_save_button_xpath}
Ldap User Should Not See Change Password
Retry Element Click //clr-header//clr-dropdown[2]//button
Sleep 2
Page Should Not Contain Password

View File

@ -1,67 +1,67 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Sign In Harbor With OIDC User
[Arguments] ${url} ${username}=${OIDC_USERNAME} ${password}=password ${is_onboard}=${false} ${username_claim}=${null} ${login_with_provider}=email
${full_name}= Set Variable If '${login_with_provider}' == 'email' ${username}@example.com ${username}
${head_username}= Set Variable If '${username_claim}' == 'email' xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header//clr-dropdown//button[contains(.,'${full_name}')] xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header//clr-dropdown//button[contains(.,'${username}')]
Init Chrome Driver
Go To ${url}
Retry Element Click ${log_oidc_provider_btn}
Run Keyword If '${login_with_provider}' == 'email' Retry Element Click ${login_with_email_btn}
Run Keyword If '${login_with_provider}' == 'ldap' Retry Element Click ${login_with_ldap_btn}
Retry Text Input ${dex_login_btn} ${full_name}
Retry Text Input ${dex_pwd_btn} ${password}
Retry Element Click ${submit_login_btn}
Retry Element Click ${grant_btn}
#If input box for harbor user name is visible, it means it's the 1st time login of this user,
# but if this user has been logged into harbor successfully, this input box will not show up,
# so there is condition branch for this stituation.
${isVisible}= Run Keyword And Return Status Element Should Be Visible ${oidc_username_input}
Run Keyword If ${is_onboard} == ${true} Should Not Be True ${isVisible}
Run Keyword If '${isVisible}' == 'True' Run Keywords Retry Text Input ${oidc_username_input} ${username} AND Retry Element Click ${save_btn}
Retry Wait Element ${head_username}
Capture Page Screenshot
${name_display}= Get Text xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header//clr-dropdown[2]//button/span
Run Keyword If '${username_claim}' == 'email' Should Be Equal As Strings ${name_display} ${full_name}
... ELSE Should Be Equal As Strings ${name_display} ${username}
Get Secrete By API
[Arguments] ${url} ${username}=${OIDC_USERNAME}
${json}= Run Curl And Return Json curl -s -k -X GET --header 'Accept: application/json' -u '${HARBOR_ADMIN}:${HARBOR_PASSWORD}' '${url}/api/v2.0/users/search?username=${username}'
${user_info}= Set Variable ${json[0]}
${user_id}= Set Variable ${user_info["user_id"]}
${json}= Run Curl And Return Json curl -s -k -X GET --header 'Accept: application/json' -u '${HARBOR_ADMIN}:${HARBOR_PASSWORD}' '${url}/api/v2.0/users/${user_id}'
${secret}= Set Variable ${json["oidc_user_meta"]["secret"]}
[Return] ${secret}
Generate And Return Secret
[Arguments] ${url}
Retry Element Click ${head_admin_xpath}
Retry Element Click ${user_profile_xpath}
Retry Element Click ${more_btn}
Retry Element Click ${generate_secret_btn}
Retry Double Keywords When Error Retry Element Click ${confirm_btn} Retry Wait Until Page Not Contains Element ${confirm_btn}
Retry Wait Until Page Contains Cli secret setting is successful
${secret}= Get Secrete By API ${url}
[Return] ${secret}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Sign In Harbor With OIDC User
[Arguments] ${url} ${username}=${OIDC_USERNAME} ${password}=password ${is_onboard}=${false} ${username_claim}=${null} ${login_with_provider}=email
${full_name}= Set Variable If '${login_with_provider}' == 'email' ${username}@example.com ${username}
${head_username}= Set Variable If '${username_claim}' == 'email' xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header//clr-dropdown//button[contains(.,'${full_name}')] xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header//clr-dropdown//button[contains(.,'${username}')]
Init Chrome Driver
Go To ${url}
Retry Element Click ${log_oidc_provider_btn}
Run Keyword If '${login_with_provider}' == 'email' Retry Element Click ${login_with_email_btn}
Run Keyword If '${login_with_provider}' == 'ldap' Retry Element Click ${login_with_ldap_btn}
Retry Text Input ${dex_login_btn} ${full_name}
Retry Text Input ${dex_pwd_btn} ${password}
Retry Element Click ${submit_login_btn}
Retry Element Click ${grant_btn}
#If input box for harbor user name is visible, it means it's the 1st time login of this user,
# but if this user has been logged into harbor successfully, this input box will not show up,
# so there is condition branch for this stituation.
${isVisible}= Run Keyword And Return Status Element Should Be Visible ${oidc_username_input}
Run Keyword If ${is_onboard} == ${true} Should Not Be True ${isVisible}
Run Keyword If '${isVisible}' == 'True' Run Keywords Retry Text Input ${oidc_username_input} ${username} AND Retry Element Click ${save_btn}
Retry Wait Element ${head_username}
Capture Page Screenshot
${name_display}= Get Text xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header//clr-dropdown[2]//button/span
Run Keyword If '${username_claim}' == 'email' Should Be Equal As Strings ${name_display} ${full_name}
... ELSE Should Be Equal As Strings ${name_display} ${username}
Get Secrete By API
[Arguments] ${url} ${username}=${OIDC_USERNAME}
${json}= Run Curl And Return Json curl -s -k -X GET --header 'Accept: application/json' -u '${HARBOR_ADMIN}:${HARBOR_PASSWORD}' '${url}/api/v2.0/users/search?username=${username}'
${user_info}= Set Variable ${json[0]}
${user_id}= Set Variable ${user_info["user_id"]}
${json}= Run Curl And Return Json curl -s -k -X GET --header 'Accept: application/json' -u '${HARBOR_ADMIN}:${HARBOR_PASSWORD}' '${url}/api/v2.0/users/${user_id}'
${secret}= Set Variable ${json["oidc_user_meta"]["secret"]}
[Return] ${secret}
Generate And Return Secret
[Arguments] ${url}
Retry Element Click ${head_admin_xpath}
Retry Element Click ${user_profile_xpath}
Retry Element Click ${more_btn}
Retry Element Click ${generate_secret_btn}
Retry Double Keywords When Error Retry Element Click ${confirm_btn} Retry Wait Until Page Not Contains Element ${confirm_btn}
Retry Wait Until Page Contains Cli secret setting is successful
${secret}= Get Secrete By API ${url}
[Return] ${secret}

View File

@ -1,30 +1,30 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${log_oidc_provider_btn} //*[@id='log_oidc']
${login_with_email_btn} //span[contains(., 'Log in with Email')]
${login_with_ldap_btn} //span[contains(., 'Log in with LDAP')]
${dex_login_btn} //*[@id='login']
${dex_pwd_btn} //*[@id='password']
${submit_login_btn} //*[@id='submit-login']
${grant_btn} xpath=/html/body/div[2]/div/div[2]/div[1]/form/button
${oidc_username_input} //*[@id='oidcUsername']
${save_btn} //*[@id='saveButton']
${OIDC_USERNAME} test1
${generate_secret_btn} //*[@id='generate-cli-btn']
${more_btn} //*[@id='hidden-generate-cli']
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${log_oidc_provider_btn} //*[@id='log_oidc']
${login_with_email_btn} //span[contains(., 'Log in with Email')]
${login_with_ldap_btn} //span[contains(., 'Log in with LDAP')]
${dex_login_btn} //*[@id='login']
${dex_pwd_btn} //*[@id='password']
${submit_login_btn} //*[@id='submit-login']
${grant_btn} xpath=/html/body/div[2]/div/div[2]/div[1]/form/button
${oidc_username_input} //*[@id='oidcUsername']
${save_btn} //*[@id='saveButton']
${OIDC_USERNAME} test1
${generate_secret_btn} //*[@id='generate-cli-btn']
${more_btn} //*[@id='hidden-generate-cli']

View File

@ -1,32 +1,32 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${artifact_action_xpath} //clr-dg-action-bar/clr-dropdown/span[contains(@class,'dropdown-toggle')]
${artifact_action_delete_xpath} //clr-dropdown-menu//div[contains(.,'Delete')]
${artifact_action_copy_xpath} //clr-dropdown-menu//div[contains(.,'Copy') and @aria-label='retag']
${artifact_achieve_icon} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]//clr-dg-cell[1]//clr-tooltip//a
${artifact_rows} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]
${archive_rows} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]//clr-dg-cell[1]//clr-tooltip//a
${artifact_list_spinner} xpath=//clr-datagrid//clr-spinner
${artifact_tag_component} xpath=//artifact-tag
${add_tag_button} xpath=//*[@id='new-tag']
${tag_name_xpath} xpath=//*[@id='name']
${add_ok_button} xpath=//*[@id='add-ok']
${delete_tag_button} xpath=//*[@id='delete-tag']
${dialog_delete_button} xpath=//clr-modal//button[contains(.,'DELETE')]
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${artifact_action_xpath} //clr-dg-action-bar/clr-dropdown/span[contains(@class,'dropdown-toggle')]
${artifact_action_delete_xpath} //clr-dropdown-menu//div[contains(.,'Delete')]
${artifact_action_copy_xpath} //clr-dropdown-menu//div[contains(.,'Copy') and @aria-label='retag']
${artifact_achieve_icon} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]//clr-dg-cell[1]//clr-tooltip//a
${artifact_rows} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]
${archive_rows} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]//clr-dg-cell[1]//clr-tooltip//a
${artifact_list_spinner} xpath=//clr-datagrid//clr-spinner
${artifact_tag_component} xpath=//artifact-tag
${add_tag_button} xpath=//*[@id='new-tag']
${tag_name_xpath} xpath=//*[@id='name']
${add_ok_button} xpath=//*[@id='add-ok']
${delete_tag_button} xpath=//*[@id='delete-tag']
${dialog_delete_button} xpath=//clr-modal//button[contains(.,'DELETE')]

View File

@ -1,51 +1,51 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
Go Into Artifact
[Arguments] ${tag}
Retry Wait Until Page Not Contains Element ${artifact_list_spinner}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tag}')]//a[contains(.,'sha256')]
Retry Wait Until Page Contains Element ${artifact_tag_component}
Retry Wait Until Page Not Contains Element ${artifact_list_spinner}
Should Contain Tag
[Arguments] ${tag}
Retry Wait Until Page Contains Element xpath=//artifact-tag//clr-dg-row//clr-dg-cell[contains(.,'${tag}')]
Should Not Contain Tag
[Arguments] ${tag}
Retry Wait Until Page Not Contains Element xpath=//artifact-tag//clr-dg-row//clr-dg-cell[contains(.,'${tag}')]
Add A New Tag
[Arguments] ${tag}
Retry Double Keywords When Error Retry Element Click ${add_tag_button} Retry Wait Element ${tag_name_xpath}
Retry Text Input ${tag_name_xpath} ${tag}
Retry Double Keywords When Error Retry Element Click ${add_ok_button} Should Contain Tag ${tag}
Delete A Tag
[Arguments] ${tag}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tag}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Double Keywords When Error Retry Element Click ${delete_tag_button} Retry Wait Until Page Contains Element ${dialog_delete_button}
Retry Double Keywords When Error Retry Element Click ${dialog_delete_button} Should Not Contain Tag ${tag}
Should Contain Artifact
Retry Wait Until Page Contains Element xpath=//artifact-list-tab//clr-dg-row//a[contains(.,'sha256')]
Should Not Contain Any Artifact
Retry Wait Until Page Not Contains Element xpath=//artifact-list-tab//clr-dg-row
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
Go Into Artifact
[Arguments] ${tag}
Retry Wait Until Page Not Contains Element ${artifact_list_spinner}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tag}')]//a[contains(.,'sha256')]
Retry Wait Until Page Contains Element ${artifact_tag_component}
Retry Wait Until Page Not Contains Element ${artifact_list_spinner}
Should Contain Tag
[Arguments] ${tag}
Retry Wait Until Page Contains Element xpath=//artifact-tag//clr-dg-row//clr-dg-cell[contains(.,'${tag}')]
Should Not Contain Tag
[Arguments] ${tag}
Retry Wait Until Page Not Contains Element xpath=//artifact-tag//clr-dg-row//clr-dg-cell[contains(.,'${tag}')]
Add A New Tag
[Arguments] ${tag}
Retry Double Keywords When Error Retry Element Click ${add_tag_button} Retry Wait Element ${tag_name_xpath}
Retry Text Input ${tag_name_xpath} ${tag}
Retry Double Keywords When Error Retry Element Click ${add_ok_button} Should Contain Tag ${tag}
Delete A Tag
[Arguments] ${tag}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tag}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Double Keywords When Error Retry Element Click ${delete_tag_button} Retry Wait Until Page Contains Element ${dialog_delete_button}
Retry Double Keywords When Error Retry Element Click ${dialog_delete_button} Should Not Contain Tag ${tag}
Should Contain Artifact
Retry Wait Until Page Contains Element xpath=//artifact-list-tab//clr-dg-row//a[contains(.,'sha256')]
Should Not Contain Any Artifact
Retry Wait Until Page Not Contains Element xpath=//artifact-list-tab//clr-dg-row

View File

@ -1,6 +1,6 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_configuration_wl_delete_a_cve_id_icon} //hbr-project-policy-config/form/section//ul/li[1]/a[2]/clr-icon
${project_configuration_wl_project_add_system_btn} //button[@id='add-system']
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_configuration_wl_delete_a_cve_id_icon} //hbr-project-policy-config/form/section//ul/li[1]/a[2]/clr-icon
${project_configuration_wl_project_add_system_btn} //button[@id='add-system']

View File

@ -1,88 +1,88 @@
*** Settings ***
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Goto Project Config
Sleep 3
Retry Element Click //project-detail//ul/li[contains(.,'Summary')]
Sleep 3
Retry Double Keywords When Error Retry Element Click //project-detail//ul/li[contains(.,'Configuration')] Retry Wait Element //clr-checkbox-wrapper/label[contains(.,'Enable content trust')]
Sleep 2
Click Project Public
Mouse Down //hbr-project-policy-config//input[@name='public']
Mouse Up //hbr-project-policy-config//input[@name='public']
Click Content Trust
Mouse Down //hbr-project-policy-config//input[@name='content-trust']
Mouse Up //hbr-project-policy-config//input[@name='content-trust']
Click Prevent Running
Mouse Down //hbr-project-policy-config//input[@name='prevent-vulnerability-image']
Mouse Up //hbr-project-policy-config//input[@name='prevent-vulnerability-image']
Select Prevent Level
#value NEGLIGIBLE LOW MEDIUM HIGH
[Arguments] ${level}
Retry Element Click //hbr-project-policy-config//select
Retry Element Click //hbr-project-policy-config//select/option[contains(.,'${level}')]
Click Auto Scan
Mouse Down //hbr-project-policy-config//input[@name='scan-image-on-push']
Mouse Up //hbr-project-policy-config//input[@name='scan-image-on-push']
Save Project Config
Sleep 1
Retry Element Click //hbr-project-policy-config//button[contains(.,'SAVE')]
Public Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='public']
Project Should Be Public
[Arguments] ${projectName}
Retry Wait Until Page Contains Element //clr-dg-row[contains(.,'${projectName}')]//clr-dg-cell[contains(.,'Public')]
Content Trust Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='content-trust']
Prevent Running Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='prevent-vulnerability-image']
Auto Scan Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='scan-image-on-push']
Select System CVE Allowlist
Retry Element Click ${project_config_system_wl_radio_input}
Select Prject CVE Allowlist
Retry Element Click ${project_config_project_wl_radio_input}
Add System CVE Allowlist to Project CVE Allowlist By Add System Button Click
Goto Project Config
Select Prject CVE Allowlist
Retry Element Click ${project_configuration_wl_project_add_system_btn}
Retry Element Click ${project_config_save_btn}
Set Project To Project Level CVE Allowlist
Goto Project Config
Select Prject CVE Allowlist
Retry Element Click ${project_config_save_btn}
Add Items to Project CVE Allowlist
[Arguments] ${cve_id}
Goto Project Config
Select Prject CVE Allowlist
Retry Element Click ${project_config_project_wl_add_btn}
Retry Text Input ${configuration_system_wl_textarea} ${cve_id}
Retry Element Click ${project_config_project_wl_add_confirm_btn}
Retry Element Click ${project_config_save_btn}
Delete Top Item In Project CVE Allowlist
[Arguments]
Goto Project Config
Retry Element Click ${project_configuration_wl_delete_a_cve_id_icon}
Retry Element Click ${project_config_save_btn}
*** Settings ***
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Goto Project Config
Sleep 3
Retry Element Click //project-detail//ul/li[contains(.,'Summary')]
Sleep 3
Retry Double Keywords When Error Retry Element Click //project-detail//ul/li[contains(.,'Configuration')] Retry Wait Element //clr-checkbox-wrapper/label[contains(.,'Enable content trust')]
Sleep 2
Click Project Public
Mouse Down //hbr-project-policy-config//input[@name='public']
Mouse Up //hbr-project-policy-config//input[@name='public']
Click Content Trust
Mouse Down //hbr-project-policy-config//input[@name='content-trust']
Mouse Up //hbr-project-policy-config//input[@name='content-trust']
Click Prevent Running
Mouse Down //hbr-project-policy-config//input[@name='prevent-vulnerability-image']
Mouse Up //hbr-project-policy-config//input[@name='prevent-vulnerability-image']
Select Prevent Level
#value NEGLIGIBLE LOW MEDIUM HIGH
[Arguments] ${level}
Retry Element Click //hbr-project-policy-config//select
Retry Element Click //hbr-project-policy-config//select/option[contains(.,'${level}')]
Click Auto Scan
Mouse Down //hbr-project-policy-config//input[@name='scan-image-on-push']
Mouse Up //hbr-project-policy-config//input[@name='scan-image-on-push']
Save Project Config
Sleep 1
Retry Element Click //hbr-project-policy-config//button[contains(.,'SAVE')]
Public Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='public']
Project Should Be Public
[Arguments] ${projectName}
Retry Wait Until Page Contains Element //clr-dg-row[contains(.,'${projectName}')]//clr-dg-cell[contains(.,'Public')]
Content Trust Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='content-trust']
Prevent Running Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='prevent-vulnerability-image']
Auto Scan Should Be Selected
Checkbox Should Be Selected //hbr-project-policy-config//input[@name='scan-image-on-push']
Select System CVE Allowlist
Retry Element Click ${project_config_system_wl_radio_input}
Select Prject CVE Allowlist
Retry Element Click ${project_config_project_wl_radio_input}
Add System CVE Allowlist to Project CVE Allowlist By Add System Button Click
Goto Project Config
Select Prject CVE Allowlist
Retry Element Click ${project_configuration_wl_project_add_system_btn}
Retry Element Click ${project_config_save_btn}
Set Project To Project Level CVE Allowlist
Goto Project Config
Select Prject CVE Allowlist
Retry Element Click ${project_config_save_btn}
Add Items to Project CVE Allowlist
[Arguments] ${cve_id}
Goto Project Config
Select Prject CVE Allowlist
Retry Element Click ${project_config_project_wl_add_btn}
Retry Text Input ${configuration_system_wl_textarea} ${cve_id}
Retry Element Click ${project_config_project_wl_add_confirm_btn}
Retry Element Click ${project_config_save_btn}
Delete Top Item In Project CVE Allowlist
[Arguments]
Goto Project Config
Retry Element Click ${project_configuration_wl_delete_a_cve_id_icon}
Retry Element Click ${project_config_save_btn}

View File

@ -1,14 +1,14 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${retag_btn} //clr-dg-action-bar//button[contains(.,'Retag')]
${copy_project_name_xpath} //*[@id='project-name']
${copy_repo_name_xpath} //*[@id='repo-name']
${tag_name_xpath} //*[@id='tag-name']
${confirm_btn} //button[contains(.,'CONFIRM')]
${target_image_name} target-alpine
${image_tag} 3.2.10-alpine
${tag_value_xpath} //clr-dg-row[contains(.,'${image_tag}')]
${modal-dialog} div.modal-dialog
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${retag_btn} //clr-dg-action-bar//button[contains(.,'Retag')]
${copy_project_name_xpath} //*[@id='project-name']
${copy_repo_name_xpath} //*[@id='repo-name']
${tag_name_xpath} //*[@id='tag-name']
${confirm_btn} //button[contains(.,'CONFIRM')]
${target_image_name} target-alpine
${image_tag} 3.2.10-alpine
${tag_value_xpath} //clr-dg-row[contains(.,'${image_tag}')]
${modal-dialog} div.modal-dialog

View File

@ -1,17 +1,17 @@
Documentation This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
Copy Image
[Arguments] ${tag} ${projectname} ${reponame}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tag}')]//label
Sleep 1
Retry Element Click ${artifact_action_xpath}
Sleep 1
Retry Element Click ${artifact_action_copy_xpath}
Sleep 1
#input necessary info
Retry Text Input xpath=${copy_project_name_xpath} ${projectname}
Retry Text Input xpath=${copy_repo_name_xpath} ${reponame}
Retry Double Keywords When Error Retry Element Click ${confirm_btn} Retry Wait Until Page Not Contains Element ${confirm_btn}
Documentation This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
Copy Image
[Arguments] ${tag} ${projectname} ${reponame}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tag}')]//label
Sleep 1
Retry Element Click ${artifact_action_xpath}
Sleep 1
Retry Element Click ${artifact_action_copy_xpath}
Sleep 1
#input necessary info
Retry Text Input xpath=${copy_project_name_xpath} ${projectname}
Retry Text Input xpath=${copy_repo_name_xpath} ${reponame}
Retry Double Keywords When Error Retry Element Click ${confirm_btn} Retry Wait Until Page Not Contains Element ${confirm_btn}

View File

@ -1,50 +1,50 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
Switch To Project Charts
Retry Element Click ${project_chart_tabpage}
Retry Wait Until Page Contains Element ${project_chart_list}
Upload Chart files
${current_dir}= Run pwd
Run wget ${harbor_chart_file_url}
Run wget ${harbor_chart_prov_file_url}
Run wget ${prometheus_chart_file_url}
Retry Double Keywords When Error Retry Element Click xpath=${upload_chart_button} Retry Wait Until Page Contains Element xpath=${upload_action_button}
${prometheus_file_path} Set Variable ${current_dir}/${prometheus_chart_filename}
Choose File xpath=${chart_file_browse} ${prometheus_file_path}
Retry Double Keywords When Error Retry Element Click xpath=${upload_action_button} Retry Wait Until Page Not Contains Element xpath=${upload_action_button}
Retry Double Keywords When Error Retry Element Click xpath=${upload_chart_button} Retry Wait Until Page Contains Element xpath=${upload_action_button}
Retry Wait Until Page Contains ${prometheus_chart_name}
${harbor_file_path} Set Variable ${current_dir}/${harbor_chart_filename}
${harbor_prov_file_path} Set Variable ${current_dir}/${harbor_chart_prov_filename}
Choose File xpath=${chart_file_browse} ${harbor_file_path}
Choose File xpath=${chart_prov_browse} ${harbor_prov_file_path}
Retry Double Keywords When Error Retry Element Click xpath=${upload_action_button} Retry Wait Until Page Not Contains Element xpath=${upload_action_button}
Retry Wait Until Page Contains ${harbor_chart_name}
Go Into Chart Version
[Arguments] ${chart_name}
Retry Element Click xpath=//hbr-helm-chart//a[contains(., '${chart_name}')]
Sleep 3
Go Into Chart Detail
[Arguments] ${version_name}
Retry Element Click xpath=//hbr-helm-chart-version//a[contains(., '${version_name}')]
Retry Wait Until Page Contains Element ${chart_detail}
Multi-delete Chart Files
[Arguments] @{obj}
Switch To Project Charts
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
#Retry Element Click xpath=${version_checkbox}
Retry Double Keywords When Error Retry Element Click xpath=${version_delete} Retry Wait Until Page Contains Element ${version_confirm_delete}
Retry Double Keywords When Error Retry Element Click ${version_confirm_delete} Retry Wait Until Page Not Contains Element xpath=${version_confirm_delete}
Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any charts!\")]
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
Switch To Project Charts
Retry Element Click ${project_chart_tabpage}
Retry Wait Until Page Contains Element ${project_chart_list}
Upload Chart files
${current_dir}= Run pwd
Run wget ${harbor_chart_file_url}
Run wget ${harbor_chart_prov_file_url}
Run wget ${prometheus_chart_file_url}
Retry Double Keywords When Error Retry Element Click xpath=${upload_chart_button} Retry Wait Until Page Contains Element xpath=${upload_action_button}
${prometheus_file_path} Set Variable ${current_dir}/${prometheus_chart_filename}
Choose File xpath=${chart_file_browse} ${prometheus_file_path}
Retry Double Keywords When Error Retry Element Click xpath=${upload_action_button} Retry Wait Until Page Not Contains Element xpath=${upload_action_button}
Retry Double Keywords When Error Retry Element Click xpath=${upload_chart_button} Retry Wait Until Page Contains Element xpath=${upload_action_button}
Retry Wait Until Page Contains ${prometheus_chart_name}
${harbor_file_path} Set Variable ${current_dir}/${harbor_chart_filename}
${harbor_prov_file_path} Set Variable ${current_dir}/${harbor_chart_prov_filename}
Choose File xpath=${chart_file_browse} ${harbor_file_path}
Choose File xpath=${chart_prov_browse} ${harbor_prov_file_path}
Retry Double Keywords When Error Retry Element Click xpath=${upload_action_button} Retry Wait Until Page Not Contains Element xpath=${upload_action_button}
Retry Wait Until Page Contains ${harbor_chart_name}
Go Into Chart Version
[Arguments] ${chart_name}
Retry Element Click xpath=//hbr-helm-chart//a[contains(., '${chart_name}')]
Sleep 3
Go Into Chart Detail
[Arguments] ${version_name}
Retry Element Click xpath=//hbr-helm-chart-version//a[contains(., '${version_name}')]
Retry Wait Until Page Contains Element ${chart_detail}
Multi-delete Chart Files
[Arguments] @{obj}
Switch To Project Charts
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
#Retry Element Click xpath=${version_checkbox}
Retry Double Keywords When Error Retry Element Click xpath=${version_delete} Retry Wait Until Page Contains Element ${version_confirm_delete}
Retry Double Keywords When Error Retry Element Click ${version_confirm_delete} Retry Wait Until Page Not Contains Element xpath=${version_confirm_delete}
Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any charts!\")]

View File

@ -1,38 +1,38 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_chart_tabpage} xpath=//project-detail//a[contains(.,'Charts')]
${project_chart_list} xpath=//hbr-helm-chart
${upload_chart_button} //*[@id='helm-chart-upload']
${chart_file_browse} //*[@id='chart']
${chart_prov_browse} //*[@id='prov']
${upload_action_button} //*[@id='upload-chart']
${harbor_chart_name} harbor
${harbor_chart_filename} harbor-0.2.0.tgz
${harbor_chart_version} 0.2.0
${harbor_chart_prov_filename} harbor-0.2.0.tgz.prov
${harbor_chart_file_url} https://storage.googleapis.com/harbor-builds/helm-chart-test-files/harbor-0.2.0.tgz
${harbor_chart_prov_file_url} https://storage.googleapis.com/harbor-builds/helm-chart-test-files/harbor-0.2.0.tgz.prov
${prometheus_chart_name} prometheus
${prometheus_chart_filename} prometheus-7.0.2.tgz
${prometheus_chart_version} 7.0.2
${prometheus_chart_file_url} https://storage.googleapis.com/harbor-builds/helm-chart-test-files/prometheus-7.0.2.tgz
${prometheus_version} //hbr-helm-chart//a[contains(.,'prometheus')]
${chart_detail} //hbr-chart-detail
${summary_markdown} //*[@id='summary-content']//div[contains(@class,'md-div')]
${summary_container} //*[@id='summary-content']//div[contains(@class,'summary-container')]
${detail_dependency} //*[@id='depend-link']
${dependency_content} //*[@id='depend-content']/hbr-chart-detail-dependency
${detail_value} //*[@id='value-link']
${value_content} //*[@id='value-content']/hbr-chart-detail-value
${version_bread_crumbs} //project-chart-detail//a[contains(.,'Versions')]
${version_checkbox} //clr-dg-row//clr-checkbox-wrapper/label
${version_delete} //clr-dg-action-bar/button[contains(.,'DELETE')]
${version_confirm_delete} //clr-modal//button[contains(.,'DELETE')]
${helmchart_content} //project-detail/project-list-charts/hbr-helm-chart
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_chart_tabpage} xpath=//project-detail//a[contains(.,'Charts')]
${project_chart_list} xpath=//hbr-helm-chart
${upload_chart_button} //*[@id='helm-chart-upload']
${chart_file_browse} //*[@id='chart']
${chart_prov_browse} //*[@id='prov']
${upload_action_button} //*[@id='upload-chart']
${harbor_chart_name} harbor
${harbor_chart_filename} harbor-0.2.0.tgz
${harbor_chart_version} 0.2.0
${harbor_chart_prov_filename} harbor-0.2.0.tgz.prov
${harbor_chart_file_url} https://storage.googleapis.com/harbor-builds/helm-chart-test-files/harbor-0.2.0.tgz
${harbor_chart_prov_file_url} https://storage.googleapis.com/harbor-builds/helm-chart-test-files/harbor-0.2.0.tgz.prov
${prometheus_chart_name} prometheus
${prometheus_chart_filename} prometheus-7.0.2.tgz
${prometheus_chart_version} 7.0.2
${prometheus_chart_file_url} https://storage.googleapis.com/harbor-builds/helm-chart-test-files/prometheus-7.0.2.tgz
${prometheus_version} //hbr-helm-chart//a[contains(.,'prometheus')]
${chart_detail} //hbr-chart-detail
${summary_markdown} //*[@id='summary-content']//div[contains(@class,'md-div')]
${summary_container} //*[@id='summary-content']//div[contains(@class,'summary-container')]
${detail_dependency} //*[@id='depend-link']
${dependency_content} //*[@id='depend-content']/hbr-chart-detail-dependency
${detail_value} //*[@id='value-link']
${value_content} //*[@id='value-content']/hbr-chart-detail-value
${version_bread_crumbs} //project-chart-detail//a[contains(.,'Versions')]
${version_checkbox} //clr-dg-row//clr-checkbox-wrapper/label
${version_delete} //clr-dg-action-bar/button[contains(.,'DELETE')]
${version_confirm_delete} //clr-modal//button[contains(.,'DELETE')]
${helmchart_content} //project-detail/project-list-charts/hbr-helm-chart

View File

@ -1,224 +1,224 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Go Into Project
[Arguments] ${project} ${has_image}=${true}
Retry Keyword N Times When Error 5 Clear Search Input And Go Into Project ${project} ${has_image}
Clear Search Input And Go Into Project
[Arguments] ${project} ${has_image}
# Close prompt in header
Sleep 2
#go To ${url}
Reload Page
Sleep 2
# Clear Search Input
Retry Element Click xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header/div[1]/a/span
Sleep 2
Retry Text Input ${search_input} ${project}
Sleep 2
# Go Into Project
${out} Run Keyword If ${has_image}==${false} Run Keywords Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a AND Wait Until Element Is Visible And Enabled xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any repositories!\")]
... ELSE Run Keywords Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a AND Wait Until Element Is Visible And Enabled xpath=//project-detail//hbr-repository-gridview//clr-dg-cell[contains(.,'${project}/')]
Sleep 1
Capture Page Screenshot
Add User To Project Admin
[Arguments] ${project} ${user}
# *** this keyword has not been used ***
Go Into Project
Retry Element Click xpath=${project_member_tag_xpath}
Retry Element Click xpath=${project_member_add_button_xpath}
Retry Text Input xpath=${project_member_add_username_xpath} ${user}
Retry Element Click xpath=${project_member_add_admin_xpath}
Retry Element Click xpath=${project_member_add_save_button_xpath}
Sleep 4
Search Project Member
[Arguments] ${project} ${user}
# *** this keyword has not been used ***
Go Into Project ${project}
Retry Element Click xpath=//clr-dg-cell//a[contains(.,'${project}')]
Retry Element Click xpath=${project_member_search_button_xpath}
Retry Element Click xpath=${project_member_search_text_xpath}
Retry Wait Until Page Contains ${user}
Change Project Member Role
[Arguments] ${project} ${user} ${role}
Retry Element Click xpath=//clr-dg-cell//a[contains(.,'${project}')]
Change Member Role ${user} ${role}
Change Member Role
[Arguments] ${user} ${role}
Retry Element Click xpath=${project_member_tag_xpath}
Retry Element Click xpath=//project-detail//clr-dg-row[contains(.,'${user}')]//clr-checkbox-wrapper
#change role
Retry Element Click ${project_member_action_xpath}
Retry Element Click //button[contains(.,'${role}')]
Retry Wait Until Page Not Contains Element ${project_member_set_role_xpath}
#Precondition is that only 1 member is in the list.
Retry Wait Until Page Contains ${role}
User Can Change Role
[arguments] ${username}
Retry Element Click xpath=//clr-dg-row[contains(.,'${username}')]//input/../label
Retry Element Click xpath=//*[@id='member-action']
Retry Wait Until Page Not Contains Element xpath=//button[@disabled='' and contains(.,'Admin')]
User Can Not Change Role
[arguments] ${username}
Retry Element Click xpath=//clr-dg-row[contains(.,'${username}')]//input/../label
Retry Element Click xpath=//*[@id='member-action']
Retry Wait Until Page Contains Element xpath=//button[@disabled='' and contains(.,'Admin')]
#this keyworkd seems will not use any more, will delete in the future
Non-admin View Member Account
[arguments] ${times}
Xpath Should Match X Times //clr-dg-row-maintainer ${times}
User Can Not Add Member
Retry Wait Until Page Contains Element xpath=//button[@disabled='' and contains(.,'User')]
Add Guest Member To Project
[arguments] ${member}
Retry Double Keywords When Error Retry Element Click xpath=${project_member_add_button_xpath} Retry Wait Until Page Contains Element 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}
Retry Double Keywords When Error Retry Element Click xpath=${project_member_add_confirmation_ok_xpath} Retry Wait Until Page Not Contains Element xpath=${project_member_add_confirmation_ok_xpath}
Delete Project Member
[arguments] ${member}
Retry Element Click xpath=//clr-dg-row[contains(.,'${member}')]//input/../label
Retry Double Keywords When Error Retry Element Click ${member_action_xpath} Retry Wait Until Page Contains Element ${delete_action_xpath}
Retry Double Keywords When Error Retry Element Click ${delete_action_xpath} Retry Wait Until Page Contains Element ${repo_delete_on_card_view_btn}
Retry Double Keywords When Error Retry Element Click ${repo_delete_on_card_view_btn} Retry Wait Element xpath=${project_member_xpath}
Sleep 1
User Should Be Owner Of Project
[Arguments] ${user} ${pwd} ${project}
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
Go Into Project ${project}
Switch To Member
User Can Not Change Role ${user}
Push image ${ip} ${user} ${pwd} ${project} hello-world
Logout Harbor
User Should Not Be A Member Of Project
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Not Display ${project}
Logout Harbor
Cannot Pull Image ${ip} ${user} ${password} ${project} ${ip}/${project}/hello-world
Cannot Pull Image ${ip} ${user} ${password} ${project} hello-world
Manage Project Member
[Arguments] ${admin} ${pwd} ${project} ${user} ${op} ${has_image}=${true} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin}
Manage Project Member Without Sign In ${project} ${user} ${op} has_image=${has_image}
Logout Harbor
Manage Project Member Without Sign In
[Arguments] ${project} ${user} ${op} ${has_image}=${true}
Go Into Project ${project} ${has_image}
Switch To Member
Run Keyword If '${op}' == 'Add' Add Guest Member To Project ${user}
... ELSE IF '${op}' == 'Remove' Delete Project Member ${user}
... ELSE Change Project Member Role ${project} ${user} ${role}
Change User Role In Project
[Arguments] ${admin} ${pwd} ${project} ${user} ${role} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin}
Retry Wait Element Visible //clr-dg-cell//a[contains(.,'${project}')]
Change Project Member Role ${project} ${user} ${role}
Logout Harbor
User Should Be Guest
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Switch To Member
User Can Not Add Member
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Guest')]
Logout Harbor
Pull image ${ip} ${user} ${password} ${project} hello-world
Cannot Push image ${ip} ${user} ${password} ${project} hello-world
User Should Be Developer
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Switch To Member
User Can Not Add Member
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Developer')]
Logout Harbor
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v1
User Should Be Admin
[Arguments] ${user} ${pwd} ${project} ${guest} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Switch To Member
Add Guest Member To Project ${guest}
User Can Change Role ${guest}
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Admin')]
Logout Harbor
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v2
User Should Be Maintainer
[Arguments] ${user} ${pwd} ${project} ${image} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Delete Repo ${project} ${image}
Switch To Member
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Maintainer')]
Logout Harbor
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v3
Project Should Have Member
[Arguments] ${project} ${user}
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Go Into Project ${project}
Switch To Member
Retry Wait Until Page Contains Element xpath=//clr-dg-cell[contains(., '${user}')]
Logout Harbor
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Go Into Project
[Arguments] ${project} ${has_image}=${true}
Retry Keyword N Times When Error 5 Clear Search Input And Go Into Project ${project} ${has_image}
Clear Search Input And Go Into Project
[Arguments] ${project} ${has_image}
# Close prompt in header
Sleep 2
#go To ${url}
Reload Page
Sleep 2
# Clear Search Input
Retry Element Click xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header/div[1]/a/span
Sleep 2
Retry Text Input ${search_input} ${project}
Sleep 2
# Go Into Project
${out} Run Keyword If ${has_image}==${false} Run Keywords Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a AND Wait Until Element Is Visible And Enabled xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any repositories!\")]
... ELSE Run Keywords Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a AND Wait Until Element Is Visible And Enabled xpath=//project-detail//hbr-repository-gridview//clr-dg-cell[contains(.,'${project}/')]
Sleep 1
Capture Page Screenshot
Add User To Project Admin
[Arguments] ${project} ${user}
# *** this keyword has not been used ***
Go Into Project
Retry Element Click xpath=${project_member_tag_xpath}
Retry Element Click xpath=${project_member_add_button_xpath}
Retry Text Input xpath=${project_member_add_username_xpath} ${user}
Retry Element Click xpath=${project_member_add_admin_xpath}
Retry Element Click xpath=${project_member_add_save_button_xpath}
Sleep 4
Search Project Member
[Arguments] ${project} ${user}
# *** this keyword has not been used ***
Go Into Project ${project}
Retry Element Click xpath=//clr-dg-cell//a[contains(.,'${project}')]
Retry Element Click xpath=${project_member_search_button_xpath}
Retry Element Click xpath=${project_member_search_text_xpath}
Retry Wait Until Page Contains ${user}
Change Project Member Role
[Arguments] ${project} ${user} ${role}
Retry Element Click xpath=//clr-dg-cell//a[contains(.,'${project}')]
Change Member Role ${user} ${role}
Change Member Role
[Arguments] ${user} ${role}
Retry Element Click xpath=${project_member_tag_xpath}
Retry Element Click xpath=//project-detail//clr-dg-row[contains(.,'${user}')]//clr-checkbox-wrapper
#change role
Retry Element Click ${project_member_action_xpath}
Retry Element Click //button[contains(.,'${role}')]
Retry Wait Until Page Not Contains Element ${project_member_set_role_xpath}
#Precondition is that only 1 member is in the list.
Retry Wait Until Page Contains ${role}
User Can Change Role
[arguments] ${username}
Retry Element Click xpath=//clr-dg-row[contains(.,'${username}')]//input/../label
Retry Element Click xpath=//*[@id='member-action']
Retry Wait Until Page Not Contains Element xpath=//button[@disabled='' and contains(.,'Admin')]
User Can Not Change Role
[arguments] ${username}
Retry Element Click xpath=//clr-dg-row[contains(.,'${username}')]//input/../label
Retry Element Click xpath=//*[@id='member-action']
Retry Wait Until Page Contains Element xpath=//button[@disabled='' and contains(.,'Admin')]
#this keyworkd seems will not use any more, will delete in the future
Non-admin View Member Account
[arguments] ${times}
Xpath Should Match X Times //clr-dg-row-maintainer ${times}
User Can Not Add Member
Retry Wait Until Page Contains Element xpath=//button[@disabled='' and contains(.,'User')]
Add Guest Member To Project
[arguments] ${member}
Retry Double Keywords When Error Retry Element Click xpath=${project_member_add_button_xpath} Retry Wait Until Page Contains Element 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}
Retry Double Keywords When Error Retry Element Click xpath=${project_member_add_confirmation_ok_xpath} Retry Wait Until Page Not Contains Element xpath=${project_member_add_confirmation_ok_xpath}
Delete Project Member
[arguments] ${member}
Retry Element Click xpath=//clr-dg-row[contains(.,'${member}')]//input/../label
Retry Double Keywords When Error Retry Element Click ${member_action_xpath} Retry Wait Until Page Contains Element ${delete_action_xpath}
Retry Double Keywords When Error Retry Element Click ${delete_action_xpath} Retry Wait Until Page Contains Element ${repo_delete_on_card_view_btn}
Retry Double Keywords When Error Retry Element Click ${repo_delete_on_card_view_btn} Retry Wait Element xpath=${project_member_xpath}
Sleep 1
User Should Be Owner Of Project
[Arguments] ${user} ${pwd} ${project}
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
Go Into Project ${project}
Switch To Member
User Can Not Change Role ${user}
Push image ${ip} ${user} ${pwd} ${project} hello-world
Logout Harbor
User Should Not Be A Member Of Project
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Not Display ${project}
Logout Harbor
Cannot Pull Image ${ip} ${user} ${password} ${project} ${ip}/${project}/hello-world
Cannot Pull Image ${ip} ${user} ${password} ${project} hello-world
Manage Project Member
[Arguments] ${admin} ${pwd} ${project} ${user} ${op} ${has_image}=${true} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin}
Manage Project Member Without Sign In ${project} ${user} ${op} has_image=${has_image}
Logout Harbor
Manage Project Member Without Sign In
[Arguments] ${project} ${user} ${op} ${has_image}=${true}
Go Into Project ${project} ${has_image}
Switch To Member
Run Keyword If '${op}' == 'Add' Add Guest Member To Project ${user}
... ELSE IF '${op}' == 'Remove' Delete Project Member ${user}
... ELSE Change Project Member Role ${project} ${user} ${role}
Change User Role In Project
[Arguments] ${admin} ${pwd} ${project} ${user} ${role} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${admin} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin}
Retry Wait Element Visible //clr-dg-cell//a[contains(.,'${project}')]
Change Project Member Role ${project} ${user} ${role}
Logout Harbor
User Should Be Guest
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Switch To Member
User Can Not Add Member
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Guest')]
Logout Harbor
Pull image ${ip} ${user} ${password} ${project} hello-world
Cannot Push image ${ip} ${user} ${password} ${project} hello-world
User Should Be Developer
[Arguments] ${user} ${pwd} ${project} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Switch To Member
User Can Not Add Member
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Developer')]
Logout Harbor
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v1
User Should Be Admin
[Arguments] ${user} ${pwd} ${project} ${guest} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Switch To Member
Add Guest Member To Project ${guest}
User Can Change Role ${guest}
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Admin')]
Logout Harbor
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v2
User Should Be Maintainer
[Arguments] ${user} ${pwd} ${project} ${image} ${is_oidc_mode}=${false}
Run Keyword If ${is_oidc_mode} == ${false} Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
... ELSE Sign In Harbor With OIDC User ${HARBOR_URL} username=${user}
${pwd_oidc}= Run Keyword And Return If ${is_oidc_mode} == ${true} Get Secrete By API ${HARBOR_URL}
${password}= Set Variable If ${is_oidc_mode} == ${true} ${pwd_oidc} ${pwd}
Project Should Display ${project}
Go Into Project ${project}
Delete Repo ${project} ${image}
Switch To Member
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${user}')]//clr-dg-cell[contains(.,'Maintainer')]
Logout Harbor
Push Image With Tag ${ip} ${user} ${password} ${project} hello-world v3
Project Should Have Member
[Arguments] ${project} ${user}
Sign In Harbor ${HARBOR_URL} %{HARBOR_ADMIN} %{HARBOR_PASSWORD}
Go Into Project ${project}
Switch To Member
Retry Wait Until Page Contains Element xpath=//clr-dg-cell[contains(., '${user}')]
Logout Harbor

View File

@ -1,30 +1,30 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_member_tag_xpath} //clr-main-container//project-detail/clr-tabs//a[contains(.,'Members')]
${project_member_add_button_xpath} //project-detail//button[contains(.,'User')]
${project_member_add_username_xpath} //*[@id='member_name']
${project_member_add_admin_xpath} /html/body/harbor-app/harbor-shell/clr-main-container/div/div/project-detail/ng-component/div/div[1]/div/div[1]/add-member/clr-modal/div/div[1]/div/div[1]/div/div[2]/form/section/div[2]/div[1]/label
${project_member_add_save_button_xpath} /html/body/harbor-app/harbor-shell/clr-main-container/div/div/project-detail/ng-component/div/div[1]/div/div[1]/add-member/clr-modal/div/div[1]/div/div[1]/div/div[3]/button[2]
${project_member_search_button_xpath} //project-detail//hbr-filter/span/clr-icon
${project_member_search_text_xpath} //project-detail//hbr-filter/span/input
${project_member_add_confirmation_ok_xpath} //project-detail//add-member//button[2]
${project_member_search_button_xpath2} //button[contains(.,'New')]
${project_member_add_button_xpath2} //project-detail//add-member//button[2]
${project_member_guest_radio_checkbox} //project-detail//form//input[@id='checkrads_guest']
${project_member_delete_button_xpath} //button[contains(.,'REMOVE')]
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_member_tag_xpath} //clr-main-container//project-detail/clr-tabs//a[contains(.,'Members')]
${project_member_add_button_xpath} //project-detail//button[contains(.,'User')]
${project_member_add_username_xpath} //*[@id='member_name']
${project_member_add_admin_xpath} /html/body/harbor-app/harbor-shell/clr-main-container/div/div/project-detail/ng-component/div/div[1]/div/div[1]/add-member/clr-modal/div/div[1]/div/div[1]/div/div[2]/form/section/div[2]/div[1]/label
${project_member_add_save_button_xpath} /html/body/harbor-app/harbor-shell/clr-main-container/div/div/project-detail/ng-component/div/div[1]/div/div[1]/add-member/clr-modal/div/div[1]/div/div[1]/div/div[3]/button[2]
${project_member_search_button_xpath} //project-detail//hbr-filter/span/clr-icon
${project_member_search_text_xpath} //project-detail//hbr-filter/span/input
${project_member_add_confirmation_ok_xpath} //project-detail//add-member//button[2]
${project_member_search_button_xpath2} //button[contains(.,'New')]
${project_member_add_button_xpath2} //project-detail//add-member//button[2]
${project_member_guest_radio_checkbox} //project-detail//form//input[@id='checkrads_guest']
${project_member_delete_button_xpath} //button[contains(.,'REMOVE')]

View File

@ -1,33 +1,33 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
View Repo Scan Details
[Arguments] @{vulnerabilities_level}
Retry Element Click xpath=${first_repo_xpath}
FOR ${item} IN @{vulnerabilities_level}
Retry Wait Until Page Contains Element //hbr-artifact-vulnerabilities//clr-dg-row[contains(.,'${item}')]
END
Retry Element Click xpath=${build_history_btn}
Retry Wait Until Page Contains Element xpath=${build_history_data}
View Scan Error Log
Retry Wait Until Page Contains View Log
Retry Element Click xpath=${view_log_xpath}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Keywords ***
View Repo Scan Details
[Arguments] @{vulnerabilities_level}
Retry Element Click xpath=${first_repo_xpath}
FOR ${item} IN @{vulnerabilities_level}
Retry Wait Until Page Contains Element //hbr-artifact-vulnerabilities//clr-dg-row[contains(.,'${item}')]
END
Retry Element Click xpath=${build_history_btn}
Retry Wait Until Page Contains Element xpath=${build_history_data}
View Scan Error Log
Retry Wait Until Page Contains View Log
Retry Element Click xpath=${view_log_xpath}

View File

@ -1,26 +1,26 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${first_repo_xpath} //clr-dg-row//clr-dg-cell[1]//a
${first_cve_xpath} //clr-dg-row[1]//clr-dg-cell//a
${view_log_xpath} //clr-dg-row//clr-dg-cell//a[contains(.,'View Log')]
${build_history_btn} //button[contains(.,'Build History')]
${build_history_data} //clr-dg-row
${push_image_command_btn} //hbr-push-image-button//button
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${first_repo_xpath} //clr-dg-row//clr-dg-cell[1]//a
${first_cve_xpath} //clr-dg-row[1]//clr-dg-cell//a
${view_log_xpath} //clr-dg-row//clr-dg-cell//a[contains(.,'View Log')]
${build_history_btn} //button[contains(.,'Build History')]
${build_history_data} //clr-dg-row
${push_image_command_btn} //hbr-push-image-button//button

View File

@ -1,119 +1,119 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Add A Tag Retention Rule
Retry Element Click xpath=${project_tag_retention_add_rule_xpath}
Retry Element Click xpath=${project_tag_retention_template_xpath}
Retry Element Click xpath=${project_tag_retention_option_always_xpath}
Retry Element Click xpath=${project_tag_retention_save_add_button_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_rule_name_xpath}
Retry Add A Tag Immutability Rule
[Arguments] @{param}
Retry Keyword N Times When Error 5 Add A Tag Immutability Rule @{param}
Add A Tag Immutability Rule
[Arguments] ${scope} ${tag}
Reload Page
Sleep 3
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_retention_add_rule_xpath} Retry Wait Until Page Contains Element xpath=${project_tag_immutability_save_add_button_xpath}
Retry Clear Element Text ${project_tag_immutability_scope_input_xpath}
Retry Text Input ${project_tag_immutability_scope_input_xpath} ${scope}
Retry Clear Element Text ${project_tag_immutability_tag_input_xpath}
Retry Text Input ${project_tag_immutability_tag_input_xpath} ${tag}
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_immutability_save_add_button_xpath} Retry Wait Until Page Contains Element xpath=${project_tag_retention_rule_name_xpath}
Retry Wait Until Page Contains ${scope}
Retry Wait Until Page Contains ${tag}
Delete A Tag Retention Rule
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_delete_button_xpath}
Retry Wait Until Page Not Contains Element xpath=${project_tag_retention_rule_name_xpath}
Delete A Tag Immutability Rule
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_delete_button_xpath}
Retry Wait Until Page Not Contains Element xpath=${project_tag_retention_rule_name_xpath}
Edit A Tag Retention Rule
[Arguments] ${repos} ${tags}
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_edit_button_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_modal_title_edit_xpath}
Input Text ${project_tag_retention_repo_input_xpath} ${repos}
Input Text ${project_tag_retention_tags_input_xpath} ${tags}
Retry Element Click xpath=${project_tag_retention_save_add_button_xpath}
Retry Wait Until Page Contains Element xpath=//span[contains(@class, 'rule-name')]//span[contains(.,'${tags}')]
Edit A Tag Immutability Rule
[Arguments] ${scope} ${tag}
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_edit_button_xpath}
Retry Clear Element Text ${project_tag_immutability_scope_input_xpath}
Retry Text Input ${project_tag_immutability_scope_input_xpath} ${scope}
Retry Clear Element Text ${project_tag_immutability_tag_input_xpath}
Retry Text Input ${project_tag_immutability_tag_input_xpath} ${tag}
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_immutability_save_add_button_xpath} Retry Wait Until Page Contains Element xpath=${project_tag_retention_rule_name_xpath}
Retry Wait Until Page Contains ${scope}
Retry Wait Until Page Contains ${tag}
Set Daily Schedule
Retry Element Click xpath=${project_tag_retention_edit_schedule_xpath}
Retry Element Click xpath=${project_tag_retention_select_policy_xpath}
Retry Element Click xpath=${project_tag_retention_option_daily_xpath}
Retry Element Click xpath=${project_tag_retention_config_save_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_schedule_ok_xpath}
Retry Element Click xpath=${project_tag_retention_schedule_ok_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_span_daily_xpath}
Execute Result Should Be
[Arguments] ${image} ${result}
FOR ${idx} IN RANGE 0 20
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element xpath=//div[contains(@role, 'grid')]//div[contains(@class, 'datagrid-row-master') and contains(@role, 'row')]//clr-datagrid//div[contains(@role, 'grid')]//div[contains(@class, 'datagrid-row-master') and contains(@role, 'row')]//div[contains(@class, 'datagrid-row-scrollable') and contains(., '${result}') and contains(., '${image}')]
Exit For Loop If '${out[0]}'=='PASS'
Sleep 1
Retry Element Click ${project_tag_retention_refresh_xpath}
Sleep 5
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_yes_xpath}
Retry Element Click ${project_tag_retention_list_expand_icon_xpath}
END
Should Be Equal As Strings '${out[0]}' 'PASS'
Execute Dry Run
[Arguments] ${image} ${result}
Retry Element Click xpath=${project_tag_retention_dry_run_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_yes_xpath}
Sleep 5
Retry Element Click xpath=${project_tag_retention_record_yes_xpath}
# memcached:123 should be deleted and hello-world:latest should be retained
Execute Result Should Be ${image} ${result}
Execute Run
[Arguments] ${image} ${result}
Retry Element Click xpath=${project_tag_retention_run_now_xpath}
Retry Element Click xpath=${project_tag_retention_execute_run_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_no_xpath}
Sleep 5
Retry Element Click xpath=${project_tag_retention_record_no_xpath}
# memcached:123 should be deleted and hello-world:latest should be retained
Execute Result Should Be ${image} ${result}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Add A Tag Retention Rule
Retry Element Click xpath=${project_tag_retention_add_rule_xpath}
Retry Element Click xpath=${project_tag_retention_template_xpath}
Retry Element Click xpath=${project_tag_retention_option_always_xpath}
Retry Element Click xpath=${project_tag_retention_save_add_button_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_rule_name_xpath}
Retry Add A Tag Immutability Rule
[Arguments] @{param}
Retry Keyword N Times When Error 5 Add A Tag Immutability Rule @{param}
Add A Tag Immutability Rule
[Arguments] ${scope} ${tag}
Reload Page
Sleep 3
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_retention_add_rule_xpath} Retry Wait Until Page Contains Element xpath=${project_tag_immutability_save_add_button_xpath}
Retry Clear Element Text ${project_tag_immutability_scope_input_xpath}
Retry Text Input ${project_tag_immutability_scope_input_xpath} ${scope}
Retry Clear Element Text ${project_tag_immutability_tag_input_xpath}
Retry Text Input ${project_tag_immutability_tag_input_xpath} ${tag}
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_immutability_save_add_button_xpath} Retry Wait Until Page Contains Element xpath=${project_tag_retention_rule_name_xpath}
Retry Wait Until Page Contains ${scope}
Retry Wait Until Page Contains ${tag}
Delete A Tag Retention Rule
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_delete_button_xpath}
Retry Wait Until Page Not Contains Element xpath=${project_tag_retention_rule_name_xpath}
Delete A Tag Immutability Rule
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_delete_button_xpath}
Retry Wait Until Page Not Contains Element xpath=${project_tag_retention_rule_name_xpath}
Edit A Tag Retention Rule
[Arguments] ${repos} ${tags}
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_edit_button_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_modal_title_edit_xpath}
Input Text ${project_tag_retention_repo_input_xpath} ${repos}
Input Text ${project_tag_retention_tags_input_xpath} ${tags}
Retry Element Click xpath=${project_tag_retention_save_add_button_xpath}
Retry Wait Until Page Contains Element xpath=//span[contains(@class, 'rule-name')]//span[contains(.,'${tags}')]
Edit A Tag Immutability Rule
[Arguments] ${scope} ${tag}
Retry Element Click xpath=${project_tag_retention_action_button_xpath}
Retry Element Click xpath=${project_tag_retention_edit_button_xpath}
Retry Clear Element Text ${project_tag_immutability_scope_input_xpath}
Retry Text Input ${project_tag_immutability_scope_input_xpath} ${scope}
Retry Clear Element Text ${project_tag_immutability_tag_input_xpath}
Retry Text Input ${project_tag_immutability_tag_input_xpath} ${tag}
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_immutability_save_add_button_xpath} Retry Wait Until Page Contains Element xpath=${project_tag_retention_rule_name_xpath}
Retry Wait Until Page Contains ${scope}
Retry Wait Until Page Contains ${tag}
Set Daily Schedule
Retry Element Click xpath=${project_tag_retention_edit_schedule_xpath}
Retry Element Click xpath=${project_tag_retention_select_policy_xpath}
Retry Element Click xpath=${project_tag_retention_option_daily_xpath}
Retry Element Click xpath=${project_tag_retention_config_save_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_schedule_ok_xpath}
Retry Element Click xpath=${project_tag_retention_schedule_ok_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_span_daily_xpath}
Execute Result Should Be
[Arguments] ${image} ${result}
FOR ${idx} IN RANGE 0 20
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element xpath=//div[contains(@role, 'grid')]//div[contains(@class, 'datagrid-row-master') and contains(@role, 'row')]//clr-datagrid//div[contains(@role, 'grid')]//div[contains(@class, 'datagrid-row-master') and contains(@role, 'row')]//div[contains(@class, 'datagrid-row-scrollable') and contains(., '${result}') and contains(., '${image}')]
Exit For Loop If '${out[0]}'=='PASS'
Sleep 1
Retry Element Click ${project_tag_retention_refresh_xpath}
Sleep 5
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_yes_xpath}
Retry Element Click ${project_tag_retention_list_expand_icon_xpath}
END
Should Be Equal As Strings '${out[0]}' 'PASS'
Execute Dry Run
[Arguments] ${image} ${result}
Retry Element Click xpath=${project_tag_retention_dry_run_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_yes_xpath}
Sleep 5
Retry Element Click xpath=${project_tag_retention_record_yes_xpath}
# memcached:123 should be deleted and hello-world:latest should be retained
Execute Result Should Be ${image} ${result}
Execute Run
[Arguments] ${image} ${result}
Retry Element Click xpath=${project_tag_retention_run_now_xpath}
Retry Element Click xpath=${project_tag_retention_execute_run_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_no_xpath}
Sleep 5
Retry Element Click xpath=${project_tag_retention_record_no_xpath}
# memcached:123 should be deleted and hello-world:latest should be retained
Execute Result Should Be ${image} ${result}

View File

@ -1,47 +1,47 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_tag_retention_add_rule_xpath} //*[@id='add-rule']
${project_tag_retention_repo_input_xpath} //*[@id='repos']
${project_tag_retention_param_input_xpath} //*[@id='param']
${project_tag_retention_tags_input_xpath} //*[@id='tags']
${project_tag_retention_save_add_button_xpath} //*[@id='save-add']
${project_tag_retention_template_xpath} //*[@id='template']
${project_tag_retention_option_always_xpath} //option[@value='always']
${project_tag_retention_rule_name_xpath} //ul//span[@class='rule-name ml-5']
${project_tag_retention_edit_schedule_xpath} //*[@id='editSchedule']
${project_tag_retention_select_policy_xpath} //*[@id='selectPolicy']
${project_tag_retention_option_daily_xpath} //option[@value='Daily']
${project_tag_retention_config_save_xpath} //*[@id='config-save']
${project_tag_retention_schedule_ok_xpath} //*[@id='schedule-ok']
${project_tag_retention_span_daily_xpath} //cron-selection//div//span[contains(.,'0 0 0 * * *')]
${project_tag_retention_dry_run_xpath} //*[@id='dry-run']
${project_tag_retention_refresh_xpath} //clr-dg-action-bar/button[4]
${project_tag_retention_record_yes_xpath} //clr-datagrid[contains(.,'Yes')]
${project_tag_retention_list_expand_icon_xpath} //project-detail/app-tag-feature-integration/tag-retention//clr-datagrid//clr-dg-row//clr-dg-cell[1]/clr-icon[contains(@shape, 'angle')]
${project_tag_retention_run_now_xpath} //*[@id='run-now']
${project_tag_retention_execute_run_xpath} //*[@id='execute-run']
${project_tag_retention_record_no_xpath} //clr-datagrid[contains(.,'No')]
${project_tag_retention_action_button_xpath} //button[contains(.,'ACTION')]
${project_tag_retention_delete_button_xpath} //div[contains(@class,'dropdown-menu')]//button[contains(.,'Delete')]
${project_tag_retention_edit_button_xpath} //div[contains(@class,'dropdown-menu')]//button[contains(.,'Edit')]
${project_tag_retention_modal_title_edit_xpath} //h3[contains(.,'Edit Tag Retention Rule')]
${project_tag_immutability_scope_input_xpath} //*[@id='scope-input']
${project_tag_immutability_tag_input_xpath} //*[@id='tag-input']
${project_tag_immutability_save_add_button_xpath} //*[@id='add-edit-btn']
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${project_tag_retention_add_rule_xpath} //*[@id='add-rule']
${project_tag_retention_repo_input_xpath} //*[@id='repos']
${project_tag_retention_param_input_xpath} //*[@id='param']
${project_tag_retention_tags_input_xpath} //*[@id='tags']
${project_tag_retention_save_add_button_xpath} //*[@id='save-add']
${project_tag_retention_template_xpath} //*[@id='template']
${project_tag_retention_option_always_xpath} //option[@value='always']
${project_tag_retention_rule_name_xpath} //ul//span[@class='rule-name ml-5']
${project_tag_retention_edit_schedule_xpath} //*[@id='editSchedule']
${project_tag_retention_select_policy_xpath} //*[@id='selectPolicy']
${project_tag_retention_option_daily_xpath} //option[@value='Daily']
${project_tag_retention_config_save_xpath} //*[@id='config-save']
${project_tag_retention_schedule_ok_xpath} //*[@id='schedule-ok']
${project_tag_retention_span_daily_xpath} //cron-selection//div//span[contains(.,'0 0 0 * * *')]
${project_tag_retention_dry_run_xpath} //*[@id='dry-run']
${project_tag_retention_refresh_xpath} //clr-dg-action-bar/button[4]
${project_tag_retention_record_yes_xpath} //clr-datagrid[contains(.,'Yes')]
${project_tag_retention_list_expand_icon_xpath} //project-detail/app-tag-feature-integration/tag-retention//clr-datagrid//clr-dg-row//clr-dg-cell[1]/clr-icon[contains(@shape, 'angle')]
${project_tag_retention_run_now_xpath} //*[@id='run-now']
${project_tag_retention_execute_run_xpath} //*[@id='execute-run']
${project_tag_retention_record_no_xpath} //clr-datagrid[contains(.,'No')]
${project_tag_retention_action_button_xpath} //button[contains(.,'ACTION')]
${project_tag_retention_delete_button_xpath} //div[contains(@class,'dropdown-menu')]//button[contains(.,'Delete')]
${project_tag_retention_edit_button_xpath} //div[contains(@class,'dropdown-menu')]//button[contains(.,'Edit')]
${project_tag_retention_modal_title_edit_xpath} //h3[contains(.,'Edit Tag Retention Rule')]
${project_tag_immutability_scope_input_xpath} //*[@id='scope-input']
${project_tag_immutability_tag_input_xpath} //*[@id='tag-input']
${project_tag_immutability_save_add_button_xpath} //*[@id='add-edit-btn']

View File

@ -1,63 +1,63 @@
*** Settings ***
Documentation Harbor Webhooks
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Switch To Project Webhooks
#Switch To Project Tab Overflow
Retry Element Click xpath=//project-detail//a[contains(.,'Webhooks')]
Sleep 1
Create A New Webhook
[Arguments] ${webhook_name} ${webhook_endpoint_url}
Retry Element Click ${new_webhook_button_xpath}
Retry Text Input ${webhook_name_xpath} ${webhook_name}
Retry Text Input ${webhook_endpoint_id_xpath} ${webhook_endpoint_url}
Retry Double Keywords When Error Retry Element Click ${create_webhooks_continue_button_xpath} Retry Wait Until Page Not Contains Element ${create_webhooks_continue_button_xpath}
Retry Wait Until Page Contains ${webhook_name}
Update A Webhook
[Arguments] ${old_webhook_name} ${new_webhook_name} ${new_webhook_enpoint}
# select one webhook
Retry Element Click xpath=//clr-dg-row[contains(.,'${old_webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_edit_button}
#cancel1
Retry Double Keywords When Error Retry Element Click ${edit_webhooks_cancel_button_xpath} Retry Wait Until Page Not Contains Element ${edit_webhooks_cancel_button_xpath}
#confirm
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_edit_button}
Retry Text Input ${webhook_name_xpath} ${new_webhook_name}
Retry Text Input ${webhook_endpoint_id_xpath} ${new_webhook_enpoint}
Retry Double Keywords When Error Retry Element Click ${edit_webhooks_save_button_xpath} Retry Wait Until Page Not Contains Element ${edit_webhooks_save_button_xpath}
Retry Wait Until Page Contains ${new_webhook_name}
Enable/Disable State of Same Webhook
[Arguments] ${webhook_name}
Retry Element Click xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_disable_or_enable_button}
Retry Wait Until Page Contains Element ${dialog_disable_id_xpath}
Retry Element Click ${dialog_disable_id_xpath}
# contain disabled webhook
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${webhook_name}')]//span[contains(.,'Disabled')]
Retry Element Click xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_disable_or_enable_button}
Retry Wait Until Page Contains Element ${dialog_enable_id_xpath}
Retry Element Click ${dialog_enable_id_xpath}
# not contain disabled webhook
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${webhook_name}')]//span[contains(.,'Disabled')]
Delete A Webhook
[Arguments] ${webhook_name}
Retry Element Click xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_delete_button}
Retry Wait Until Page Contains Element ${dialog_delete_button}
Retry Element Click ${dialog_delete_button}
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
*** Settings ***
Documentation Harbor Webhooks
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Switch To Project Webhooks
#Switch To Project Tab Overflow
Retry Element Click xpath=//project-detail//a[contains(.,'Webhooks')]
Sleep 1
Create A New Webhook
[Arguments] ${webhook_name} ${webhook_endpoint_url}
Retry Element Click ${new_webhook_button_xpath}
Retry Text Input ${webhook_name_xpath} ${webhook_name}
Retry Text Input ${webhook_endpoint_id_xpath} ${webhook_endpoint_url}
Retry Double Keywords When Error Retry Element Click ${create_webhooks_continue_button_xpath} Retry Wait Until Page Not Contains Element ${create_webhooks_continue_button_xpath}
Retry Wait Until Page Contains ${webhook_name}
Update A Webhook
[Arguments] ${old_webhook_name} ${new_webhook_name} ${new_webhook_enpoint}
# select one webhook
Retry Element Click xpath=//clr-dg-row[contains(.,'${old_webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_edit_button}
#cancel1
Retry Double Keywords When Error Retry Element Click ${edit_webhooks_cancel_button_xpath} Retry Wait Until Page Not Contains Element ${edit_webhooks_cancel_button_xpath}
#confirm
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_edit_button}
Retry Text Input ${webhook_name_xpath} ${new_webhook_name}
Retry Text Input ${webhook_endpoint_id_xpath} ${new_webhook_enpoint}
Retry Double Keywords When Error Retry Element Click ${edit_webhooks_save_button_xpath} Retry Wait Until Page Not Contains Element ${edit_webhooks_save_button_xpath}
Retry Wait Until Page Contains ${new_webhook_name}
Enable/Disable State of Same Webhook
[Arguments] ${webhook_name}
Retry Element Click xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_disable_or_enable_button}
Retry Wait Until Page Contains Element ${dialog_disable_id_xpath}
Retry Element Click ${dialog_disable_id_xpath}
# contain disabled webhook
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${webhook_name}')]//span[contains(.,'Disabled')]
Retry Element Click xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_disable_or_enable_button}
Retry Wait Until Page Contains Element ${dialog_enable_id_xpath}
Retry Element Click ${dialog_enable_id_xpath}
# not contain disabled webhook
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${webhook_name}')]//span[contains(.,'Disabled')]
Delete A Webhook
[Arguments] ${webhook_name}
Retry Element Click xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]
Retry Element Click ${action_webhook_xpath}
Retry Element Click ${action_webhook_delete_button}
Retry Wait Until Page Contains Element ${dialog_delete_button}
Retry Element Click ${dialog_delete_button}
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${webhook_name}')]//clr-checkbox-wrapper//label[contains(@class,'clr-control-label')]

View File

@ -1,24 +1,24 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${new_webhook_button_xpath} xpath=//*[@id='new-webhook']
${webhook_name_xpath} xpath=//*[@id='name']
${webhook_endpoint_id_xpath} xpath=//*[@id='edit_endpoint_url']
${webhook_auth_header_xpath} xpath=//*[@id='auth_header']
${action_webhook_xpath} xpath=//*[@id='action-webhook']
${action_webhook_edit_button} xpath=//*[@id='edit-webhook']
${action_webhook_disable_or_enable_button} xpath=//*[@id='toggle-webhook']
${action_webhook_delete_button} xpath=//*[@id='delete-webhook']
${dialog_delete_button} xpath=//clr-modal//button[contains(.,'DELETE')]
${create_webhooks_continue_button_xpath} xpath=//*[@id='new-webhook-continue']
${edit_webhooks_cancel_button_xpath} xpath=//*[@id='edit-webhook-cancel']
${edit_webhooks_save_button_xpath} xpath=//*[@id='edit-webhook-save']
${edit_webhooks_verify_remote_cert_chkb_xpath} xpath=//input[@id='verify_remote_cert']
${project_webhook_edit_id_xpath} xpath=//*[@id='edit-webhook']
${project_webhook_enable_id_xpath} xpath=//*[@id='enable-webhook-action']
${project_webhook_disable_id_xpath} xpath=//*[@id='disable-webhook-action']
${dialog_disable_id_xpath} xpath=//*[@id='dialog-action-disable']
${dialog_enable_id_xpath} xpath=//*[@id='dialog-action-enable']
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${new_webhook_button_xpath} xpath=//*[@id='new-webhook']
${webhook_name_xpath} xpath=//*[@id='name']
${webhook_endpoint_id_xpath} xpath=//*[@id='edit_endpoint_url']
${webhook_auth_header_xpath} xpath=//*[@id='auth_header']
${action_webhook_xpath} xpath=//*[@id='action-webhook']
${action_webhook_edit_button} xpath=//*[@id='edit-webhook']
${action_webhook_disable_or_enable_button} xpath=//*[@id='toggle-webhook']
${action_webhook_delete_button} xpath=//*[@id='delete-webhook']
${dialog_delete_button} xpath=//clr-modal//button[contains(.,'DELETE')]
${create_webhooks_continue_button_xpath} xpath=//*[@id='new-webhook-continue']
${edit_webhooks_cancel_button_xpath} xpath=//*[@id='edit-webhook-cancel']
${edit_webhooks_save_button_xpath} xpath=//*[@id='edit-webhook-save']
${edit_webhooks_verify_remote_cert_chkb_xpath} xpath=//input[@id='verify_remote_cert']
${project_webhook_edit_id_xpath} xpath=//*[@id='edit-webhook']
${project_webhook_enable_id_xpath} xpath=//*[@id='enable-webhook-action']
${project_webhook_disable_id_xpath} xpath=//*[@id='disable-webhook-action']
${dialog_disable_id_xpath} xpath=//*[@id='dialog-action-disable']
${dialog_enable_id_xpath} xpath=//*[@id='dialog-action-enable']

View File

@ -1,379 +1,379 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Create An New Project And Go Into Project
[Arguments] ${projectname} ${public}=false ${count_quota}=${null} ${storage_quota}=${null} ${storage_quota_unit}=${null} ${proxy_cache}=${false} ${registry}=${null}
Navigate To Projects
FOR ${n} IN RANGE 1 8
${out} Run Keyword And Ignore Error Retry Button Click xpath=${create_project_button_xpath}
Log All Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 1
END
Log To Console Project Name: ${projectname}
Retry Text Input xpath=${project_name_xpath} ${projectname}
${element_project_public}= Set Variable xpath=${project_public_xpath}
Run Keyword If '${public}' == 'true' Run Keywords Wait Until Element Is Visible And Enabled ${element_project_public} AND Retry Element Click ${element_project_public}
Run Keyword If '${count_quota}'!='${null}' Input Count Quota ${count_quota}
Run Keyword If '${storage_quota}'!='${null}' Input Storage Quota ${storage_quota} ${storage_quota_unit}
Run Keyword If '${proxy_cache}' == '${true}' Run Keywords Mouse Down ${project_proxy_cache_switcher_id} AND Mouse Up ${project_proxy_cache_switcher_id} AND Retry Element Click ${project_registry_select_id} AND Retry Element Click xpath=//select[@id='registry']//option[contains(.,'${registry}')]
Retry Double Keywords When Error Retry Element Click ${create_project_OK_button_xpath} Retry Wait Until Page Not Contains Element ${create_project_OK_button_xpath}
Sleep 2
Go Into Project ${projectname} has_image=${false}
Create An New Project With New User
[Arguments] ${url} ${username} ${email} ${realname} ${newPassword} ${comment} ${projectname} ${public}
Create An New User url=${url} username=${username} email=${email} realname=${realname} newPassword=${newPassword} comment=${comment}
Logout Harbor
Sign In Harbor ${url} ${username} ${newPassword}
Create An New Project And Go Into Project ${projectname} ${public}
Sleep 1
Artifact Exist
[Arguments] ${tag_name}
Retry Wait Until Page Contains Element //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256') and contains(.,'${tag_name}')]
#It's the log of project.
Go To Project Log
#Switch To Project Tab Overflow
Retry Element Click xpath=${project_log_xpath}
Sleep 2
Switch To Member
Sleep 3
Retry Element Click xpath=${project_member_xpath}
Sleep 1
Switch To Log
Retry Element Click xpath=${log_xpath}
Sleep 1
Switch To Replication
Retry Element Click xpath=${project_replication_xpath}
Sleep 1
Switch To Project Configuration
Retry Element Click ${project_config_tabsheet}
Sleep 1
Switch To Tag Retention
#Switch To Project Tab Overflow
Retry Element Click xpath=${project_tag_strategy_xpath}
Sleep 1
Switch To Tag Immutability
#Switch To Project Tab Overflow
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_strategy_xpath} Retry Wait Until Page Contains Element ${project_tag_immutability_switch}
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_immutability_switch} Retry Wait Until Page Contains Immutability rules
Sleep 1
Switch To Project Tab Overflow
Retry Element Click xpath=${project_tab_overflow_btn}
Sleep 1
Navigate To Projects
Reload Page
Sleep 3
Retry Element Click xpath=${projects_xpath}
Sleep 1
Project Should Display
[Arguments] ${projectname}
Retry Wait Element xpath=//projects//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Project Should Not Display
[Arguments] ${projectname}
Retry Wait Until Page Not Contains Element xpath=//projects//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Search Private Projects
Retry Element Click xpath=//select
Retry Element Click xpath=//select/option[@value=1]
Sleep 1
Make Project Private
[Arguments] ${projectname}
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Be Selected ${project_config_public_checkbox}
Retry Double Keywords When Error Retry Element Click ${project_config_public_checkbox_label} Retry Checkbox Should Not Be Selected ${project_config_public_checkbox}
Retry Element Click //button[contains(.,'SAVE')]
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Not Be Selected ${project_config_public_checkbox}
Make Project Public
[Arguments] ${projectname}
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Not Be Selected ${project_config_public_checkbox}
Retry Double Keywords When Error Retry Element Click ${project_config_public_checkbox_label} Retry Checkbox Should Be Selected ${project_config_public_checkbox}
Retry Element Click //button[contains(.,'SAVE')]
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Be Selected ${project_config_public_checkbox}
Repo Exist
[Arguments] ${pro_name} ${repo_name}
Retry Wait Until Page Contains Element //clr-dg-row[contains(.,'${pro_name}/${repo_name}')]
Repo Not Exist
[Arguments] ${pro_name} ${repo_name}
Retry Wait Until Page Not Contains Element //clr-dg-row[contains(.,'${pro_name}/${repo_name}')]
Filter Repo
[Arguments] ${pro_name} ${repo_name} ${exsit}=${true}
Retry Double Keywords When Error Retry Element Click ${filter_dist_btn} Wait Until Element Is Visible And Enabled ${filter_dist_input}
Retry Clear Element Text ${filter_dist_input}
Retry Text Input ${filter_dist_input} ${pro_name}/${repo_name}
Run Keyword If ${exsit}==${true} Repo Exist ${pro_name} ${repo_name}
... ELSE Repo Not Exist ${pro_name} ${repo_name}
Delete Repo
[Arguments] ${pro_name} ${repo_name}
${element_repo_checkbox}= Set Variable xpath=//clr-dg-row[contains(.,'${pro_name}/${repo_name}')]//clr-checkbox-wrapper//label
Filter Repo ${pro_name} ${repo_name}
Retry Double Keywords When Error Retry Element Click ${element_repo_checkbox} Wait Until Element Is Visible And Enabled ${repo_delete_btn}
Retry Double Keywords When Error Retry Element Click ${repo_delete_btn} Wait Until Element Is Visible And Enabled ${delete_confirm_btn}
Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn}
Retry Wait Until Page Not Contains Element ${element_repo_checkbox}
Filter Repo ${pro_name} ${repo_name} exsit=${false}
Delete Repo on CardView
[Arguments] ${reponame}
Retry Element Click //hbr-gridview//span[contains(.,'${reponame}')]//clr-dropdown/button
Retry Element Click //hbr-gridview//span[contains(.,'${reponame}')]//clr-dropdown/clr-dropdown-menu/button[contains(.,'Delete')]
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 2
Delete Project
[Arguments] ${projectname}
Navigate To Projects
Retry Element Click xpath=//clr-dg-row[contains(.,'${projectname}')]//clr-checkbox-wrapper//label
Retry Element Click xpath=//*[@id='delete-project']
Retry Element Click //clr-modal//button[contains(.,'DELETE')]
Sleep 1
Project Should Not Be Deleted
[Arguments] ${projname}
Delete Project ${projname}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${projname}')]/../div/clr-icon[@shape='error-standard']
Project Should Be Deleted
[Arguments] ${projname}
Delete Project ${projname}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${projname}')]/../div/clr-icon[@shape='success-standard']
Advanced Search Should Display
Retry Wait Until Page Contains Element xpath=//audit-log//div[@class='flex-xs-middle']/button
# it's not a common keywords, only used into log case.
Do Log Advanced Search
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'pull')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'create')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'delete')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'project') and contains(.,'create')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'repository') and contains(.,'delete')]
Retry Element Click xpath=//audit-log//div[@class='flex-xs-middle']/button
Retry Element Click xpath=//project-detail//audit-log//clr-dropdown/button
#pull log
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Pull')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'pull')]
#push log
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Push')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'push')]
#create log
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Create')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'create')]
#delete log
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Delete')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'delete')]
#others
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Others')]
Retry Element Click xpath=//audit-log//hbr-filter//clr-icon
Retry Text Input xpath=//audit-log//hbr-filter//input harbor-jobservice
Sleep 1
${rc} = Get Element Count //audit-log//clr-dg-row
Should Be Equal As Integers ${rc} 1
Retry Click Repo Name
[Arguments] ${repo_name_element}
FOR ${n} IN RANGE 1 2
${out} Run Keyword And Ignore Error Retry Double Keywords When Error Retry Element Click ${repo_name_element} Retry Wait Element ${tag_table_column_vulnerabilities}
Exit For Loop If '${out[0]}'=='PASS'
END
Should Be Equal As Strings '${out[0]}' 'PASS'
FOR ${n} IN RANGE 1 2
${out} Run Keyword And Ignore Error Retry Wait Until Page Not Contains Element ${repo_list_spinner}
Exit For Loop If '${out[0]}'=='PASS'
END
Should Be Equal As Strings '${out[0]}' 'PASS'
Go Into Repo
[Arguments] ${repoName}
Sleep 2
Retry Wait Until Page Not Contains Element ${repo_list_spinner}
${repo_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${repoName}')]/a
FOR ${n} IN RANGE 1 3
Retry Element Click ${repo_search_icon}
Retry Clear Element Text ${repo_search_input}
Retry Text Input ${repo_search_input} ${repoName}
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element ${repo_name_element}
Sleep 2
Run Keyword If '${out[0]}'=='FAIL' Reload Page
Continue For Loop If '${out[0]}'=='FAIL'
Retry Click Repo Name ${repo_name_element}
Sleep 2
Exit For Loop
END
Should Be Equal As Strings '${out[0]}' 'PASS'
Click Index Achieve
[Arguments] ${tag_name}
Retry Element Click //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256') and contains(.,'${tag_name}')]//clr-dg-cell[1]//clr-tooltip//a
Go Into Index And Contain Artifacts
[Arguments] ${tag_name} ${total_artifact_count}=3 ${archive_count}=0
Retry Double Keywords When Error Click Index Achieve ${tag_name} Page Should Contain Element ${tag_table_column_os_arch}
FOR ${n} IN RANGE 1 10
${out1} Run Keyword And Ignore Error Page Should Contain Element ${artifact_rows} limit=${total_artifact_count}
${out2} Run Keyword And Ignore Error Page Should Contain Element ${archive_rows} limit=${archive_count}
Exit For Loop If '${out1[0]}'=='PASS' and '${out2[0]}'=='PASS'
Sleep 3
END
Run Keyword If '${out1[0]}'=='FAIL' or '${out2[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out1[0]}' 'PASS'
Should Be Equal As Strings '${out2[0]}' 'PASS'
Switch To CardView
Retry Element Click xpath=//hbr-repository-gridview//span[@class='card-btn']/clr-icon
Sleep 5
Expand Repo
[Arguments] ${projectname}
Retry Element Click //repository//clr-dg-row[contains(.,'${projectname}')]//button/clr-icon
Sleep 1
Edit Repo Info
Retry Element Click //*[@id='repo-info']
Retry Wait Until Page Contains Element //*[@id='info']/form/div[2]
# Cancel input
Retry Element Click xpath=//*[@id='info-edit-button']/button
Input Text xpath=//*[@id='info-edit-textarea'] test_description_info
Retry Element Click xpath=//*[@id='edit-cancel']
Retry Element Click xpath=//clr-modal//button[contains(.,'CONFIRM')]
Retry Wait Until Page Contains Element //*[@id='no-editing']
# Confirm input
Retry Element Click xpath=//*[@id='info-edit-button']/button
Input Text xpath=//*[@id='info-edit-textarea'] test_description_info
Retry Element Click xpath=//*[@id='edit-save']
Retry Wait Until Page Contains test_description_info
Switch To Project Label
Retry Element Click xpath=//project-detail//a[contains(.,'Labels')]
Sleep 1
Switch To Project Repo
Retry Element Click xpath=//project-detail//a[contains(.,'Repositories')]
Sleep 1
Add Labels To Tag
[Arguments] ${tagName} ${labelName}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tagName}')]//label
Retry Element Click xpath=//clr-dg-action-bar//clr-dropdown//span
Retry Element Click xpath=//clr-dropdown-menu//clr-dropdown//button[contains(.,'Add Labels')]
Retry Element Click xpath=//clr-dropdown//div//label[contains(.,'${labelName}')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row//label[contains(.,'${labelName}')]
Filter Labels In Tags
[Arguments] ${labelName1} ${labelName2}
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Retry Element Click xpath=//clr-main-container//artifact-list-tab//clr-select-container//select
Retry Element Click xpath=//clr-main-container//artifact-list-tab//clr-select-container//select/option[@value='labels']
Retry Wait Until Page Contains Element xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName1}')]
Retry Element Click xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName1}')]
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Retry Wait Until Page Contains Element xpath=//clr-datagrid//label[contains(.,'${labelName1}')]
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Retry Element Click xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName2}')]
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Sleep 2
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${labelName2}')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${labelName1}')]
Get Statics
[Arguments] ${locator}
Reload Page
Sleep 5
${privaterepo}= Get Text ${locator}
[Return] ${privaterepo}
Retry Get Statics
[Arguments] ${locator}
@{param} Create List ${locator}
${ret}= Retry Keyword N Times When Error 5 Get Statics @{param}
[Return] ${ret}
Get Statics Private Repo
${privaterepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
[Return] ${privaterepo}
Get Statics Private Project
${privateproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[1]/statistics/div/span[1]
[Return] ${privateproj}
Get Statics Public Repo
${publicrepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[2]/statistics/div/span[1]
[Return] ${publicrepo}
Get Statics Public Project
${publicproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[1]/statistics/div/span[1]
[Return] ${publicproj}
Get Statics Total Repo
${totalrepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[2]/statistics/div/span[1]
[Return] ${totalrepo}
Get Statics Total Project
${totalproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[1]/statistics/div/span[1]
[Return] ${totalproj}
Input Count Quota
[Arguments] ${text}
${element_xpath}= Set Variable ${project_add_count_quota_input_text_id}
Retry Clear Element Text ${element_xpath}
Retry Text Input ${element_xpath} ${text}
Input Storage Quota
[Arguments] ${text} ${unit}=${null}
${element_xpath}= Set Variable ${project_add_storage_quota_input_text_id}
Retry Clear Element Text ${element_xpath}
Retry Text Input ${element_xpath} ${text}
Run Keyword If '${unit}'!='${null}' Select Storage Quota unit ${unit}
Select Storage Quota unit
[Arguments] ${unit}
Select From List By Value ${project_add_storage_quota_unit_id} ${unit}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Create An New Project And Go Into Project
[Arguments] ${projectname} ${public}=false ${count_quota}=${null} ${storage_quota}=${null} ${storage_quota_unit}=${null} ${proxy_cache}=${false} ${registry}=${null}
Navigate To Projects
FOR ${n} IN RANGE 1 8
${out} Run Keyword And Ignore Error Retry Button Click xpath=${create_project_button_xpath}
Log All Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 1
END
Log To Console Project Name: ${projectname}
Retry Text Input xpath=${project_name_xpath} ${projectname}
${element_project_public}= Set Variable xpath=${project_public_xpath}
Run Keyword If '${public}' == 'true' Run Keywords Wait Until Element Is Visible And Enabled ${element_project_public} AND Retry Element Click ${element_project_public}
Run Keyword If '${count_quota}'!='${null}' Input Count Quota ${count_quota}
Run Keyword If '${storage_quota}'!='${null}' Input Storage Quota ${storage_quota} ${storage_quota_unit}
Run Keyword If '${proxy_cache}' == '${true}' Run Keywords Mouse Down ${project_proxy_cache_switcher_id} AND Mouse Up ${project_proxy_cache_switcher_id} AND Retry Element Click ${project_registry_select_id} AND Retry Element Click xpath=//select[@id='registry']//option[contains(.,'${registry}')]
Retry Double Keywords When Error Retry Element Click ${create_project_OK_button_xpath} Retry Wait Until Page Not Contains Element ${create_project_OK_button_xpath}
Sleep 2
Go Into Project ${projectname} has_image=${false}
Create An New Project With New User
[Arguments] ${url} ${username} ${email} ${realname} ${newPassword} ${comment} ${projectname} ${public}
Create An New User url=${url} username=${username} email=${email} realname=${realname} newPassword=${newPassword} comment=${comment}
Logout Harbor
Sign In Harbor ${url} ${username} ${newPassword}
Create An New Project And Go Into Project ${projectname} ${public}
Sleep 1
Artifact Exist
[Arguments] ${tag_name}
Retry Wait Until Page Contains Element //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256') and contains(.,'${tag_name}')]
#It's the log of project.
Go To Project Log
#Switch To Project Tab Overflow
Retry Element Click xpath=${project_log_xpath}
Sleep 2
Switch To Member
Sleep 3
Retry Element Click xpath=${project_member_xpath}
Sleep 1
Switch To Log
Retry Element Click xpath=${log_xpath}
Sleep 1
Switch To Replication
Retry Element Click xpath=${project_replication_xpath}
Sleep 1
Switch To Project Configuration
Retry Element Click ${project_config_tabsheet}
Sleep 1
Switch To Tag Retention
#Switch To Project Tab Overflow
Retry Element Click xpath=${project_tag_strategy_xpath}
Sleep 1
Switch To Tag Immutability
#Switch To Project Tab Overflow
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_strategy_xpath} Retry Wait Until Page Contains Element ${project_tag_immutability_switch}
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_immutability_switch} Retry Wait Until Page Contains Immutability rules
Sleep 1
Switch To Project Tab Overflow
Retry Element Click xpath=${project_tab_overflow_btn}
Sleep 1
Navigate To Projects
Reload Page
Sleep 3
Retry Element Click xpath=${projects_xpath}
Sleep 1
Project Should Display
[Arguments] ${projectname}
Retry Wait Element xpath=//projects//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Project Should Not Display
[Arguments] ${projectname}
Retry Wait Until Page Not Contains Element xpath=//projects//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Search Private Projects
Retry Element Click xpath=//select
Retry Element Click xpath=//select/option[@value=1]
Sleep 1
Make Project Private
[Arguments] ${projectname}
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Be Selected ${project_config_public_checkbox}
Retry Double Keywords When Error Retry Element Click ${project_config_public_checkbox_label} Retry Checkbox Should Not Be Selected ${project_config_public_checkbox}
Retry Element Click //button[contains(.,'SAVE')]
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Not Be Selected ${project_config_public_checkbox}
Make Project Public
[Arguments] ${projectname}
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Not Be Selected ${project_config_public_checkbox}
Retry Double Keywords When Error Retry Element Click ${project_config_public_checkbox_label} Retry Checkbox Should Be Selected ${project_config_public_checkbox}
Retry Element Click //button[contains(.,'SAVE')]
Go Into Project ${project name}
Switch To Project Configuration
Retry Checkbox Should Be Selected ${project_config_public_checkbox}
Repo Exist
[Arguments] ${pro_name} ${repo_name}
Retry Wait Until Page Contains Element //clr-dg-row[contains(.,'${pro_name}/${repo_name}')]
Repo Not Exist
[Arguments] ${pro_name} ${repo_name}
Retry Wait Until Page Not Contains Element //clr-dg-row[contains(.,'${pro_name}/${repo_name}')]
Filter Repo
[Arguments] ${pro_name} ${repo_name} ${exsit}=${true}
Retry Double Keywords When Error Retry Element Click ${filter_dist_btn} Wait Until Element Is Visible And Enabled ${filter_dist_input}
Retry Clear Element Text ${filter_dist_input}
Retry Text Input ${filter_dist_input} ${pro_name}/${repo_name}
Run Keyword If ${exsit}==${true} Repo Exist ${pro_name} ${repo_name}
... ELSE Repo Not Exist ${pro_name} ${repo_name}
Delete Repo
[Arguments] ${pro_name} ${repo_name}
${element_repo_checkbox}= Set Variable xpath=//clr-dg-row[contains(.,'${pro_name}/${repo_name}')]//clr-checkbox-wrapper//label
Filter Repo ${pro_name} ${repo_name}
Retry Double Keywords When Error Retry Element Click ${element_repo_checkbox} Wait Until Element Is Visible And Enabled ${repo_delete_btn}
Retry Double Keywords When Error Retry Element Click ${repo_delete_btn} Wait Until Element Is Visible And Enabled ${delete_confirm_btn}
Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn}
Retry Wait Until Page Not Contains Element ${element_repo_checkbox}
Filter Repo ${pro_name} ${repo_name} exsit=${false}
Delete Repo on CardView
[Arguments] ${reponame}
Retry Element Click //hbr-gridview//span[contains(.,'${reponame}')]//clr-dropdown/button
Retry Element Click //hbr-gridview//span[contains(.,'${reponame}')]//clr-dropdown/clr-dropdown-menu/button[contains(.,'Delete')]
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 2
Delete Project
[Arguments] ${projectname}
Navigate To Projects
Retry Element Click xpath=//clr-dg-row[contains(.,'${projectname}')]//clr-checkbox-wrapper//label
Retry Element Click xpath=//*[@id='delete-project']
Retry Element Click //clr-modal//button[contains(.,'DELETE')]
Sleep 1
Project Should Not Be Deleted
[Arguments] ${projname}
Delete Project ${projname}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${projname}')]/../div/clr-icon[@shape='error-standard']
Project Should Be Deleted
[Arguments] ${projname}
Delete Project ${projname}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${projname}')]/../div/clr-icon[@shape='success-standard']
Advanced Search Should Display
Retry Wait Until Page Contains Element xpath=//audit-log//div[@class='flex-xs-middle']/button
# it's not a common keywords, only used into log case.
Do Log Advanced Search
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'pull')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'create')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'delete')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'project') and contains(.,'create')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'repository') and contains(.,'delete')]
Retry Element Click xpath=//audit-log//div[@class='flex-xs-middle']/button
Retry Element Click xpath=//project-detail//audit-log//clr-dropdown/button
#pull log
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Pull')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'pull')]
#push log
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Push')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'push')]
#create log
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Create')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'create')]
#delete log
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Delete')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'delete')]
#others
Retry Element Click xpath=//audit-log//clr-dropdown/button
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Others')]
Retry Element Click xpath=//audit-log//hbr-filter//clr-icon
Retry Text Input xpath=//audit-log//hbr-filter//input harbor-jobservice
Sleep 1
${rc} = Get Element Count //audit-log//clr-dg-row
Should Be Equal As Integers ${rc} 1
Retry Click Repo Name
[Arguments] ${repo_name_element}
FOR ${n} IN RANGE 1 2
${out} Run Keyword And Ignore Error Retry Double Keywords When Error Retry Element Click ${repo_name_element} Retry Wait Element ${tag_table_column_vulnerabilities}
Exit For Loop If '${out[0]}'=='PASS'
END
Should Be Equal As Strings '${out[0]}' 'PASS'
FOR ${n} IN RANGE 1 2
${out} Run Keyword And Ignore Error Retry Wait Until Page Not Contains Element ${repo_list_spinner}
Exit For Loop If '${out[0]}'=='PASS'
END
Should Be Equal As Strings '${out[0]}' 'PASS'
Go Into Repo
[Arguments] ${repoName}
Sleep 2
Retry Wait Until Page Not Contains Element ${repo_list_spinner}
${repo_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${repoName}')]/a
FOR ${n} IN RANGE 1 3
Retry Element Click ${repo_search_icon}
Retry Clear Element Text ${repo_search_input}
Retry Text Input ${repo_search_input} ${repoName}
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element ${repo_name_element}
Sleep 2
Run Keyword If '${out[0]}'=='FAIL' Reload Page
Continue For Loop If '${out[0]}'=='FAIL'
Retry Click Repo Name ${repo_name_element}
Sleep 2
Exit For Loop
END
Should Be Equal As Strings '${out[0]}' 'PASS'
Click Index Achieve
[Arguments] ${tag_name}
Retry Element Click //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256') and contains(.,'${tag_name}')]//clr-dg-cell[1]//clr-tooltip//a
Go Into Index And Contain Artifacts
[Arguments] ${tag_name} ${total_artifact_count}=3 ${archive_count}=0
Retry Double Keywords When Error Click Index Achieve ${tag_name} Page Should Contain Element ${tag_table_column_os_arch}
FOR ${n} IN RANGE 1 10
${out1} Run Keyword And Ignore Error Page Should Contain Element ${artifact_rows} limit=${total_artifact_count}
${out2} Run Keyword And Ignore Error Page Should Contain Element ${archive_rows} limit=${archive_count}
Exit For Loop If '${out1[0]}'=='PASS' and '${out2[0]}'=='PASS'
Sleep 3
END
Run Keyword If '${out1[0]}'=='FAIL' or '${out2[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out1[0]}' 'PASS'
Should Be Equal As Strings '${out2[0]}' 'PASS'
Switch To CardView
Retry Element Click xpath=//hbr-repository-gridview//span[@class='card-btn']/clr-icon
Sleep 5
Expand Repo
[Arguments] ${projectname}
Retry Element Click //repository//clr-dg-row[contains(.,'${projectname}')]//button/clr-icon
Sleep 1
Edit Repo Info
Retry Element Click //*[@id='repo-info']
Retry Wait Until Page Contains Element //*[@id='info']/form/div[2]
# Cancel input
Retry Element Click xpath=//*[@id='info-edit-button']/button
Input Text xpath=//*[@id='info-edit-textarea'] test_description_info
Retry Element Click xpath=//*[@id='edit-cancel']
Retry Element Click xpath=//clr-modal//button[contains(.,'CONFIRM')]
Retry Wait Until Page Contains Element //*[@id='no-editing']
# Confirm input
Retry Element Click xpath=//*[@id='info-edit-button']/button
Input Text xpath=//*[@id='info-edit-textarea'] test_description_info
Retry Element Click xpath=//*[@id='edit-save']
Retry Wait Until Page Contains test_description_info
Switch To Project Label
Retry Element Click xpath=//project-detail//a[contains(.,'Labels')]
Sleep 1
Switch To Project Repo
Retry Element Click xpath=//project-detail//a[contains(.,'Repositories')]
Sleep 1
Add Labels To Tag
[Arguments] ${tagName} ${labelName}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tagName}')]//label
Retry Element Click xpath=//clr-dg-action-bar//clr-dropdown//span
Retry Element Click xpath=//clr-dropdown-menu//clr-dropdown//button[contains(.,'Add Labels')]
Retry Element Click xpath=//clr-dropdown//div//label[contains(.,'${labelName}')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row//label[contains(.,'${labelName}')]
Filter Labels In Tags
[Arguments] ${labelName1} ${labelName2}
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Retry Element Click xpath=//clr-main-container//artifact-list-tab//clr-select-container//select
Retry Element Click xpath=//clr-main-container//artifact-list-tab//clr-select-container//select/option[@value='labels']
Retry Wait Until Page Contains Element xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName1}')]
Retry Element Click xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName1}')]
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Retry Wait Until Page Contains Element xpath=//clr-datagrid//label[contains(.,'${labelName1}')]
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Retry Element Click xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName2}')]
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Sleep 2
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${labelName2}')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${labelName1}')]
Get Statics
[Arguments] ${locator}
Reload Page
Sleep 5
${privaterepo}= Get Text ${locator}
[Return] ${privaterepo}
Retry Get Statics
[Arguments] ${locator}
@{param} Create List ${locator}
${ret}= Retry Keyword N Times When Error 5 Get Statics @{param}
[Return] ${ret}
Get Statics Private Repo
${privaterepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
[Return] ${privaterepo}
Get Statics Private Project
${privateproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[1]/statistics/div/span[1]
[Return] ${privateproj}
Get Statics Public Repo
${publicrepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[2]/statistics/div/span[1]
[Return] ${publicrepo}
Get Statics Public Project
${publicproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[1]/statistics/div/span[1]
[Return] ${publicproj}
Get Statics Total Repo
${totalrepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[2]/statistics/div/span[1]
[Return] ${totalrepo}
Get Statics Total Project
${totalproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[1]/statistics/div/span[1]
[Return] ${totalproj}
Input Count Quota
[Arguments] ${text}
${element_xpath}= Set Variable ${project_add_count_quota_input_text_id}
Retry Clear Element Text ${element_xpath}
Retry Text Input ${element_xpath} ${text}
Input Storage Quota
[Arguments] ${text} ${unit}=${null}
${element_xpath}= Set Variable ${project_add_storage_quota_input_text_id}
Retry Clear Element Text ${element_xpath}
Retry Text Input ${element_xpath} ${text}
Run Keyword If '${unit}'!='${null}' Select Storage Quota unit ${unit}
Select Storage Quota unit
[Arguments] ${unit}
Select From List By Value ${project_add_storage_quota_unit_id} ${unit}

View File

@ -1,81 +1,81 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${create_project_button_xpath} //clr-main-container//button[contains(., 'New Project')]
${project_name_xpath} //*[@id='create_project_name']
${project_public_xpath} //input[@name='public']/..//label
${project_save_css} html body.no-scrolling harbor-app harbor-shell clr-main-container.main-container div.content-container div.content-area.content-area-override project div.row div.col-lg-12.col-md-12.col-sm-12.col-xs-12 div.row.flex-items-xs-between div.option-left create-project clr-modal div.modal div.modal-dialog div.modal-content div.modal-footer button.btn.btn-primary
${log_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,'Logs')]
${projects_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,'Projects')]
${project_replication_xpath} //project-detail//a[contains(.,'Replication')]
${project_log_xpath} //project-detail//a[contains(.,'Logs')]
${project_member_xpath} //project-detail//a[contains(.,'Members')]
${project_config_tabsheet} xpath=//project-detail//a[contains(.,'Configuration')]
${project_tag_strategy_xpath} //clr-tabs//a[contains(.,'Policy')]
${project_tab_overflow_btn} //clr-tabs//li//button[contains(@class,"dropdown-toggle")]
${project_tag_immutability_switch} //project-detail/app-tag-feature-integration//label/a[contains(.,'Tag Immutability')]
${create_project_CANCEL_button_xpath} xpath=//button[contains(.,'CANCEL')]
${create_project_OK_button_xpath} xpath=//button[contains(.,'OK')]
${delete_confirm_btn} xpath=//button[contains(.,'DELETE')]
${project_statistics_private_repository_icon} xpath=//projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
${project_statistics_total_projects_icon} xpath=//div[contains(@class, 'statistic-column-block') and contains(., 'TOTAL')]//div[1]/statistics//span[contains(@class, 'statistic-data')]
${repo_delete_confirm_btn} xpath=//clr-modal//button[2]
${repo_retag_confirm_dlg} css=${modal-dialog}
${repo_delete_on_card_view_btn} //clr-modal//button[contains(.,'DELETE')]
${delete_btn} //button[contains(.,'Delete')]
${repo_delete_btn} xpath=//hbr-repository-gridview//button[contains(.,'Delete')]
${project_delete_btn} xpath=//button[@id='delete-project']
${tag_delete_btn} xpath=//tag-repository//clr-datagrid//button[contains(.,'Delete')]
${user_delete_btn} xpath=/clr-dropdown-menu//button[contains(.,'Delete')]
${repo_search_icon} xpath=//hbr-filter//clr-icon
${repo_search_input} xpath=//hbr-filter//input
${repo_list_spinner} xpath=//clr-datagrid//clr-spinner
#${repo_search_icon} xpath=//hbr-repository-gridview//clr-datagrid//clr-dg-column[contains(.,'Name')]//clr-dg-string-filter//button//clr-icon
#${repo_search_input} xpath=//div[@class[contains(.,'datagrid-filter')]]//input
${repo_tag_1st_checkbox} xpath=//clr-datagrid//clr-dg-row//clr-checkbox-wrapper
${tag_table_column_pull_command} xpath=//clr-dg-column//span[contains(.,'Pull Command')]
${tag_table_column_vulnerabilities} xpath=//clr-dg-column//span[contains(.,'Vulnerabilities')]
${tag_table_column_os_arch} xpath=//clr-dg-column//span[contains(.,'OS/ARCH')]
${tag_table_column_tag} xpath=//clr-dg-column//span[contains(.,'Tag')]
${tag_table_column_size} xpath=//clr-dg-column//span[contains(.,'Size')]
${tag_table_column_vulnerability} xpath=//clr-dg-column//span[contains(.,'Vulnerability')]
${tag_images_btn} xpath=//hbr-repository//button[contains(.,'Images')]
${project_member_action_xpath} xpath=//*[@id='member-action']
${project_member_set_role_xpath} xpath=//clr-dropdown-menu//label[contains(.,'Set Role')]
${project_config_public_checkbox} xpath=//input[@name='public']
${project_config_content_trust_checkbox} xpath=//input[@name='content-trust']
${project_config_scan_images_on_push_checkbox} xpath=//input[@name='scan-image-on-push']
${project_config_prevent_vulnerable_images_from_running_checkbox} xpath=//input[@name='prevent-vulenrability-image-input']
${project_config_severity_select} xpath=//select[@id='severity']
${project_config_public_checkbox_label} xpath=//*[@id="clr-wrapper-public"]/div/clr-checkbox-wrapper/label
${project_config_prevent_vulenrability_checkbox_label} xpath=//*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
${project_config_system_wl_radio_input} xpath=//clr-radio-wrapper//label[contains(.,'System allowlist')]
${project_config_project_wl_radio_input} xpath=//clr-radio-wrapper//label[contains(.,'Project allowlist')]
${project_config_system_wl_radio_input_id} systemAllowlistOrProjectAllowlist
${project_config_project_wl_radio_input_id} systemAllowlistOrProjectAllowlist
${project_config_project_wl_add_btn} xpath=//*[@id='show-add-modal']
${project_config_project_wl_add_confirm_btn} xpath=//*[@id='add-to-allowlist']
${project_config_save_btn} xpath=//hbr-project-policy-config//button[contains(.,'SAVE')]
${project_add_count_quota_input_text_id} xpath=//*[@id='create_project_count_limit']
${project_add_storage_quota_input_text_id} xpath=//*[@id='create_project_storage_limit']
${project_add_storage_quota_unit_id} xpath=//*[@id='create_project_storage_limit_unit']
${project_proxy_cache_switcher_id} xpath=//*[@id='proxy-cache']
${project_registry_select_id} xpath=//*[@id='registry']
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${create_project_button_xpath} //clr-main-container//button[contains(., 'New Project')]
${project_name_xpath} //*[@id='create_project_name']
${project_public_xpath} //input[@name='public']/..//label
${project_save_css} html body.no-scrolling harbor-app harbor-shell clr-main-container.main-container div.content-container div.content-area.content-area-override project div.row div.col-lg-12.col-md-12.col-sm-12.col-xs-12 div.row.flex-items-xs-between div.option-left create-project clr-modal div.modal div.modal-dialog div.modal-content div.modal-footer button.btn.btn-primary
${log_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,'Logs')]
${projects_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,'Projects')]
${project_replication_xpath} //project-detail//a[contains(.,'Replication')]
${project_log_xpath} //project-detail//a[contains(.,'Logs')]
${project_member_xpath} //project-detail//a[contains(.,'Members')]
${project_config_tabsheet} xpath=//project-detail//a[contains(.,'Configuration')]
${project_tag_strategy_xpath} //clr-tabs//a[contains(.,'Policy')]
${project_tab_overflow_btn} //clr-tabs//li//button[contains(@class,"dropdown-toggle")]
${project_tag_immutability_switch} //project-detail/app-tag-feature-integration//label/a[contains(.,'Tag Immutability')]
${create_project_CANCEL_button_xpath} xpath=//button[contains(.,'CANCEL')]
${create_project_OK_button_xpath} xpath=//button[contains(.,'OK')]
${delete_confirm_btn} xpath=//button[contains(.,'DELETE')]
${project_statistics_private_repository_icon} xpath=//projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
${project_statistics_total_projects_icon} xpath=//div[contains(@class, 'statistic-column-block') and contains(., 'TOTAL')]//div[1]/statistics//span[contains(@class, 'statistic-data')]
${repo_delete_confirm_btn} xpath=//clr-modal//button[2]
${repo_retag_confirm_dlg} css=${modal-dialog}
${repo_delete_on_card_view_btn} //clr-modal//button[contains(.,'DELETE')]
${delete_btn} //button[contains(.,'Delete')]
${repo_delete_btn} xpath=//hbr-repository-gridview//button[contains(.,'Delete')]
${project_delete_btn} xpath=//button[@id='delete-project']
${tag_delete_btn} xpath=//tag-repository//clr-datagrid//button[contains(.,'Delete')]
${user_delete_btn} xpath=/clr-dropdown-menu//button[contains(.,'Delete')]
${repo_search_icon} xpath=//hbr-filter//clr-icon
${repo_search_input} xpath=//hbr-filter//input
${repo_list_spinner} xpath=//clr-datagrid//clr-spinner
#${repo_search_icon} xpath=//hbr-repository-gridview//clr-datagrid//clr-dg-column[contains(.,'Name')]//clr-dg-string-filter//button//clr-icon
#${repo_search_input} xpath=//div[@class[contains(.,'datagrid-filter')]]//input
${repo_tag_1st_checkbox} xpath=//clr-datagrid//clr-dg-row//clr-checkbox-wrapper
${tag_table_column_pull_command} xpath=//clr-dg-column//span[contains(.,'Pull Command')]
${tag_table_column_vulnerabilities} xpath=//clr-dg-column//span[contains(.,'Vulnerabilities')]
${tag_table_column_os_arch} xpath=//clr-dg-column//span[contains(.,'OS/ARCH')]
${tag_table_column_tag} xpath=//clr-dg-column//span[contains(.,'Tag')]
${tag_table_column_size} xpath=//clr-dg-column//span[contains(.,'Size')]
${tag_table_column_vulnerability} xpath=//clr-dg-column//span[contains(.,'Vulnerability')]
${tag_images_btn} xpath=//hbr-repository//button[contains(.,'Images')]
${project_member_action_xpath} xpath=//*[@id='member-action']
${project_member_set_role_xpath} xpath=//clr-dropdown-menu//label[contains(.,'Set Role')]
${project_config_public_checkbox} xpath=//input[@name='public']
${project_config_content_trust_checkbox} xpath=//input[@name='content-trust']
${project_config_scan_images_on_push_checkbox} xpath=//input[@name='scan-image-on-push']
${project_config_prevent_vulnerable_images_from_running_checkbox} xpath=//input[@name='prevent-vulenrability-image-input']
${project_config_severity_select} xpath=//select[@id='severity']
${project_config_public_checkbox_label} xpath=//*[@id="clr-wrapper-public"]/div/clr-checkbox-wrapper/label
${project_config_prevent_vulenrability_checkbox_label} xpath=//*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
${project_config_system_wl_radio_input} xpath=//clr-radio-wrapper//label[contains(.,'System allowlist')]
${project_config_project_wl_radio_input} xpath=//clr-radio-wrapper//label[contains(.,'Project allowlist')]
${project_config_system_wl_radio_input_id} systemAllowlistOrProjectAllowlist
${project_config_project_wl_radio_input_id} systemAllowlistOrProjectAllowlist
${project_config_project_wl_add_btn} xpath=//*[@id='show-add-modal']
${project_config_project_wl_add_confirm_btn} xpath=//*[@id='add-to-allowlist']
${project_config_save_btn} xpath=//hbr-project-policy-config//button[contains(.,'SAVE')]
${project_add_count_quota_input_text_id} xpath=//*[@id='create_project_count_limit']
${project_add_storage_quota_input_text_id} xpath=//*[@id='create_project_storage_limit']
${project_add_storage_quota_unit_id} xpath=//*[@id='create_project_storage_limit_unit']
${project_proxy_cache_switcher_id} xpath=//*[@id='proxy-cache']
${project_registry_select_id} xpath=//*[@id='registry']

View File

@ -1,25 +1,25 @@
*** Settings ***
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Switch To Project Robot Account
#Switch To Project Tab Overflow
Retry Element Click ${project_robot_account_tabpage}
Retry Wait Until Page Contains Element ${project_robot_account_create_btn}
Create A Robot Account And Return Token
[Arguments] ${projectname} ${robot_account_name} ${project_has_image}=${false}
Go Into Project ${projectname} has_image=${project_has_image}
Switch To Project Robot Account
Retry Element Click ${project_robot_account_create_btn}
Retry Text Input ${project_robot_account_create_name_input} ${robot_account_name}
Retry Element Click xpath=//select[@id='expiration-type']
Retry Element Click xpath=//select[@id='expiration-type']//option[@value='never']
Retry Double Keywords When Error Retry Element Click ${project_robot_account_create_save_btn} Retry Wait Until Page Not Contains Element ${project_robot_account_create_save_btn}
${token}= Get Value ${project_robot_account_token_input}
[Return] ${token}
*** Settings ***
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Switch To Project Robot Account
#Switch To Project Tab Overflow
Retry Element Click ${project_robot_account_tabpage}
Retry Wait Until Page Contains Element ${project_robot_account_create_btn}
Create A Robot Account And Return Token
[Arguments] ${projectname} ${robot_account_name} ${project_has_image}=${false}
Go Into Project ${projectname} has_image=${project_has_image}
Switch To Project Robot Account
Retry Element Click ${project_robot_account_create_btn}
Retry Text Input ${project_robot_account_create_name_input} ${robot_account_name}
Retry Element Click xpath=//select[@id='expiration-type']
Retry Element Click xpath=//select[@id='expiration-type']//option[@value='never']
Retry Double Keywords When Error Retry Element Click ${project_robot_account_create_save_btn} Retry Wait Until Page Not Contains Element ${project_robot_account_create_save_btn}
${token}= Get Value ${project_robot_account_token_input}
[Return] ${token}

View File

@ -1,9 +1,9 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor robot-account feature
*** Variables ***
${project_robot_account_tabpage} xpath=//project-detail//a[contains(.,'Robot Accounts')]
${project_robot_account_create_btn} xpath=//project-detail/app-robot-account//button
${project_robot_account_token_input} xpath=//app-robot-account//hbr-copy-input//input
${project_robot_account_create_name_input} //input[@id='name']
${project_robot_account_create_save_btn} //button[@id='system-robot-save']
*** Settings ***
Documentation This resource provides any keywords related to the Harbor robot-account feature
*** Variables ***
${project_robot_account_tabpage} xpath=//project-detail//a[contains(.,'Robot Accounts')]
${project_robot_account_create_btn} xpath=//project-detail/app-robot-account//button
${project_robot_account_token_input} xpath=//app-robot-account//hbr-copy-input//input
${project_robot_account_create_name_input} //input[@id='name']
${project_robot_account_create_save_btn} //button[@id='system-robot-save']

View File

@ -1,24 +1,24 @@
# 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 This resource provides any keywords related to public
*** Variables ***
${delete_btn} //clr-modal//button[contains(.,'DELETE')]
${delete_btn_2} //button[contains(.,'Delete')]
${default_scanner_info_close_icon} /html/body/harbor-app/harbor-shell/clr-main-container/div[1]/div[3]/clr-icon
${back_to_home_link} /html/body/harbor-app/harbor-shell/clr-main-container/div[2]/div/search-result/div/div[2]/a
# 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 This resource provides any keywords related to public
*** Variables ***
${delete_btn} //clr-modal//button[contains(.,'DELETE')]
${delete_btn_2} //button[contains(.,'Delete')]
${default_scanner_info_close_icon} /html/body/harbor-app/harbor-shell/clr-main-container/div[1]/div[3]/clr-icon
${back_to_home_link} /html/body/harbor-app/harbor-shell/clr-main-container/div[2]/div/search-result/div/div[2]/a

View File

@ -1,256 +1,256 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Filter Replication Rule
[Arguments] ${ruleName} ${exist}=${true}
${rule_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${ruleName}')]
Retry Element Click ${filter_rules_btn}
Retry Clear Element Text ${filter_rules_input}
Retry Text Input ${filter_rules_input} ${ruleName}
Run Keyword If ${exist}==${true} Retry Wait Until Page Contains Element ${rule_name_element}
... ELSE Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any replication rules!\")]
Filter Registry
[Arguments] ${registry_name}
${registry_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${registry_name}')]
Switch To Replication Manage
Switch To Registries
Retry Element Click ${filter_registry_btn}
Retry Text Input ${filter_registry_input} ${registry_name}
Retry Wait Until Page Contains Element ${registry_name_element}
Select Dest Registry
[Arguments] ${endpoint}
Retry Element Click ${dest_registry_dropdown_list}
Retry Element Click ${dest_registry_dropdown_list}//option[contains(.,'${endpoint}')]
Select Source Registry
[Arguments] ${endpoint}
Retry Element Click ${src_registry_dropdown_list}
Retry Element Click ${src_registry_dropdown_list}//option[contains(.,'${endpoint}')]
Select Trigger
[Arguments] ${mode}
Retry Element Click ${rule_trigger_select}
Retry Element Click ${rule_trigger_select}//option[contains(.,'${mode}')]
Select Destination URL
[Arguments] ${type}
Retry Element Click ${destination_url_xpath}
Retry Element Click //div[contains(@class, 'selectBox')]//li[contains(.,'${type}')]
Check New Rule UI Without Endpoint
Retry Element Click ${new_replication-rule_button}
Page Should Contain Please add an endpoint first
Retry Element Click ${link_to_registries}
Retry Wait Until Page Contains Endpoint URL
Retry Wait Element ${new_endpoint_button}
Create A New Endpoint
[Arguments] ${provider} ${name} ${url} ${username} ${pwd} ${save}=Y
#click new button
Retry Element Click xpath=${new_endpoint_button}
#input necessary info
Select From List By Value ${provider_selector} ${provider}
Retry Text Input xpath=${destination_name_xpath} ${name}
Run Keyword If '${provider}' == 'harbor' or '${provider}' == 'gitlab' Run keyword Retry Text Input xpath=${destination_url_xpath} ${url}
Run Keyword If '${provider}' == 'aws-ecr' or '${provider}' == 'google-gcr' Run keyword Select Destination URL ${url}
Run Keyword If '${provider}' != 'google-gcr' and '${username}' != '${null}' Retry Text Input xpath=${destination_username_xpath} ${username}
Run Keyword If '${pwd}' != '${null}' Retry Text Input xpath=${destination_password_xpath} ${pwd}
#cancel verify cert since we use a selfsigned cert
Retry Element Click ${destination_insecure_xpath}
Run Keyword If '${save}' == 'Y' Run keyword Retry Double Keywords When Error Retry Element Click ${replication_save_xpath} Retry Wait Until Page Not Contains Element ${replication_save_xpath}
Run Keyword If '${save}' == 'Y' Run keyword Filter Registry ${name}
Run Keyword If '${save}' == 'N' No Operation
Create A Rule With Existing Endpoint
[Arguments] ${name} ${replication_mode} ${filter_project_name} ${resource_type} ${endpoint} ${dest_namespace}
... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag}=${false}
#click new
Retry Element Click ${new_name_xpath}
#input name
Retry Text Input ${rule_name} ${name}
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push} AND Select Dest Registry ${endpoint}
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull} AND Select Source Registry ${endpoint}
#set filter
Retry Text Input ${filter_name_id} ${filter_project_name}
Run Keyword If '${filter_tag}' != '${false}' Retry Text Input ${filter_tag_id} ${filter_tag}
Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
#set trigger
Select Trigger ${mode}
Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron}
Run Keyword If '${mode}' == 'Event Based' and '${del_remote}' == '${true}' Retry Element Click ${del_remote_checkbox}
#click save
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
Sleep 2
Endpoint Is Unpingable
Retry Element Click ${ping_test_button}
Wait Until Page Contains Failed
Endpoint Is Pingable
Retry Element Click ${ping_test_button}
Wait Until Page Contains successfully
Disable Certificate Verification
Checkbox Should Be Selected ${destination_insecure_checkbox}
Retry Element Click ${destination_insecure_xpath}
Sleep 1
Enable Certificate Verification
Checkbox Should Not Be Selected ${destination_insecure_checkbox}
Retry Element Click ${destination_insecure_xpath}
Sleep 1
Switch To Registries
Retry Element Click ${nav_to_registries}
Sleep 1
Switch To Replication Manage
Retry Element Click ${nav_to_replications}
Sleep 1
Trigger Replication Manual
[Arguments] ${rule}
Retry Element Click ${rule_filter_search}
Retry Text Input ${rule_filter_input} ${rule}
Retry Element Click //clr-dg-row[contains(.,'${rule}')]//label
Retry Element Click ${action_bar_replicate}
Retry Wait Until Page Contains Element ${dialog_replicate}
#change from click to mouse down and up
Mouse Down ${dialog_replicate}
Mouse Up ${dialog_replicate}
Sleep 2
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${rule}')]/../div/clr-icon[@shape='success-standard']
Sleep 1
Rename Rule
[Arguments] ${rule} ${newname}
Retry Element Click ${rule_filter_search}
Retry Text Input ${rule_filter_input} ${rule}
Retry Element Click //clr-dg-row[contains(.,'${rule}')]//label
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_edit}
Retry Text Input ${rule_name} ${newname}
Retry Element Click ${rule_save_button}
Select Rule
[Arguments] ${rule}
Retry Double Keywords When Error Retry Element Click //clr-dg-row[contains(.,'${rule}')]/div/div[1]/div Retry Wait Element ${replication_rule_exec_id}
Stop Jobs
Retry Element Click ${stop_jobs_button}
View Job Log
[arguments] ${job}
Retry Element Click ${job_filter_search}
Retry Text Input ${job_filter_input} ${job}
Retry Link Click //clr-dg-row[contains(.,'${job}')]//a
Find Registry And Click Edit Button
[Arguments] ${name}
Filter Object ${name}
Retry Select Object ${name}
Retry Element Click ${registry_edit_btn}
Switch To Replication Manage Page
Switch To Registries
Switch To Replication Manage
Click Edit Button
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_edit}
Click Delete Button
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_delete}
Edit Replication Rule
[Arguments] ${name}
Switch To Replication Manage Page
Filter Replication Rule ${name}
Select Rule ${name}
Click Edit Button
Retry Wait Until Page Contains Edit Replication Rule
Delete Replication Rule
[Arguments] ${name}
Switch To Replication Manage Page
Filter Replication Rule ${name}
Select Rule ${name}
Click Delete Button
Wait Until Page Contains Element ${dialog_delete}
Retry Double Keywords When Error Retry Element Click ${dialog_delete} Retry Wait Until Page Not Contains Element ${dialog_delete}
Filter Replication Rule ${name} exist=${false}
Rename Endpoint
[arguments] ${name} ${newname}
Find Registry And Click Edit Button ${name}
Retry Wait Until Page Contains Element ${destination_name_xpath}
Retry Text Input ${destination_name_xpath} ${newname}
Retry Element Click ${replication_save_xpath}
Delete Endpoint
[Arguments] ${name}
Retry Element Click ${endpoint_filter_search}
Retry Text Input ${endpoint_filter_input} ${name}
#click checkbox before target endpoint
Retry Double Keywords When Error Retry Element Click //clr-dg-row[contains(.,'${name}')]//clr-checkbox-wrapper Retry Wait Element ${registry_del_btn}
Retry Element Click ${registry_del_btn}
Wait Until Page Contains Element ${dialog_delete}
Retry Element Click ${dialog_delete}
Select Rule And Replicate
[Arguments] ${rule_name}
Select Rule ${rule_name}
Retry Element Click ${replication_rule_exec_id}
Retry Double Keywords When Error Retry Element Click xpath=${dialog_replicate} Retry Wait Until Page Not Contains Element xpath=${dialog_replicate}
Image Should Be Replicated To Project
[Arguments] ${project} ${image} ${period}=60 ${times}=20 ${tag}=${EMPTY} ${expected_image_size_in_regexp}=${null} ${total_artifact_count}=${null} ${archive_count}=${null}
FOR ${n} IN RANGE 0 ${times}
Sleep ${period}
Go Into Project ${project}
Switch To Project Repo
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains ${project}/${image}
Log To Console Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 5
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
Go Into Repo ${project}/${image}
${size}= Run Keyword If '${tag}'!='${EMPTY}' and '${expected_image_size_in_regexp}'!='${null}' Get Text //clr-dg-row[contains(., '${tag}')]//clr-dg-cell[4]/div
Run Keyword If '${tag}'!='${EMPTY}' and '${expected_image_size_in_regexp}'!='${null}' Should Match Regexp '${size}' '${expected_image_size_in_regexp}'
Run Keyword If '${total_artifact_count}'!='${null}' Run Keywords
... Should Not Be Empty ${tag}
... AND Go Into Index And Contain Artifacts ${tag} total_artifact_count=${total_artifact_count} archive_count=${archive_count}
Executions Result Count Should Be
[Arguments] ${expected_status} ${expected_trigger_type} ${expected_result_count}
Sleep 10
${count}= Get Element Count xpath=//clr-dg-row[contains(.,'${expected_status}') and contains(.,'${expected_trigger_type}')]
Should Be Equal As Integers ${count} ${expected_result_count}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Filter Replication Rule
[Arguments] ${ruleName} ${exist}=${true}
${rule_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${ruleName}')]
Retry Element Click ${filter_rules_btn}
Retry Clear Element Text ${filter_rules_input}
Retry Text Input ${filter_rules_input} ${ruleName}
Run Keyword If ${exist}==${true} Retry Wait Until Page Contains Element ${rule_name_element}
... ELSE Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any replication rules!\")]
Filter Registry
[Arguments] ${registry_name}
${registry_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${registry_name}')]
Switch To Replication Manage
Switch To Registries
Retry Element Click ${filter_registry_btn}
Retry Text Input ${filter_registry_input} ${registry_name}
Retry Wait Until Page Contains Element ${registry_name_element}
Select Dest Registry
[Arguments] ${endpoint}
Retry Element Click ${dest_registry_dropdown_list}
Retry Element Click ${dest_registry_dropdown_list}//option[contains(.,'${endpoint}')]
Select Source Registry
[Arguments] ${endpoint}
Retry Element Click ${src_registry_dropdown_list}
Retry Element Click ${src_registry_dropdown_list}//option[contains(.,'${endpoint}')]
Select Trigger
[Arguments] ${mode}
Retry Element Click ${rule_trigger_select}
Retry Element Click ${rule_trigger_select}//option[contains(.,'${mode}')]
Select Destination URL
[Arguments] ${type}
Retry Element Click ${destination_url_xpath}
Retry Element Click //div[contains(@class, 'selectBox')]//li[contains(.,'${type}')]
Check New Rule UI Without Endpoint
Retry Element Click ${new_replication-rule_button}
Page Should Contain Please add an endpoint first
Retry Element Click ${link_to_registries}
Retry Wait Until Page Contains Endpoint URL
Retry Wait Element ${new_endpoint_button}
Create A New Endpoint
[Arguments] ${provider} ${name} ${url} ${username} ${pwd} ${save}=Y
#click new button
Retry Element Click xpath=${new_endpoint_button}
#input necessary info
Select From List By Value ${provider_selector} ${provider}
Retry Text Input xpath=${destination_name_xpath} ${name}
Run Keyword If '${provider}' == 'harbor' or '${provider}' == 'gitlab' Run keyword Retry Text Input xpath=${destination_url_xpath} ${url}
Run Keyword If '${provider}' == 'aws-ecr' or '${provider}' == 'google-gcr' Run keyword Select Destination URL ${url}
Run Keyword If '${provider}' != 'google-gcr' and '${username}' != '${null}' Retry Text Input xpath=${destination_username_xpath} ${username}
Run Keyword If '${pwd}' != '${null}' Retry Text Input xpath=${destination_password_xpath} ${pwd}
#cancel verify cert since we use a selfsigned cert
Retry Element Click ${destination_insecure_xpath}
Run Keyword If '${save}' == 'Y' Run keyword Retry Double Keywords When Error Retry Element Click ${replication_save_xpath} Retry Wait Until Page Not Contains Element ${replication_save_xpath}
Run Keyword If '${save}' == 'Y' Run keyword Filter Registry ${name}
Run Keyword If '${save}' == 'N' No Operation
Create A Rule With Existing Endpoint
[Arguments] ${name} ${replication_mode} ${filter_project_name} ${resource_type} ${endpoint} ${dest_namespace}
... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag}=${false}
#click new
Retry Element Click ${new_name_xpath}
#input name
Retry Text Input ${rule_name} ${name}
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push} AND Select Dest Registry ${endpoint}
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull} AND Select Source Registry ${endpoint}
#set filter
Retry Text Input ${filter_name_id} ${filter_project_name}
Run Keyword If '${filter_tag}' != '${false}' Retry Text Input ${filter_tag_id} ${filter_tag}
Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
#set trigger
Select Trigger ${mode}
Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron}
Run Keyword If '${mode}' == 'Event Based' and '${del_remote}' == '${true}' Retry Element Click ${del_remote_checkbox}
#click save
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
Sleep 2
Endpoint Is Unpingable
Retry Element Click ${ping_test_button}
Wait Until Page Contains Failed
Endpoint Is Pingable
Retry Element Click ${ping_test_button}
Wait Until Page Contains successfully
Disable Certificate Verification
Checkbox Should Be Selected ${destination_insecure_checkbox}
Retry Element Click ${destination_insecure_xpath}
Sleep 1
Enable Certificate Verification
Checkbox Should Not Be Selected ${destination_insecure_checkbox}
Retry Element Click ${destination_insecure_xpath}
Sleep 1
Switch To Registries
Retry Element Click ${nav_to_registries}
Sleep 1
Switch To Replication Manage
Retry Element Click ${nav_to_replications}
Sleep 1
Trigger Replication Manual
[Arguments] ${rule}
Retry Element Click ${rule_filter_search}
Retry Text Input ${rule_filter_input} ${rule}
Retry Element Click //clr-dg-row[contains(.,'${rule}')]//label
Retry Element Click ${action_bar_replicate}
Retry Wait Until Page Contains Element ${dialog_replicate}
#change from click to mouse down and up
Mouse Down ${dialog_replicate}
Mouse Up ${dialog_replicate}
Sleep 2
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${rule}')]/../div/clr-icon[@shape='success-standard']
Sleep 1
Rename Rule
[Arguments] ${rule} ${newname}
Retry Element Click ${rule_filter_search}
Retry Text Input ${rule_filter_input} ${rule}
Retry Element Click //clr-dg-row[contains(.,'${rule}')]//label
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_edit}
Retry Text Input ${rule_name} ${newname}
Retry Element Click ${rule_save_button}
Select Rule
[Arguments] ${rule}
Retry Double Keywords When Error Retry Element Click //clr-dg-row[contains(.,'${rule}')]/div/div[1]/div Retry Wait Element ${replication_rule_exec_id}
Stop Jobs
Retry Element Click ${stop_jobs_button}
View Job Log
[arguments] ${job}
Retry Element Click ${job_filter_search}
Retry Text Input ${job_filter_input} ${job}
Retry Link Click //clr-dg-row[contains(.,'${job}')]//a
Find Registry And Click Edit Button
[Arguments] ${name}
Filter Object ${name}
Retry Select Object ${name}
Retry Element Click ${registry_edit_btn}
Switch To Replication Manage Page
Switch To Registries
Switch To Replication Manage
Click Edit Button
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_edit}
Click Delete Button
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_delete}
Edit Replication Rule
[Arguments] ${name}
Switch To Replication Manage Page
Filter Replication Rule ${name}
Select Rule ${name}
Click Edit Button
Retry Wait Until Page Contains Edit Replication Rule
Delete Replication Rule
[Arguments] ${name}
Switch To Replication Manage Page
Filter Replication Rule ${name}
Select Rule ${name}
Click Delete Button
Wait Until Page Contains Element ${dialog_delete}
Retry Double Keywords When Error Retry Element Click ${dialog_delete} Retry Wait Until Page Not Contains Element ${dialog_delete}
Filter Replication Rule ${name} exist=${false}
Rename Endpoint
[arguments] ${name} ${newname}
Find Registry And Click Edit Button ${name}
Retry Wait Until Page Contains Element ${destination_name_xpath}
Retry Text Input ${destination_name_xpath} ${newname}
Retry Element Click ${replication_save_xpath}
Delete Endpoint
[Arguments] ${name}
Retry Element Click ${endpoint_filter_search}
Retry Text Input ${endpoint_filter_input} ${name}
#click checkbox before target endpoint
Retry Double Keywords When Error Retry Element Click //clr-dg-row[contains(.,'${name}')]//clr-checkbox-wrapper Retry Wait Element ${registry_del_btn}
Retry Element Click ${registry_del_btn}
Wait Until Page Contains Element ${dialog_delete}
Retry Element Click ${dialog_delete}
Select Rule And Replicate
[Arguments] ${rule_name}
Select Rule ${rule_name}
Retry Element Click ${replication_rule_exec_id}
Retry Double Keywords When Error Retry Element Click xpath=${dialog_replicate} Retry Wait Until Page Not Contains Element xpath=${dialog_replicate}
Image Should Be Replicated To Project
[Arguments] ${project} ${image} ${period}=60 ${times}=20 ${tag}=${EMPTY} ${expected_image_size_in_regexp}=${null} ${total_artifact_count}=${null} ${archive_count}=${null}
FOR ${n} IN RANGE 0 ${times}
Sleep ${period}
Go Into Project ${project}
Switch To Project Repo
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains ${project}/${image}
Log To Console Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 5
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
Go Into Repo ${project}/${image}
${size}= Run Keyword If '${tag}'!='${EMPTY}' and '${expected_image_size_in_regexp}'!='${null}' Get Text //clr-dg-row[contains(., '${tag}')]//clr-dg-cell[4]/div
Run Keyword If '${tag}'!='${EMPTY}' and '${expected_image_size_in_regexp}'!='${null}' Should Match Regexp '${size}' '${expected_image_size_in_regexp}'
Run Keyword If '${total_artifact_count}'!='${null}' Run Keywords
... Should Not Be Empty ${tag}
... AND Go Into Index And Contain Artifacts ${tag} total_artifact_count=${total_artifact_count} archive_count=${archive_count}
Executions Result Count Should Be
[Arguments] ${expected_status} ${expected_trigger_type} ${expected_result_count}
Sleep 10
${count}= Get Element Count xpath=//clr-dg-row[contains(.,'${expected_status}') and contains(.,'${expected_trigger_type}')]
Should Be Equal As Integers ${count} ${expected_result_count}

View File

@ -1,97 +1,97 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${new_name_xpath} //hbr-list-replication-rule//button[contains(.,'New')]
${policy_name_xpath} //*[@id='policy_name']
${policy_description_xpath} //*[@id='policy_description']
${policy_enable_checkbox} //input[@id='policy_enable']/../label
${policy_endpoint_checkbox} //input[@id='check_new']/../label
${destination_name_xpath} //*[@id='destination_name']
${destination_url_xpath} //*[@id='destination_url']
${destination_username_xpath} //*[@id='destination_access_key']
${destination_password_xpath} //*[@id='destination_password']
${replication_save_xpath} //button[contains(.,'OK')]
${replication_xpath} //clr-vertical-nav-group-children/a[contains(.,'Replication')]
${destination_insecure_xpath} //label[@id='destination_insecure_checkbox']
${new_replication-rule_button} //button[contains(.,'New Replication Rule')]
${link_to_registries} //clr-modal//span[contains(.,'Endpoint')]
${new_endpoint_button} //hbr-endpoint//button[contains(.,'New Endpoint')]
${rule_name} //input[@id='ruleName']
${source_image_filter_add} //hbr-create-edit-rule/clr-modal//clr-icon[@id='add-label-list']
${source_iamge_repo_filter} //hbr-create-edit-rule//section/div[4]/div/div[1]/div/label/input
${source_image_tag_filter} //hbr-create-edit-rule//section/div[4]/div/div[2]/div/label/input
${rule_target_select} //select[@id='ruleTarget']
${rule_trigger_select} //select[@id='ruleTrigger']
${schedule_type_select} //select[@name='scheduleType']
${schedule_day_select} //select[@name='scheduleDay']
${shcedule_time} //input[@type='time']
${destination_insecure_checkbox} //hbr-create-edit-endpoint/clr-modal//input[@id='destination_insecure']
#${destination_insecure_checkbox} //clr-checkbox-wrapper/label[contains(@for, 'destination_insecure')]
${ping_test_button} //button[contains(.,'Test')]
${nav_to_registries} //clr-vertical-nav//span[contains(.,'Registries')]
${nav_to_replications} //clr-vertical-nav//span[contains(.,'Replications')]
${rule_filter_search} //hbr-replication/div/div[1]//hbr-filter/span/clr-icon
${rule_filter_input} //hbr-replication/div/div[1]//hbr-filter/span//input
${job_filter_search} //hbr-replication/div/div[3]//hbr-filter/span/clr-icon
${job_filter_input} //hbr-replication/div/div[3]//hbr-filter/span//input
${endpoint_filter_search} //hbr-filter/span/clr-icon
${endpoint_filter_input} //hbr-filter/span//input
${stop_jobs_button} //button[contains(.,'Stop Jobs')]
${dialog_close} //clr-modal//button[contains(.,'CLOSE')]
${dialog_delete} //clr-modal//button[contains(.,'DELETE')]
${dialog_replicate} //clr-modal//button[contains(.,'REPLICATE')]
${action_bar_replicate} //button[contains(.,'Replicate')]
${rule_save_button} //button[contains(.,'SAVE')]
${provider_selector} //*[@id='adapter']
${replication_mode_radio_push} //clr-main-container//hbr-create-edit-rule//label[contains(.,'Push-based')]
${replication_mode_radio_pull} //clr-main-container//hbr-create-edit-rule//label[contains(.,'Pull-based')]
${filter_name_id} //input[@id='filter_name']
${filter_tag_id} //input[@id='filter_tag']
${rule_resource_selector} //*[@id='select_resource']
${trigger_mode_selector} //*[@id='ruleTrigger']
${dest_namespace_xpath} //*[@id='dest_namespace']
${new_replication_rule_id} //*[@id='new_replication_rule_id']
${registry_edit_btn} //button[contains(.,'Edit')]
${registry_del_btn} //button[contains(.,'Delete')]
${replication_rule_action} //*[@id='rule-action']
${replication_rule_action_bar_edit} //*[@id='edit_replication_rule_id']
${replication_rule_action_bar_delete} //*[@id='delete_replication_rule_id']
${replication_rule_exec_id} //*[@id='replication_exe_id']
${replication_task_line_1} //clr-datagrid//clr-dg-row/div/div[2]//clr-checkbox-wrapper/label[1]
${is_overide_xpath} //label[contains(.,'Replace the destination resources if name exists')]
${enable_rule_xpath} //label[contains(.,'Enable rule')]
${targetCron_id} //*[@id='targetCron']
${rule_name_input} //*[@id='ruleName']
${src_registry_dropdown_list} //select[@id='src_registry_id']
${dest_registry_dropdown_list} //select[@id='dest_registry']
${rule_confirm_btn} //*[@id='ruleBtnOk']
${rule_cancel_btn} //*[@id='ruleBtnCancel']
${filter_rules_btn} //*[@id='filter-rules']
${filter_rules_input} //*[@id='filter-rules']//input
${del_remote_checkbox} //label[@for='ruleDeletion']
${filter_registry_btn} //hbr-filter
${filter_registry_input} //input[contains(@class,'filter-input')]
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${new_name_xpath} //hbr-list-replication-rule//button[contains(.,'New')]
${policy_name_xpath} //*[@id='policy_name']
${policy_description_xpath} //*[@id='policy_description']
${policy_enable_checkbox} //input[@id='policy_enable']/../label
${policy_endpoint_checkbox} //input[@id='check_new']/../label
${destination_name_xpath} //*[@id='destination_name']
${destination_url_xpath} //*[@id='destination_url']
${destination_username_xpath} //*[@id='destination_access_key']
${destination_password_xpath} //*[@id='destination_password']
${replication_save_xpath} //button[contains(.,'OK')]
${replication_xpath} //clr-vertical-nav-group-children/a[contains(.,'Replication')]
${destination_insecure_xpath} //label[@id='destination_insecure_checkbox']
${new_replication-rule_button} //button[contains(.,'New Replication Rule')]
${link_to_registries} //clr-modal//span[contains(.,'Endpoint')]
${new_endpoint_button} //hbr-endpoint//button[contains(.,'New Endpoint')]
${rule_name} //input[@id='ruleName']
${source_image_filter_add} //hbr-create-edit-rule/clr-modal//clr-icon[@id='add-label-list']
${source_iamge_repo_filter} //hbr-create-edit-rule//section/div[4]/div/div[1]/div/label/input
${source_image_tag_filter} //hbr-create-edit-rule//section/div[4]/div/div[2]/div/label/input
${rule_target_select} //select[@id='ruleTarget']
${rule_trigger_select} //select[@id='ruleTrigger']
${schedule_type_select} //select[@name='scheduleType']
${schedule_day_select} //select[@name='scheduleDay']
${shcedule_time} //input[@type='time']
${destination_insecure_checkbox} //hbr-create-edit-endpoint/clr-modal//input[@id='destination_insecure']
#${destination_insecure_checkbox} //clr-checkbox-wrapper/label[contains(@for, 'destination_insecure')]
${ping_test_button} //button[contains(.,'Test')]
${nav_to_registries} //clr-vertical-nav//span[contains(.,'Registries')]
${nav_to_replications} //clr-vertical-nav//span[contains(.,'Replications')]
${rule_filter_search} //hbr-replication/div/div[1]//hbr-filter/span/clr-icon
${rule_filter_input} //hbr-replication/div/div[1]//hbr-filter/span//input
${job_filter_search} //hbr-replication/div/div[3]//hbr-filter/span/clr-icon
${job_filter_input} //hbr-replication/div/div[3]//hbr-filter/span//input
${endpoint_filter_search} //hbr-filter/span/clr-icon
${endpoint_filter_input} //hbr-filter/span//input
${stop_jobs_button} //button[contains(.,'Stop Jobs')]
${dialog_close} //clr-modal//button[contains(.,'CLOSE')]
${dialog_delete} //clr-modal//button[contains(.,'DELETE')]
${dialog_replicate} //clr-modal//button[contains(.,'REPLICATE')]
${action_bar_replicate} //button[contains(.,'Replicate')]
${rule_save_button} //button[contains(.,'SAVE')]
${provider_selector} //*[@id='adapter']
${replication_mode_radio_push} //clr-main-container//hbr-create-edit-rule//label[contains(.,'Push-based')]
${replication_mode_radio_pull} //clr-main-container//hbr-create-edit-rule//label[contains(.,'Pull-based')]
${filter_name_id} //input[@id='filter_name']
${filter_tag_id} //input[@id='filter_tag']
${rule_resource_selector} //*[@id='select_resource']
${trigger_mode_selector} //*[@id='ruleTrigger']
${dest_namespace_xpath} //*[@id='dest_namespace']
${new_replication_rule_id} //*[@id='new_replication_rule_id']
${registry_edit_btn} //button[contains(.,'Edit')]
${registry_del_btn} //button[contains(.,'Delete')]
${replication_rule_action} //*[@id='rule-action']
${replication_rule_action_bar_edit} //*[@id='edit_replication_rule_id']
${replication_rule_action_bar_delete} //*[@id='delete_replication_rule_id']
${replication_rule_exec_id} //*[@id='replication_exe_id']
${replication_task_line_1} //clr-datagrid//clr-dg-row/div/div[2]//clr-checkbox-wrapper/label[1]
${is_overide_xpath} //label[contains(.,'Replace the destination resources if name exists')]
${enable_rule_xpath} //label[contains(.,'Enable rule')]
${targetCron_id} //*[@id='targetCron']
${rule_name_input} //*[@id='ruleName']
${src_registry_dropdown_list} //select[@id='src_registry_id']
${dest_registry_dropdown_list} //select[@id='dest_registry']
${rule_confirm_btn} //*[@id='ruleBtnOk']
${rule_cancel_btn} //*[@id='ruleBtnCancel']
${filter_rules_btn} //*[@id='filter-rules']
${filter_rules_input} //*[@id='filter-rules']//input
${del_remote_checkbox} //label[@for='ruleDeletion']
${filter_registry_btn} //hbr-filter
${filter_registry_input} //input[contains(@class,'filter-input')]

View File

@ -1,116 +1,116 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Delete Success
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='success-standard']
END
Sleep 1
Delete Fail
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='error-standard']
END
Sleep 1
Filter Object
#Filter project repo user tag.
[Arguments] ${kw}
Retry Element Click xpath=//hbr-filter//clr-icon
${element}= Set Variable xpath=//hbr-filter//input
Wait Until Element Is Visible And Enabled ${element}
Retry Clear Element Text ${element}
Retry Text Input ${element} ${kw}
Sleep 3
Filter Project
#Filter project repo user tag.
[Arguments] ${kw}
Retry Element Click ${log_xpath}
Retry Element Click ${projects_xpath}
Filter Object ${kw}
Select Object
#select single element such as user project repo tag
[Arguments] ${obj}
Retry Element Click xpath=//clr-dg-row[contains(.,'${obj}')]//label
Multi-delete Object
[Arguments] ${delete_btn} @{obj}
FOR ${obj} IN @{obj}
${element}= Set Variable xpath=//clr-dg-row[contains(.,'${obj}')]//label
Retry Element Click ${element}
END
Sleep 1
Retry Element Click ${delete_btn}
Sleep 1
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 1
Sleep 1
# This func cannot support as the delete user flow changed.
Multi-delete Artifact
[Arguments] ${delete_btn} @{obj}
FOR ${obj} IN @{obj}
${element}= Set Variable xpath=//clr-dg-row[contains(.,'${obj}')]//label
Retry Element Click ${element}
END
Sleep 1
Retry Element Click ${artifact_action_xpath}
Sleep 1
Retry Element Click ${artifact_action_delete_xpath}
Sleep 1
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 1
Sleep 1
Multi-delete User
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
Retry Element Click ${member_action_xpath}
Retry Element Click //*[@id='deleteUser']
Retry Double Keywords When Error Retry Element Click ${delete_btn} Retry Wait Until Page Not Contains Element ${delete_btn}
Multi-delete Member
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//clr-checkbox-wrapper/label
END
Retry Double Keywords When Error Retry Element Click ${member_action_xpath} Retry Wait Until Page Contains Element ${delete_action_xpath}
Retry Double Keywords When Error Retry Element Click ${delete_action_xpath} Retry Wait Until Page Contains Element ${delete_btn}
Retry Double Keywords When Error Retry Element Click ${delete_btn} Retry Wait Until Page Not Contains Element ${delete_btn}
Multi-delete Object Without Confirmation
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
Retry Double Keywords When Error Retry Element Click ${delete_btn_2} Retry Wait Until Page Not Contains Element ${delete_btn_2}
Select All On Current Page Object
Retry Element Click //div[@class='datagrid-head']//label
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Delete Success
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='success-standard']
END
Sleep 1
Delete Fail
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='error-standard']
END
Sleep 1
Filter Object
#Filter project repo user tag.
[Arguments] ${kw}
Retry Element Click xpath=//hbr-filter//clr-icon
${element}= Set Variable xpath=//hbr-filter//input
Wait Until Element Is Visible And Enabled ${element}
Retry Clear Element Text ${element}
Retry Text Input ${element} ${kw}
Sleep 3
Filter Project
#Filter project repo user tag.
[Arguments] ${kw}
Retry Element Click ${log_xpath}
Retry Element Click ${projects_xpath}
Filter Object ${kw}
Select Object
#select single element such as user project repo tag
[Arguments] ${obj}
Retry Element Click xpath=//clr-dg-row[contains(.,'${obj}')]//label
Multi-delete Object
[Arguments] ${delete_btn} @{obj}
FOR ${obj} IN @{obj}
${element}= Set Variable xpath=//clr-dg-row[contains(.,'${obj}')]//label
Retry Element Click ${element}
END
Sleep 1
Retry Element Click ${delete_btn}
Sleep 1
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 1
Sleep 1
# This func cannot support as the delete user flow changed.
Multi-delete Artifact
[Arguments] ${delete_btn} @{obj}
FOR ${obj} IN @{obj}
${element}= Set Variable xpath=//clr-dg-row[contains(.,'${obj}')]//label
Retry Element Click ${element}
END
Sleep 1
Retry Element Click ${artifact_action_xpath}
Sleep 1
Retry Element Click ${artifact_action_delete_xpath}
Sleep 1
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 1
Sleep 1
Multi-delete User
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
Retry Element Click ${member_action_xpath}
Retry Element Click //*[@id='deleteUser']
Retry Double Keywords When Error Retry Element Click ${delete_btn} Retry Wait Until Page Not Contains Element ${delete_btn}
Multi-delete Member
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//clr-checkbox-wrapper/label
END
Retry Double Keywords When Error Retry Element Click ${member_action_xpath} Retry Wait Until Page Contains Element ${delete_action_xpath}
Retry Double Keywords When Error Retry Element Click ${delete_action_xpath} Retry Wait Until Page Contains Element ${delete_btn}
Retry Double Keywords When Error Retry Element Click ${delete_btn} Retry Wait Until Page Not Contains Element ${delete_btn}
Multi-delete Object Without Confirmation
[Arguments] @{obj}
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
Retry Double Keywords When Error Retry Element Click ${delete_btn_2} Retry Wait Until Page Not Contains Element ${delete_btn_2}
Select All On Current Page Object
Retry Element Click //div[@class='datagrid-head']//label

View File

@ -1,20 +1,20 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${member_action_xpath} //*[@id="member-action"]
${delete_action_xpath} //clr-dropdown/clr-dropdown-menu/button[contains(.,'Remove')]
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${member_action_xpath} //*[@id="member-action"]
${delete_action_xpath} //clr-dropdown/clr-dropdown-menu/button[contains(.,'Remove')]

View File

@ -1,45 +1,45 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Change Password
[Arguments] ${cur_pw} ${new_pw}
Retry Element Click ${head_admin_xpath}
Retry Element Click ${change_password_xpath}
Retry Text Input ${old_password_xpath} ${cur_pw}
Retry Text Input ${new_password_xpath} ${new_pw}
Retry Text Input ${renew_password_xpath} ${new_pw}
Retry Element Click ${change_password_confirm_btn_xpath}
Retry Element Click xpath=${log_xpath}
Sleep 1
Update User Comment
[Arguments] ${new_comment}
Retry Element Click ${head_admin_xpath}
Retry Element Click ${user_profile_xpath}
Retry Text Input ${account_settings_comments_xpath} ${new_comment}
Retry Element Click ${user_profile_confirm_btn_xpath}
Sleep 2
Logout Harbor
Retry Element Click ${head_admin_xpath}
Retry Link Click Log Out
Sleep 2
Wait Until Keyword Succeeds 5x 1 Retry Wait Until Page Contains Element ${sign_in_title_xpath}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Change Password
[Arguments] ${cur_pw} ${new_pw}
Retry Element Click ${head_admin_xpath}
Retry Element Click ${change_password_xpath}
Retry Text Input ${old_password_xpath} ${cur_pw}
Retry Text Input ${new_password_xpath} ${new_pw}
Retry Text Input ${renew_password_xpath} ${new_pw}
Retry Element Click ${change_password_confirm_btn_xpath}
Retry Element Click xpath=${log_xpath}
Sleep 1
Update User Comment
[Arguments] ${new_comment}
Retry Element Click ${head_admin_xpath}
Retry Element Click ${user_profile_xpath}
Retry Text Input ${account_settings_comments_xpath} ${new_comment}
Retry Element Click ${user_profile_confirm_btn_xpath}
Sleep 2
Logout Harbor
Retry Element Click ${head_admin_xpath}
Retry Link Click Log Out
Sleep 2
Wait Until Keyword Succeeds 5x 1 Retry Wait Until Page Contains Element ${sign_in_title_xpath}

View File

@ -1,28 +1,28 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${head_admin_xpath} xpath=/html/body/harbor-app/harbor-shell/clr-main-container/navigator/clr-header/div[3]/clr-dropdown[2]/button/span
${change_password_xpath} xpath=//clr-main-container//clr-dropdown//a[2]
${user_profile_xpath} xpath=//clr-main-container//clr-dropdown//a[1]
${old_password_xpath} xpath=//*[@id='oldPassword']
${new_password_xpath} xpath=//*[@id='newPassword']
${renew_password_xpath} xpath=//*[@id='reNewPassword']
${change_password_confirm_btn_xpath} xpath=//password-setting/clr-modal//button[2]
${user_profile_confirm_btn_xpath} xpath=//account-settings-modal/clr-modal//button[2]
${sign_in_title_xpath} xpath=//sign-in//form//*[@class='title']
${account_settings_comments_xpath} xpath=//*[@id='account_settings_comments']
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${head_admin_xpath} xpath=/html/body/harbor-app/harbor-shell/clr-main-container/navigator/clr-header/div[3]/clr-dropdown[2]/button/span
${change_password_xpath} xpath=//clr-main-container//clr-dropdown//a[2]
${user_profile_xpath} xpath=//clr-main-container//clr-dropdown//a[1]
${old_password_xpath} xpath=//*[@id='oldPassword']
${new_password_xpath} xpath=//*[@id='newPassword']
${renew_password_xpath} xpath=//*[@id='reNewPassword']
${change_password_confirm_btn_xpath} xpath=//password-setting/clr-modal//button[2]
${user_profile_confirm_btn_xpath} xpath=//account-settings-modal/clr-modal//button[2]
${sign_in_title_xpath} xpath=//sign-in//form//*[@class='title']
${account_settings_comments_xpath} xpath=//*[@id='account_settings_comments']

File diff suppressed because it is too large Load Diff

View File

@ -1,109 +1,109 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Disable Scan Schedule
Retry Double Keywords When Error Retry Element Click ${vulnerability_edit_btn} Retry Wait Until Page Not Contains Element ${vulnerability_edit_btn}
Retry Element Click ${vulnerability_dropdown_list}
Retry Element Click ${vulnerability_dropdown_list_item_none}
Retry Double Keywords When Error Retry Element Click ${vulnerability_save_btn} Retry Wait Until Page Not Contains Element ${vulnerability_save_btn}
Set Scan Schedule
[Arguments] ${type} ${value}=${null}
Retry Double Keywords When Error Retry Element Click ${vulnerability_edit_btn} Retry Wait Until Page Not Contains Element ${vulnerability_edit_btn}
Retry Element Click ${vulnerability_dropdown_list}
Run Keyword If '${type}'=='custom' Run Keywords Retry Element Click ${vulnerability_dropdown_list_item_custom} AND Retry Text Input ${targetCron_id} ${value}
Retry Double Keywords When Error Retry Element Click ${vulnerability_save_btn} Retry Wait Until Page Not Contains Element ${vulnerability_save_btn}
Trigger Scan Now And Wait Until The Result Appears
Retry Element Click xpath=${scan_now_button}
Sleep 60
Retry Wait Until Page Contains Element ${scan_now_result}
Switch To Vulnerability Page
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Interrogation')]
Retry Element Click xpath=//app-interrogation-services//a[contains(.,'Vulnerability')]
Retry Wait Element ${scan_now_button}
Set Vulnerabilty Serverity
#0 is critical, 1 is high, 2 is medium, 3 is low, 4 is negligible.
[Arguments] ${level}
Goto Project Config
#enable first
Retry Element Click ${project_config_prevent_vulenrability_checkbox_label}
Checkbox Should Be Selected //project-detail//clr-checkbox-wrapper//input[@name='prevent-vulenrability-image-input']
Retry Element Click //project-detail//select
#wait for dropdown popup
Sleep 1
Select From List By Index //project-detail//select ${level}
Retry Element Click ${project_config_save_btn}
Scan Is Disabled
Retry Wait Until Page Contains Element //button[@id='scan-btn' and @disabled='']
Move To Summary Chart
Sleep 2
Wait Until Element Is Visible //hbr-vulnerability-bar//hbr-result-tip-histogram
Mouse Over //hbr-result-tip-histogram
Sleep 1
Scan Repo
#use fail for image can not scan, otherwise use success
[Arguments] ${tagname} ${status}
#select one tag
Retry Element Click //clr-dg-row[contains(.,'${tagname}')]//label
Retry Element Click //button[@id='scan-btn']
Run Keyword If '${status}' == 'Succeed' Wait Until Element Is Visible //hbr-vulnerability-bar//hbr-result-tip-histogram 300
Run Keyword If '${status}' == 'Fail' Wait Until Element Is Visible //hbr-vulnerability-bar//a 300
Scan Result Should Display In List Row
[Arguments] ${tagname} ${is_no_vulerabilty}=${false}
Run Keyword If ${is_no_vulerabilty}==${true} Retry Wait Until Page Contains Element //artifact-list-tab//clr-dg-row[contains(.,'No vulnerability') and contains(.,'${tagname}')]//clr-dg-cell//clr-tooltip
... ELSE Retry Wait Until Page Contains Element //artifact-list-tab//clr-dg-row[contains(.,'Total') and contains(.,'Fixable') and contains(.,'${tagname}')]//clr-dg-cell//clr-tooltip
Enable Scan On Push
Checkbox Should Not Be Selected //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Retry Element Click //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//label
Checkbox Should Be Selected //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Retry Element Click ${project_config_save_btn}
Sleep 10
Vulnerability Not Ready Project Hint
Sleep 2
${element}= Set Variable xpath=//span[contains(@class, 'db-status-warning')]
Wait Until Element Is Visible And Enabled ${element}
Switch To Scanners Page
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Interrogation')]
Retry Wait Until Page Contains Element ${set_default_scanner}
Should Display The Default Trivy Scanner
Retry Wait Until Page Contains Element //clr-datagrid//clr-dg-row//clr-dg-cell[contains(.,'Trivy')]//span[contains(.,'Default')]
Trivy Is Immutable Scanner
Retry Element Click //clr-dg-row[contains(.,'Trivy')]//clr-radio-wrapper/label
Retry Double Keywords When Error Retry Element Click ${scanner_action_xpath} Retry Wait Until Page Contains Element ${delete_scanner_action_xpath}
Retry Double Keywords When Error Retry Element Click ${delete_scanner_action_xpath} Retry Wait Until Page Contains Element ${delete_scanner_confirm_btn}
Retry Double Keywords When Error Retry Element Click ${delete_scanner_confirm_btn} Retry Wait Until Page Contains Element ${immutable_trivy_msg_xpath}
Set Default Scanner
[Arguments] ${scanner_name}
Retry Element Click //clr-dg-row[contains(.,'${scanner_name}')]//clr-radio-wrapper/label
Retry Double Keywords When Error Retry Element Click ${scanner_set_default} Retry Wait Until Page Contains Element ${scanner_set_default_success_xpath}
Check Listed In CVE Allowlist
[Arguments] ${project_name} ${image} ${tag} ${cve_id} ${is_in}=Yes
Go Into Project ${project_name}
Go Into Repo ${project_name}/${image}
Go Into Artifact ${tag}
Scroll Element Into View //clr-dg-row[contains(.,'${cve_id}')]
${text}= Get Text //clr-dg-row[contains(.,'${cve_id}')]//clr-dg-cell[7]
Capture Page Screenshot
Log All is_in_allow_list:${text}
Should Be Equal As Strings '${text}' '${is_in}'
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
Disable Scan Schedule
Retry Double Keywords When Error Retry Element Click ${vulnerability_edit_btn} Retry Wait Until Page Not Contains Element ${vulnerability_edit_btn}
Retry Element Click ${vulnerability_dropdown_list}
Retry Element Click ${vulnerability_dropdown_list_item_none}
Retry Double Keywords When Error Retry Element Click ${vulnerability_save_btn} Retry Wait Until Page Not Contains Element ${vulnerability_save_btn}
Set Scan Schedule
[Arguments] ${type} ${value}=${null}
Retry Double Keywords When Error Retry Element Click ${vulnerability_edit_btn} Retry Wait Until Page Not Contains Element ${vulnerability_edit_btn}
Retry Element Click ${vulnerability_dropdown_list}
Run Keyword If '${type}'=='custom' Run Keywords Retry Element Click ${vulnerability_dropdown_list_item_custom} AND Retry Text Input ${targetCron_id} ${value}
Retry Double Keywords When Error Retry Element Click ${vulnerability_save_btn} Retry Wait Until Page Not Contains Element ${vulnerability_save_btn}
Trigger Scan Now And Wait Until The Result Appears
Retry Element Click xpath=${scan_now_button}
Sleep 60
Retry Wait Until Page Contains Element ${scan_now_result}
Switch To Vulnerability Page
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Interrogation')]
Retry Element Click xpath=//app-interrogation-services//a[contains(.,'Vulnerability')]
Retry Wait Element ${scan_now_button}
Set Vulnerabilty Serverity
#0 is critical, 1 is high, 2 is medium, 3 is low, 4 is negligible.
[Arguments] ${level}
Goto Project Config
#enable first
Retry Element Click ${project_config_prevent_vulenrability_checkbox_label}
Checkbox Should Be Selected //project-detail//clr-checkbox-wrapper//input[@name='prevent-vulenrability-image-input']
Retry Element Click //project-detail//select
#wait for dropdown popup
Sleep 1
Select From List By Index //project-detail//select ${level}
Retry Element Click ${project_config_save_btn}
Scan Is Disabled
Retry Wait Until Page Contains Element //button[@id='scan-btn' and @disabled='']
Move To Summary Chart
Sleep 2
Wait Until Element Is Visible //hbr-vulnerability-bar//hbr-result-tip-histogram
Mouse Over //hbr-result-tip-histogram
Sleep 1
Scan Repo
#use fail for image can not scan, otherwise use success
[Arguments] ${tagname} ${status}
#select one tag
Retry Element Click //clr-dg-row[contains(.,'${tagname}')]//label
Retry Element Click //button[@id='scan-btn']
Run Keyword If '${status}' == 'Succeed' Wait Until Element Is Visible //hbr-vulnerability-bar//hbr-result-tip-histogram 300
Run Keyword If '${status}' == 'Fail' Wait Until Element Is Visible //hbr-vulnerability-bar//a 300
Scan Result Should Display In List Row
[Arguments] ${tagname} ${is_no_vulerabilty}=${false}
Run Keyword If ${is_no_vulerabilty}==${true} Retry Wait Until Page Contains Element //artifact-list-tab//clr-dg-row[contains(.,'No vulnerability') and contains(.,'${tagname}')]//clr-dg-cell//clr-tooltip
... ELSE Retry Wait Until Page Contains Element //artifact-list-tab//clr-dg-row[contains(.,'Total') and contains(.,'Fixable') and contains(.,'${tagname}')]//clr-dg-cell//clr-tooltip
Enable Scan On Push
Checkbox Should Not Be Selected //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Retry Element Click //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//label
Checkbox Should Be Selected //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Retry Element Click ${project_config_save_btn}
Sleep 10
Vulnerability Not Ready Project Hint
Sleep 2
${element}= Set Variable xpath=//span[contains(@class, 'db-status-warning')]
Wait Until Element Is Visible And Enabled ${element}
Switch To Scanners Page
Retry Element Click xpath=//clr-main-container//clr-vertical-nav//a[contains(.,'Interrogation')]
Retry Wait Until Page Contains Element ${set_default_scanner}
Should Display The Default Trivy Scanner
Retry Wait Until Page Contains Element //clr-datagrid//clr-dg-row//clr-dg-cell[contains(.,'Trivy')]//span[contains(.,'Default')]
Trivy Is Immutable Scanner
Retry Element Click //clr-dg-row[contains(.,'Trivy')]//clr-radio-wrapper/label
Retry Double Keywords When Error Retry Element Click ${scanner_action_xpath} Retry Wait Until Page Contains Element ${delete_scanner_action_xpath}
Retry Double Keywords When Error Retry Element Click ${delete_scanner_action_xpath} Retry Wait Until Page Contains Element ${delete_scanner_confirm_btn}
Retry Double Keywords When Error Retry Element Click ${delete_scanner_confirm_btn} Retry Wait Until Page Contains Element ${immutable_trivy_msg_xpath}
Set Default Scanner
[Arguments] ${scanner_name}
Retry Element Click //clr-dg-row[contains(.,'${scanner_name}')]//clr-radio-wrapper/label
Retry Double Keywords When Error Retry Element Click ${scanner_set_default} Retry Wait Until Page Contains Element ${scanner_set_default_success_xpath}
Check Listed In CVE Allowlist
[Arguments] ${project_name} ${image} ${tag} ${cve_id} ${is_in}=Yes
Go Into Project ${project_name}
Go Into Repo ${project_name}/${image}
Go Into Artifact ${tag}
Scroll Element Into View //clr-dg-row[contains(.,'${cve_id}')]
${text}= Get Text //clr-dg-row[contains(.,'${cve_id}')]//clr-dg-cell[7]
Capture Page Screenshot
Log All is_in_allow_list:${text}
Should Be Equal As Strings '${text}' '${is_in}'

View File

@ -1,36 +1,36 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${vulnerability_edit_btn} xpath=//vulnerability-config//cron-selection//button[contains(.,'EDIT')]
${vulnerability_dropdown_list} xpath=//vulnerability-config//cron-selection//select[@id='selectPolicy']
${vulnerability_dropdown_list_item_none} xpath=//select[@id='selectPolicy']//option[contains(.,'None')]
${vulnerability_dropdown_list_item_custom} xpath=//select[@id='selectPolicy']//option[contains(.,'Custom')]
${vulnerability_save_btn} xpath=//cron-selection//button[contains(.,'SAVE')]
${scan_now_button} //vulnerability-config//button[contains(.,'NOW')]
${vulnerability_page} //clr-vertical-nav-group-children/a[contains(.,'Vulnerability')]
${set_default_scanner} //button[@id='set-default']
${scanner_action_xpath} //span[@id='action-scanner']
${delete_scanner_action_xpath} //span[@id='delete-scanner-action']
${immutable_trivy_msg_xpath} //span[contains(.,'registration Trivy is not allowed to delete as it is immutable: scanner API: delete')]
${delete_scanner_confirm_btn} xpath=//clr-modal//button[contains(.,'DELETE')]
${scan_now_result} xpath=//div[@id="scan-result-container"]
${scanner_set_default} xpath=//button[@id="set-default"]
${scanner_set_default_success_xpath} //span[contains(.,'Successfully updated')]
${not_scanned_icon} xpath=//span[@class[contains(.,'not-scan')]]
# 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 This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${vulnerability_edit_btn} xpath=//vulnerability-config//cron-selection//button[contains(.,'EDIT')]
${vulnerability_dropdown_list} xpath=//vulnerability-config//cron-selection//select[@id='selectPolicy']
${vulnerability_dropdown_list_item_none} xpath=//select[@id='selectPolicy']//option[contains(.,'None')]
${vulnerability_dropdown_list_item_custom} xpath=//select[@id='selectPolicy']//option[contains(.,'Custom')]
${vulnerability_save_btn} xpath=//cron-selection//button[contains(.,'SAVE')]
${scan_now_button} //vulnerability-config//button[contains(.,'NOW')]
${vulnerability_page} //clr-vertical-nav-group-children/a[contains(.,'Vulnerability')]
${set_default_scanner} //button[@id='set-default']
${scanner_action_xpath} //span[@id='action-scanner']
${delete_scanner_action_xpath} //span[@id='delete-scanner-action']
${immutable_trivy_msg_xpath} //span[contains(.,'registration Trivy is not allowed to delete as it is immutable: scanner API: delete')]
${delete_scanner_confirm_btn} xpath=//clr-modal//button[contains(.,'DELETE')]
${scan_now_result} xpath=//div[@id="scan-result-container"]
${scanner_set_default} xpath=//button[@id="set-default"]
${scanner_set_default_success_xpath} //span[contains(.,'Successfully updated')]
${not_scanned_icon} xpath=//span[@class[contains(.,'not-scan')]]

View File

@ -1,183 +1,183 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Library SeleniumLibrary
Library OperatingSystem
*** Variables ***
*** Keywords ***
Install Harbor to Test Server
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
Sleep 5s
${rc} ${output}= Run And Return Rc And Output docker ps
Should Be Equal As Integers ${rc} 0
Log To Console ${output}
Log To Console \nconfig harbor cfg
Config Harbor cfg http_proxy=https
Prepare Cert
Log To Console \ncomplile and up harbor now
Compile and Up Harbor With Source Code
${rc} ${output}= Run And Return Rc And Output docker ps
Should Be Equal As Integers ${rc} 0
Log To Console ${output}
Generate Certificate Authority For Chrome
Up Harbor
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make start -e NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum}
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Down Harbor
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output echo "Y" | make down -e NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum}
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Package Harbor Offline
[Arguments] ${with_notary}=true ${with_chartmuseum}=true ${with_trivy}=true
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
Log To Console make package_offline GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
${rc} ${output}= Run And Return Rc And Output make package_offline GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
Log To Console ${rc}
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Package Harbor Online
[Arguments] ${with_notary}=true ${with_chartmuseum}=true ${with_trivy}=true
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
Log To Console \nmake package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
${rc} ${output}= Run And Return Rc And Output make package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Switch To LDAP
Down Harbor
${rc} ${output}= Run And Return Rc And Output rm -rf /data
Log ${rc}
Should Be Equal As Integers ${rc} 0
Prepare Cert
Config Harbor cfg auth=ldap_auth http_proxy=https
Prepare
Up Harbor
Docker Pull osixia/openldap:1.1.7
${rc} ${output}= Run And Return Rc And Output cd tests && ./ldapprepare.sh
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker ps
Log ${output}
Should Be Equal As Integers ${rc} 0
Generate Certificate Authority For Chrome
Get Harbor CA
[Arguments] ${ip} ${cert}
Log All Start to get harbor ca: ${ip} ${cert}
Run Keyword If '${http_get_ca}' == 'false' Run Keywords
... Wait Unitl Command Success cp /ca/harbor_ca.crt ${cert}
... AND Return From Keyword
${rc} ${output}= Run And Return Rc And Output rm -rf ~/.docker/
Log All ${rc}
${rc} ${output}= Run And Return Rc and Output curl -o ${cert} -s -k -X GET -u 'admin:Harbor12345' 'https://${ip}/api/v2.0/systeminfo/getcert'
Log All ${output}
Should Be Equal As Integers ${rc} 0
Enable Notary Client
${rc} ${output}= Run And Return Rc And Output rm -rf ~/.docker/
Log ${rc}
${rc} ${output}= Run And Return Rc and Output curl -o /notary_ca.crt -s -k -X GET -u 'admin:Harbor12345' 'https://${ip}/api/v2.0/systeminfo/getcert'
Log ${output}
Should Be Equal As Integers ${rc} 0
Notary Remove Signature
[Arguments] ${ip} ${project} ${image} ${tag} ${user} ${pwd}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-util.sh remove ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${user} ${pwd}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
Notary Key Rotate
[Arguments] ${ip} ${project} ${image} ${tag} ${user} ${pwd}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-util.sh key_rotate ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${user} ${pwd}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
Prepare
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make prepare -e NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum}
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Config Harbor cfg
# Will change the IP and Protocol in the harbor.cfg
[Arguments] ${http_proxy}=http ${auth}=db_auth
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
${rc}= Run And Return Rc sed "s/^hostname = .*/hostname = ${output}/g" -i ./make/harbor.cfg
Log ${rc}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc sed "s/^ui_url_protocol = .*/ui_url_protocol = ${http_proxy}/g" -i ./make/harbor.cfg
Log ${rc}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc sed "s/^auth_mode = .*/auth_mode = ${auth}/g" -i ./make/harbor.cfg
Log ${rc}
Should Be Equal As Integers ${rc} 0
${out}= Run cat ./make/harbor.cfg
Log ${out}
Prepare Cert
# Will change the IP and Protocol in the harbor.cfg
${rc} ${ip}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
Log ${ip}
${rc}= Run And Return Rc sed "s/^IP=.*/IP=${ip}/g" -i ./tests/generateCerts.sh
Log ${rc}
${out}= Run cat ./tests/generateCerts.sh
Log ${out}
${rc} ${output}= Run And Return Rc And Output ./tests/generateCerts.sh
Should Be Equal As Integers ${rc} 0
Compile and Up Harbor With Source Code
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make install swagger_client NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
Log ${output}
Should Be Equal As Integers ${rc} 0
Sleep 20
Wait for Harbor Ready
[Arguments] ${protocol} ${HARBOR_IP}
Log To Console Waiting for Harbor to Come Up...
FOR ${i} IN RANGE 20
${out}= Run curl -k ${protocol}://${HARBOR_IP}
Log ${out}
${status}= Run Keyword And Return Status Should Not Contain ${out} 502 Bad Gateway
${status}= Run Keyword If ${status} Run Keyword And Return Status Should Not Contain ${out} Connection refused
${status}= Run Keyword If ${status} Run Keyword And Return Status Should Contain ${out} <title>Harbor</title>
Return From Keyword If ${status} ${HARBOR_IP}
Sleep 30s
END
Fail Harbor failed to come up properly!
Get Harbor Version
${rc} ${output}= Run And Return Rc And Output curl -k -X GET --header 'Accept: application/json' 'https://${ip}/api/v2.0/systeminfo'|grep -i harbor_version
Log To Console ${output}
# 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 This resource provides any keywords related to the Harbor private registry appliance
Library SeleniumLibrary
Library OperatingSystem
*** Variables ***
*** Keywords ***
Install Harbor to Test Server
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
Sleep 5s
${rc} ${output}= Run And Return Rc And Output docker ps
Should Be Equal As Integers ${rc} 0
Log To Console ${output}
Log To Console \nconfig harbor cfg
Config Harbor cfg http_proxy=https
Prepare Cert
Log To Console \ncomplile and up harbor now
Compile and Up Harbor With Source Code
${rc} ${output}= Run And Return Rc And Output docker ps
Should Be Equal As Integers ${rc} 0
Log To Console ${output}
Generate Certificate Authority For Chrome
Up Harbor
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make start -e NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum}
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Down Harbor
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output echo "Y" | make down -e NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum}
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Package Harbor Offline
[Arguments] ${with_notary}=true ${with_chartmuseum}=true ${with_trivy}=true
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
Log To Console make package_offline GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
${rc} ${output}= Run And Return Rc And Output make package_offline GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
Log To Console ${rc}
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Package Harbor Online
[Arguments] ${with_notary}=true ${with_chartmuseum}=true ${with_trivy}=true
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
Log To Console \nmake package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
${rc} ${output}= Run And Return Rc And Output make package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} TRIVYFLAG=${with_trivy} HTTPPROXY=
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Switch To LDAP
Down Harbor
${rc} ${output}= Run And Return Rc And Output rm -rf /data
Log ${rc}
Should Be Equal As Integers ${rc} 0
Prepare Cert
Config Harbor cfg auth=ldap_auth http_proxy=https
Prepare
Up Harbor
Docker Pull osixia/openldap:1.1.7
${rc} ${output}= Run And Return Rc And Output cd tests && ./ldapprepare.sh
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker ps
Log ${output}
Should Be Equal As Integers ${rc} 0
Generate Certificate Authority For Chrome
Get Harbor CA
[Arguments] ${ip} ${cert}
Log All Start to get harbor ca: ${ip} ${cert}
Run Keyword If '${http_get_ca}' == 'false' Run Keywords
... Wait Unitl Command Success cp /ca/harbor_ca.crt ${cert}
... AND Return From Keyword
${rc} ${output}= Run And Return Rc And Output rm -rf ~/.docker/
Log All ${rc}
${rc} ${output}= Run And Return Rc and Output curl -o ${cert} -s -k -X GET -u 'admin:Harbor12345' 'https://${ip}/api/v2.0/systeminfo/getcert'
Log All ${output}
Should Be Equal As Integers ${rc} 0
Enable Notary Client
${rc} ${output}= Run And Return Rc And Output rm -rf ~/.docker/
Log ${rc}
${rc} ${output}= Run And Return Rc and Output curl -o /notary_ca.crt -s -k -X GET -u 'admin:Harbor12345' 'https://${ip}/api/v2.0/systeminfo/getcert'
Log ${output}
Should Be Equal As Integers ${rc} 0
Notary Remove Signature
[Arguments] ${ip} ${project} ${image} ${tag} ${user} ${pwd}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-util.sh remove ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${user} ${pwd}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
Notary Key Rotate
[Arguments] ${ip} ${project} ${image} ${tag} ${user} ${pwd}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-util.sh key_rotate ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${user} ${pwd}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
Prepare
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make prepare -e NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum}
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
Config Harbor cfg
# Will change the IP and Protocol in the harbor.cfg
[Arguments] ${http_proxy}=http ${auth}=db_auth
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
${rc}= Run And Return Rc sed "s/^hostname = .*/hostname = ${output}/g" -i ./make/harbor.cfg
Log ${rc}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc sed "s/^ui_url_protocol = .*/ui_url_protocol = ${http_proxy}/g" -i ./make/harbor.cfg
Log ${rc}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc sed "s/^auth_mode = .*/auth_mode = ${auth}/g" -i ./make/harbor.cfg
Log ${rc}
Should Be Equal As Integers ${rc} 0
${out}= Run cat ./make/harbor.cfg
Log ${out}
Prepare Cert
# Will change the IP and Protocol in the harbor.cfg
${rc} ${ip}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
Log ${ip}
${rc}= Run And Return Rc sed "s/^IP=.*/IP=${ip}/g" -i ./tests/generateCerts.sh
Log ${rc}
${out}= Run cat ./tests/generateCerts.sh
Log ${out}
${rc} ${output}= Run And Return Rc And Output ./tests/generateCerts.sh
Should Be Equal As Integers ${rc} 0
Compile and Up Harbor With Source Code
[Arguments] ${with_notary}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make install swagger_client NOTARYFLAG=${with_notary} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
Log ${output}
Should Be Equal As Integers ${rc} 0
Sleep 20
Wait for Harbor Ready
[Arguments] ${protocol} ${HARBOR_IP}
Log To Console Waiting for Harbor to Come Up...
FOR ${i} IN RANGE 20
${out}= Run curl -k ${protocol}://${HARBOR_IP}
Log ${out}
${status}= Run Keyword And Return Status Should Not Contain ${out} 502 Bad Gateway
${status}= Run Keyword If ${status} Run Keyword And Return Status Should Not Contain ${out} Connection refused
${status}= Run Keyword If ${status} Run Keyword And Return Status Should Contain ${out} <title>Harbor</title>
Return From Keyword If ${status} ${HARBOR_IP}
Sleep 30s
END
Fail Harbor failed to come up properly!
Get Harbor Version
${rc} ${output}= Run And Return Rc And Output curl -k -X GET --header 'Accept: application/json' 'https://${ip}/api/v2.0/systeminfo'|grep -i harbor_version
Log To Console ${output}

View File

@ -1,43 +1,43 @@
# 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 This resource provides helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
Prepare Helm Plugin
Wait Unitl Command Success helm init --stable-repo-url https://charts.helm.sh/stable --client-only
Wait Unitl Command Success helm plugin install https://github.com/chartmuseum/helm-push
Wait Unitl Command Success helm3 plugin install https://github.com/chartmuseum/helm-push
Helm Repo Add
[Arguments] ${harbor_url} ${user} ${pwd} ${project_name}=library ${helm_repo_name}=myrepo
${rc} ${output}= Run And Return Rc And Output helm repo remove ${project_name}
Log To Console ${output}
Wait Unitl Command Success helm repo add --ca-file /ca/ca.crt --username=${user} --password=${pwd} ${helm_repo_name} ${harbor_url}/chartrepo/${project_name}
Helm Repo Push
[Arguments] ${user} ${pwd} ${chart_filename} ${helm_repo_name}=myrepo ${helm_cmd}=helm
${current_dir}= Run pwd
Run cd ${current_dir}
Run wget ${harbor_chart_file_url}
Wait Unitl Command Success ${helm_cmd} push --ca-file=/ca/ca.crt --username=${user} --password=${pwd} ${chart_filename} ${helm_repo_name}
Helm Chart Push
[Arguments] ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/helm_push_chart.sh ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion}
Log ${output}
Should Be Equal As Integers ${rc} 0
# 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 This resource provides helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
Prepare Helm Plugin
Wait Unitl Command Success helm init --stable-repo-url https://charts.helm.sh/stable --client-only
Wait Unitl Command Success helm plugin install https://github.com/chartmuseum/helm-push
Wait Unitl Command Success helm3 plugin install https://github.com/chartmuseum/helm-push
Helm Repo Add
[Arguments] ${harbor_url} ${user} ${pwd} ${project_name}=library ${helm_repo_name}=myrepo
${rc} ${output}= Run And Return Rc And Output helm repo remove ${project_name}
Log To Console ${output}
Wait Unitl Command Success helm repo add --ca-file /ca/ca.crt --username=${user} --password=${pwd} ${helm_repo_name} ${harbor_url}/chartrepo/${project_name}
Helm Repo Push
[Arguments] ${user} ${pwd} ${chart_filename} ${helm_repo_name}=myrepo ${helm_cmd}=helm
${current_dir}= Run pwd
Run cd ${current_dir}
Run wget ${harbor_chart_file_url}
Wait Unitl Command Success ${helm_cmd} push --ca-file=/ca/ca.crt --username=${user} --password=${pwd} ${chart_filename} ${helm_repo_name}
Helm Chart Push
[Arguments] ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/helm_push_chart.sh ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion}
Log ${output}
Should Be Equal As Integers ${rc} 0

View File

@ -1,89 +1,89 @@
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource Util.robot
*** Variables ***
${SSH_USER} root
*** Keywords ***
Prepare Test Tools
Wait Unitl Command Success tar zxvf /usr/local/bin/tools.tar.gz -C /usr/local/bin/
Get And Setup Harbor CA
[Arguments] ${ip} ${HARBOR_PASSWORD} ${ca_setup_keyword} ${ip1}==${EMPTY}
Run Keyword If '${ip1}' != '${EMPTY}' Run Keywords
... Get Harbor CA ${ip1} /drone/harbor_ca1.crt
... AND Run Keyword ${ca_setup_keyword} ${ip1} ${HARBOR_PASSWORD} /drone/harbor_ca1.crt
Get Harbor CA ${ip} /drone/harbor_ca.crt
Log To Console ${ca_setup_keyword} ...
Run Keyword ${ca_setup_keyword} ${ip} ${HARBOR_PASSWORD} /drone/harbor_ca.crt
Nightly Test Setup In Photon
[Arguments] ${ip} ${HARBOR_PASSWORD} ${ip1}==${EMPTY}
Get And Setup Harbor CA ${ip} ${HARBOR_PASSWORD} CA Setup In Photon ip1=${ip1}
Prepare Test Tools
Log To Console Start Docker Daemon Locally ...
Start Docker Daemon Locally
Log To Console Start Containerd Daemon Locally ...
Start Containerd Daemon Locally
Log To Console wget mariadb ...
Run wget ${prometheus_chart_file_url}
Prepare Helm Plugin
#Prepare docker image for push special image keyword in replication test
Run Keyword If '${DOCKER_USER}' != '${EMPTY}' Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
Nightly Test Setup In Ubuntu
[Arguments] ${ip} ${HARBOR_PASSWORD} ${ip1}==${EMPTY}
Get And Setup Harbor CA ${ip} ${HARBOR_PASSWORD} CA Setup In ubuntu ip1=${ip1}
Prepare Test Tools
Log To Console Start Docker Daemon Locally ...
Run Keyword Start Docker Daemon Locally
Log To Console Start Containerd Daemon Locally ...
Run Keyword Start Containerd Daemon Locally
Prepare Helm Plugin
Run Keyword If '${DOCKER_USER}' != '${EMPTY}' Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
CA Setup In ubuntu
[Arguments] ${ip} ${HARBOR_PASSWORD} ${cert}
Prepare Docker Cert In Ubuntu ${ip} ${cert}
#Generate Certificate Authority For Chrome ${HARBOR_PASSWORD}
CA Setup In Photon
[Arguments] ${ip} ${HARBOR_PASSWORD} ${cert}
Prepare Docker Cert In Photon ${ip} ${cert}
Collect Nightly Logs
[Arguments] ${ip} ${SSH_PWD} ${ip1}==${EMPTY}
Run Keyword Collect Logs ${ip} ${SSH_PWD}
Run Keyword If '${ip1}' != '${EMPTY}' Collect Logs ${ip1} ${SSH_PWD}
Collect Logs
[Arguments] ${ip} ${SSH_PWD}
Open Connection ${ip}
Login ${SSH_USER} ${SSH_PWD}
SSHLibrary.Get File /var/log/harbor/ui.log
SSHLibrary.Get File /var/log/harbor/registry.log
SSHLibrary.Get File /var/log/harbor/proxy.log
SSHLibrary.Get File /var/log/harbor/adminserver.log
SSHLibrary.Get File /var/log/harbor/jobservice.log
SSHLibrary.Get File /var/log/harbor/postgresql.log
SSHLibrary.Get File /var/log/harbor/notary-server.log
SSHLibrary.Get File /var/log/harbor/notary-signer.log
SSHLibrary.Get File /var/log/harbor/chartmuseum.log
SSHLibrary.Get File /var/log/harbor/registryctl.log
Run rename 's/^/${ip}/' *.log
Close All Connections
# 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 This resource provides any keywords related to the Harbor private registry appliance
Resource Util.robot
*** Variables ***
${SSH_USER} root
*** Keywords ***
Prepare Test Tools
Wait Unitl Command Success tar zxvf /usr/local/bin/tools.tar.gz -C /usr/local/bin/
Get And Setup Harbor CA
[Arguments] ${ip} ${HARBOR_PASSWORD} ${ca_setup_keyword} ${ip1}==${EMPTY}
Run Keyword If '${ip1}' != '${EMPTY}' Run Keywords
... Get Harbor CA ${ip1} /drone/harbor_ca1.crt
... AND Run Keyword ${ca_setup_keyword} ${ip1} ${HARBOR_PASSWORD} /drone/harbor_ca1.crt
Get Harbor CA ${ip} /drone/harbor_ca.crt
Log To Console ${ca_setup_keyword} ...
Run Keyword ${ca_setup_keyword} ${ip} ${HARBOR_PASSWORD} /drone/harbor_ca.crt
Nightly Test Setup In Photon
[Arguments] ${ip} ${HARBOR_PASSWORD} ${ip1}==${EMPTY}
Get And Setup Harbor CA ${ip} ${HARBOR_PASSWORD} CA Setup In Photon ip1=${ip1}
Prepare Test Tools
Log To Console Start Docker Daemon Locally ...
Start Docker Daemon Locally
Log To Console Start Containerd Daemon Locally ...
Start Containerd Daemon Locally
Log To Console wget mariadb ...
Run wget ${prometheus_chart_file_url}
Prepare Helm Plugin
#Prepare docker image for push special image keyword in replication test
Run Keyword If '${DOCKER_USER}' != '${EMPTY}' Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
Nightly Test Setup In Ubuntu
[Arguments] ${ip} ${HARBOR_PASSWORD} ${ip1}==${EMPTY}
Get And Setup Harbor CA ${ip} ${HARBOR_PASSWORD} CA Setup In ubuntu ip1=${ip1}
Prepare Test Tools
Log To Console Start Docker Daemon Locally ...
Run Keyword Start Docker Daemon Locally
Log To Console Start Containerd Daemon Locally ...
Run Keyword Start Containerd Daemon Locally
Prepare Helm Plugin
Run Keyword If '${DOCKER_USER}' != '${EMPTY}' Docker Login "" ${DOCKER_USER} ${DOCKER_PWD}
CA Setup In ubuntu
[Arguments] ${ip} ${HARBOR_PASSWORD} ${cert}
Prepare Docker Cert In Ubuntu ${ip} ${cert}
#Generate Certificate Authority For Chrome ${HARBOR_PASSWORD}
CA Setup In Photon
[Arguments] ${ip} ${HARBOR_PASSWORD} ${cert}
Prepare Docker Cert In Photon ${ip} ${cert}
Collect Nightly Logs
[Arguments] ${ip} ${SSH_PWD} ${ip1}==${EMPTY}
Run Keyword Collect Logs ${ip} ${SSH_PWD}
Run Keyword If '${ip1}' != '${EMPTY}' Collect Logs ${ip1} ${SSH_PWD}
Collect Logs
[Arguments] ${ip} ${SSH_PWD}
Open Connection ${ip}
Login ${SSH_USER} ${SSH_PWD}
SSHLibrary.Get File /var/log/harbor/ui.log
SSHLibrary.Get File /var/log/harbor/registry.log
SSHLibrary.Get File /var/log/harbor/proxy.log
SSHLibrary.Get File /var/log/harbor/adminserver.log
SSHLibrary.Get File /var/log/harbor/jobservice.log
SSHLibrary.Get File /var/log/harbor/postgresql.log
SSHLibrary.Get File /var/log/harbor/notary-server.log
SSHLibrary.Get File /var/log/harbor/notary-signer.log
SSHLibrary.Get File /var/log/harbor/chartmuseum.log
SSHLibrary.Get File /var/log/harbor/registryctl.log
Run rename 's/^/${ip}/' *.log
Close All Connections

View File

@ -1,407 +1,407 @@
# 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 This resource contains any keywords related to using the Nimbus cluster
*** Variables ***
${ESX_VERSION} 4564106 #6.5 RTM
${VC_VERSION} 4602587 #6.5 RTM
${NIMBUS_ESX_PASSWORD} e2eFunctionalTest
*** Keywords ***
Deploy Nimbus ESXi Server
[Arguments] ${user} ${password} ${version}=${ESX_VERSION} ${tls_disabled}=True
${name}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
Log To Console \nDeploying Nimbus ESXi server: ${name}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command nimbus-esxdeploy ${name} --disk=48000000 --ssd=24000000 --memory=8192 --nics 2 ob-${version}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} To manage this VM use
\ Exit For Loop If ${status}
\ Log To Console ${out}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} IP is
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip}= Remove String @{gotIP}[5] ,
# Let's set a password so govc doesn't complain
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Run Keyword If ${tls_disabled} Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
Deploy Multiple Nimbus ESXi Servers in Parallel
[Arguments] ${user} ${password} ${version}=${ESX_VERSION}
${name1}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
${name2}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
${name3}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out1}= Deploy Nimbus ESXi Server Async ${name1}
${out2}= Deploy Nimbus ESXi Server Async ${name2}
${out3}= Deploy Nimbus ESXi Server Async ${name3}
Wait For Process ${out1}
Wait For Process ${out2}
Wait For Process ${out3}
${out}= Execute Command nimbus-ctl ip ${user}-${name1}
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} ${user}-${name1}
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip1}= Remove String @{gotIP}[2]
${out}= Execute Command nimbus-ctl ip ${user}-${name2}
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} ${user}-${name2}
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip2}= Remove String @{gotIP}[2]
${out}= Execute Command nimbus-ctl ip ${user}-${name3}
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} ${user}-${name3}
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip3}= Remove String @{gotIP}[2]
Log To Console \nDeploying Nimbus ESXi server: ${gotIP}
# Let's set a password so govc doesn't complain
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip1}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name1}
Log To Console \nNimbus ESXi server IP: ${ip1}
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip2}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name2}
Log To Console \nNimbus ESXi server IP: ${ip2}
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip3}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name3}
Log To Console \nNimbus ESXi server IP: ${ip3}
Close connection
[Return] ${user}-${name1} ${ip1} ${user}-${name2} ${ip2} ${user}-${name3} ${ip3}
Deploy Nimbus vCenter Server
[Arguments] ${user} ${password} ${version}=${VC_VERSION}
${name}= Evaluate 'VC-' + str(random.randint(1000,9999)) modules=random
Log To Console \nDeploying Nimbus vCenter server: ${name}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command nimbus-vcvadeploy --vcvaBuild ${version} ${name}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} Overall Status: Succeeded
\ Exit For Loop If ${status}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} Cloudvm is running on IP
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
${ip}= Fetch From Right ${line} ${SPACE}
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_USERNAME Administrator@vsphere.local
Set Environment Variable GOVC_PASSWORD Admin!23
Set Environment Variable GOVC_URL ${ip}
Log To Console Successfully deployed new vCenter server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
Deploy Nimbus ESXi Server Async
[Tags] secret
[Arguments] ${name} ${version}=${ESX_VERSION}
Log To Console \nDeploying Nimbus ESXi server: ${name}
${out}= Run Secret SSHPASS command %{NIMBUS_USER} %{NIMBUS_PASSWORD} 'nimbus-esxdeploy ${name} --disk\=48000000 --ssd\=24000000 --memory\=8192 --nics 2 ${version}'
[Return] ${out}
Run Secret SSHPASS command
[Tags] secret
[Arguments] ${user} ${password} ${cmd}
${out}= Start Process sshpass -p ${password} ssh -o StrictHostKeyChecking\=no ${user}@%{NIMBUS_GW} ${cmd} shell=True
[Return] ${out}
Deploy Nimbus vCenter Server Async
[Tags] secret
[Arguments] ${name} ${version}=${VC_VERSION}
Log To Console \nDeploying Nimbus VC server: ${name}
${out}= Run Secret SSHPASS command %{NIMBUS_USER} %{NIMBUS_PASSWORD} 'nimbus-vcvadeploy --vcvaBuild ${version} ${name}'
[Return] ${out}
Deploy Nimbus Testbed
[Arguments] ${user} ${password} ${testbed}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command nimbus-testbeddeploy ${testbed}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} is up. IP:
\ Exit For Loop If ${status}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
[Return] ${out}
Kill Nimbus Server
[Arguments] ${user} ${password} ${name}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out}= Execute Command nimbus-ctl kill '${name}'
Close connection
Cleanup Nimbus PXE folder
[Arguments] ${user} ${password}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out}= Execute Command rm -rf public_html/pxe/*
Close connection
Nimbus Cleanup
[Arguments] ${vm_list} ${collect_log}=True ${dontDelete}=${false}
Run Keyword If ${collect_log} Run Keyword And Continue On Failure Gather Logs From Test Server
Run Keyword And Ignore Error Cleanup Nimbus PXE folder %{NIMBUS_USER} %{NIMBUS_PASSWORD}
Return From Keyword If ${dontDelete}
:FOR ${item} IN @{vm_list}
\ Run Keyword And Ignore Error Kill Nimbus Server %{NIMBUS_USER} %{NIMBUS_PASSWORD} ${item}
Gather Host IPs
${out}= Run govc ls host/cls
${out}= Split To Lines ${out}
${idx}= Set Variable 1
:FOR ${line} IN @{out}
\ Continue For Loop If '${line}' == '/vcqaDC/host/cls/Resources'
\ ${ip}= Fetch From Right ${line} /
\ Set Suite Variable ${esx${idx}-ip} ${ip}
\ ${idx}= Evaluate ${idx}+1
Create a VSAN Cluster
Log To Console \nStarting basic VSAN cluster deploy...
${out}= Deploy Nimbus Testbed %{NIMBUS_USER} %{NIMBUS_PASSWORD} --noSupportBundles --vcvaBuild ${VC_VERSION} --esxPxeDir ${ESX_VERSION} --esxBuild ${ESX_VERSION} --testbedName vcqa-vsan-simple-pxeBoot-vcva --runName vic-vmotion
${out}= Split To Lines ${out}
:FOR ${line} IN @{out}
\ ${status}= Run Keyword And Return Status Should Contain ${line} .vcva-${VC_VERSION}' is up. IP:
\ ${ip}= Run Keyword If ${status} Fetch From Right ${line} ${SPACE}
\ Run Keyword If ${status} Set Suite Variable ${vc-ip} ${ip}
\ Exit For Loop If ${status}
Log To Console Set environment variables up for GOVC
Set Environment Variable GOVC_URL ${vc-ip}
Set Environment Variable GOVC_USERNAME Administrator@vsphere.local
Set Environment Variable GOVC_PASSWORD Admin\!23
Log To Console Create a distributed switch
${out}= Run govc dvs.create -dc=vcqaDC test-ds
Should Contain ${out} OK
Log To Console Create three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds bridge
Should Contain ${out} OK
Log To Console Add all the hosts to the distributed switch
${out}= Run govc dvs.add -dvs=test-ds -pnic=vmnic1 /vcqaDC/host/cls
Should Contain ${out} OK
Log To Console Enable DRS and VSAN on the cluster
${out}= Run govc cluster.change -drs-enabled /vcqaDC/host/cls
Should Be Empty ${out}
Log To Console Deploy VIC to the VC cluster
Set Environment Variable TEST_URL_ARRAY ${vc-ip}
Set Environment Variable TEST_USERNAME Administrator@vsphere.local
Set Environment Variable TEST_PASSWORD Admin\!23
Set Environment Variable BRIDGE_NETWORK bridge
Set Environment Variable PUBLIC_NETWORK vm-network
Set Environment Variable TEST_DATASTORE vsanDatastore
Set Environment Variable TEST_RESOURCE cls
Set Environment Variable TEST_TIMEOUT 30m
Gather Host IPs
Create a Simple VC Cluster
[Arguments] ${datacenter}=ha-datacenter ${cluster}=cls ${esx_number}=3 ${network}=True
Log To Console \nStarting simple VC cluster deploy...
${esx_names}= Create List
${esx_ips}= Create List
:FOR ${IDX} IN RANGE ${esx_number}
\ ${esx} ${esx_ip}= Deploy Nimbus ESXi Server %{NIMBUS_USER} %{NIMBUS_PASSWORD} ${ESX_VERSION} False
\ Append To List ${esx_names} ${esx}
\ Append To List ${esx_ips} ${esx_ip}
${vc} ${vc_ip}= Deploy Nimbus vCenter Server %{NIMBUS_USER} %{NIMBUS_PASSWORD}
Log To Console Create a datacenter on the VC
${out}= Run govc datacenter.create ${datacenter}
Should Be Empty ${out}
Log To Console Create a cluster on the VC
${out}= Run govc cluster.create ${cluster}
Should Be Empty ${out}
Log To Console Add ESX host to the VC
:FOR ${IDX} IN RANGE ${esx_number}
\ ${out}= Run govc cluster.add -hostname=@{esx_ips}[${IDX}] -username=root -dc=${datacenter} -password=${NIMBUS_ESX_PASSWORD} -noverify=true
\ Should Contain ${out} OK
Run Keyword If ${network} Setup Network For Simple VC Cluster ${esx_number} ${datacenter} ${cluster}
Log To Console Enable DRS on the cluster
${out}= Run govc cluster.change -drs-enabled /${datacenter}/host/${cluster}
Should Be Empty ${out}
Set Environment Variable TEST_URL_ARRAY ${vc_ip}
Set Environment Variable TEST_URL ${vc_ip}
Set Environment Variable TEST_USERNAME Administrator@vsphere.local
Set Environment Variable TEST_PASSWORD Admin\!23
Set Environment Variable TEST_DATASTORE datastore1
Set Environment Variable TEST_DATACENTER /${datacenter}
Set Environment Variable TEST_RESOURCE ${cluster}
Set Environment Variable TEST_TIMEOUT 30m
[Return] @{esx_names} ${vc} @{esx_ips} ${vc_ip}
Setup Network For Simple VC Cluster
[Arguments] ${esx_number} ${datacenter} ${cluster}
Log To Console Create a distributed switch
${out}= Run govc dvs.create -dc=${datacenter} test-ds
Should Contain ${out} OK
Log To Console Create three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds bridge
Should Contain ${out} OK
Log To Console Add all the hosts to the distributed switch
${out}= Run govc dvs.add -dvs=test-ds -pnic=vmnic1 /${datacenter}/host/${cluster}
Should Contain ${out} OK
Log To Console Enable DRS on the cluster
${out}= Run govc cluster.change -drs-enabled /${datacenter}/host/${cluster}
Should Be Empty ${out}
Set Environment Variable BRIDGE_NETWORK bridge
Set Environment Variable PUBLIC_NETWORK vm-network
Create A Distributed Switch
[Arguments] ${datacenter} ${dvs}=test-ds
Log To Console \nCreate a distributed switch
${out}= Run govc dvs.create -product-version 5.5.0 -dc=${datacenter} ${dvs}
Should Contain ${out} OK
Create Three Distributed Port Groups
[Arguments] ${datacenter} ${dvs}=test-ds
Log To Console \nCreate three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} bridge
Should Contain ${out} OK
Add Host To Distributed Switch
[Arguments] ${host} ${dvs}=test-ds
Log To Console \nAdd host(s) to the distributed switch
${out}= Run govc dvs.add -dvs=${dvs} -pnic=vmnic1 ${host}
Should Contain ${out} OK
Disable TLS On ESX Host
Log To Console \nDisable TLS on the host
${ver}= Get Vsphere Version
${out}= Run Keyword If '${ver}' != '5.5.0' Run govc host.option.set UserVars.ESXiVPsDisabledProtocols sslv3,tlsv1,tlsv1.1
Run Keyword If '${ver}' != '5.5.0' Should Be Empty ${out}
Get Vsphere Version
${out}= Run govc about
${out}= Split To Lines ${out}
:FOR ${line} IN @{out}
\ ${status}= Run Keyword And Return Status Should Contain ${line} Version:
\ Run Keyword And Return If ${status} Fetch From Right ${line} ${SPACE}
Deploy Nimbus NFS Datastore
[Arguments] ${user} ${password}
${name}= Evaluate 'NFS-' + str(random.randint(1000,9999)) modules=random
Log To Console \nDeploying Nimbus NFS server: ${name}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out}= Execute Command nimbus-nfsdeploy ${name}
# Make sure the deploy actually worked
Should Contain ${out} To manage this VM use
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} IP is
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip}= Remove String @{gotIP}[5] ,
Log To Console Successfully deployed new NFS server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
# 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 This resource contains any keywords related to using the Nimbus cluster
*** Variables ***
${ESX_VERSION} 4564106 #6.5 RTM
${VC_VERSION} 4602587 #6.5 RTM
${NIMBUS_ESX_PASSWORD} e2eFunctionalTest
*** Keywords ***
Deploy Nimbus ESXi Server
[Arguments] ${user} ${password} ${version}=${ESX_VERSION} ${tls_disabled}=True
${name}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
Log To Console \nDeploying Nimbus ESXi server: ${name}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command nimbus-esxdeploy ${name} --disk=48000000 --ssd=24000000 --memory=8192 --nics 2 ob-${version}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} To manage this VM use
\ Exit For Loop If ${status}
\ Log To Console ${out}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} IP is
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip}= Remove String @{gotIP}[5] ,
# Let's set a password so govc doesn't complain
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Run Keyword If ${tls_disabled} Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
Deploy Multiple Nimbus ESXi Servers in Parallel
[Arguments] ${user} ${password} ${version}=${ESX_VERSION}
${name1}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
${name2}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
${name3}= Evaluate 'ESX-' + str(random.randint(1000,9999)) modules=random
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out1}= Deploy Nimbus ESXi Server Async ${name1}
${out2}= Deploy Nimbus ESXi Server Async ${name2}
${out3}= Deploy Nimbus ESXi Server Async ${name3}
Wait For Process ${out1}
Wait For Process ${out2}
Wait For Process ${out3}
${out}= Execute Command nimbus-ctl ip ${user}-${name1}
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} ${user}-${name1}
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip1}= Remove String @{gotIP}[2]
${out}= Execute Command nimbus-ctl ip ${user}-${name2}
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} ${user}-${name2}
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip2}= Remove String @{gotIP}[2]
${out}= Execute Command nimbus-ctl ip ${user}-${name3}
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} ${user}-${name3}
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip3}= Remove String @{gotIP}[2]
Log To Console \nDeploying Nimbus ESXi server: ${gotIP}
# Let's set a password so govc doesn't complain
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip1}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name1}
Log To Console \nNimbus ESXi server IP: ${ip1}
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip2}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name2}
Log To Console \nNimbus ESXi server IP: ${ip2}
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip3}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name3}
Log To Console \nNimbus ESXi server IP: ${ip3}
Close connection
[Return] ${user}-${name1} ${ip1} ${user}-${name2} ${ip2} ${user}-${name3} ${ip3}
Deploy Nimbus vCenter Server
[Arguments] ${user} ${password} ${version}=${VC_VERSION}
${name}= Evaluate 'VC-' + str(random.randint(1000,9999)) modules=random
Log To Console \nDeploying Nimbus vCenter server: ${name}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command nimbus-vcvadeploy --vcvaBuild ${version} ${name}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} Overall Status: Succeeded
\ Exit For Loop If ${status}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} Cloudvm is running on IP
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
${ip}= Fetch From Right ${line} ${SPACE}
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_USERNAME Administrator@vsphere.local
Set Environment Variable GOVC_PASSWORD Admin!23
Set Environment Variable GOVC_URL ${ip}
Log To Console Successfully deployed new vCenter server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
Deploy Nimbus ESXi Server Async
[Tags] secret
[Arguments] ${name} ${version}=${ESX_VERSION}
Log To Console \nDeploying Nimbus ESXi server: ${name}
${out}= Run Secret SSHPASS command %{NIMBUS_USER} %{NIMBUS_PASSWORD} 'nimbus-esxdeploy ${name} --disk\=48000000 --ssd\=24000000 --memory\=8192 --nics 2 ${version}'
[Return] ${out}
Run Secret SSHPASS command
[Tags] secret
[Arguments] ${user} ${password} ${cmd}
${out}= Start Process sshpass -p ${password} ssh -o StrictHostKeyChecking\=no ${user}@%{NIMBUS_GW} ${cmd} shell=True
[Return] ${out}
Deploy Nimbus vCenter Server Async
[Tags] secret
[Arguments] ${name} ${version}=${VC_VERSION}
Log To Console \nDeploying Nimbus VC server: ${name}
${out}= Run Secret SSHPASS command %{NIMBUS_USER} %{NIMBUS_PASSWORD} 'nimbus-vcvadeploy --vcvaBuild ${version} ${name}'
[Return] ${out}
Deploy Nimbus Testbed
[Arguments] ${user} ${password} ${testbed}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command nimbus-testbeddeploy ${testbed}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} is up. IP:
\ Exit For Loop If ${status}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
[Return] ${out}
Kill Nimbus Server
[Arguments] ${user} ${password} ${name}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out}= Execute Command nimbus-ctl kill '${name}'
Close connection
Cleanup Nimbus PXE folder
[Arguments] ${user} ${password}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out}= Execute Command rm -rf public_html/pxe/*
Close connection
Nimbus Cleanup
[Arguments] ${vm_list} ${collect_log}=True ${dontDelete}=${false}
Run Keyword If ${collect_log} Run Keyword And Continue On Failure Gather Logs From Test Server
Run Keyword And Ignore Error Cleanup Nimbus PXE folder %{NIMBUS_USER} %{NIMBUS_PASSWORD}
Return From Keyword If ${dontDelete}
:FOR ${item} IN @{vm_list}
\ Run Keyword And Ignore Error Kill Nimbus Server %{NIMBUS_USER} %{NIMBUS_PASSWORD} ${item}
Gather Host IPs
${out}= Run govc ls host/cls
${out}= Split To Lines ${out}
${idx}= Set Variable 1
:FOR ${line} IN @{out}
\ Continue For Loop If '${line}' == '/vcqaDC/host/cls/Resources'
\ ${ip}= Fetch From Right ${line} /
\ Set Suite Variable ${esx${idx}-ip} ${ip}
\ ${idx}= Evaluate ${idx}+1
Create a VSAN Cluster
Log To Console \nStarting basic VSAN cluster deploy...
${out}= Deploy Nimbus Testbed %{NIMBUS_USER} %{NIMBUS_PASSWORD} --noSupportBundles --vcvaBuild ${VC_VERSION} --esxPxeDir ${ESX_VERSION} --esxBuild ${ESX_VERSION} --testbedName vcqa-vsan-simple-pxeBoot-vcva --runName vic-vmotion
${out}= Split To Lines ${out}
:FOR ${line} IN @{out}
\ ${status}= Run Keyword And Return Status Should Contain ${line} .vcva-${VC_VERSION}' is up. IP:
\ ${ip}= Run Keyword If ${status} Fetch From Right ${line} ${SPACE}
\ Run Keyword If ${status} Set Suite Variable ${vc-ip} ${ip}
\ Exit For Loop If ${status}
Log To Console Set environment variables up for GOVC
Set Environment Variable GOVC_URL ${vc-ip}
Set Environment Variable GOVC_USERNAME Administrator@vsphere.local
Set Environment Variable GOVC_PASSWORD Admin\!23
Log To Console Create a distributed switch
${out}= Run govc dvs.create -dc=vcqaDC test-ds
Should Contain ${out} OK
Log To Console Create three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds bridge
Should Contain ${out} OK
Log To Console Add all the hosts to the distributed switch
${out}= Run govc dvs.add -dvs=test-ds -pnic=vmnic1 /vcqaDC/host/cls
Should Contain ${out} OK
Log To Console Enable DRS and VSAN on the cluster
${out}= Run govc cluster.change -drs-enabled /vcqaDC/host/cls
Should Be Empty ${out}
Log To Console Deploy VIC to the VC cluster
Set Environment Variable TEST_URL_ARRAY ${vc-ip}
Set Environment Variable TEST_USERNAME Administrator@vsphere.local
Set Environment Variable TEST_PASSWORD Admin\!23
Set Environment Variable BRIDGE_NETWORK bridge
Set Environment Variable PUBLIC_NETWORK vm-network
Set Environment Variable TEST_DATASTORE vsanDatastore
Set Environment Variable TEST_RESOURCE cls
Set Environment Variable TEST_TIMEOUT 30m
Gather Host IPs
Create a Simple VC Cluster
[Arguments] ${datacenter}=ha-datacenter ${cluster}=cls ${esx_number}=3 ${network}=True
Log To Console \nStarting simple VC cluster deploy...
${esx_names}= Create List
${esx_ips}= Create List
:FOR ${IDX} IN RANGE ${esx_number}
\ ${esx} ${esx_ip}= Deploy Nimbus ESXi Server %{NIMBUS_USER} %{NIMBUS_PASSWORD} ${ESX_VERSION} False
\ Append To List ${esx_names} ${esx}
\ Append To List ${esx_ips} ${esx_ip}
${vc} ${vc_ip}= Deploy Nimbus vCenter Server %{NIMBUS_USER} %{NIMBUS_PASSWORD}
Log To Console Create a datacenter on the VC
${out}= Run govc datacenter.create ${datacenter}
Should Be Empty ${out}
Log To Console Create a cluster on the VC
${out}= Run govc cluster.create ${cluster}
Should Be Empty ${out}
Log To Console Add ESX host to the VC
:FOR ${IDX} IN RANGE ${esx_number}
\ ${out}= Run govc cluster.add -hostname=@{esx_ips}[${IDX}] -username=root -dc=${datacenter} -password=${NIMBUS_ESX_PASSWORD} -noverify=true
\ Should Contain ${out} OK
Run Keyword If ${network} Setup Network For Simple VC Cluster ${esx_number} ${datacenter} ${cluster}
Log To Console Enable DRS on the cluster
${out}= Run govc cluster.change -drs-enabled /${datacenter}/host/${cluster}
Should Be Empty ${out}
Set Environment Variable TEST_URL_ARRAY ${vc_ip}
Set Environment Variable TEST_URL ${vc_ip}
Set Environment Variable TEST_USERNAME Administrator@vsphere.local
Set Environment Variable TEST_PASSWORD Admin\!23
Set Environment Variable TEST_DATASTORE datastore1
Set Environment Variable TEST_DATACENTER /${datacenter}
Set Environment Variable TEST_RESOURCE ${cluster}
Set Environment Variable TEST_TIMEOUT 30m
[Return] @{esx_names} ${vc} @{esx_ips} ${vc_ip}
Setup Network For Simple VC Cluster
[Arguments] ${esx_number} ${datacenter} ${cluster}
Log To Console Create a distributed switch
${out}= Run govc dvs.create -dc=${datacenter} test-ds
Should Contain ${out} OK
Log To Console Create three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds bridge
Should Contain ${out} OK
Log To Console Add all the hosts to the distributed switch
${out}= Run govc dvs.add -dvs=test-ds -pnic=vmnic1 /${datacenter}/host/${cluster}
Should Contain ${out} OK
Log To Console Enable DRS on the cluster
${out}= Run govc cluster.change -drs-enabled /${datacenter}/host/${cluster}
Should Be Empty ${out}
Set Environment Variable BRIDGE_NETWORK bridge
Set Environment Variable PUBLIC_NETWORK vm-network
Create A Distributed Switch
[Arguments] ${datacenter} ${dvs}=test-ds
Log To Console \nCreate a distributed switch
${out}= Run govc dvs.create -product-version 5.5.0 -dc=${datacenter} ${dvs}
Should Contain ${out} OK
Create Three Distributed Port Groups
[Arguments] ${datacenter} ${dvs}=test-ds
Log To Console \nCreate three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} bridge
Should Contain ${out} OK
Add Host To Distributed Switch
[Arguments] ${host} ${dvs}=test-ds
Log To Console \nAdd host(s) to the distributed switch
${out}= Run govc dvs.add -dvs=${dvs} -pnic=vmnic1 ${host}
Should Contain ${out} OK
Disable TLS On ESX Host
Log To Console \nDisable TLS on the host
${ver}= Get Vsphere Version
${out}= Run Keyword If '${ver}' != '5.5.0' Run govc host.option.set UserVars.ESXiVPsDisabledProtocols sslv3,tlsv1,tlsv1.1
Run Keyword If '${ver}' != '5.5.0' Should Be Empty ${out}
Get Vsphere Version
${out}= Run govc about
${out}= Split To Lines ${out}
:FOR ${line} IN @{out}
\ ${status}= Run Keyword And Return Status Should Contain ${line} Version:
\ Run Keyword And Return If ${status} Fetch From Right ${line} ${SPACE}
Deploy Nimbus NFS Datastore
[Arguments] ${user} ${password}
${name}= Evaluate 'NFS-' + str(random.randint(1000,9999)) modules=random
Log To Console \nDeploying Nimbus NFS server: ${name}
Open Connection %{NIMBUS_GW}
Login ${user} ${password}
${out}= Execute Command nimbus-nfsdeploy ${name}
# Make sure the deploy actually worked
Should Contain ${out} To manage this VM use
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} IP is
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip}= Remove String @{gotIP}[5] ,
Log To Console Successfully deployed new NFS server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}

View File

@ -1,97 +1,97 @@
# 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 This resource provides any keywords related to Unified OVA
*** Variables ***
${ova_root_pwd} ova-test-root-pwd
${ova_appliance_options} --prop:root_pwd=${ova_root_pwd} --prop:permit_root_login=true
${ova_target_vm_name} harbor-unified-ova-integration-test
${ovftool_options} --noSSLVerify --acceptAllEulas --name=${ova_target_vm_name} --diskMode=thin --powerOn --X:waitForIp --X:injectOvfEnv --X:enableHiddenProperties
${ova_network_ip0} 10.17.109.207
${ova_network_netmask0} 255.255.255.0
${ova_network_gateway} 10.17.109.253
${ova_network_dns} 10.118.81.1
${ova_network_searchpath} eng.vmware.com
${ova_network_domain} mrburns
${ova_network_options} --prop:network.ip0=${ova_network_ip0} --prop:network.netmask0=${ova_network_netmask0} --prop:network.gateway=${ova_network_gateway} --prop:network.DNS=${ova_network_dns} --prop:network.searchpath=${ova_network_searchpath} --prop:network.domain=${ova_network_domain}
${ova_harbor_admin_password} harbor-admin-passwd
${ova_harbor_db_password} harbor-db-passwd
#${ova_service_options} --prop:auth_mode="%{AUTH_MODE}" --prop:max_job_workers="%{MAX_JOB_WORKERS}" --prop:harbor_admin_password="%{HARBOR_ADMIN_PASSWORD}" --prop:db_password="%{DB_PASSWORD}"
#${ova_options} ${ovftool_options} ${ova_appliance_options} ${ova_service_options}
#${ova_options_with_network} ${ova_options} ${ova_network_options}
${tls_not_disabled} False
*** Keywords ***
# Requires vc credential for govc
Deploy Harbor-OVA To Test Server
[Arguments] ${dhcp} ${protocol} ${build} ${user} ${password} ${ova_path} ${host} ${datastore} ${cluster} ${datacenter}
Log To Console \nCleanup environment...
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.destroy ${ova_target_vm_name}
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc object.destroy /${datacenter}/vm/${ova_target_vm_name}
Log To Console \nStarting to deploy unified-ova to test server...
Run Keyword If ${dhcp} Log To Console ovftool --datastore=${datastore} ${ova_options} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
... ELSE Log To Console ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
${out}= Run Keyword If ${dhcp} Run ovftool --datastore=${datastore} ${ova_options} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
... ELSE Run ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
Should Contain ${out} Received IP address:
Should Not Contain ${out} None
${out}= Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc ls /ha-datacenter/host/cls/
${out}= Split To Lines ${out}
${idx}= Set Variable 1
:FOR ${line} IN @{out}
\ Continue For Loop If '${line}' == '/ha-datacenter/host/cls/Resources'
\ ${ip}= Fetch From Right ${line} /
\ Set Suite Variable ${esx${idx}-ip} ${ip}
\ ${idx}= Evaluate ${idx}+1
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc host.esxcli -host.ip=${esx1-ip} system settings advanced set -o /Net/GuestIPHack -i 1
${ip}= Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.ip -esxcli harbor-unified-ova-integration-test
Set Environment Variable HARBOR_IP ${ip}
Log To Console \nHarbor IP: %{HARBOR_IP}
Wait for Harbor Ready ${protocol} %{HARBOR_IP}
[Return] %{HARBOR_IP}
# Requires vc credential for govc
Cleanup Harbor-OVA On Test Server
[Arguments] ${url}=%{GOVC_URL} ${username}=%{GOVC_USERNAME} ${password}=%{GOVC_PASSWORD}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${url} GOVC_USERNAME=${username} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.destroy ${ova_target_vm_name}
Log ${output}
Should Be Equal As Integers ${rc} 0
Run Keyword And Ignore Error Run GOVC_URL=${url} GOVC_USERNAME=${username} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc object.destroy /%{TEST_DATACENTER}/vm/${ova_target_vm_name}
Log To Console \nUnified-OVA deployment is cleaned up on test server
Build Unified OVA
[Arguments] ${user}=%{TEST_USERNAME} ${password}=%{TEST_PASSWORD} ${host}=%{TEST_URL}
Log To Console \nStarting to build Unified OVA...
Log To Console \nRemove stale local OVA artifacts
Run Remove OVA Artifacts Locally
${out}= Run PACKER_ESX_HOST=${host} PACKER_USER=${user} PACKER_PASSWORD=${password} make ova-release
Log ${out}
@{out}= Split To Lines ${out}
Should Not Contain @{out}[-1] Error
Log To Console \nUnified OVA is built successfully
# 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 This resource provides any keywords related to Unified OVA
*** Variables ***
${ova_root_pwd} ova-test-root-pwd
${ova_appliance_options} --prop:root_pwd=${ova_root_pwd} --prop:permit_root_login=true
${ova_target_vm_name} harbor-unified-ova-integration-test
${ovftool_options} --noSSLVerify --acceptAllEulas --name=${ova_target_vm_name} --diskMode=thin --powerOn --X:waitForIp --X:injectOvfEnv --X:enableHiddenProperties
${ova_network_ip0} 10.17.109.207
${ova_network_netmask0} 255.255.255.0
${ova_network_gateway} 10.17.109.253
${ova_network_dns} 10.118.81.1
${ova_network_searchpath} eng.vmware.com
${ova_network_domain} mrburns
${ova_network_options} --prop:network.ip0=${ova_network_ip0} --prop:network.netmask0=${ova_network_netmask0} --prop:network.gateway=${ova_network_gateway} --prop:network.DNS=${ova_network_dns} --prop:network.searchpath=${ova_network_searchpath} --prop:network.domain=${ova_network_domain}
${ova_harbor_admin_password} harbor-admin-passwd
${ova_harbor_db_password} harbor-db-passwd
#${ova_service_options} --prop:auth_mode="%{AUTH_MODE}" --prop:max_job_workers="%{MAX_JOB_WORKERS}" --prop:harbor_admin_password="%{HARBOR_ADMIN_PASSWORD}" --prop:db_password="%{DB_PASSWORD}"
#${ova_options} ${ovftool_options} ${ova_appliance_options} ${ova_service_options}
#${ova_options_with_network} ${ova_options} ${ova_network_options}
${tls_not_disabled} False
*** Keywords ***
# Requires vc credential for govc
Deploy Harbor-OVA To Test Server
[Arguments] ${dhcp} ${protocol} ${build} ${user} ${password} ${ova_path} ${host} ${datastore} ${cluster} ${datacenter}
Log To Console \nCleanup environment...
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.destroy ${ova_target_vm_name}
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc object.destroy /${datacenter}/vm/${ova_target_vm_name}
Log To Console \nStarting to deploy unified-ova to test server...
Run Keyword If ${dhcp} Log To Console ovftool --datastore=${datastore} ${ova_options} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
... ELSE Log To Console ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
${out}= Run Keyword If ${dhcp} Run ovftool --datastore=${datastore} ${ova_options} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
... ELSE Run ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
Should Contain ${out} Received IP address:
Should Not Contain ${out} None
${out}= Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc ls /ha-datacenter/host/cls/
${out}= Split To Lines ${out}
${idx}= Set Variable 1
:FOR ${line} IN @{out}
\ Continue For Loop If '${line}' == '/ha-datacenter/host/cls/Resources'
\ ${ip}= Fetch From Right ${line} /
\ Set Suite Variable ${esx${idx}-ip} ${ip}
\ ${idx}= Evaluate ${idx}+1
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc host.esxcli -host.ip=${esx1-ip} system settings advanced set -o /Net/GuestIPHack -i 1
${ip}= Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.ip -esxcli harbor-unified-ova-integration-test
Set Environment Variable HARBOR_IP ${ip}
Log To Console \nHarbor IP: %{HARBOR_IP}
Wait for Harbor Ready ${protocol} %{HARBOR_IP}
[Return] %{HARBOR_IP}
# Requires vc credential for govc
Cleanup Harbor-OVA On Test Server
[Arguments] ${url}=%{GOVC_URL} ${username}=%{GOVC_USERNAME} ${password}=%{GOVC_PASSWORD}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${url} GOVC_USERNAME=${username} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.destroy ${ova_target_vm_name}
Log ${output}
Should Be Equal As Integers ${rc} 0
Run Keyword And Ignore Error Run GOVC_URL=${url} GOVC_USERNAME=${username} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc object.destroy /%{TEST_DATACENTER}/vm/${ova_target_vm_name}
Log To Console \nUnified-OVA deployment is cleaned up on test server
Build Unified OVA
[Arguments] ${user}=%{TEST_USERNAME} ${password}=%{TEST_PASSWORD} ${host}=%{TEST_URL}
Log To Console \nStarting to build Unified OVA...
Log To Console \nRemove stale local OVA artifacts
Run Remove OVA Artifacts Locally
${out}= Run PACKER_ESX_HOST=${host} PACKER_USER=${user} PACKER_PASSWORD=${password} make ova-release
Log ${out}
@{out}= Split To Lines ${out}
Should Not Contain @{out}[-1] Error
Log To Console \nUnified OVA is built successfully

View File

@ -1,49 +1,49 @@
# 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 This resource provides helper functions for docker operations
Resource Util.robot
*** Keywords ***
Start Selenium Standalone Server Locally
OperatingSystem.File Should Exist /go/selenium-server-standalone-3.4.0.jar
${handle}= Start Process java -jar /go/selenium-server-standalone-3.4.0.jar >./selenium-local.log 2>&1 shell=True
Process Should Be Running ${handle}
Sleep 10s
[Return] ${handle}
Init Chrome Driver
Run pkill chromedriver
Run pkill chrome
${chrome options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
${capabilities}= Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.CHROME sys
Set To Dictionary ${capabilities} acceptInsecureCerts ${True}
Call Method ${chrome options} add_argument --headless
Call Method ${chrome options} add_argument --disable-gpu
Call Method ${chrome options} add_argument --start-maximized
Call Method ${chrome options} add_argument --no-sandbox
Call Method ${chrome options} add_argument --window-size\=1600,900
${chrome options.binary_location} Set Variable /usr/bin/google-chrome
#Create Webdriver Chrome Chrome_headless chrome_options=${chrome options} desired_capabilities=${capabilities}
FOR ${n} IN RANGE 1 6
Log To Console Trying Create Webdriver ${n} times ...
${out} Run Keyword And Ignore Error Create Webdriver Chrome Chrome_headless chrome_options=${chrome options} desired_capabilities=${capabilities}
Log To Console Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 2
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
Sleep 5
# 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 This resource provides helper functions for docker operations
Resource Util.robot
*** Keywords ***
Start Selenium Standalone Server Locally
OperatingSystem.File Should Exist /go/selenium-server-standalone-3.4.0.jar
${handle}= Start Process java -jar /go/selenium-server-standalone-3.4.0.jar >./selenium-local.log 2>&1 shell=True
Process Should Be Running ${handle}
Sleep 10s
[Return] ${handle}
Init Chrome Driver
Run pkill chromedriver
Run pkill chrome
${chrome options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
${capabilities}= Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.CHROME sys
Set To Dictionary ${capabilities} acceptInsecureCerts ${True}
Call Method ${chrome options} add_argument --headless
Call Method ${chrome options} add_argument --disable-gpu
Call Method ${chrome options} add_argument --start-maximized
Call Method ${chrome options} add_argument --no-sandbox
Call Method ${chrome options} add_argument --window-size\=1600,900
${chrome options.binary_location} Set Variable /usr/bin/google-chrome
#Create Webdriver Chrome Chrome_headless chrome_options=${chrome options} desired_capabilities=${capabilities}
FOR ${n} IN RANGE 1 6
Log To Console Trying Create Webdriver ${n} times ...
${out} Run Keyword And Ignore Error Create Webdriver Chrome Chrome_headless chrome_options=${chrome options} desired_capabilities=${capabilities}
Log To Console Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 2
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
Sleep 5

View File

@ -1,28 +1,28 @@
*** Settings ***
Documentation Harbor BATs
Resource ../Util.robot
*** Variables ***
${HARBOR_URL} https://${ip}
${HARBOR_ADMIN} admin
${HARBOR_PASSWORD} Harbor12345
*** Test Cases ***
# For Windows
Test Case - Example For Windows
Open Browser https://localhost:4200 Chrome
Retry Element Click xpath=//clr-dropdown/button
Retry Element Click xpath=//clr-dropdown/clr-dropdown-menu/a[contains(., 'English')]
# your case starts =====================================
# your case ends ======================================
Close Browser
# For Linux
Test Case - Example For Linux
init chrome driver
# your case starts =====================================
# your case ends ======================================
Close Browser
*** Settings ***
Documentation Harbor BATs
Resource ../Util.robot
*** Variables ***
${HARBOR_URL} https://${ip}
${HARBOR_ADMIN} admin
${HARBOR_PASSWORD} Harbor12345
*** Test Cases ***
# For Windows
Test Case - Example For Windows
Open Browser https://localhost:4200 Chrome
Retry Element Click xpath=//clr-dropdown/button
Retry Element Click xpath=//clr-dropdown/clr-dropdown-menu/a[contains(., 'English')]
# your case starts =====================================
# your case ends ======================================
Close Browser
# For Linux
Test Case - Example For Linux
init chrome driver
# your case starts =====================================
# your case ends ======================================
Close Browser

View File

@ -1,401 +1,401 @@
# 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 This resource wrap test case body
*** Variables ***
*** Keywords ***
Body Of Manage project publicity
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user007 Test1@34
Create An New Project And Go Into Project project${d} public=true
Push image ${ip} user007 Test1@34 project${d} hello-world:latest
Pull image ${ip} user008 Test1@34 project${d} hello-world:latest
Logout Harbor
Sign In Harbor ${HARBOR_URL} user008 Test1@34
Project Should Display project${d}
Search Private Projects
Project Should Not Display project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} user007 Test1@34
Make Project Private project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} user008 Test1@34
Project Should Not Display project${d}
Cannot Pull Image ${ip} user008 Test1@34 project${d} hello-world:latest err_msg=unauthorized to access repository
Logout Harbor
Sign In Harbor ${HARBOR_URL} user007 Test1@34
Make Project Public project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} user008 Test1@34
Project Should Display project${d}
Close Browser
Body Of Scan A Tag In The Repo
[Arguments] ${image_argument} ${tag_argument} ${is_no_vulerabilty}=${false}
Init Chrome Driver
${d}= get current date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user023 Test1@34
Create An New Project And Go Into Project project${d}
Push Image ${ip} user023 Test1@34 project${d} ${image_argument}:${tag_argument}
Go Into Project project${d}
Go Into Repo project${d}/${image_argument}
Scan Repo ${tag_argument} Succeed
Scan Result Should Display In List Row ${tag_argument} is_no_vulerabilty=${is_no_vulerabilty}
Pull Image ${ip} user023 Test1@34 project${d} ${image_argument} ${tag_argument}
# Edit Repo Info
Close Browser
Body Of Scan Image With Empty Vul
[Arguments] ${image_argument} ${tag_argument}
Init Chrome Driver
${tag}= Set Variable ${tag_argument}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library ${image_argument}:${tag_argument}
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project library
Go Into Repo ${image_argument}
Scan Repo ${tag} Succeed
Move To Summary Chart
Scan Result Should Display In List Row ${tag} is_no_vulerabilty=${true}
Close Browser
Body Of Manual Scan All
[Arguments] @{vulnerability_levels}
Init Chrome Driver
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library redis
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Vulnerability Page
Trigger Scan Now And Wait Until The Result Appears
Navigate To Projects
Go Into Project library
Go Into Repo redis
Scan Result Should Display In List Row latest
View Repo Scan Details @{vulnerability_levels}
Close Browser
Body Of View Scan Results
[Arguments] @{vulnerability_levels}
Init Chrome Driver
${d}= get current date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user025 Test1@34
Create An New Project And Go Into Project project${d}
Push Image ${ip} user025 Test1@34 project${d} tomcat
Go Into Project project${d}
Go Into Repo project${d}/tomcat
Scan Repo latest Succeed
Scan Result Should Display In List Row latest
View Repo Scan Details @{vulnerability_levels}
Close Browser
Body Of Scan Image On Push
[Arguments] @{vulnerability_levels}
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project library
Goto Project Config
Enable Scan On Push
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library memcached
Navigate To Projects
Go Into Project library
Go Into Repo memcached
Scan Result Should Display In List Row latest
View Repo Scan Details @{vulnerability_levels}
Close Browser
Body Of List Helm Charts
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user027 Test1@34
Create An New Project And Go Into Project project${d}
Switch To Project Charts
Upload Chart files
Go Into Chart Version ${prometheus_chart_name}
Retry Wait Until Page Contains ${prometheus_chart_version}
Go Into Chart Detail ${prometheus_chart_version}
# Summary tab
Retry Wait Until Page Contains Element ${summary_markdown}
Retry Wait Until Page Contains Element ${summary_container}
# Dependency tab
Retry Double Keywords When Error Retry Element Click xpath=${detail_dependency} Retry Wait Until Page Contains Element ${dependency_content}
# Values tab
Retry Double Keywords When Error Retry Element Click xpath=${detail_value} Retry Wait Until Page Contains Element ${value_content}
Go Into Project project${d} has_image=${false}
Switch To Project Charts
Multi-delete Chart Files ${prometheus_chart_name} ${harbor_chart_name}
Close Browser
Body Of Push Signed Image
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${user}= Set Variable user010
${pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
Create An New Project And Go Into Project project${d}
Body Of Admin Push Signed Image project${d} tomcat latest ${user} ${pwd}
Body Of Admin Push Signed Image project${d} alpine latest ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Close Browser
Body Of Admin Push Signed Image
[Arguments] ${project} ${image} ${tag} ${user} ${pwd} ${with_remove}=${false}
Enable Notary Client
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${tag} ${user} ${pwd}
Clean All Local Images
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/v2.0/projects/${project}/repositories/${image}/artifacts/${tag}?with_signature=true"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} "signed":true
Run Keyword If ${with_remove} == ${true} Notary Remove Signature ${ip} ${project} ${image} ${tag} ${user} ${pwd}
Delete A Project Without Sign In Harbor
[Arguments] ${harbor_ip}=${ip} ${username}=${HARBOR_ADMIN} ${password}=${HARBOR_PASSWORD}
${d}= Get Current Date result_format=%m%s
${project_name}= Set Variable 000${d}
${image}= Set Variable hello-world
Create An New Project And Go Into Project ${project_name}
Push Image ${harbor_ip} ${username} ${password} ${project_name} ${image}
Project Should Not Be Deleted ${project_name}
Go Into Project ${project_name}
Delete Repo ${project_name} ${image}
Navigate To Projects
Project Should Be Deleted ${project_name}
Manage Project Member Without Sign In Harbor
[Arguments] ${sign_in_user} ${sign_in_pwd} ${test_user1}=user005 ${test_user2}=user006 ${is_oidc_mode}=${false}
${d}= Get current Date result_format=%m%s
${image}= Set Variable hello-world
Create An New Project And Go Into Project project${d}
Push image ${ip} ${sign_in_user} ${sign_in_pwd} project${d} ${image}
Logout Harbor
User Should Not Be A Member Of Project ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Manage Project Member ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Add is_oidc_mode=${is_oidc_mode}
User Should Be Guest ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Developer is_oidc_mode=${is_oidc_mode}
User Should Be Developer ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Admin is_oidc_mode=${is_oidc_mode}
User Should Be Admin ${test_user1} ${sign_in_pwd} project${d} ${test_user2} is_oidc_mode=${is_oidc_mode}
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Maintainer is_oidc_mode=${is_oidc_mode}
User Should Be Maintainer ${test_user1} ${sign_in_pwd} project${d} ${image} is_oidc_mode=${is_oidc_mode}
Manage Project Member ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Remove is_oidc_mode=${is_oidc_mode}
User Should Not Be A Member Of Project ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Push image ${ip} ${sign_in_user} ${sign_in_pwd} project${d} hello-world
User Should Be Guest ${test_user2} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Helm CLI Push Without Sign In Harbor
[Arguments] ${sign_in_user} ${sign_in_pwd}
${d}= Get Current Date result_format=%m%s
Create An New Project And Go Into Project project${d}
Helm Repo Add ${HARBOR_URL} ${sign_in_user} ${sign_in_pwd} project_name=project${d}
Helm Repo Push ${sign_in_user} ${sign_in_pwd} ${harbor_chart_filename}
Switch To Project Charts
Go Into Chart Version ${harbor_chart_name}
Retry Wait Until Page Contains ${harbor_chart_version}
Helm3 CLI Push Without Sign In Harbor
[Arguments] ${sign_in_user} ${sign_in_pwd}
${d}= Get Current Date result_format=%m%s
Create An New Project And Go Into Project project${d}
Helm Repo Push ${sign_in_user} ${sign_in_pwd} ${harbor_chart_filename} helm_repo_name=${HARBOR_URL}/chartrepo/project${d} helm_cmd=helm3
Switch To Project Charts
Retry Double Keywords When Error Go Into Chart Version ${harbor_chart_name} Retry Wait Until Page Contains ${harbor_chart_version}
#Important Note: All CVE IDs in CVE Allowlist cases must unique!
Body Of Verfiy System Level CVE Allowlist
[Arguments] ${image_argument} ${sha256_argument} ${most_cve_list} ${single_cve}
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable ${image_argument}
# ${image}= Set Variable goharbor/harbor-portal
${sha256}= Set Variable ${sha256_argument}
# ${sha256}= Set Variable 2cb6a1c24dd6b88f11fd44ccc6560cb7be969f8ac5f752802c99cae6bcd592bb
${signin_user}= Set Variable user025
${signin_pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${signin_user} ${signin_pwd}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} sha256=${sha256}
Go Into Project project${d}
Set Vulnerabilty Serverity 2
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256} err_msg=cannot be pulled due to configured policy
Go Into Project project${d}
Go Into Repo project${d}/${image}
Scan Repo ${sha256} Succeed
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Check Listed In CVE Allowlist project${d} ${image} ${sha256} ${single_cve} is_in=No
Switch To Configure
Switch To Configuration System Setting
# Add Items To System CVE Allowlist CVE-2019-19317\nCVE-2019-19646 \nCVE-2019-5188 \nCVE-2019-20387 \nCVE-2019-17498 \nCVE-2019-20372 \nCVE-2019-19244 \nCVE-2019-19603 \nCVE-2019-19880 \nCVE-2019-19923 \nCVE-2019-19925 \nCVE-2019-19926 \nCVE-2019-19959 \nCVE-2019-20218 \nCVE-2019-19232 \nCVE-2019-19234 \nCVE-2019-19645
Add Items To System CVE Allowlist ${most_cve_list}
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256} err_msg=cannot be pulled due to configured policy
# Add Items To System CVE Allowlist CVE-2019-18276
Add Items To System CVE Allowlist ${single_cve}
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Delete Top Item In System CVE Allowlist count=16
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256} err_msg=cannot be pulled due to configured policy
Check Listed In CVE Allowlist project${d} ${image} ${sha256} ${single_cve}
Close Browser
Body Of Verfiy Project Level CVE Allowlist
[Arguments] ${image_argument} ${sha256_argument} ${most_cve_list} ${single_cve}
[Tags] run-once
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable ${image_argument}
${sha256}= Set Variable ${sha256_argument}
${signin_user}= Set Variable user025
${signin_pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${signin_user} ${signin_pwd}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} sha256=${sha256}
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Go Into Project project${d}
Set Vulnerabilty Serverity 2
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Go Into Project project${d}
Go Into Repo project${d}/${image}
Scan Repo ${sha256} Succeed
Go Into Project project${d}
Add Items to Project CVE Allowlist ${most_cve_list}
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Add Items to Project CVE Allowlist ${single_cve}
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Delete Top Item In Project CVE Allowlist
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Close Browser
Body Of Verfiy Project Level CVE Allowlist By Quick Way of Add System
[Arguments] ${image_argument} ${sha256_argument} ${cve_list}
[Tags] run-once
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable ${image_argument}
${sha256}= Set Variable ${sha256_argument}
${signin_user}= Set Variable user025
${signin_pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Configure
Switch To Configuration System Setting
Add Items To System CVE Allowlist ${cve_list}
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${signin_user} ${signin_pwd}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} sha256=${sha256}
Go Into Project project${d}
Set Vulnerabilty Serverity 2
Go Into Project project${d}
Go Into Repo project${d}/${image}
Scan Repo ${sha256} Succeed
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Go Into Project project${d}
Set Project To Project Level CVE Allowlist
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Add System CVE Allowlist to Project CVE Allowlist By Add System Button Click
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Close Browser
Body Of Replication Of Push Images to Registry Triggered By Event
[Arguments] ${provider} ${endpoint} ${username} ${pwd} ${dest_namespace} ${image_size}=12
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${sha256}= Set Variable 0e67625224c1da47cb3270e7a861a83e332f708d3d89dde0cbed432c94824d9a
${image}= Set Variable test_push_repli
${tag1}= Set Variable v1.1.0
@{tags} Create List ${tag1}
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint ${provider} e${d} ${endpoint} ${username} ${pwd} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} ${dest_namespace} mode=Event Based del_remote=${true}
Push Special Image To Project project${d} ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${image} tags=@{tags} size=${image_size}
Filter Replication Rule rule${d}
Select Rule rule${d}
${endpoint_body}= Fetch From Right ${endpoint} //
${dest_namespace}= Set Variable If '${provider}'=='gitlab' ${endpoint_body}/${dest_namespace} ${dest_namespace}
Run Keyword If '${provider}'=='docker-hub' or '${provider}'=='gitlab' Docker Image Can Be Pulled ${dest_namespace}/${image}:${tag1} times=3
Executions Result Count Should Be Succeeded event_based 1
Go Into Project project${d}
Delete Repo project${d} ${image}
Run Keyword If '${provider}'=='docker-hub' or '${provider}'=='gitlab' Docker Image Can Not Be Pulled ${dest_namespace}/${image}:${tag1}
Switch To Replication Manage
Filter Replication Rule rule${d}
Select Rule rule${d}
Executions Result Count Should Be Succeeded event_based 2
Body Of Replication Of Pull Images from Registry To Self
[Arguments] ${provider} ${endpoint} ${username} ${pwd} ${src_project_name} ${des_project_name} ${verify_verbose} @{target_images}
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${_des_pro_name}= Set Variable If '${des_project_name}'=='${null}' project${d} ${des_project_name}
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Run Keyword If '${des_project_name}'=='${null}' Create An New Project And Go Into Project ${_des_pro_name}
Switch To Registries
Create A New Endpoint ${provider} e${d} ${endpoint} ${username} ${pwd} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} pull ${src_project_name} all e${d} ${_des_pro_name}
Select Rule And Replicate rule${d}
Run Keyword If '${verify_verbose}'=='Y' Verify Artifact Display Verbose ${_des_pro_name} @{target_images}
... ELSE Verify Artifact Display ${_des_pro_name} @{target_images}
Close Browser
Verify Artifact Display Verbose
[Arguments] ${pro_name} @{target_images}
FOR ${item} IN @{target_images}
${item}= Get Substring ${item} 1 -1
${item}= Evaluate ${item}
${image}= Get From Dictionary ${item} image
${tag}= Get From Dictionary ${item} tag
${total_artifact_count}= Get From Dictionary ${item} total_artifact_count
${archive_count}= Get From Dictionary ${item} archive_count
Log To Console Check image ${image}:${tag} replication to Project ${pro_name}
Image Should Be Replicated To Project ${pro_name} ${image} tag=${tag} total_artifact_count=${total_artifact_count} archive_count=${archive_count} times=2
END
Verify Artifact Display
[Arguments] ${pro_name} @{target_images}
FOR ${item} IN @{target_images}
${item}= Get Substring ${item} 1 -1
${item}= Evaluate ${item}
${image}= Get From Dictionary ${item} image
Image Should Be Replicated To Project ${pro_name} ${image} times=2
END
# 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 This resource wrap test case body
*** Variables ***
*** Keywords ***
Body Of Manage project publicity
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user007 Test1@34
Create An New Project And Go Into Project project${d} public=true
Push image ${ip} user007 Test1@34 project${d} hello-world:latest
Pull image ${ip} user008 Test1@34 project${d} hello-world:latest
Logout Harbor
Sign In Harbor ${HARBOR_URL} user008 Test1@34
Project Should Display project${d}
Search Private Projects
Project Should Not Display project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} user007 Test1@34
Make Project Private project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} user008 Test1@34
Project Should Not Display project${d}
Cannot Pull Image ${ip} user008 Test1@34 project${d} hello-world:latest err_msg=unauthorized to access repository
Logout Harbor
Sign In Harbor ${HARBOR_URL} user007 Test1@34
Make Project Public project${d}
Logout Harbor
Sign In Harbor ${HARBOR_URL} user008 Test1@34
Project Should Display project${d}
Close Browser
Body Of Scan A Tag In The Repo
[Arguments] ${image_argument} ${tag_argument} ${is_no_vulerabilty}=${false}
Init Chrome Driver
${d}= get current date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user023 Test1@34
Create An New Project And Go Into Project project${d}
Push Image ${ip} user023 Test1@34 project${d} ${image_argument}:${tag_argument}
Go Into Project project${d}
Go Into Repo project${d}/${image_argument}
Scan Repo ${tag_argument} Succeed
Scan Result Should Display In List Row ${tag_argument} is_no_vulerabilty=${is_no_vulerabilty}
Pull Image ${ip} user023 Test1@34 project${d} ${image_argument} ${tag_argument}
# Edit Repo Info
Close Browser
Body Of Scan Image With Empty Vul
[Arguments] ${image_argument} ${tag_argument}
Init Chrome Driver
${tag}= Set Variable ${tag_argument}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library ${image_argument}:${tag_argument}
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project library
Go Into Repo ${image_argument}
Scan Repo ${tag} Succeed
Move To Summary Chart
Scan Result Should Display In List Row ${tag} is_no_vulerabilty=${true}
Close Browser
Body Of Manual Scan All
[Arguments] @{vulnerability_levels}
Init Chrome Driver
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library redis
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Vulnerability Page
Trigger Scan Now And Wait Until The Result Appears
Navigate To Projects
Go Into Project library
Go Into Repo redis
Scan Result Should Display In List Row latest
View Repo Scan Details @{vulnerability_levels}
Close Browser
Body Of View Scan Results
[Arguments] @{vulnerability_levels}
Init Chrome Driver
${d}= get current date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user025 Test1@34
Create An New Project And Go Into Project project${d}
Push Image ${ip} user025 Test1@34 project${d} tomcat
Go Into Project project${d}
Go Into Repo project${d}/tomcat
Scan Repo latest Succeed
Scan Result Should Display In List Row latest
View Repo Scan Details @{vulnerability_levels}
Close Browser
Body Of Scan Image On Push
[Arguments] @{vulnerability_levels}
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project library
Goto Project Config
Enable Scan On Push
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library memcached
Navigate To Projects
Go Into Project library
Go Into Repo memcached
Scan Result Should Display In List Row latest
View Repo Scan Details @{vulnerability_levels}
Close Browser
Body Of List Helm Charts
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user027 Test1@34
Create An New Project And Go Into Project project${d}
Switch To Project Charts
Upload Chart files
Go Into Chart Version ${prometheus_chart_name}
Retry Wait Until Page Contains ${prometheus_chart_version}
Go Into Chart Detail ${prometheus_chart_version}
# Summary tab
Retry Wait Until Page Contains Element ${summary_markdown}
Retry Wait Until Page Contains Element ${summary_container}
# Dependency tab
Retry Double Keywords When Error Retry Element Click xpath=${detail_dependency} Retry Wait Until Page Contains Element ${dependency_content}
# Values tab
Retry Double Keywords When Error Retry Element Click xpath=${detail_value} Retry Wait Until Page Contains Element ${value_content}
Go Into Project project${d} has_image=${false}
Switch To Project Charts
Multi-delete Chart Files ${prometheus_chart_name} ${harbor_chart_name}
Close Browser
Body Of Push Signed Image
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${user}= Set Variable user010
${pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
Create An New Project And Go Into Project project${d}
Body Of Admin Push Signed Image project${d} tomcat latest ${user} ${pwd}
Body Of Admin Push Signed Image project${d} alpine latest ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Close Browser
Body Of Admin Push Signed Image
[Arguments] ${project} ${image} ${tag} ${user} ${pwd} ${with_remove}=${false}
Enable Notary Client
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${tag} ${user} ${pwd}
Clean All Local Images
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/v2.0/projects/${project}/repositories/${image}/artifacts/${tag}?with_signature=true"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} "signed":true
Run Keyword If ${with_remove} == ${true} Notary Remove Signature ${ip} ${project} ${image} ${tag} ${user} ${pwd}
Delete A Project Without Sign In Harbor
[Arguments] ${harbor_ip}=${ip} ${username}=${HARBOR_ADMIN} ${password}=${HARBOR_PASSWORD}
${d}= Get Current Date result_format=%m%s
${project_name}= Set Variable 000${d}
${image}= Set Variable hello-world
Create An New Project And Go Into Project ${project_name}
Push Image ${harbor_ip} ${username} ${password} ${project_name} ${image}
Project Should Not Be Deleted ${project_name}
Go Into Project ${project_name}
Delete Repo ${project_name} ${image}
Navigate To Projects
Project Should Be Deleted ${project_name}
Manage Project Member Without Sign In Harbor
[Arguments] ${sign_in_user} ${sign_in_pwd} ${test_user1}=user005 ${test_user2}=user006 ${is_oidc_mode}=${false}
${d}= Get current Date result_format=%m%s
${image}= Set Variable hello-world
Create An New Project And Go Into Project project${d}
Push image ${ip} ${sign_in_user} ${sign_in_pwd} project${d} ${image}
Logout Harbor
User Should Not Be A Member Of Project ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Manage Project Member ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Add is_oidc_mode=${is_oidc_mode}
User Should Be Guest ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Developer is_oidc_mode=${is_oidc_mode}
User Should Be Developer ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Admin is_oidc_mode=${is_oidc_mode}
User Should Be Admin ${test_user1} ${sign_in_pwd} project${d} ${test_user2} is_oidc_mode=${is_oidc_mode}
Change User Role In Project ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Maintainer is_oidc_mode=${is_oidc_mode}
User Should Be Maintainer ${test_user1} ${sign_in_pwd} project${d} ${image} is_oidc_mode=${is_oidc_mode}
Manage Project Member ${sign_in_user} ${sign_in_pwd} project${d} ${test_user1} Remove is_oidc_mode=${is_oidc_mode}
User Should Not Be A Member Of Project ${test_user1} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Push image ${ip} ${sign_in_user} ${sign_in_pwd} project${d} hello-world
User Should Be Guest ${test_user2} ${sign_in_pwd} project${d} is_oidc_mode=${is_oidc_mode}
Helm CLI Push Without Sign In Harbor
[Arguments] ${sign_in_user} ${sign_in_pwd}
${d}= Get Current Date result_format=%m%s
Create An New Project And Go Into Project project${d}
Helm Repo Add ${HARBOR_URL} ${sign_in_user} ${sign_in_pwd} project_name=project${d}
Helm Repo Push ${sign_in_user} ${sign_in_pwd} ${harbor_chart_filename}
Switch To Project Charts
Go Into Chart Version ${harbor_chart_name}
Retry Wait Until Page Contains ${harbor_chart_version}
Helm3 CLI Push Without Sign In Harbor
[Arguments] ${sign_in_user} ${sign_in_pwd}
${d}= Get Current Date result_format=%m%s
Create An New Project And Go Into Project project${d}
Helm Repo Push ${sign_in_user} ${sign_in_pwd} ${harbor_chart_filename} helm_repo_name=${HARBOR_URL}/chartrepo/project${d} helm_cmd=helm3
Switch To Project Charts
Retry Double Keywords When Error Go Into Chart Version ${harbor_chart_name} Retry Wait Until Page Contains ${harbor_chart_version}
#Important Note: All CVE IDs in CVE Allowlist cases must unique!
Body Of Verfiy System Level CVE Allowlist
[Arguments] ${image_argument} ${sha256_argument} ${most_cve_list} ${single_cve}
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable ${image_argument}
# ${image}= Set Variable goharbor/harbor-portal
${sha256}= Set Variable ${sha256_argument}
# ${sha256}= Set Variable 2cb6a1c24dd6b88f11fd44ccc6560cb7be969f8ac5f752802c99cae6bcd592bb
${signin_user}= Set Variable user025
${signin_pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${signin_user} ${signin_pwd}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} sha256=${sha256}
Go Into Project project${d}
Set Vulnerabilty Serverity 2
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256} err_msg=cannot be pulled due to configured policy
Go Into Project project${d}
Go Into Repo project${d}/${image}
Scan Repo ${sha256} Succeed
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Check Listed In CVE Allowlist project${d} ${image} ${sha256} ${single_cve} is_in=No
Switch To Configure
Switch To Configuration System Setting
# Add Items To System CVE Allowlist CVE-2019-19317\nCVE-2019-19646 \nCVE-2019-5188 \nCVE-2019-20387 \nCVE-2019-17498 \nCVE-2019-20372 \nCVE-2019-19244 \nCVE-2019-19603 \nCVE-2019-19880 \nCVE-2019-19923 \nCVE-2019-19925 \nCVE-2019-19926 \nCVE-2019-19959 \nCVE-2019-20218 \nCVE-2019-19232 \nCVE-2019-19234 \nCVE-2019-19645
Add Items To System CVE Allowlist ${most_cve_list}
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256} err_msg=cannot be pulled due to configured policy
# Add Items To System CVE Allowlist CVE-2019-18276
Add Items To System CVE Allowlist ${single_cve}
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Delete Top Item In System CVE Allowlist count=16
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256} err_msg=cannot be pulled due to configured policy
Check Listed In CVE Allowlist project${d} ${image} ${sha256} ${single_cve}
Close Browser
Body Of Verfiy Project Level CVE Allowlist
[Arguments] ${image_argument} ${sha256_argument} ${most_cve_list} ${single_cve}
[Tags] run-once
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable ${image_argument}
${sha256}= Set Variable ${sha256_argument}
${signin_user}= Set Variable user025
${signin_pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${signin_user} ${signin_pwd}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} sha256=${sha256}
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Go Into Project project${d}
Set Vulnerabilty Serverity 2
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Go Into Project project${d}
Go Into Repo project${d}/${image}
Scan Repo ${sha256} Succeed
Go Into Project project${d}
Add Items to Project CVE Allowlist ${most_cve_list}
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Add Items to Project CVE Allowlist ${single_cve}
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Delete Top Item In Project CVE Allowlist
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Close Browser
Body Of Verfiy Project Level CVE Allowlist By Quick Way of Add System
[Arguments] ${image_argument} ${sha256_argument} ${cve_list}
[Tags] run-once
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable ${image_argument}
${sha256}= Set Variable ${sha256_argument}
${signin_user}= Set Variable user025
${signin_pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Configure
Switch To Configuration System Setting
Add Items To System CVE Allowlist ${cve_list}
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${signin_user} ${signin_pwd}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} sha256=${sha256}
Go Into Project project${d}
Set Vulnerabilty Serverity 2
Go Into Project project${d}
Go Into Repo project${d}/${image}
Scan Repo ${sha256} Succeed
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Go Into Project project${d}
Set Project To Project Level CVE Allowlist
Cannot Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Add System CVE Allowlist to Project CVE Allowlist By Add System Button Click
Pull Image ${ip} ${signin_user} ${signin_pwd} project${d} ${image} tag=${sha256}
Close Browser
Body Of Replication Of Push Images to Registry Triggered By Event
[Arguments] ${provider} ${endpoint} ${username} ${pwd} ${dest_namespace} ${image_size}=12
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${sha256}= Set Variable 0e67625224c1da47cb3270e7a861a83e332f708d3d89dde0cbed432c94824d9a
${image}= Set Variable test_push_repli
${tag1}= Set Variable v1.1.0
@{tags} Create List ${tag1}
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint ${provider} e${d} ${endpoint} ${username} ${pwd} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} ${dest_namespace} mode=Event Based del_remote=${true}
Push Special Image To Project project${d} ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${image} tags=@{tags} size=${image_size}
Filter Replication Rule rule${d}
Select Rule rule${d}
${endpoint_body}= Fetch From Right ${endpoint} //
${dest_namespace}= Set Variable If '${provider}'=='gitlab' ${endpoint_body}/${dest_namespace} ${dest_namespace}
Run Keyword If '${provider}'=='docker-hub' or '${provider}'=='gitlab' Docker Image Can Be Pulled ${dest_namespace}/${image}:${tag1} times=3
Executions Result Count Should Be Succeeded event_based 1
Go Into Project project${d}
Delete Repo project${d} ${image}
Run Keyword If '${provider}'=='docker-hub' or '${provider}'=='gitlab' Docker Image Can Not Be Pulled ${dest_namespace}/${image}:${tag1}
Switch To Replication Manage
Filter Replication Rule rule${d}
Select Rule rule${d}
Executions Result Count Should Be Succeeded event_based 2
Body Of Replication Of Pull Images from Registry To Self
[Arguments] ${provider} ${endpoint} ${username} ${pwd} ${src_project_name} ${des_project_name} ${verify_verbose} @{target_images}
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${_des_pro_name}= Set Variable If '${des_project_name}'=='${null}' project${d} ${des_project_name}
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Run Keyword If '${des_project_name}'=='${null}' Create An New Project And Go Into Project ${_des_pro_name}
Switch To Registries
Create A New Endpoint ${provider} e${d} ${endpoint} ${username} ${pwd} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} pull ${src_project_name} all e${d} ${_des_pro_name}
Select Rule And Replicate rule${d}
Run Keyword If '${verify_verbose}'=='Y' Verify Artifact Display Verbose ${_des_pro_name} @{target_images}
... ELSE Verify Artifact Display ${_des_pro_name} @{target_images}
Close Browser
Verify Artifact Display Verbose
[Arguments] ${pro_name} @{target_images}
FOR ${item} IN @{target_images}
${item}= Get Substring ${item} 1 -1
${item}= Evaluate ${item}
${image}= Get From Dictionary ${item} image
${tag}= Get From Dictionary ${item} tag
${total_artifact_count}= Get From Dictionary ${item} total_artifact_count
${archive_count}= Get From Dictionary ${item} archive_count
Log To Console Check image ${image}:${tag} replication to Project ${pro_name}
Image Should Be Replicated To Project ${pro_name} ${image} tag=${tag} total_artifact_count=${total_artifact_count} archive_count=${archive_count} times=2
END
Verify Artifact Display
[Arguments] ${pro_name} @{target_images}
FOR ${item} IN @{target_images}
${item}= Get Substring ${item} 1 -1
${item}= Evaluate ${item}
${image}= Get From Dictionary ${item} image
Image Should Be Replicated To Project ${pro_name} ${image} times=2
END

View File

@ -1,294 +1,294 @@
# 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 ***
Library OperatingSystem
Library String
Library Collections
Library requests
Library Process
Library SSHLibrary 1 minute
Library DateTime
Library SeleniumLibrary 60 10
Library JSONLibrary
Resource Nimbus-Util.robot
Resource Vsphere-Util.robot
Resource VCH-Util.robot
Resource Drone-Util.robot
Resource Github-Util.robot
Resource Harbor-Util.robot
Resource Harbor-Pages/Public_Elements.robot
Resource Harbor-Pages/HomePage.robot
Resource Harbor-Pages/HomePage_Elements.robot
Resource Harbor-Pages/Project.robot
Resource Harbor-Pages/Project_Elements.robot
Resource Harbor-Pages/Project-Members.robot
Resource Harbor-Pages/Project-Members_Elements.robot
Resource Harbor-Pages/Project-P2P-Preheat.robot
Resource Harbor-Pages/Project-P2P-Preheat-Elements.robot
Resource Harbor-Pages/Project-Webhooks.robot
Resource Harbor-Pages/Project-Webhooks_Elements.robot
Resource Harbor-Pages/Project-Repository.robot
Resource Harbor-Pages/Project-Repository_Elements.robot
Resource Harbor-Pages/Project-Artifact.robot
Resource Harbor-Pages/Project-Artifact-Elements.robot
Resource Harbor-Pages/Project-Config.robot
Resource Harbor-Pages/Project-Config-Elements.robot
Resource Harbor-Pages/Project-Helmcharts.robot
Resource Harbor-Pages/Project-Helmcharts_Elements.robot
Resource Harbor-Pages/Project-Copy.robot
Resource Harbor-Pages/Project-Copy-Elements.robot
Resource Harbor-Pages/Project-Tag-Retention.robot
Resource Harbor-Pages/Project-Tag-Retention_Elements.robot
Resource Harbor-Pages/Project_Robot_Account.robot
Resource Harbor-Pages/Project_Robot_Account_Elements.robot
Resource Harbor-Pages/Replication.robot
Resource Harbor-Pages/Replication_Elements.robot
Resource Harbor-Pages/UserProfile.robot
Resource Harbor-Pages/UserProfile_Elements.robot
Resource Harbor-Pages/Administration-Users.robot
Resource Harbor-Pages/Administration-Users_Elements.robot
Resource Harbor-Pages/GC.robot
Resource Harbor-Pages/Configuration.robot
Resource Harbor-Pages/Configuration_Elements.robot
Resource Harbor-Pages/ToolKit.robot
Resource Harbor-Pages/ToolKit_Elements.robot
Resource Harbor-Pages/Vulnerability.robot
Resource Harbor-Pages/Vulnerability_Elements.robot
Resource Harbor-Pages/LDAP-Mode.robot
Resource Harbor-Pages/OIDC_Auth.robot
Resource Harbor-Pages/OIDC_Auth_Elements.robot
Resource Harbor-Pages/Robot_Account.robot
Resource Harbor-Pages/Robot_Account_Elements.robot
Resource Harbor-Pages/Verify.robot
Resource Docker-Util.robot
Resource CNAB_Util.robot
Resource Helm-Util.robot
Resource OVA-Util.robot
Resource Cert-Util.robot
Resource SeleniumUtil.robot
Resource Nightly-Util.robot
Resource APITest-Util.robot
Resource TestCaseBody.robot
*** Keywords ***
Wait Until Element Is Visible And Enabled
[Arguments] ${element}
Wait Until Element Is Visible ${element}
Wait Until Element Is Enabled ${element}
Retry Action Keyword
[Arguments] ${keyword} @{param}
Retry Keyword N Times When Error 4 ${keyword} @{param}
Retry Wait Element
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Visible And Enabled @{param}
Retry Wait Element Visible
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Visible @{param}
Retry Wait Element Not Visible
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Not Visible @{param}
Retry Wait Element Should Be Disabled
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Element Should Be Disabled @{param}
Retry Element Click
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Element Click @{param}
Retry Button Click
[Arguments] ${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 Clear Element Text
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Clear Element Text @{param}
Retry Link Click
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Link Click @{param}
Retry Checkbox Should Be Selected
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Checkbox Should Be Selected @{param}
Retry Checkbox Should Not Be Selected
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Checkbox Should Not Be Selected @{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 Does Not Contains
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Does Not Contain @{param}
Retry Wait Until Page Contains Element
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Contains Element @{param}
Retry Wait Until Page Not Contains Element
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Does Not Contain Element @{param}
Retry Select Object
[Arguments] ${obj_name}
@{param} Create List ${obj_name}
Retry Action Keyword Select Object @{param}
Retry Textfield Value Should Be
[Arguments] ${element} ${text}
@{param} Create List ${element} ${text}
Retry Action Keyword Wait And Textfield Value Should Be @{param}
Retry List Selection Should Be
[Arguments] ${element} ${text}
@{param} Create List ${element} ${text}
Retry Action Keyword Wait And List Selection Should Be @{param}
Link Click
[Arguments] ${element_xpath}
Click Link ${element_xpath}
Wait And List Selection Should Be
[Arguments] ${element} ${text}
Wait Until Element Is Visible And Enabled ${element}
List Selection Should Be ${element} ${text}
Wait And Textfield Value Should Be
[Arguments] ${element} ${text}
Wait Until Element Is Visible And Enabled ${element}
Textfield Value Should Be ${element} ${text}
Element Click
[Arguments] ${element_xpath}
Wait Until Element Is Visible And Enabled ${element_xpath}
Click Element ${element_xpath}
Sleep 1
Button Click
[Arguments] ${element_xpath}
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}
Clear Field Of Characters
[Arguments] ${field} ${character count}
[Documentation] This keyword pushes the delete key (ascii: \8) a specified number of times in a specified field.
FOR ${index} IN RANGE ${character count}
Press Keys ${field} \\8
END
Wait Unitl Command Success
[Arguments] ${cmd} ${times}=5
FOR ${n} IN RANGE 1 ${times}
Log Trying ${cmd}: ${n} ... console=True
${rc} ${output}= Run And Return Rc And Output ${cmd}
Exit For Loop If '${rc}'=='0'
Sleep 2
END
Log Command Result is ${output}
Should Be Equal As Strings '${rc}' '0'
[Return] ${output}
Command Should be Failed
[Arguments] ${cmd}
${rc} ${output}= Run And Return Rc And Output ${cmd}
Should Not Be Equal As Strings '${rc}' '0'
Log ${output}
[Return] ${output}
Retry Keyword N Times When Error
[Arguments] ${times} ${keyword} @{elements}
FOR ${n} IN RANGE 1 ${times}
Log To Console Trying ${keyword} elements @{elements} ${n} times ...
${out} Run Keyword And Ignore Error ${keyword} @{elements}
Log To Console Return value is ${out} and ${out[0]}
Run Keyword If '${keyword}'=='Make Swagger Client' Exit For Loop If '${out[0]}'=='PASS' and '${out[1]}'=='0'
... ELSE Exit For Loop If '${out[0]}'=='PASS'
Sleep 10
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
[Return] ${out[1]}
Retry Keyword When Return Value Mismatch
[Arguments] ${keyword} ${expected_value} ${count} @{elements}
FOR ${n} IN RANGE 1 ${count}
Log To Console Trying ${keyword} ${n} times ...
${out} Run Keyword And Ignore Error ${keyword} @{elements}
Log To Console Return value is ${out[1]}
${status}= Set Variable If '${out[1]}'=='${expected_value}' 'PASS' 'FAIL'
Exit For Loop If '${out[1]}'=='${expected_value}'
Sleep 2
END
Run Keyword If ${status}=='FAIL' Capture Page Screenshot
Should Be Equal As Strings ${status} 'PASS'
Retry Double Keywords When Error
[Arguments] ${keyword1} ${element1} ${keyword2} ${element2} ${DoAssert}=${true} ${times}=3
FOR ${n} IN RANGE 1 ${times}
Log To Console Trying ${keyword1} and ${keyword2} ${n} times ...
${out1} Run Keyword And Ignore Error ${keyword1} ${element1}
Sleep 1
${out2} Run Keyword And Ignore Error ${keyword2} ${element2}
Log To Console Return value is ${out1[0]} ${out2[0]}
Exit For Loop If '${out2[0]}'=='PASS'
Sleep 1
END
Capture Page Screenshot
Return From Keyword If ${DoAssert} == ${false} '${out2[0]}'
Should Be Equal As Strings '${out2[0]}' 'PASS'
Run Curl And Return Json
[Arguments] ${curl_cmd}
${json_data_file}= Set Variable ${CURDIR}${/}cur_user_info.json
${rc} ${output}= Run And Return Rc And Output ${curl_cmd}
Should Be Equal As Integers 0 ${rc}
Create File ${json_data_file} ${output}
${json}= Load Json From File ${json_data_file}
[Return] ${json}
Log All
[Arguments] ${text}
Log To Console ${text}
Log ${text}
# 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 ***
Library OperatingSystem
Library String
Library Collections
Library requests
Library Process
Library SSHLibrary 1 minute
Library DateTime
Library SeleniumLibrary 60 10
Library JSONLibrary
Resource Nimbus-Util.robot
Resource Vsphere-Util.robot
Resource VCH-Util.robot
Resource Drone-Util.robot
Resource Github-Util.robot
Resource Harbor-Util.robot
Resource Harbor-Pages/Public_Elements.robot
Resource Harbor-Pages/HomePage.robot
Resource Harbor-Pages/HomePage_Elements.robot
Resource Harbor-Pages/Project.robot
Resource Harbor-Pages/Project_Elements.robot
Resource Harbor-Pages/Project-Members.robot
Resource Harbor-Pages/Project-Members_Elements.robot
Resource Harbor-Pages/Project-P2P-Preheat.robot
Resource Harbor-Pages/Project-P2P-Preheat-Elements.robot
Resource Harbor-Pages/Project-Webhooks.robot
Resource Harbor-Pages/Project-Webhooks_Elements.robot
Resource Harbor-Pages/Project-Repository.robot
Resource Harbor-Pages/Project-Repository_Elements.robot
Resource Harbor-Pages/Project-Artifact.robot
Resource Harbor-Pages/Project-Artifact-Elements.robot
Resource Harbor-Pages/Project-Config.robot
Resource Harbor-Pages/Project-Config-Elements.robot
Resource Harbor-Pages/Project-Helmcharts.robot
Resource Harbor-Pages/Project-Helmcharts_Elements.robot
Resource Harbor-Pages/Project-Copy.robot
Resource Harbor-Pages/Project-Copy-Elements.robot
Resource Harbor-Pages/Project-Tag-Retention.robot
Resource Harbor-Pages/Project-Tag-Retention_Elements.robot
Resource Harbor-Pages/Project_Robot_Account.robot
Resource Harbor-Pages/Project_Robot_Account_Elements.robot
Resource Harbor-Pages/Replication.robot
Resource Harbor-Pages/Replication_Elements.robot
Resource Harbor-Pages/UserProfile.robot
Resource Harbor-Pages/UserProfile_Elements.robot
Resource Harbor-Pages/Administration-Users.robot
Resource Harbor-Pages/Administration-Users_Elements.robot
Resource Harbor-Pages/GC.robot
Resource Harbor-Pages/Configuration.robot
Resource Harbor-Pages/Configuration_Elements.robot
Resource Harbor-Pages/ToolKit.robot
Resource Harbor-Pages/ToolKit_Elements.robot
Resource Harbor-Pages/Vulnerability.robot
Resource Harbor-Pages/Vulnerability_Elements.robot
Resource Harbor-Pages/LDAP-Mode.robot
Resource Harbor-Pages/OIDC_Auth.robot
Resource Harbor-Pages/OIDC_Auth_Elements.robot
Resource Harbor-Pages/Robot_Account.robot
Resource Harbor-Pages/Robot_Account_Elements.robot
Resource Harbor-Pages/Verify.robot
Resource Docker-Util.robot
Resource CNAB_Util.robot
Resource Helm-Util.robot
Resource OVA-Util.robot
Resource Cert-Util.robot
Resource SeleniumUtil.robot
Resource Nightly-Util.robot
Resource APITest-Util.robot
Resource TestCaseBody.robot
*** Keywords ***
Wait Until Element Is Visible And Enabled
[Arguments] ${element}
Wait Until Element Is Visible ${element}
Wait Until Element Is Enabled ${element}
Retry Action Keyword
[Arguments] ${keyword} @{param}
Retry Keyword N Times When Error 4 ${keyword} @{param}
Retry Wait Element
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Visible And Enabled @{param}
Retry Wait Element Visible
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Visible @{param}
Retry Wait Element Not Visible
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Element Is Not Visible @{param}
Retry Wait Element Should Be Disabled
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Element Should Be Disabled @{param}
Retry Element Click
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Element Click @{param}
Retry Button Click
[Arguments] ${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 Clear Element Text
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Clear Element Text @{param}
Retry Link Click
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Link Click @{param}
Retry Checkbox Should Be Selected
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Checkbox Should Be Selected @{param}
Retry Checkbox Should Not Be Selected
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Checkbox Should Not Be Selected @{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 Does Not Contains
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Does Not Contain @{param}
Retry Wait Until Page Contains Element
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Contains Element @{param}
Retry Wait Until Page Not Contains Element
[Arguments] ${element_xpath}
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Does Not Contain Element @{param}
Retry Select Object
[Arguments] ${obj_name}
@{param} Create List ${obj_name}
Retry Action Keyword Select Object @{param}
Retry Textfield Value Should Be
[Arguments] ${element} ${text}
@{param} Create List ${element} ${text}
Retry Action Keyword Wait And Textfield Value Should Be @{param}
Retry List Selection Should Be
[Arguments] ${element} ${text}
@{param} Create List ${element} ${text}
Retry Action Keyword Wait And List Selection Should Be @{param}
Link Click
[Arguments] ${element_xpath}
Click Link ${element_xpath}
Wait And List Selection Should Be
[Arguments] ${element} ${text}
Wait Until Element Is Visible And Enabled ${element}
List Selection Should Be ${element} ${text}
Wait And Textfield Value Should Be
[Arguments] ${element} ${text}
Wait Until Element Is Visible And Enabled ${element}
Textfield Value Should Be ${element} ${text}
Element Click
[Arguments] ${element_xpath}
Wait Until Element Is Visible And Enabled ${element_xpath}
Click Element ${element_xpath}
Sleep 1
Button Click
[Arguments] ${element_xpath}
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}
Clear Field Of Characters
[Arguments] ${field} ${character count}
[Documentation] This keyword pushes the delete key (ascii: \8) a specified number of times in a specified field.
FOR ${index} IN RANGE ${character count}
Press Keys ${field} \\8
END
Wait Unitl Command Success
[Arguments] ${cmd} ${times}=5
FOR ${n} IN RANGE 1 ${times}
Log Trying ${cmd}: ${n} ... console=True
${rc} ${output}= Run And Return Rc And Output ${cmd}
Exit For Loop If '${rc}'=='0'
Sleep 2
END
Log Command Result is ${output}
Should Be Equal As Strings '${rc}' '0'
[Return] ${output}
Command Should be Failed
[Arguments] ${cmd}
${rc} ${output}= Run And Return Rc And Output ${cmd}
Should Not Be Equal As Strings '${rc}' '0'
Log ${output}
[Return] ${output}
Retry Keyword N Times When Error
[Arguments] ${times} ${keyword} @{elements}
FOR ${n} IN RANGE 1 ${times}
Log To Console Trying ${keyword} elements @{elements} ${n} times ...
${out} Run Keyword And Ignore Error ${keyword} @{elements}
Log To Console Return value is ${out} and ${out[0]}
Run Keyword If '${keyword}'=='Make Swagger Client' Exit For Loop If '${out[0]}'=='PASS' and '${out[1]}'=='0'
... ELSE Exit For Loop If '${out[0]}'=='PASS'
Sleep 10
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
[Return] ${out[1]}
Retry Keyword When Return Value Mismatch
[Arguments] ${keyword} ${expected_value} ${count} @{elements}
FOR ${n} IN RANGE 1 ${count}
Log To Console Trying ${keyword} ${n} times ...
${out} Run Keyword And Ignore Error ${keyword} @{elements}
Log To Console Return value is ${out[1]}
${status}= Set Variable If '${out[1]}'=='${expected_value}' 'PASS' 'FAIL'
Exit For Loop If '${out[1]}'=='${expected_value}'
Sleep 2
END
Run Keyword If ${status}=='FAIL' Capture Page Screenshot
Should Be Equal As Strings ${status} 'PASS'
Retry Double Keywords When Error
[Arguments] ${keyword1} ${element1} ${keyword2} ${element2} ${DoAssert}=${true} ${times}=3
FOR ${n} IN RANGE 1 ${times}
Log To Console Trying ${keyword1} and ${keyword2} ${n} times ...
${out1} Run Keyword And Ignore Error ${keyword1} ${element1}
Sleep 1
${out2} Run Keyword And Ignore Error ${keyword2} ${element2}
Log To Console Return value is ${out1[0]} ${out2[0]}
Exit For Loop If '${out2[0]}'=='PASS'
Sleep 1
END
Capture Page Screenshot
Return From Keyword If ${DoAssert} == ${false} '${out2[0]}'
Should Be Equal As Strings '${out2[0]}' 'PASS'
Run Curl And Return Json
[Arguments] ${curl_cmd}
${json_data_file}= Set Variable ${CURDIR}${/}cur_user_info.json
${rc} ${output}= Run And Return Rc And Output ${curl_cmd}
Should Be Equal As Integers 0 ${rc}
Create File ${json_data_file} ${output}
${json}= Load Json From File ${json_data_file}
[Return] ${json}
Log All
[Arguments] ${text}
Log To Console ${text}
Log ${text}

View File

@ -1,404 +1,404 @@
# 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 This resource contains all keywords related to creating, deleting, maintaining VCHs
*** Keywords ***
Set Test Environment Variables
# Finish setting up environment variables
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set DRONE_BUILD_NUMBER
Run Keyword If '${status}' == 'FAIL' Set Environment Variable DRONE_BUILD_NUMBER 0
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set BRIDGE_NETWORK
Run Keyword If '${status}' == 'FAIL' Set Environment Variable BRIDGE_NETWORK network
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set PUBLIC_NETWORK
Run Keyword If '${status}' == 'FAIL' Set Environment Variable PUBLIC_NETWORK 'VM Network'
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set TEST_DATACENTER
Run Keyword If '${status}' == 'FAIL' Set Environment Variable TEST_DATACENTER ${SPACE}
@{URLs}= Split String %{TEST_URL_ARRAY}
${len}= Get Length ${URLs}
${IDX}= Evaluate %{DRONE_BUILD_NUMBER} \% ${len}
Set Environment Variable TEST_URL @{URLs}[${IDX}]
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
# TODO: need an integration/vic-test image update to include the about.cert command
#${rc} ${thumbprint}= Run And Return Rc And Output govc about.cert -k | jq -r .ThumbprintSHA1
${rc} ${thumbprint}= Run And Return Rc And Output openssl s_client -connect $(govc env -x GOVC_URL_HOST):443 </dev/null 2>/dev/null | openssl x509 -fingerprint -noout | cut -d= -f2
Should Be Equal As Integers ${rc} 0
Set Environment Variable TEST_THUMBPRINT ${thumbprint}
Log To Console \nTEST_URL=%{TEST_URL}
${host}= Run govc ls host
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set TEST_RESOURCE
Run Keyword If '${status}' == 'FAIL' Set Environment Variable TEST_RESOURCE ${host}/Resources
Set Environment Variable GOVC_RESOURCE_POOL %{TEST_RESOURCE}
${noQuotes}= Strip String %{TEST_DATASTORE} characters="
Set Environment Variable GOVC_DATASTORE ${noQuotes}
${about}= Run govc about
${status}= Run Keyword And Return Status Should Contain ${about} VMware ESXi
Run Keyword If ${status} Set Environment Variable HOST_TYPE ESXi
Run Keyword Unless ${status} Set Environment Variable HOST_TYPE VC
${about}= Run govc datastore.info %{TEST_DATASTORE} | grep 'Type'
${status}= Run Keyword And Return Status Should Contain ${about} vsan
Run Keyword If ${status} Set Environment Variable DATASTORE_TYPE VSAN
Run Keyword Unless ${status} Set Environment Variable DATASTORE_TYPE Non_VSAN
# set the TLS config options suitable for vic-machine in this env
${domain}= Get Environment Variable DOMAIN ''
Run Keyword If $domain == '' Set Suite Variable ${vicmachinetls} --no-tlsverify
Run Keyword If $domain != '' Set Suite Variable ${vicmachinetls} --tls-cname=*.${domain}
Set Test VCH Name
# Set a unique bridge network for each VCH that has a random VLAN ID
${vlan}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Evaluate str(random.randint(1, 4093)) modules=random
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.add -vlan=${vlan} -vswitch vSwitchLAN %{VCH-NAME}-bridge
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Set Environment Variable BRIDGE_NETWORK %{VCH-NAME}-bridge
Set Test VCH Name
${name}= Evaluate 'VCH-%{DRONE_BUILD_NUMBER}-' + str(random.randint(1000,9999)) modules=random
Set Environment Variable VCH-NAME ${name}
Set List Of Env Variables
[Arguments] ${vars}
@{vars}= Split String ${vars}
:FOR ${var} IN @{vars}
\ ${varname} ${varval}= Split String ${var} =
\ Set Environment Variable ${varname} ${varval}
Parse Environment Variables
[Arguments] ${line}
# If using the old logging format
${status}= Run Keyword And Return Status Should Contain ${line} mINFO
${logdeco} ${vars}= Run Keyword If ${status} Split String ${line} ${SPACE} 1
Run Keyword If ${status} Set List Of Env Variables ${vars}
Return From Keyword If ${status}
# Split the log log into pieces, discarding the initial log decoration, and assign to env vars
${logmon} ${logday} ${logyear} ${logtime} ${loglevel} ${vars}= Split String ${line} max_split=5
Set List Of Env Variables ${vars}
Get Docker Params
# Get VCH docker params e.g. "-H 192.168.218.181:2376 --tls"
[Arguments] ${output} ${certs}
@{output}= Split To Lines ${output}
:FOR ${item} IN @{output}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} DOCKER_HOST=
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
# Ensure we start from a clean slate with docker env vars
Remove Environment Variable DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_PATH CURL_CA_BUNDLE COMPOSE_PARAMS COMPOSE_TLS_VERSION
Parse Environment Variables ${line}
${dockerHost}= Get Environment Variable DOCKER_HOST
@{hostParts}= Split String ${dockerHost} :
${ip}= Strip String @{hostParts}[0]
${port}= Strip String @{hostParts}[1]
Set Environment Variable VCH-IP ${ip}
Set Environment Variable VCH-PORT ${port}
:FOR ${index} ${item} IN ENUMERATE @{output}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} http
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} Published ports can be reached at
\ ${idx} = Evaluate ${index} + 1
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${ext-ip} @{output}[${idx}]
${rest} ${ext-ip} = Split String From Right ${ext-ip} ${SPACE} 1
${ext-ip} = Strip String ${ext-ip}
Set Environment Variable EXT-IP ${ext-ip}
${rest} ${vic-admin}= Split String From Right ${line} ${SPACE} 1
Set Environment Variable VIC-ADMIN ${vic-admin}
Run Keyword If ${port} == 2376 Set Environment Variable VCH-PARAMS -H ${dockerHost} --tls
Run Keyword If ${port} == 2375 Set Environment Variable VCH-PARAMS -H ${dockerHost}
### Add environment variables for Compose and TLS
# Check if tls is enable from vic-machine's output and not trust ${certs} which some tests bypasses
${tls_enabled}= Get Environment Variable DOCKER_TLS_VERIFY ${false}
### Compose case for no-tlsverify
# Set environment variables if certs not used to create the VCH. This is NOT the recommended
# approach to running compose. There will be security warnings in the logs and some compose
# operations may not work properly because certs == false currently means we install with
# --no-tlsverify. Add CURL_CA_BUNDLE for a workaround in compose tests. If we change
# certs == false to install with --no-tls, then we need to change this again.
Run Keyword If ${tls_enabled} == ${false} Set Environment Variable CURL_CA_BUNDLE ${EMPTY}
# Get around quirk in compose if no-tlsverify, then CURL_CA_BUNDLE must exist and compose called with --tls
Run Keyword If ${tls_enabled} == ${false} Set Environment Variable COMPOSE-PARAMS -H ${dockerHost} --tls
### Compose case for tlsverify (assumes DOCKER_TLS_VERIFY also set)
Run Keyword If ${tls_enabled} == ${true} Set Environment Variable COMPOSE_TLS_VERSION TLSv1_2
Run Keyword If ${tls_enabled} == ${true} Set Environment Variable COMPOSE-PARAMS -H ${dockerHost}
Install VIC Appliance To Test Server
[Arguments] ${vic-machine}=bin/vic-machine-linux ${appliance-iso}=bin/appliance.iso ${bootstrap-iso}=bin/bootstrap.iso ${certs}=${true} ${vol}=default ${cleanup}=${true}
Set Test Environment Variables
# disable firewall
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.esxcli network firewall set -e false
# Attempt to cleanup old/canceled tests
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling VMs On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Datastore On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling Networks On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling vSwitches On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling Containers On Test Server
# Install the VCH now
Log To Console \nInstalling VCH to test server...
${output}= Run VIC Machine Command ${vic-machine} ${appliance-iso} ${bootstrap-iso} ${certs} ${vol}
Log ${output}
Should Contain ${output} Installer completed successfully
Get Docker Params ${output} ${certs}
Log To Console Installer completed successfully: %{VCH-NAME}...
Run VIC Machine Command
[Tags] secret
[Arguments] ${vic-machine} ${appliance-iso} ${bootstrap-iso} ${certs} ${vol}
${output}= Run Keyword If ${certs} Run ${vic-machine} create --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --image-store=%{TEST_DATASTORE} --appliance-iso=${appliance-iso} --bootstrap-iso=${bootstrap-iso} --password=%{TEST_PASSWORD} --force=true --bridge-network=%{BRIDGE_NETWORK} --public-network=%{PUBLIC_NETWORK} --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --volume-store=%{TEST_DATASTORE}/test:${vol} ${vicmachinetls}
Run Keyword If ${certs} Should Contain ${output} Installer completed successfully
Return From Keyword If ${certs} ${output}
${output}= Run Keyword Unless ${certs} Run ${vic-machine} create --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --image-store=%{TEST_DATASTORE} --appliance-iso=${appliance-iso} --bootstrap-iso=${bootstrap-iso} --password=%{TEST_PASSWORD} --force=true --bridge-network=%{BRIDGE_NETWORK} --public-network=%{PUBLIC_NETWORK} --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --volume-store=%{TEST_DATASTORE}/test:${vol} --no-tlsverify
Run Keyword Unless ${certs} Should Contain ${output} Installer completed successfully
[Return] ${output}
Run Secret VIC Machine Delete Command
[Tags] secret
[Arguments] ${vch-name}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux delete --name=${vch-name} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT}
[Return] ${rc} ${output}
Run Secret VIC Machine Inspect Command
[Tags] secret
[Arguments] ${name}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=${name} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --thumbprint=%{TEST_THUMBPRINT}
[Return] ${rc} ${output}
Run VIC Machine Delete Command
${rc} ${output}= Run Secret VIC Machine Delete Command %{VCH-NAME}
Wait Until Keyword Succeeds 6x 5s Check Delete Success %{VCH-NAME}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Completed successfully
${output}= Run rm -rf %{VCH-NAME}
[Return] ${output}
Run VIC Machine Inspect Command
${rc} ${output}= Run Secret VIC Machine Inspect Command %{VCH-NAME}
Get Docker Params ${output} ${true}
Gather Logs From Test Server
[Tags] secret
Run Keyword And Continue On Failure Run zip %{VCH-NAME}-certs -r %{VCH-NAME}
${out}= Run curl -k -D vic-admin-cookies -Fusername=%{TEST_USERNAME} -Fpassword=%{TEST_PASSWORD} %{VIC-ADMIN}/authentication
Log ${out}
${out}= Run curl -k -b vic-admin-cookies %{VIC-ADMIN}/container-logs.zip -o ${SUITE NAME}-%{VCH-NAME}-container-logs.zip
Log ${out}
Remove File vic-admin-cookies
${out}= Run govc datastore.download %{VCH-NAME}/vmware.log %{VCH-NAME}-vmware.log
Should Contain ${out} OK
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc logs -log=vmkernel -n=10000 > vmkernel.log
Check For The Proper Log Files
[Arguments] ${container}
# Ensure container logs are correctly being gathered for debugging purposes
${rc} ${output}= Run And Return Rc and Output curl -sk %{VIC-ADMIN}/authentication -XPOST -F username=%{TEST_USERNAME} -F password=%{TEST_PASSWORD} -D /tmp/cookies-%{VCH-NAME}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc and Output curl -sk %{VIC-ADMIN}/container-logs.tar.gz -b /tmp/cookies-%{VCH-NAME} | tar tvzf -
Should Be Equal As Integers ${rc} 0
Log ${output}
Should Contain ${output} ${container}/output.log
Should Contain ${output} ${container}/vmware.log
Should Contain ${output} ${container}/tether.debug
Scrape Logs For the Password
[Tags] secret
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/authentication -XPOST -F username=%{TEST_USERNAME} -F password=%{TEST_PASSWORD} -D /tmp/cookies-%{VCH-NAME}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/port-layer.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/init.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/docker-personality.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/vicadmin.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
Remove File /tmp/cookies-%{VCH-NAME}
Cleanup VIC Appliance On Test Server
Log To Console Gathering logs from the test server %{VCH-NAME}
Gather Logs From Test Server
Log To Console Deleting the VCH appliance %{VCH-NAME}
${output}= Run VIC Machine Delete Command
Run Keyword And Ignore Error Cleanup VCH Bridge Network %{VCH-NAME}
[Return] ${output}
Cleanup VCH Bridge Network
[Arguments] ${name}
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.remove ${name}-bridge
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.info
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Should Not Contain ${out} ${name}-bridge
Cleanup Datastore On Test Server
${out}= Run govc datastore.ls
${items}= Split To Lines ${out}
:FOR ${item} IN @{items}
\ ${build}= Split String ${item} -
\ # Skip any item that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any item that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ Log To Console Removing the following item from datastore: ${item}
\ ${out}= Run govc datastore.rm ${item}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${item}
Cleanup Dangling VMs On Test Server
${out}= Run govc ls vm
${vms}= Split To Lines ${out}
:FOR ${vm} IN @{vms}
\ ${vm}= Fetch From Right ${vm} /
\ ${build}= Split String ${vm} -
\ # Skip any VM that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any VM that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc vm.info -json\=true ${vm} | jq -r '.VirtualMachines[0].Config.Uuid'
\ Log To Console Destroying dangling VCH: ${vm}
\ ${rc} ${output}= Run Secret VIC Machine Delete Command ${vm}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${vm}
Cleanup Dangling Networks On Test Server
${out}= Run govc ls network
${nets}= Split To Lines ${out}
:FOR ${net} IN @{nets}
\ ${net}= Fetch From Right ${net} /
\ ${build}= Split String ${net} -
\ # Skip any Network that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any Network that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc host.portgroup.remove ${net}
Cleanup Dangling vSwitches On Test Server
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.vswitch.info | grep VCH
${nets}= Split To Lines ${out}
:FOR ${net} IN @{nets}
\ ${net}= Fetch From Right ${net} ${SPACE}
\ ${build}= Split String ${net} -
\ # Skip any vSwitch that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any vSwitch that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc host.vswitch.remove ${net}
Get Scratch Disk From VM Info
[Arguments] ${vm}
${disks}= Run govc vm.info -json ${vm} | jq -r '.VirtualMachines[].Layout.Disk[].DiskFile[]'
${disks}= Split To Lines ${disks}
:FOR ${disk} IN @{disks}
\ ${disk}= Fetch From Right ${disk} ${SPACE}
\ ${status}= Run Keyword And Return Status Should Contain ${disk} scratch.vmdk
\ Return From Keyword If ${status} ${disk}
Cleanup Dangling Containers On Test Server
${vms}= Run govc ls vm
${vms}= Split To Lines ${vms}
:FOR ${vm} IN @{vms}
\ # Ignore VCH's, we only care about containers at this point
\ ${status}= Run Keyword And Return Status Should Contain ${vm} VCH
\ Continue For Loop If ${status}
\ ${disk}= Get Scratch Disk From VM Info ${vm}
\ ${vch}= Fetch From Left ${disk} /
\ ${vch}= Split String ${vch} -
\ # Skip any VM that is not associated with integration tests
\ Continue For Loop If '@{vch}[0]' != 'VCH'
\ ${state}= Get State Of Drone Build @{vch}[1]
\ # Skip any VM that is still running
\ Continue For Loop If '${state}' == 'running'
\ # Destroy the VM and remove it from datastore because it is a dangling container
\ Log To Console Cleaning up dangling container: ${vm}
\ ${out}= Run govc vm.destroy ${vm}
\ ${name}= Fetch From Right ${vm} /
\ ${out}= Run govc datastore.rm ${name}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${name}
# VCH upgrade helpers
Install VIC with version to Test Server
[Arguments] ${version}=7315 ${insecureregistry}=
Log To Console \nDownloading vic ${version} from bintray...
${rc} ${output}= Run And Return Rc And Output wget https://bintray.com/vmware/vic-repo/download_file?file_path=vic_${version}.tar.gz -O vic.tar.gz
${rc} ${output}= Run And Return Rc And Output tar zxvf vic.tar.gz
Set Environment Variable TEST_TIMEOUT 20m0s
Install VIC Appliance To Test Server vic-machine=./vic/vic-machine-linux appliance-iso=./vic/appliance.iso bootstrap-iso=./vic/bootstrap.iso certs=${false} vol=default ${insecureregistry}
Set Environment Variable VIC-ADMIN %{VCH-IP}:2378
Set Environment Variable INITIAL-VERSION ${version}
Clean up VIC Appliance And Local Binary
Cleanup VIC Appliance On Test Server
Run rm -rf vic.tar.gz vic
Upgrade
Log To Console \nUpgrading VCH...
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux upgrade --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT}
Should Contain ${output} Completed successfully
Should Not Contain ${output} Rolling back upgrade
Should Be Equal As Integers ${rc} 0
Check Upgraded Version
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux version
@{vers}= Split String ${output}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE}
Should Contain ${output} Completed successfully
Should Contain ${output} @{vers}[2]
Should Not Contain ${output} %{INITIAL-VERSION}
Should Be Equal As Integers ${rc} 0
Log ${output}
Get Docker Params ${output} ${true}
Check Original Version
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux version
@{vers}= Split String ${output}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE}
Should Contain ${output} Completed successfully
Should Contain ${output} @{vers}[2]
Should Be Equal As Integers ${rc} 0
Log ${output}
Get Docker Params ${output} ${true}
Rollback
Log To Console \nTesting rollback...
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux upgrade --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --rollback
Should Contain ${output} Completed successfully
Should Be Equal As Integers ${rc} 0
Enable VCH SSH
[Arguments] ${vic-machine}=bin/vic-machine-linux ${rootpw}=%{TEST_PASSWORD} ${target}=%{TEST_URL} ${password}=%{TEST_PASSWORD} ${thumbprint}=%{TEST_THUMBPRINT} ${name}=%{VCH-NAME} ${user}=%{TEST_USERNAME} ${resource}=%{TEST_RESOURCE}
Log To Console \nEnable SSH on vch...
${rc} ${output}= Run And Return Rc And Output ${vic-machine} debug --rootpw ${rootpw} --target ${target} --password ${password} --thumbprint ${thumbprint} --name ${name} --user ${user} --compute-resource ${resource} --enable-ssh
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Completed successfully
# 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 This resource contains all keywords related to creating, deleting, maintaining VCHs
*** Keywords ***
Set Test Environment Variables
# Finish setting up environment variables
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set DRONE_BUILD_NUMBER
Run Keyword If '${status}' == 'FAIL' Set Environment Variable DRONE_BUILD_NUMBER 0
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set BRIDGE_NETWORK
Run Keyword If '${status}' == 'FAIL' Set Environment Variable BRIDGE_NETWORK network
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set PUBLIC_NETWORK
Run Keyword If '${status}' == 'FAIL' Set Environment Variable PUBLIC_NETWORK 'VM Network'
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set TEST_DATACENTER
Run Keyword If '${status}' == 'FAIL' Set Environment Variable TEST_DATACENTER ${SPACE}
@{URLs}= Split String %{TEST_URL_ARRAY}
${len}= Get Length ${URLs}
${IDX}= Evaluate %{DRONE_BUILD_NUMBER} \% ${len}
Set Environment Variable TEST_URL @{URLs}[${IDX}]
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
# TODO: need an integration/vic-test image update to include the about.cert command
#${rc} ${thumbprint}= Run And Return Rc And Output govc about.cert -k | jq -r .ThumbprintSHA1
${rc} ${thumbprint}= Run And Return Rc And Output openssl s_client -connect $(govc env -x GOVC_URL_HOST):443 </dev/null 2>/dev/null | openssl x509 -fingerprint -noout | cut -d= -f2
Should Be Equal As Integers ${rc} 0
Set Environment Variable TEST_THUMBPRINT ${thumbprint}
Log To Console \nTEST_URL=%{TEST_URL}
${host}= Run govc ls host
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set TEST_RESOURCE
Run Keyword If '${status}' == 'FAIL' Set Environment Variable TEST_RESOURCE ${host}/Resources
Set Environment Variable GOVC_RESOURCE_POOL %{TEST_RESOURCE}
${noQuotes}= Strip String %{TEST_DATASTORE} characters="
Set Environment Variable GOVC_DATASTORE ${noQuotes}
${about}= Run govc about
${status}= Run Keyword And Return Status Should Contain ${about} VMware ESXi
Run Keyword If ${status} Set Environment Variable HOST_TYPE ESXi
Run Keyword Unless ${status} Set Environment Variable HOST_TYPE VC
${about}= Run govc datastore.info %{TEST_DATASTORE} | grep 'Type'
${status}= Run Keyword And Return Status Should Contain ${about} vsan
Run Keyword If ${status} Set Environment Variable DATASTORE_TYPE VSAN
Run Keyword Unless ${status} Set Environment Variable DATASTORE_TYPE Non_VSAN
# set the TLS config options suitable for vic-machine in this env
${domain}= Get Environment Variable DOMAIN ''
Run Keyword If $domain == '' Set Suite Variable ${vicmachinetls} --no-tlsverify
Run Keyword If $domain != '' Set Suite Variable ${vicmachinetls} --tls-cname=*.${domain}
Set Test VCH Name
# Set a unique bridge network for each VCH that has a random VLAN ID
${vlan}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Evaluate str(random.randint(1, 4093)) modules=random
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.add -vlan=${vlan} -vswitch vSwitchLAN %{VCH-NAME}-bridge
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Set Environment Variable BRIDGE_NETWORK %{VCH-NAME}-bridge
Set Test VCH Name
${name}= Evaluate 'VCH-%{DRONE_BUILD_NUMBER}-' + str(random.randint(1000,9999)) modules=random
Set Environment Variable VCH-NAME ${name}
Set List Of Env Variables
[Arguments] ${vars}
@{vars}= Split String ${vars}
:FOR ${var} IN @{vars}
\ ${varname} ${varval}= Split String ${var} =
\ Set Environment Variable ${varname} ${varval}
Parse Environment Variables
[Arguments] ${line}
# If using the old logging format
${status}= Run Keyword And Return Status Should Contain ${line} mINFO
${logdeco} ${vars}= Run Keyword If ${status} Split String ${line} ${SPACE} 1
Run Keyword If ${status} Set List Of Env Variables ${vars}
Return From Keyword If ${status}
# Split the log log into pieces, discarding the initial log decoration, and assign to env vars
${logmon} ${logday} ${logyear} ${logtime} ${loglevel} ${vars}= Split String ${line} max_split=5
Set List Of Env Variables ${vars}
Get Docker Params
# Get VCH docker params e.g. "-H 192.168.218.181:2376 --tls"
[Arguments] ${output} ${certs}
@{output}= Split To Lines ${output}
:FOR ${item} IN @{output}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} DOCKER_HOST=
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
# Ensure we start from a clean slate with docker env vars
Remove Environment Variable DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_PATH CURL_CA_BUNDLE COMPOSE_PARAMS COMPOSE_TLS_VERSION
Parse Environment Variables ${line}
${dockerHost}= Get Environment Variable DOCKER_HOST
@{hostParts}= Split String ${dockerHost} :
${ip}= Strip String @{hostParts}[0]
${port}= Strip String @{hostParts}[1]
Set Environment Variable VCH-IP ${ip}
Set Environment Variable VCH-PORT ${port}
:FOR ${index} ${item} IN ENUMERATE @{output}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} http
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} Published ports can be reached at
\ ${idx} = Evaluate ${index} + 1
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${ext-ip} @{output}[${idx}]
${rest} ${ext-ip} = Split String From Right ${ext-ip} ${SPACE} 1
${ext-ip} = Strip String ${ext-ip}
Set Environment Variable EXT-IP ${ext-ip}
${rest} ${vic-admin}= Split String From Right ${line} ${SPACE} 1
Set Environment Variable VIC-ADMIN ${vic-admin}
Run Keyword If ${port} == 2376 Set Environment Variable VCH-PARAMS -H ${dockerHost} --tls
Run Keyword If ${port} == 2375 Set Environment Variable VCH-PARAMS -H ${dockerHost}
### Add environment variables for Compose and TLS
# Check if tls is enable from vic-machine's output and not trust ${certs} which some tests bypasses
${tls_enabled}= Get Environment Variable DOCKER_TLS_VERIFY ${false}
### Compose case for no-tlsverify
# Set environment variables if certs not used to create the VCH. This is NOT the recommended
# approach to running compose. There will be security warnings in the logs and some compose
# operations may not work properly because certs == false currently means we install with
# --no-tlsverify. Add CURL_CA_BUNDLE for a workaround in compose tests. If we change
# certs == false to install with --no-tls, then we need to change this again.
Run Keyword If ${tls_enabled} == ${false} Set Environment Variable CURL_CA_BUNDLE ${EMPTY}
# Get around quirk in compose if no-tlsverify, then CURL_CA_BUNDLE must exist and compose called with --tls
Run Keyword If ${tls_enabled} == ${false} Set Environment Variable COMPOSE-PARAMS -H ${dockerHost} --tls
### Compose case for tlsverify (assumes DOCKER_TLS_VERIFY also set)
Run Keyword If ${tls_enabled} == ${true} Set Environment Variable COMPOSE_TLS_VERSION TLSv1_2
Run Keyword If ${tls_enabled} == ${true} Set Environment Variable COMPOSE-PARAMS -H ${dockerHost}
Install VIC Appliance To Test Server
[Arguments] ${vic-machine}=bin/vic-machine-linux ${appliance-iso}=bin/appliance.iso ${bootstrap-iso}=bin/bootstrap.iso ${certs}=${true} ${vol}=default ${cleanup}=${true}
Set Test Environment Variables
# disable firewall
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.esxcli network firewall set -e false
# Attempt to cleanup old/canceled tests
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling VMs On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Datastore On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling Networks On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling vSwitches On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling Containers On Test Server
# Install the VCH now
Log To Console \nInstalling VCH to test server...
${output}= Run VIC Machine Command ${vic-machine} ${appliance-iso} ${bootstrap-iso} ${certs} ${vol}
Log ${output}
Should Contain ${output} Installer completed successfully
Get Docker Params ${output} ${certs}
Log To Console Installer completed successfully: %{VCH-NAME}...
Run VIC Machine Command
[Tags] secret
[Arguments] ${vic-machine} ${appliance-iso} ${bootstrap-iso} ${certs} ${vol}
${output}= Run Keyword If ${certs} Run ${vic-machine} create --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --image-store=%{TEST_DATASTORE} --appliance-iso=${appliance-iso} --bootstrap-iso=${bootstrap-iso} --password=%{TEST_PASSWORD} --force=true --bridge-network=%{BRIDGE_NETWORK} --public-network=%{PUBLIC_NETWORK} --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --volume-store=%{TEST_DATASTORE}/test:${vol} ${vicmachinetls}
Run Keyword If ${certs} Should Contain ${output} Installer completed successfully
Return From Keyword If ${certs} ${output}
${output}= Run Keyword Unless ${certs} Run ${vic-machine} create --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --image-store=%{TEST_DATASTORE} --appliance-iso=${appliance-iso} --bootstrap-iso=${bootstrap-iso} --password=%{TEST_PASSWORD} --force=true --bridge-network=%{BRIDGE_NETWORK} --public-network=%{PUBLIC_NETWORK} --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --volume-store=%{TEST_DATASTORE}/test:${vol} --no-tlsverify
Run Keyword Unless ${certs} Should Contain ${output} Installer completed successfully
[Return] ${output}
Run Secret VIC Machine Delete Command
[Tags] secret
[Arguments] ${vch-name}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux delete --name=${vch-name} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT}
[Return] ${rc} ${output}
Run Secret VIC Machine Inspect Command
[Tags] secret
[Arguments] ${name}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=${name} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --thumbprint=%{TEST_THUMBPRINT}
[Return] ${rc} ${output}
Run VIC Machine Delete Command
${rc} ${output}= Run Secret VIC Machine Delete Command %{VCH-NAME}
Wait Until Keyword Succeeds 6x 5s Check Delete Success %{VCH-NAME}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Completed successfully
${output}= Run rm -rf %{VCH-NAME}
[Return] ${output}
Run VIC Machine Inspect Command
${rc} ${output}= Run Secret VIC Machine Inspect Command %{VCH-NAME}
Get Docker Params ${output} ${true}
Gather Logs From Test Server
[Tags] secret
Run Keyword And Continue On Failure Run zip %{VCH-NAME}-certs -r %{VCH-NAME}
${out}= Run curl -k -D vic-admin-cookies -Fusername=%{TEST_USERNAME} -Fpassword=%{TEST_PASSWORD} %{VIC-ADMIN}/authentication
Log ${out}
${out}= Run curl -k -b vic-admin-cookies %{VIC-ADMIN}/container-logs.zip -o ${SUITE NAME}-%{VCH-NAME}-container-logs.zip
Log ${out}
Remove File vic-admin-cookies
${out}= Run govc datastore.download %{VCH-NAME}/vmware.log %{VCH-NAME}-vmware.log
Should Contain ${out} OK
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc logs -log=vmkernel -n=10000 > vmkernel.log
Check For The Proper Log Files
[Arguments] ${container}
# Ensure container logs are correctly being gathered for debugging purposes
${rc} ${output}= Run And Return Rc and Output curl -sk %{VIC-ADMIN}/authentication -XPOST -F username=%{TEST_USERNAME} -F password=%{TEST_PASSWORD} -D /tmp/cookies-%{VCH-NAME}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc and Output curl -sk %{VIC-ADMIN}/container-logs.tar.gz -b /tmp/cookies-%{VCH-NAME} | tar tvzf -
Should Be Equal As Integers ${rc} 0
Log ${output}
Should Contain ${output} ${container}/output.log
Should Contain ${output} ${container}/vmware.log
Should Contain ${output} ${container}/tether.debug
Scrape Logs For the Password
[Tags] secret
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/authentication -XPOST -F username=%{TEST_USERNAME} -F password=%{TEST_PASSWORD} -D /tmp/cookies-%{VCH-NAME}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/port-layer.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/init.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/docker-personality.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/vicadmin.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
Remove File /tmp/cookies-%{VCH-NAME}
Cleanup VIC Appliance On Test Server
Log To Console Gathering logs from the test server %{VCH-NAME}
Gather Logs From Test Server
Log To Console Deleting the VCH appliance %{VCH-NAME}
${output}= Run VIC Machine Delete Command
Run Keyword And Ignore Error Cleanup VCH Bridge Network %{VCH-NAME}
[Return] ${output}
Cleanup VCH Bridge Network
[Arguments] ${name}
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.remove ${name}-bridge
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.info
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Should Not Contain ${out} ${name}-bridge
Cleanup Datastore On Test Server
${out}= Run govc datastore.ls
${items}= Split To Lines ${out}
:FOR ${item} IN @{items}
\ ${build}= Split String ${item} -
\ # Skip any item that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any item that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ Log To Console Removing the following item from datastore: ${item}
\ ${out}= Run govc datastore.rm ${item}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${item}
Cleanup Dangling VMs On Test Server
${out}= Run govc ls vm
${vms}= Split To Lines ${out}
:FOR ${vm} IN @{vms}
\ ${vm}= Fetch From Right ${vm} /
\ ${build}= Split String ${vm} -
\ # Skip any VM that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any VM that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc vm.info -json\=true ${vm} | jq -r '.VirtualMachines[0].Config.Uuid'
\ Log To Console Destroying dangling VCH: ${vm}
\ ${rc} ${output}= Run Secret VIC Machine Delete Command ${vm}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${vm}
Cleanup Dangling Networks On Test Server
${out}= Run govc ls network
${nets}= Split To Lines ${out}
:FOR ${net} IN @{nets}
\ ${net}= Fetch From Right ${net} /
\ ${build}= Split String ${net} -
\ # Skip any Network that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any Network that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc host.portgroup.remove ${net}
Cleanup Dangling vSwitches On Test Server
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.vswitch.info | grep VCH
${nets}= Split To Lines ${out}
:FOR ${net} IN @{nets}
\ ${net}= Fetch From Right ${net} ${SPACE}
\ ${build}= Split String ${net} -
\ # Skip any vSwitch that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any vSwitch that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc host.vswitch.remove ${net}
Get Scratch Disk From VM Info
[Arguments] ${vm}
${disks}= Run govc vm.info -json ${vm} | jq -r '.VirtualMachines[].Layout.Disk[].DiskFile[]'
${disks}= Split To Lines ${disks}
:FOR ${disk} IN @{disks}
\ ${disk}= Fetch From Right ${disk} ${SPACE}
\ ${status}= Run Keyword And Return Status Should Contain ${disk} scratch.vmdk
\ Return From Keyword If ${status} ${disk}
Cleanup Dangling Containers On Test Server
${vms}= Run govc ls vm
${vms}= Split To Lines ${vms}
:FOR ${vm} IN @{vms}
\ # Ignore VCH's, we only care about containers at this point
\ ${status}= Run Keyword And Return Status Should Contain ${vm} VCH
\ Continue For Loop If ${status}
\ ${disk}= Get Scratch Disk From VM Info ${vm}
\ ${vch}= Fetch From Left ${disk} /
\ ${vch}= Split String ${vch} -
\ # Skip any VM that is not associated with integration tests
\ Continue For Loop If '@{vch}[0]' != 'VCH'
\ ${state}= Get State Of Drone Build @{vch}[1]
\ # Skip any VM that is still running
\ Continue For Loop If '${state}' == 'running'
\ # Destroy the VM and remove it from datastore because it is a dangling container
\ Log To Console Cleaning up dangling container: ${vm}
\ ${out}= Run govc vm.destroy ${vm}
\ ${name}= Fetch From Right ${vm} /
\ ${out}= Run govc datastore.rm ${name}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${name}
# VCH upgrade helpers
Install VIC with version to Test Server
[Arguments] ${version}=7315 ${insecureregistry}=
Log To Console \nDownloading vic ${version} from bintray...
${rc} ${output}= Run And Return Rc And Output wget https://bintray.com/vmware/vic-repo/download_file?file_path=vic_${version}.tar.gz -O vic.tar.gz
${rc} ${output}= Run And Return Rc And Output tar zxvf vic.tar.gz
Set Environment Variable TEST_TIMEOUT 20m0s
Install VIC Appliance To Test Server vic-machine=./vic/vic-machine-linux appliance-iso=./vic/appliance.iso bootstrap-iso=./vic/bootstrap.iso certs=${false} vol=default ${insecureregistry}
Set Environment Variable VIC-ADMIN %{VCH-IP}:2378
Set Environment Variable INITIAL-VERSION ${version}
Clean up VIC Appliance And Local Binary
Cleanup VIC Appliance On Test Server
Run rm -rf vic.tar.gz vic
Upgrade
Log To Console \nUpgrading VCH...
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux upgrade --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT}
Should Contain ${output} Completed successfully
Should Not Contain ${output} Rolling back upgrade
Should Be Equal As Integers ${rc} 0
Check Upgraded Version
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux version
@{vers}= Split String ${output}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE}
Should Contain ${output} Completed successfully
Should Contain ${output} @{vers}[2]
Should Not Contain ${output} %{INITIAL-VERSION}
Should Be Equal As Integers ${rc} 0
Log ${output}
Get Docker Params ${output} ${true}
Check Original Version
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux version
@{vers}= Split String ${output}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE}
Should Contain ${output} Completed successfully
Should Contain ${output} @{vers}[2]
Should Be Equal As Integers ${rc} 0
Log ${output}
Get Docker Params ${output} ${true}
Rollback
Log To Console \nTesting rollback...
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux upgrade --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --rollback
Should Contain ${output} Completed successfully
Should Be Equal As Integers ${rc} 0
Enable VCH SSH
[Arguments] ${vic-machine}=bin/vic-machine-linux ${rootpw}=%{TEST_PASSWORD} ${target}=%{TEST_URL} ${password}=%{TEST_PASSWORD} ${thumbprint}=%{TEST_THUMBPRINT} ${name}=%{VCH-NAME} ${user}=%{TEST_USERNAME} ${resource}=%{TEST_RESOURCE}
Log To Console \nEnable SSH on vch...
${rc} ${output}= Run And Return Rc And Output ${vic-machine} debug --rootpw ${rootpw} --target ${target} --password ${password} --thumbprint ${thumbprint} --name ${name} --user ${user} --compute-resource ${resource} --enable-ssh
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Completed successfully

View File

@ -1,217 +1,217 @@
# 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 This resource contains any keywords dealing with operations being performed on a Vsphere instance, mostly govc wrappers
*** Keywords ***
Power On VM OOB
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -on "${vm}"
Should Be Equal As Integers ${rc} 0
Log To Console Waiting for VM to power on ...
Wait Until VM Powers On "${vm}" ${vc_host} ${vc_user} ${vc_password}
Power Off VM OOB
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -off "${vm}"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Log To Console Waiting for VM to power off ...
Wait Until VM Powers Off "${vm}" ${vc_host} ${vc_user} ${vc_password}
Destroy VM OOB
[Arguments] ${vm}
${rc} ${output}= Run And Return Rc And Output govc vm.destroy "*-${vm}"
Should Be Equal As Integers ${rc} 0
Put Host Into Maintenance Mode
${rc} ${output}= Run And Return Rc And Output govc host.maintenance.enter -host.ip=%{TEST_URL}
Should Contain ${output} entering maintenance mode... OK
Remove Host From Maintenance Mode
${rc} ${output}= Run And Return Rc And Output govc host.maintenance.exit -host.ip=%{TEST_URL}
Should Contain ${output} exiting maintenance mode... OK
Reboot VM
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
Log To Console Rebooting ${vm} ...
Power Off VM OOB ${vm} ${vc_host} ${vc_user} ${vc_password}
Power On VM OOB ${vm} ${vc_host} ${vc_user} ${vc_password}
Log To Console ${vm} Powered On
Reset VM
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -reset "${vm}"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Log To Console Waiting for VM to reset ...
Wait Until VM Powers On "${vm}" ${vc_host} ${vc_user} ${vc_password}
Wait Until VM Powers On
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
FOR ${idx} IN RANGE 0 30
${ret}= Run GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.info ${vm}
Set Test Variable ${out} ${ret}
${status}= Run Keyword And Return Status Should Contain ${out} poweredOn
Return From Keyword If ${status}
Sleep 1
END
Fail VM did not power on within 30 seconds
Wait Until VM Powers Off
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
FOR ${idx} IN RANGE 0 30
${ret}= Run GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.info ${vm}
Set Test Variable ${out} ${ret}
${status}= Run Keyword And Return Status Should Contain ${out} poweredOff
Return From Keyword If ${status}
Sleep 1
END
Fail VM did not power off within 30 seconds
Wait Until VM Is Destroyed
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${ret}= Run govc ls vm/${vm}
\ Set Test Variable ${out} ${ret}
\ ${status}= Run Keyword And Return Status Should Be Empty ${out}
\ Return From Keyword If ${status}
\ Sleep 1
Fail VM was not destroyed within 30 seconds
Get VM IP
[Arguments] ${vm}
${rc} ${out}= Run And Return Rc And Output govc vm.ip ${vm}
Should Be Equal As Integers ${rc} 0
[Return] ${out}
Get VM Host Name
[Arguments] ${vm}
${out}= Run govc vm.info ${vm}
${out}= Split To Lines ${out}
${host}= Fetch From Right @{out}[-1] ${SPACE}
[Return] ${host}
Get VM Info
[Arguments] ${vm}
${rc} ${out}= Run And Return Rc And Output govc vm.info -r ${vm}
Should Be Equal As Integers ${rc} 0
[Return] ${out}
vMotion A VM
[Arguments] ${vm}
${host}= Get VM Host Name ${vm}
${status}= Run Keyword And Return Status Should Contain ${host} ${esx1-ip}
Run Keyword If ${status} Run govc vm.migrate -host cls/${esx2-ip} -pool cls/Resources ${vm}
Run Keyword Unless ${status} Run govc vm.migrate -host cls/${esx1-ip} -pool cls/Resources ${vm}
Create Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.create -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Revert Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.revert -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Delete Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.remove -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Setup Snapshot
${hostname}= Get Test Server Hostname
Set Environment Variable TEST_HOSTNAME ${hostname}
Set Environment Variable SNAPSHOT vic-ci-test-%{DRONE_BUILD_NUMBER}
Create Test Server Snapshot %{TEST_HOSTNAME} %{SNAPSHOT}
Get Datacenter Name
${out}= Run govc datacenter.info
${out}= Split To Lines ${out}
${name}= Fetch From Right @{out}[0] ${SPACE}
[Return] ${name}
Get Test Server Hostname
[Tags] secret
${hostname}= Run sshpass -p $TEST_PASSWORD ssh $TEST_USERNAME@$TEST_URL hostname
[Return] ${hostname}
Check Delete Success
[Arguments] ${name}
${out}= Run govc ls vm
Log ${out}
Should Not Contain ${out} ${name}
${out}= Run govc datastore.ls
Log ${out}
Should Not Contain ${out} ${name}
${out}= Run govc ls host/*/Resources/*
Log ${out}
Should Not Contain ${out} ${name}
Gather Logs From ESX Server
Environment Variable Should Be Set TEST_URL
${out}= Run govc logs.download
Change Log Level On Server
[Arguments] ${level}
${out}= Run govc host.option.set Config.HostAgent.log.level ${level}
Should Be Empty ${out}
Add Vsphere License
[Tags] secret
[Arguments] ${license}
${out}= Run govc license.add ${license}
Should Contain ${out} Key:
Assign Vsphere License
[Tags] secret
[Arguments] ${license} ${host}
${out}= Run govc license.assign -host ${host} ${license}
Should Contain ${out} Key:
Add Host To VCenter
[Arguments] ${host} ${user} ${dc} ${pw}
:FOR ${idx} IN RANGE 1 4
\ ${out}= Run govc cluster.add -hostname=${host} -username=${user} -dc=${dc} -password=${pw} -noverify=true
\ ${status}= Run Keyword And Return Status Should Contain ${out} OK
\ Return From Keyword If ${status}
Fail Failed to add the host to the VC in 3 attempts
Get Host Firewall Enabled
${output}= Run govc host.esxcli network firewall get
Should Contain ${output} Enabled
@{output}= Split To Lines ${output}
:FOR ${line} IN @{output}
\ Run Keyword If "Enabled" in '''${line}''' Set Test Variable ${out} ${line}
${enabled}= Fetch From Right ${out} :
${enabled}= Strip String ${enabled}
Return From Keyword If '${enabled}' == 'false' ${false}
Return From Keyword If '${enabled}' == 'true' ${true}
Enable Host Firewall
Run govc host.esxcli network firewall set --enabled true
Disable Host Firewall
Run govc host.esxcli network firewall set --enabled false
# 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 This resource contains any keywords dealing with operations being performed on a Vsphere instance, mostly govc wrappers
*** Keywords ***
Power On VM OOB
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -on "${vm}"
Should Be Equal As Integers ${rc} 0
Log To Console Waiting for VM to power on ...
Wait Until VM Powers On "${vm}" ${vc_host} ${vc_user} ${vc_password}
Power Off VM OOB
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -off "${vm}"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Log To Console Waiting for VM to power off ...
Wait Until VM Powers Off "${vm}" ${vc_host} ${vc_user} ${vc_password}
Destroy VM OOB
[Arguments] ${vm}
${rc} ${output}= Run And Return Rc And Output govc vm.destroy "*-${vm}"
Should Be Equal As Integers ${rc} 0
Put Host Into Maintenance Mode
${rc} ${output}= Run And Return Rc And Output govc host.maintenance.enter -host.ip=%{TEST_URL}
Should Contain ${output} entering maintenance mode... OK
Remove Host From Maintenance Mode
${rc} ${output}= Run And Return Rc And Output govc host.maintenance.exit -host.ip=%{TEST_URL}
Should Contain ${output} exiting maintenance mode... OK
Reboot VM
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
Log To Console Rebooting ${vm} ...
Power Off VM OOB ${vm} ${vc_host} ${vc_user} ${vc_password}
Power On VM OOB ${vm} ${vc_host} ${vc_user} ${vc_password}
Log To Console ${vm} Powered On
Reset VM
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -reset "${vm}"
Log To Console ${output}
Should Be Equal As Integers ${rc} 0
Log To Console Waiting for VM to reset ...
Wait Until VM Powers On "${vm}" ${vc_host} ${vc_user} ${vc_password}
Wait Until VM Powers On
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
FOR ${idx} IN RANGE 0 30
${ret}= Run GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.info ${vm}
Set Test Variable ${out} ${ret}
${status}= Run Keyword And Return Status Should Contain ${out} poweredOn
Return From Keyword If ${status}
Sleep 1
END
Fail VM did not power on within 30 seconds
Wait Until VM Powers Off
[Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password}
FOR ${idx} IN RANGE 0 30
${ret}= Run GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.info ${vm}
Set Test Variable ${out} ${ret}
${status}= Run Keyword And Return Status Should Contain ${out} poweredOff
Return From Keyword If ${status}
Sleep 1
END
Fail VM did not power off within 30 seconds
Wait Until VM Is Destroyed
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${ret}= Run govc ls vm/${vm}
\ Set Test Variable ${out} ${ret}
\ ${status}= Run Keyword And Return Status Should Be Empty ${out}
\ Return From Keyword If ${status}
\ Sleep 1
Fail VM was not destroyed within 30 seconds
Get VM IP
[Arguments] ${vm}
${rc} ${out}= Run And Return Rc And Output govc vm.ip ${vm}
Should Be Equal As Integers ${rc} 0
[Return] ${out}
Get VM Host Name
[Arguments] ${vm}
${out}= Run govc vm.info ${vm}
${out}= Split To Lines ${out}
${host}= Fetch From Right @{out}[-1] ${SPACE}
[Return] ${host}
Get VM Info
[Arguments] ${vm}
${rc} ${out}= Run And Return Rc And Output govc vm.info -r ${vm}
Should Be Equal As Integers ${rc} 0
[Return] ${out}
vMotion A VM
[Arguments] ${vm}
${host}= Get VM Host Name ${vm}
${status}= Run Keyword And Return Status Should Contain ${host} ${esx1-ip}
Run Keyword If ${status} Run govc vm.migrate -host cls/${esx2-ip} -pool cls/Resources ${vm}
Run Keyword Unless ${status} Run govc vm.migrate -host cls/${esx1-ip} -pool cls/Resources ${vm}
Create Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.create -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Revert Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.revert -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Delete Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.remove -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Setup Snapshot
${hostname}= Get Test Server Hostname
Set Environment Variable TEST_HOSTNAME ${hostname}
Set Environment Variable SNAPSHOT vic-ci-test-%{DRONE_BUILD_NUMBER}
Create Test Server Snapshot %{TEST_HOSTNAME} %{SNAPSHOT}
Get Datacenter Name
${out}= Run govc datacenter.info
${out}= Split To Lines ${out}
${name}= Fetch From Right @{out}[0] ${SPACE}
[Return] ${name}
Get Test Server Hostname
[Tags] secret
${hostname}= Run sshpass -p $TEST_PASSWORD ssh $TEST_USERNAME@$TEST_URL hostname
[Return] ${hostname}
Check Delete Success
[Arguments] ${name}
${out}= Run govc ls vm
Log ${out}
Should Not Contain ${out} ${name}
${out}= Run govc datastore.ls
Log ${out}
Should Not Contain ${out} ${name}
${out}= Run govc ls host/*/Resources/*
Log ${out}
Should Not Contain ${out} ${name}
Gather Logs From ESX Server
Environment Variable Should Be Set TEST_URL
${out}= Run govc logs.download
Change Log Level On Server
[Arguments] ${level}
${out}= Run govc host.option.set Config.HostAgent.log.level ${level}
Should Be Empty ${out}
Add Vsphere License
[Tags] secret
[Arguments] ${license}
${out}= Run govc license.add ${license}
Should Contain ${out} Key:
Assign Vsphere License
[Tags] secret
[Arguments] ${license} ${host}
${out}= Run govc license.assign -host ${host} ${license}
Should Contain ${out} Key:
Add Host To VCenter
[Arguments] ${host} ${user} ${dc} ${pw}
:FOR ${idx} IN RANGE 1 4
\ ${out}= Run govc cluster.add -hostname=${host} -username=${user} -dc=${dc} -password=${pw} -noverify=true
\ ${status}= Run Keyword And Return Status Should Contain ${out} OK
\ Return From Keyword If ${status}
Fail Failed to add the host to the VC in 3 attempts
Get Host Firewall Enabled
${output}= Run govc host.esxcli network firewall get
Should Contain ${output} Enabled
@{output}= Split To Lines ${output}
:FOR ${line} IN @{output}
\ Run Keyword If "Enabled" in '''${line}''' Set Test Variable ${out} ${line}
${enabled}= Fetch From Right ${out} :
${enabled}= Strip String ${enabled}
Return From Keyword If '${enabled}' == 'false' ${false}
Return From Keyword If '${enabled}' == 'true' ${true}
Enable Host Firewall
Run govc host.esxcli network firewall set --enabled true
Disable Host Firewall
Run govc host.esxcli network firewall set --enabled false

View File

@ -1,22 +1,22 @@
// 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 Bundle
*** Test Cases ***
Distro Harbor Offline
Package Harbor Offline
// 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 Bundle
*** Test Cases ***
Distro Harbor Offline
Package Harbor Offline

View File

@ -1,22 +1,22 @@
// 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 Bundle
*** Test Cases ***
Distro Harbor Online
Package Harbor Online
// 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 Bundle
*** Test Cases ***
Distro Harbor Online
Package Harbor Online

File diff suppressed because it is too large Load Diff

View File

@ -1,125 +1,125 @@
// 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://${OIDC_HOSTNAME}
${HARBOR_ADMIN} admin
*** Test Cases ***
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version
Test Case - OIDC User Sign In
#Sign in with all 9 users is for user population, other test cases might use these users.
Sign In Harbor With OIDC User ${HARBOR_URL}
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test2
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test3
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test4
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test5
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test6
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test7
Sleep 2
Close Browser
Test Case - Create An New Project
Sign In Harbor With OIDC User ${HARBOR_URL}
${d}= Get Current Date result_format=%m%s
Create An New Project And Go Into Project test${d}
Close Browser
Test Case - Delete A Project
Init Chrome Driver
Sign In Harbor With OIDC User ${HARBOR_URL}
${secret}= Get Secrete By API ${HARBOR_URL}
Delete A Project Without Sign In Harbor harbor_ip=${OIDC_HOSTNAME} username=${OIDC_USERNAME} password=${secret}
Close Browser
Test Case - Manage Project Member
Init Chrome Driver
Sign In Harbor With OIDC User ${HARBOR_URL}
${secret}= Get Secrete By API ${HARBOR_URL}
Manage Project Member Without Sign In Harbor sign_in_user=${OIDC_USERNAME} sign_in_pwd=${secret} test_user1=test2 test_user2=test3 is_oidc_mode=${true}
Close Browser
Test Case - Generate User CLI Secret
Init Chrome Driver
${d}= Get current Date result_format=%m%s
${image}= Set Variable hello-world
Sign In Harbor With OIDC User ${HARBOR_URL}
Create An New Project And Go Into Project project${d}
${secret_old}= Get Secrete By API ${HARBOR_URL}
Push image ${ip} ${OIDC_USERNAME} ${secret_old} project${d} ${image}
${secret_new}= Generate And Return Secret ${HARBOR_URL}
Log To Console ${secret_old}
Log To Console ${secret_new}
Should Not Be Equal As Strings '${secret_old}' '${secret_new}'
Cannot Docker Login Harbor ${ip} ${OIDC_USERNAME} ${secret_old}
Pull image ${ip} ${OIDC_USERNAME} ${secret_new} project${d} ${image}
Push image ${ip} ${OIDC_USERNAME} ${secret_new} project${d} ${image}
Close Browser
Test Case - Helm CLI Push
Init Chrome Driver
Sign In Harbor With OIDC User ${HARBOR_URL}
${secret}= Get Secrete By API ${HARBOR_URL}
Helm CLI Push Without Sign In Harbor ${OIDC_USERNAME} ${secret}
Close Browser
Test Case - Onboard OIDC User Sign In
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Check Automatic Onboarding And Save
Logout Harbor
Sign In Harbor With OIDC User ${HARBOR_URL} test8 is_onboard=${true}
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Set User Name Claim And Save email
Logout Harbor
Sign In Harbor With OIDC User ${HARBOR_URL} test9 is_onboard=${true} username_claim=email
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Set User Name Claim And Save ${null}
Sleep 2
Close Browser
Test Case - OIDC Group User
Init Chrome Driver
${d}= Get current Date result_format=%m%s
${image}= Set Variable hello-world
${admin_user}= Set Variable admin_user
${admin_pwd}= Set Variable zhu88jie
${user}= Set Variable mike
${pwd}= Set Variable ${admin_pwd}
Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin_user} password=${admin_pwd} login_with_provider=ldap
Switch To Registries
Create A New Endpoint harbor test_oidc_admin https://cicd.harbor.vmwarecna.net ${null} ${null} Y
${secret}= Get Secrete By API ${HARBOR_URL} username=${admin_user}
Push image ${ip} ${admin_user} ${secret} library ${image}
Logout Harbor
Sign In Harbor With OIDC User ${HARBOR_URL} username=${user} password=${pwd} login_with_provider=ldap
${output}= Run Keyword And Ignore Error Switch To Configure
Should Be Equal As Strings '${output[0]}' 'FAIL'
Close Browser
// 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://${OIDC_HOSTNAME}
${HARBOR_ADMIN} admin
*** Test Cases ***
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version
Test Case - OIDC User Sign In
#Sign in with all 9 users is for user population, other test cases might use these users.
Sign In Harbor With OIDC User ${HARBOR_URL}
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test2
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test3
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test4
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test5
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test6
Sleep 2
Sign In Harbor With OIDC User ${HARBOR_URL} test7
Sleep 2
Close Browser
Test Case - Create An New Project
Sign In Harbor With OIDC User ${HARBOR_URL}
${d}= Get Current Date result_format=%m%s
Create An New Project And Go Into Project test${d}
Close Browser
Test Case - Delete A Project
Init Chrome Driver
Sign In Harbor With OIDC User ${HARBOR_URL}
${secret}= Get Secrete By API ${HARBOR_URL}
Delete A Project Without Sign In Harbor harbor_ip=${OIDC_HOSTNAME} username=${OIDC_USERNAME} password=${secret}
Close Browser
Test Case - Manage Project Member
Init Chrome Driver
Sign In Harbor With OIDC User ${HARBOR_URL}
${secret}= Get Secrete By API ${HARBOR_URL}
Manage Project Member Without Sign In Harbor sign_in_user=${OIDC_USERNAME} sign_in_pwd=${secret} test_user1=test2 test_user2=test3 is_oidc_mode=${true}
Close Browser
Test Case - Generate User CLI Secret
Init Chrome Driver
${d}= Get current Date result_format=%m%s
${image}= Set Variable hello-world
Sign In Harbor With OIDC User ${HARBOR_URL}
Create An New Project And Go Into Project project${d}
${secret_old}= Get Secrete By API ${HARBOR_URL}
Push image ${ip} ${OIDC_USERNAME} ${secret_old} project${d} ${image}
${secret_new}= Generate And Return Secret ${HARBOR_URL}
Log To Console ${secret_old}
Log To Console ${secret_new}
Should Not Be Equal As Strings '${secret_old}' '${secret_new}'
Cannot Docker Login Harbor ${ip} ${OIDC_USERNAME} ${secret_old}
Pull image ${ip} ${OIDC_USERNAME} ${secret_new} project${d} ${image}
Push image ${ip} ${OIDC_USERNAME} ${secret_new} project${d} ${image}
Close Browser
Test Case - Helm CLI Push
Init Chrome Driver
Sign In Harbor With OIDC User ${HARBOR_URL}
${secret}= Get Secrete By API ${HARBOR_URL}
Helm CLI Push Without Sign In Harbor ${OIDC_USERNAME} ${secret}
Close Browser
Test Case - Onboard OIDC User Sign In
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Check Automatic Onboarding And Save
Logout Harbor
Sign In Harbor With OIDC User ${HARBOR_URL} test8 is_onboard=${true}
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Set User Name Claim And Save email
Logout Harbor
Sign In Harbor With OIDC User ${HARBOR_URL} test9 is_onboard=${true} username_claim=email
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Set User Name Claim And Save ${null}
Sleep 2
Close Browser
Test Case - OIDC Group User
Init Chrome Driver
${d}= Get current Date result_format=%m%s
${image}= Set Variable hello-world
${admin_user}= Set Variable admin_user
${admin_pwd}= Set Variable zhu88jie
${user}= Set Variable mike
${pwd}= Set Variable ${admin_pwd}
Sign In Harbor With OIDC User ${HARBOR_URL} username=${admin_user} password=${admin_pwd} login_with_provider=ldap
Switch To Registries
Create A New Endpoint harbor test_oidc_admin https://cicd.harbor.vmwarecna.net ${null} ${null} Y
${secret}= Get Secrete By API ${HARBOR_URL} username=${admin_user}
Push image ${ip} ${admin_user} ${secret} library ${image}
Logout Harbor
Sign In Harbor With OIDC User ${HARBOR_URL} username=${user} password=${pwd} login_with_provider=ldap
${output}= Run Keyword And Ignore Error Switch To Configure
Should Be Equal As Strings '${output[0]}' 'FAIL'
Close Browser

View File

@ -1,308 +1,308 @@
// 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
Library ../../apitests/python/testutils.py
Library ../../apitests/python/library/repository.py
Resource ../../resources/Util.robot
Default Tags Replication
*** Variables ***
${HARBOR_URL} https://${ip}
${SSH_USER} root
${HARBOR_ADMIN} admin
${SERVER} ${ip}
${SERVER_URL} https://${SERVER}
${SERVER_API_ENDPOINT} ${SERVER_URL}/api
&{SERVER_CONFIG} endpoint=${SERVER_API_ENDPOINT} verify_ssl=False
${REMOTE_SERVER} ${ip1}
${REMOTE_SERVER_URL} https://${REMOTE_SERVER}
${REMOTE_SERVER_API_ENDPOINT} ${REMOTE_SERVER_URL}/api
*** Test Cases ***
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version
Test Case - Pro Replication Rules Add
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Switch To Replication Manage
Check New Rule UI Without Endpoint
Close Browser
Test Case - Harbor Endpoint Verification
#This case need vailid info and selfsign cert
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint harbor edp1${d} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} N
Endpoint Is Pingable
Enable Certificate Verification
Endpoint Is Unpingable
Close Browser
##Test Case - DockerHub Endpoint Add
#This case need vailid info and selfsign cert
##Init Chrome Driver
##${d}= Get Current Date result_format=%m%s
##Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
##Switch To Registries
##Create A New Endpoint docker-hub edp1${d} https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} Y
##Close Browser
Test Case - Harbor Endpoint Add
#This case need vailid info and selfsign cert
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint harbor testabc https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
Close Browser
Test Case - Harbor Endpoint Edit
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Rename Endpoint testabc deletea
Retry Wait Until Page Contains deletea
Close Browser
Test Case - Harbor Endpoint Delete
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Delete Endpoint deletea
Delete Success deletea
Close Browser
Test Case - Replication Rule Edit
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${endpoint1}= Set Variable e1${d}
${endpoint2}= Set Variable e2${d}
${rule_name_old}= Set Variable rule_testabc${d}
${rule_name_new}= Set Variable rule_abctest${d}
${resource_type}= Set Variable chart
${dest_namespace}= Set Variable dest_namespace${d}
${mode}= Set Variable Scheduled
${cron_str}= Set Variable 10 10 10 * * *
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
#Due to docker-hub access limitation, remove docker-hub endpoint
Create A New Endpoint harbor ${endpoint1} https://cicd.harbor.vmwarecna.net ${null} ${null} Y
Create A New Endpoint harbor ${endpoint2} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint ${rule_name_old} pull nightly/a* image ${endpoint1} project${d}
Edit Replication Rule ${rule_name_old}
# Change rule-name, source-registry, filter, trigger-mode for edition verification
Clear Field Of Characters ${rule_name_input} 30
Retry Text Input ${rule_name_input} ${rule_name_new}
Select Source Registry ${endpoint2}
#Source Resource Filter
Retry Text Input ${filter_name_id} project${d}
Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
Select Trigger ${mode}
Retry Text Input ${targetCron_id} ${cron_str}
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
# verify all items were changed as expected
Edit Replication Rule ${rule_name_new}
Retry Textfield Value Should Be ${rule_name_input} ${rule_name_new}
Retry List Selection Should Be ${src_registry_dropdown_list} ${endpoint2}-https://${ip}
Retry Textfield Value Should Be ${filter_name_id} project${d}
Retry Textfield Value Should Be ${dest_namespace_xpath} ${dest_namespace}
Retry List Selection Should Be ${rule_resource_selector} ${resource_type}
Retry List Selection Should Be ${rule_trigger_select} ${mode}
Retry Textfield Value Should Be ${targetCron_id} ${cron_str}
Retry Element Click ${rule_cancel_btn}
Delete Replication Rule ${rule_name_new}
Close Browser
Test Case - Replication Rule Delete
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${endpoint1}= Set Variable e1${d}
${rule_name}= Set Variable rule_testabc${d}
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint harbor ${endpoint1} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint ${rule_name} pull ${DOCKER_USER}/* image ${endpoint1} project${d}
Delete Replication Rule ${rule_name}
Close Browser
Test Case - Replication Of Pull Images from DockerHub To Self
@{target_images}= Create List mariadb centos
&{image1_with_tag}= Create Dictionary image=centos tag=1.0
&{image2_with_tag}= Create Dictionary image=mariadb tag=latest
${image1}= Get From Dictionary ${image1_with_tag} image
${image1}= Get Substring ${image1} 0 -2
Log All image1:${image1}
${image2}= Get From Dictionary ${image2_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}'
Body Of Replication Of Pull Images from Registry To Self docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}/{${image1}*,${image2}} ${null} N @{target_images}
Test Case - Replication Of Push Images from Self To Harbor
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world v1
Switch To Registries
Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} project_dest${d}
#logout and login target
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project_dest${d}
#logout and login source
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Select Rule And Replicate rule${d}
Sleep 20
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Image Should Be Replicated To Project project_dest${d} hello-world
Image Should Be Replicated To Project project_dest${d} busybox
Close Browser
Test Case - Replication Of Push Chart from Self To Harbor
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Project Charts
Upload Chart files
Switch To Registries
Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* chart e${d} project_dest${d}
#logout and login target
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project_dest${d}
#logout and login source
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Select Rule And Replicate rule${d}
Sleep 20
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project project_dest${d} has_image=${false}
Switch To Project Charts
Go Into Chart Version ${harbor_chart_name}
Retry Wait Until Page Contains ${harbor_chart_version}
Go Into Chart Detail ${harbor_chart_version}
Close Browser
Test Case - Replication Of Push Images from Self To Harbor By Push Event
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable test_large_image
${image_size}= Set Variable 4096
${tag1}= Set Variable large_f
@{tags} Create List ${tag1}
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} project_dest${d}
... Event Based
#logout and login target
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project_dest${d}
Push Special Image To Project project${d} ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${image} tags=@{tags} size=${image_size}
# Use tag as identifier for this artifact
Image Should Be Replicated To Project project_dest${d} ${image} tag=${tag1} expected_image_size_in_regexp=4(\\\.\\d{1,2})*GB
Close Browser
Test Case - Replication Of Pull Images from AWS-ECR To Self
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint aws-ecr e${d} us-east-2 ${ecr_ac_id} ${ecr_ac_key} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} pull a/* image e${d} project${d}
Select Rule And Replicate rule${d}
Image Should Be Replicated To Project project${d} httpd
Image Should Be Replicated To Project project${d} alpine
Image Should Be Replicated To Project project${d} hello-world
Close Browser
Test Case - Replication Of Pull Images from Google-GCR To Self
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint google-gcr e${d} asia.gcr.io ${null} ${gcr_ac_key} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} pull eminent-nation-87317/* image e${d} project${d}
Filter Replication Rule rule${d}
Select Rule And Replicate rule${d}
Image Should Be Replicated To Project project${d} httpd
Image Should Be Replicated To Project project${d} tomcat
Close Browser
Test Case - Replication Of Push Images to DockerHub Triggered By Event
Body Of Replication Of Push Images to Registry Triggered By Event docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}
#Due to issue of delete event replication
#Test Case - Replication Of Push Images to Google-GCR Triggered By Event
#Body Of Replication Of Push Images to Registry Triggered By Event google-gcr gcr.io ${null} ${gcr_ac_key} eminent-nation-87317/harbor-nightly-replication
Test Case - Replication Of Push Images to AWS-ECR Triggered By Event
Body Of Replication Of Push Images to Registry Triggered By Event aws-ecr us-east-2 ${ecr_ac_id} ${ecr_ac_key} harbor-nightly-replication
Test Case - Replication Of Pull Images from Gitlab To Self
&{image1_with_tag}= Create Dictionary image=photon tag=1.0
&{image2_with_tag}= Create Dictionary image=alpine tag=latest
${image1}= Get From Dictionary ${image1_with_tag} image
${image2}= Get From Dictionary ${image2_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}'
Body Of Replication Of Pull Images from Registry To Self gitlab https://registry.gitlab.com ${gitlab_id} ${gitlab_key} dannylunsa/test_replication/{${image1},${image2}} ${null} N @{target_images}
Test Case - Replication Of Push Images to Gitlab Triggered By Event
Body Of Replication Of Push Images to Registry Triggered By Event gitlab https://registry.gitlab.com ${gitlab_id} ${gitlab_key} dannylunsa/test_replication
Test Case - Replication Of Pull Manifest List and CNAB from Harbor To Self
&{image1_with_tag}= Create Dictionary image=busybox tag=1.32.0 total_artifact_count=9 archive_count=0
&{image2_with_tag}= Create Dictionary image=index101603308079 tag=index_tag101603308079 total_artifact_count=2 archive_count=0
&{image3_with_tag}= Create Dictionary image=cnab011609785126 tag=cnab_tag011609785126 total_artifact_count=3 archive_count=2
${image1}= Get From Dictionary ${image1_with_tag} image
${image2}= Get From Dictionary ${image2_with_tag} image
${image3}= Get From Dictionary ${image3_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}'
Body Of Replication Of Pull Images from Registry To Self harbor https://cicd.harbor.vmwarecna.net admin qA5ZgV nightly/{${image1},${image2},${image3}} ${null} Y @{target_images}
// 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
Library ../../apitests/python/testutils.py
Library ../../apitests/python/library/repository.py
Resource ../../resources/Util.robot
Default Tags Replication
*** Variables ***
${HARBOR_URL} https://${ip}
${SSH_USER} root
${HARBOR_ADMIN} admin
${SERVER} ${ip}
${SERVER_URL} https://${SERVER}
${SERVER_API_ENDPOINT} ${SERVER_URL}/api
&{SERVER_CONFIG} endpoint=${SERVER_API_ENDPOINT} verify_ssl=False
${REMOTE_SERVER} ${ip1}
${REMOTE_SERVER_URL} https://${REMOTE_SERVER}
${REMOTE_SERVER_API_ENDPOINT} ${REMOTE_SERVER_URL}/api
*** Test Cases ***
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version
Test Case - Pro Replication Rules Add
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Switch To Replication Manage
Check New Rule UI Without Endpoint
Close Browser
Test Case - Harbor Endpoint Verification
#This case need vailid info and selfsign cert
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint harbor edp1${d} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} N
Endpoint Is Pingable
Enable Certificate Verification
Endpoint Is Unpingable
Close Browser
##Test Case - DockerHub Endpoint Add
#This case need vailid info and selfsign cert
##Init Chrome Driver
##${d}= Get Current Date result_format=%m%s
##Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
##Switch To Registries
##Create A New Endpoint docker-hub edp1${d} https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} Y
##Close Browser
Test Case - Harbor Endpoint Add
#This case need vailid info and selfsign cert
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint harbor testabc https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
Close Browser
Test Case - Harbor Endpoint Edit
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Rename Endpoint testabc deletea
Retry Wait Until Page Contains deletea
Close Browser
Test Case - Harbor Endpoint Delete
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Delete Endpoint deletea
Delete Success deletea
Close Browser
Test Case - Replication Rule Edit
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${endpoint1}= Set Variable e1${d}
${endpoint2}= Set Variable e2${d}
${rule_name_old}= Set Variable rule_testabc${d}
${rule_name_new}= Set Variable rule_abctest${d}
${resource_type}= Set Variable chart
${dest_namespace}= Set Variable dest_namespace${d}
${mode}= Set Variable Scheduled
${cron_str}= Set Variable 10 10 10 * * *
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
#Due to docker-hub access limitation, remove docker-hub endpoint
Create A New Endpoint harbor ${endpoint1} https://cicd.harbor.vmwarecna.net ${null} ${null} Y
Create A New Endpoint harbor ${endpoint2} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint ${rule_name_old} pull nightly/a* image ${endpoint1} project${d}
Edit Replication Rule ${rule_name_old}
# Change rule-name, source-registry, filter, trigger-mode for edition verification
Clear Field Of Characters ${rule_name_input} 30
Retry Text Input ${rule_name_input} ${rule_name_new}
Select Source Registry ${endpoint2}
#Source Resource Filter
Retry Text Input ${filter_name_id} project${d}
Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
Select Trigger ${mode}
Retry Text Input ${targetCron_id} ${cron_str}
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
# verify all items were changed as expected
Edit Replication Rule ${rule_name_new}
Retry Textfield Value Should Be ${rule_name_input} ${rule_name_new}
Retry List Selection Should Be ${src_registry_dropdown_list} ${endpoint2}-https://${ip}
Retry Textfield Value Should Be ${filter_name_id} project${d}
Retry Textfield Value Should Be ${dest_namespace_xpath} ${dest_namespace}
Retry List Selection Should Be ${rule_resource_selector} ${resource_type}
Retry List Selection Should Be ${rule_trigger_select} ${mode}
Retry Textfield Value Should Be ${targetCron_id} ${cron_str}
Retry Element Click ${rule_cancel_btn}
Delete Replication Rule ${rule_name_new}
Close Browser
Test Case - Replication Rule Delete
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${endpoint1}= Set Variable e1${d}
${rule_name}= Set Variable rule_testabc${d}
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint harbor ${endpoint1} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint ${rule_name} pull ${DOCKER_USER}/* image ${endpoint1} project${d}
Delete Replication Rule ${rule_name}
Close Browser
Test Case - Replication Of Pull Images from DockerHub To Self
@{target_images}= Create List mariadb centos
&{image1_with_tag}= Create Dictionary image=centos tag=1.0
&{image2_with_tag}= Create Dictionary image=mariadb tag=latest
${image1}= Get From Dictionary ${image1_with_tag} image
${image1}= Get Substring ${image1} 0 -2
Log All image1:${image1}
${image2}= Get From Dictionary ${image2_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}'
Body Of Replication Of Pull Images from Registry To Self docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}/{${image1}*,${image2}} ${null} N @{target_images}
Test Case - Replication Of Push Images from Self To Harbor
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world v1
Switch To Registries
Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} project_dest${d}
#logout and login target
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project_dest${d}
#logout and login source
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Select Rule And Replicate rule${d}
Sleep 20
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Image Should Be Replicated To Project project_dest${d} hello-world
Image Should Be Replicated To Project project_dest${d} busybox
Close Browser
Test Case - Replication Of Push Chart from Self To Harbor
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Project Charts
Upload Chart files
Switch To Registries
Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* chart e${d} project_dest${d}
#logout and login target
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project_dest${d}
#logout and login source
Logout Harbor
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Select Rule And Replicate rule${d}
Sleep 20
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project project_dest${d} has_image=${false}
Switch To Project Charts
Go Into Chart Version ${harbor_chart_name}
Retry Wait Until Page Contains ${harbor_chart_version}
Go Into Chart Detail ${harbor_chart_version}
Close Browser
Test Case - Replication Of Push Images from Self To Harbor By Push Event
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image}= Set Variable test_large_image
${image_size}= Set Variable 4096
${tag1}= Set Variable large_f
@{tags} Create List ${tag1}
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} project_dest${d}
... Event Based
#logout and login target
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project_dest${d}
Push Special Image To Project project${d} ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${image} tags=@{tags} size=${image_size}
# Use tag as identifier for this artifact
Image Should Be Replicated To Project project_dest${d} ${image} tag=${tag1} expected_image_size_in_regexp=4(\\\.\\d{1,2})*GB
Close Browser
Test Case - Replication Of Pull Images from AWS-ECR To Self
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint aws-ecr e${d} us-east-2 ${ecr_ac_id} ${ecr_ac_key} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} pull a/* image e${d} project${d}
Select Rule And Replicate rule${d}
Image Should Be Replicated To Project project${d} httpd
Image Should Be Replicated To Project project${d} alpine
Image Should Be Replicated To Project project${d} hello-world
Close Browser
Test Case - Replication Of Pull Images from Google-GCR To Self
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
Switch To Registries
Create A New Endpoint google-gcr e${d} asia.gcr.io ${null} ${gcr_ac_key} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} pull eminent-nation-87317/* image e${d} project${d}
Filter Replication Rule rule${d}
Select Rule And Replicate rule${d}
Image Should Be Replicated To Project project${d} httpd
Image Should Be Replicated To Project project${d} tomcat
Close Browser
Test Case - Replication Of Push Images to DockerHub Triggered By Event
Body Of Replication Of Push Images to Registry Triggered By Event docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}
#Due to issue of delete event replication
#Test Case - Replication Of Push Images to Google-GCR Triggered By Event
#Body Of Replication Of Push Images to Registry Triggered By Event google-gcr gcr.io ${null} ${gcr_ac_key} eminent-nation-87317/harbor-nightly-replication
Test Case - Replication Of Push Images to AWS-ECR Triggered By Event
Body Of Replication Of Push Images to Registry Triggered By Event aws-ecr us-east-2 ${ecr_ac_id} ${ecr_ac_key} harbor-nightly-replication
Test Case - Replication Of Pull Images from Gitlab To Self
&{image1_with_tag}= Create Dictionary image=photon tag=1.0
&{image2_with_tag}= Create Dictionary image=alpine tag=latest
${image1}= Get From Dictionary ${image1_with_tag} image
${image2}= Get From Dictionary ${image2_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}'
Body Of Replication Of Pull Images from Registry To Self gitlab https://registry.gitlab.com ${gitlab_id} ${gitlab_key} dannylunsa/test_replication/{${image1},${image2}} ${null} N @{target_images}
Test Case - Replication Of Push Images to Gitlab Triggered By Event
Body Of Replication Of Push Images to Registry Triggered By Event gitlab https://registry.gitlab.com ${gitlab_id} ${gitlab_key} dannylunsa/test_replication
Test Case - Replication Of Pull Manifest List and CNAB from Harbor To Self
&{image1_with_tag}= Create Dictionary image=busybox tag=1.32.0 total_artifact_count=9 archive_count=0
&{image2_with_tag}= Create Dictionary image=index101603308079 tag=index_tag101603308079 total_artifact_count=2 archive_count=0
&{image3_with_tag}= Create Dictionary image=cnab011609785126 tag=cnab_tag011609785126 total_artifact_count=3 archive_count=2
${image1}= Get From Dictionary ${image1_with_tag} image
${image2}= Get From Dictionary ${image2_with_tag} image
${image3}= Get From Dictionary ${image3_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}'
Body Of Replication Of Pull Images from Registry To Self harbor https://cicd.harbor.vmwarecna.net admin qA5ZgV nightly/{${image1},${image2},${image3}} ${null} Y @{target_images}

View File

@ -1,28 +1,28 @@
// 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
*** Test Cases ***
Test Suites Setup
[Tags] setup
Nightly Test Setup In Photon ${ip} ${HARBOR_PASSWORD} ${ip1}
Setup API Test
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version
// 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
*** Test Cases ***
Test Suites Setup
[Tags] setup
Nightly Test Setup In Photon ${ip} ${HARBOR_PASSWORD} ${ip1}
Setup API Test
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version

View File

@ -1,28 +1,28 @@
// 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
*** Test Cases ***
Test Suites Setup For UI Test
[Tags] setup
Nightly Test Setup In Ubuntu ${ip} ${HARBOR_PASSWORD} ${ip1}
Setup API Test
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version
// 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
*** Test Cases ***
Test Suites Setup For UI Test
[Tags] setup
Nightly Test Setup In Ubuntu ${ip} ${HARBOR_PASSWORD} ${ip1}
Setup API Test
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
from hurry.filesize import size
from hurry.filesize import alternative
def convert_int_to_readable_file_size(file_size):
return size(file_size, system=alternative).replace(' ', '')
from hurry.filesize import size
from hurry.filesize import alternative
def convert_int_to_readable_file_size(file_size):
return size(file_size, system=alternative).replace(' ', '')

View File

@ -1,117 +1,117 @@
*** Settings ***
Documentation Harbor BATs
Resource ../../resources/Util.robot
Default Tags Nightly
*** Variables ***
${HARBOR_URL} https://${ip}
${HARBOR_ADMIN} admin
*** Test Cases ***
Test Case - Upgrade Verify
[Tags] 1.8-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Label ${data}
Run Keyword Verify Project Metadata ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify User System Admin Role ${data}
Run Keyword Verify Endpoint ${data}
Run Keyword Verify Replicationrule ${data}
Run Keyword Verify System Setting ${data}
Run Keyword Verify Image Tag ${data}
Test Case - Upgrade Verify
[Tags] 1.9-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Label ${data}
Run Keyword Verify Project Metadata ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Webhook ${data}
Run Keyword Verify Tag Retention Rule ${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 Image Tag ${data}
Run Keyword Verify Trivy Is Default Scanner
Test Case - Upgrade Verify
[Tags] 1.10-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Label ${data}
Run Keyword Verify Project Metadata ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Webhook ${data}
Run Keyword Verify Tag Retention Rule ${data}
Run Keyword Verify Tag Immutability Rule ${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 Image Tag ${data}
Test Case - Upgrade Verify
[Tags] 2.0-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Metadata ${data} check_content_trust=${false}
#Run Keyword Verify Project Label ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Webhook For 2.0 ${data}
Run Keyword Verify Tag Retention Rule ${data}
Run Keyword Verify Tag Immutability Rule ${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 Image Tag ${data}
Run Keyword Verify Trivy Is Default Scanner
Run Keyword Verify Artifact Index ${data}
Run Keyword Verify Quotas Display ${data}
Test Case - Upgrade Verify
[Tags] 2.1-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data} verify_registry_name=${true}
Run Keyword Verify Project Metadata ${data} check_content_trust=${false} verify_registry_name=${true}
#Run Keyword Verify Project Label ${data} verify_registry_name=${true}
Run Keyword Verify Member Exist ${data} verify_registry_name=${true}
Run Keyword Verify Robot Account Exist ${data} verify_registry_name=${true}
Run Keyword Verify Project-level Allowlist ${data} verify_registry_name=${true}
Run Keyword Verify Webhook For 2.0 ${data} verify_registry_name=${true}
Run Keyword Verify Tag Retention Rule ${data} verify_registry_name=${true}
Run Keyword Verify Tag Immutability Rule ${data} verify_registry_name=${true}
Run Keyword Verify Image Tag ${data} verify_registry_name=${true}
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}
Run Keyword Verify Quotas Display ${data}
*** Settings ***
Documentation Harbor BATs
Resource ../../resources/Util.robot
Default Tags Nightly
*** Variables ***
${HARBOR_URL} https://${ip}
${HARBOR_ADMIN} admin
*** Test Cases ***
Test Case - Upgrade Verify
[Tags] 1.8-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Label ${data}
Run Keyword Verify Project Metadata ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify User System Admin Role ${data}
Run Keyword Verify Endpoint ${data}
Run Keyword Verify Replicationrule ${data}
Run Keyword Verify System Setting ${data}
Run Keyword Verify Image Tag ${data}
Test Case - Upgrade Verify
[Tags] 1.9-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Label ${data}
Run Keyword Verify Project Metadata ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Webhook ${data}
Run Keyword Verify Tag Retention Rule ${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 Image Tag ${data}
Run Keyword Verify Trivy Is Default Scanner
Test Case - Upgrade Verify
[Tags] 1.10-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Label ${data}
Run Keyword Verify Project Metadata ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Webhook ${data}
Run Keyword Verify Tag Retention Rule ${data}
Run Keyword Verify Tag Immutability Rule ${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 Image Tag ${data}
Test Case - Upgrade Verify
[Tags] 2.0-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data}
Run Keyword Verify Project Metadata ${data} check_content_trust=${false}
#Run Keyword Verify Project Label ${data}
Run Keyword Verify Member Exist ${data}
Run Keyword Verify Robot Account Exist ${data}
Run Keyword Verify Project-level Allowlist ${data}
Run Keyword Verify Webhook For 2.0 ${data}
Run Keyword Verify Tag Retention Rule ${data}
Run Keyword Verify Tag Immutability Rule ${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 Image Tag ${data}
Run Keyword Verify Trivy Is Default Scanner
Run Keyword Verify Artifact Index ${data}
Run Keyword Verify Quotas Display ${data}
Test Case - Upgrade Verify
[Tags] 2.1-latest
${data}= Load Json From File ${CURDIR}${/}data.json
Run Keyword Verify User ${data}
Run Keyword Verify Project ${data} verify_registry_name=${true}
Run Keyword Verify Project Metadata ${data} check_content_trust=${false} verify_registry_name=${true}
#Run Keyword Verify Project Label ${data} verify_registry_name=${true}
Run Keyword Verify Member Exist ${data} verify_registry_name=${true}
Run Keyword Verify Robot Account Exist ${data} verify_registry_name=${true}
Run Keyword Verify Project-level Allowlist ${data} verify_registry_name=${true}
Run Keyword Verify Webhook For 2.0 ${data} verify_registry_name=${true}
Run Keyword Verify Tag Retention Rule ${data} verify_registry_name=${true}
Run Keyword Verify Tag Immutability Rule ${data} verify_registry_name=${true}
Run Keyword Verify Image Tag ${data} verify_registry_name=${true}
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}
Run Keyword Verify Quotas Display ${data}

View File

@ -5,7 +5,7 @@ set -e
IMAGE_FOR=$1
VERSION=$2
CMD_BASE="cat Dockerfile.base"
CMD_BASE="cat Dockerfile.common"
SRC_FILE=""
DST_FILE=Dockerfile