Upgrade robot-framework and Selenium library

1. Upgrade robot-framework to 3.1 and Selenium library to 4.4.0.
2. Fix a registry issue for clear filter text input.

Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
danfengliu 2020-07-30 08:04:14 +00:00
parent da662f52d5
commit 3b8a2890f9
94 changed files with 4474 additions and 4372 deletions

View File

@ -91,10 +91,6 @@ class Artifact(base.Base, object):
if (timeout_count == 0):
break
artifact = self.get_reference_info(project_name, repo_name, reference, **kwargs)
print "artifact", artifact
print "artifact[0]", artifact[0]
print "artifact[0].scan_overview", artifact[0].scan_overview
print "artifact[0].scan_overview['application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0']", artifact[0].scan_overview['application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0']
scan_status = artifact[0].scan_overview['application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0']["scan_status"]
if scan_status == expected_scan_status:
return

View File

@ -76,7 +76,7 @@ def _get_string_from_unicode(udata):
return result
def run_command(command):
print "Command: ", subprocess.list2cmdline(command)
print("Command: ", subprocess.list2cmdline(command))
try:
output = subprocess.check_output(command,
stderr=subprocess.STDOUT,

View File

@ -17,7 +17,6 @@ class Chart(base.Base, object):
def chart_should_exist(self, repository, chart_name, **kwargs):
charts_data = self.get_charts(repository, **kwargs)
print "charts_data:", charts_data
for chart in charts_data:
if chart.name == chart_name:
return True

View File

@ -9,12 +9,9 @@ def load_bundle(service_image, invocation_image):
bundle_tmpl_file = "./tests/apitests/python/bundle_data/bundle.json.tmpl"
with open(bundle_tmpl_file,'r') as load_f:
load_dict = json.load(load_f)
print "load_dict:", load_dict
print "load_dict-invocationImages:", load_dict["invocationImages"][0]["contentDigest"]
load_dict["images"]["hello"]["image"] = service_image
load_dict["invocationImages"][0]["image"] = invocation_image
bundle_str = json.dumps(load_dict)
print "bundle_str:", bundle_str
with open(bundle_file,'w') as dump_f:
dump_f.write(bundle_str)
dump_f.close()
@ -26,16 +23,16 @@ def cnab_fixup_bundle(bundle_file, target, auto_update_bundle = True):
if auto_update_bundle == True:
command.append("--auto-update-bundle")
#fixed_bundle_file = bundle_file
print "Command: ", command
print("Command: ", command)
ret = base.run_command(command)
print "Command return: ", ret
print("Command return: ", ret)
return fixed_bundle_file
def cnab_push_bundle(bundle_file, target):
command = ["cnab-to-oci", "push", bundle_file, "--target", target, "--auto-update-bundle"]
print "Command: ", command
print("Command: ", command)
ret = base.run_command(command)
print "Command return: ", ret
print("Command return: ", ret)
for line in ret.split("\n"):
line = line.replace('\"', '')
if line.find('sha256') >= 0:
@ -48,5 +45,4 @@ def push_cnab_bundle(harbor_server, user, password, service_image, invocation_im
bundle_file = load_bundle(service_image, invocation_image)
fixed_bundle_file = cnab_fixup_bundle(bundle_file, target, auto_update_bundle = auto_update_bundle)
sha256 = cnab_push_bundle(fixed_bundle_file, target)
print "sha256:", sha256
return sha256

View File

@ -6,15 +6,15 @@ import docker_api
def ctr_images_pull(username, password, oci):
command = ["sudo", "ctr", "images", "pull", "-u", username+":"+password, oci]
print "Command: ", command
print("Command: ", command)
ret = base.run_command(command)
print "Command return: ", ret
print("Command return: ", ret)
def ctr_images_list(oci_ref = None):
command = ["sudo", "ctr", "images", "list", "--q"]
print "Command: ", command
print("Command: ", command)
ret = base.run_command(command)
print "Command return: ", ret
print("Command return: ", ret)
if oci_ref is not None and oci_ref not in ret.split("\n"):
raise Exception(r" Get OCI ref failed, expected ref is [{}], but return ref list is [{}]".format (ret))

View File

@ -13,29 +13,29 @@ except ImportError:
def docker_info_display():
command = ["docker", "info", "-f", "'{{.OSType}}/{{.Architecture}}'"]
print "Docker Info: ", command
print("Docker Info: ", command)
ret = base.run_command(command)
print "Command return: ", ret
print("Command return: ", ret)
def docker_login_cmd(harbor_host, user, password, enable_manifest = True):
command = ["sudo", "docker", "login", harbor_host, "-u", user, "-p", password]
print "Docker Login Command: ", command
print( "Docker Login Command: ", command)
base.run_command(command)
if enable_manifest == True:
try:
ret = subprocess.check_output(["./tests/apitests/python/update_docker_cfg.sh"], shell=False)
except subprocess.CalledProcessError, exc:
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 = ["sudo", "docker","manifest","create",index]
command.extend(manifests)
print "Docker Manifest Command: ", command
print( "Docker Manifest Command: ", command)
base.run_command(command)
def docker_manifest_push(index):
command = ["sudo", "docker","manifest","push",index]
print "Docker Manifest Command: ", command
print( "Docker Manifest Command: ", command)
ret = base.run_command(command)
index_sha256=""
manifest_list=[]
@ -58,7 +58,7 @@ def list_repositories(harbor_host, user, password, n = None, last = None):
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/_catalog", "--insecure"]
print "List Repositories Command: ", command
print( "List Repositories Command: ", command)
ret = base.run_command(command)
repos = json.loads(ret).get("repositories","")
return repos
@ -70,7 +70,7 @@ def list_image_tags(harbor_host, repository, user, password, n = None, last = No
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list", "--insecure"]
print "List Image Tags Command: ", command
print( "List Image Tags Command: ", command)
ret = base.run_command(command)
tags = json.loads(ret).get("tags","")
return tags
@ -85,9 +85,9 @@ class DockerAPI(object):
expected_error_message = None
try:
self.DCLIENT.login(registry = registry, username=username, password=password)
except docker.errors.APIError, err:
except docker.errors.APIError as err:
if expected_error_message is not None:
print "docker login error:", str(err)
print( "docker login error:", str(err))
if str(err).lower().find(expected_error_message.lower()) < 0:
raise Exception(r"Docker login: Return message {} is not as expected {}".format(str(err), expected_error_message))
else:
@ -105,10 +105,10 @@ class DockerAPI(object):
try:
ret = base._get_string_from_unicode(self.DCLIENT.pull(r'{}:{}'.format(image, _tag)))
return ret
except Exception, err:
except Exception as err:
caught_err = True
if expected_error_message is not None:
print "docker image pull error:", str(err)
print( "docker image pull error:", str(err))
if str(err).lower().find(expected_error_message.lower()) < 0:
raise Exception(r"Pull image: Return message {} is not as expected {}".format(str(err), expected_error_message))
else:
@ -128,7 +128,7 @@ class DockerAPI(object):
try:
self.DCLIENT.tag(image, harbor_registry, _tag, force=True)
return harbor_registry, _tag
except docker.errors.APIError, e:
except docker.errors.APIError as e:
raise Exception(r" Docker tag image {} failed, error is [{}]".format (image, e.message))
def docker_image_push(self, harbor_registry, tag, expected_error_message = None):
@ -139,10 +139,10 @@ class DockerAPI(object):
try:
ret = base._get_string_from_unicode(self.DCLIENT.push(harbor_registry, tag, stream=True))
return ret
except Exception, err:
except Exception as err:
caught_err = True
if expected_error_message is not None:
print "docker image push error:", str(err)
print( "docker image push error:", str(err))
if str(err).lower().find(expected_error_message.lower()) < 0:
raise Exception(r"Push image: Return message {} is not as expected {}".format(str(err), expected_error_message))
else:
@ -184,10 +184,10 @@ class DockerAPI(object):
self.DCLIENT.pull(repo)
image = self.DCLIENT2.images.get(repo)
return repo, image.id
except Exception, err:
except Exception as err:
caught_err = True
if expected_error_message is not None:
print "docker image build error:", str(err)
print( "docker image build error:", str(err))
if str(err).lower().find(expected_error_message.lower()) < 0:
raise Exception(r"Push image: Return message {} is not as expected {}".format(str(err), expected_error_message))
else:

View File

@ -6,26 +6,26 @@ import base
def get_chart_file(file_name):
command = ["wget", file_name]
ret = base.run_command(command)
print "Command Return: ", ret
print("Command return: ", ret)
command = ["tar", "xvf", file_name.split('/')[-1]]
ret = base.run_command(command)
print "Command Return: ", ret
print("Command return: ", ret)
def helm_login(harbor_server, user, password):
os.putenv("HELM_EXPERIMENTAL_OCI", "1")
command = ["helm3", "registry", "login", harbor_server, "-u", user, "-p", password]
print "Command: ", command
print("Command: ", command)
ret = base.run_command(command)
print "Command return: ", ret
print("Command return: ", ret)
def helm_save(chart_archive, harbor_server, project, repo_name):
command = ["helm3", "chart","save", chart_archive, harbor_server+"/"+project+"/"+repo_name]
print "Command: ", command
print("Command: ", command)
base.run_command(command)
def helm_push(harbor_server, project, repo_name, version):
command = ["helm3", "chart","push", harbor_server+"/"+project+"/"+repo_name+":"+version]
print "Command: ", command
print("Command: ", command)
ret = base.run_command(command)
return ret
@ -37,11 +37,11 @@ def helm_chart_push_to_harbor(chart_file, archive, harbor_server, project, repo_
def helm2_add_repo(helm_repo_name, harbor_url, project, username, password):
command = ["helm2", "repo", "add", "--username=" + username, "--password=" + password, helm_repo_name, harbor_url + "/chartrepo/" + project]
print "Command: ", command
print("Command: ", command)
base.run_command(command)
def helm2_push(helm_repo_name, chart_file, project, username, password):
get_chart_file(chart_file)
command = ["helm2", "push", "--username=" + username, "--password=" + password, chart_file.split('/')[-1], helm_repo_name]
print "Command: ", command
print("Command: ", command)
base.run_command(command)

View File

@ -39,7 +39,6 @@ def oras_pull(harbor_server, user, password, project, repo, tag):
os.rmdir(cwd)
os.makedirs(cwd)
os.chdir(cwd)
print "Tmp dir:", cwd
except Exception as e:
raise Exception('Error: Exited with error {}',format(e))
ret = base.run_command([oras_cmd, "pull", harbor_server + "/" + project + "/" + repo+":"+ tag, "-a"])

View File

@ -38,7 +38,7 @@ class Replication(base.Base):
if str(rule_data.name) != str(expect_rule_name):
raise Exception(r"Check replication rule failed, expect <{}> actual <{}>.".format(expect_rule_name, str(rule_data.name)))
else:
print r"Check Replication rule passed, rule name <{}>.".format(str(rule_data.name))
print(r"Check Replication rule passed, rule name <{}>.".format(str(rule_data.name)))
#get_trigger = str(rule_data.trigger.kind)
#if expect_trigger is not None and get_trigger == str(expect_trigger):
# print r"Check Replication rule trigger passed, trigger name <{}>.".format(get_trigger)

View File

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
import site
reload(site)
import time
import base
import swagger_client
@ -121,7 +119,6 @@ class Repository(base.Base, object):
def check_repository_exist(self, project_Name, repo_name, **kwargs):
repositories = self.list_repositories(project_Name, **kwargs)
for repo in repositories:
print project_Name+"/"+repo_name
if repo.name == project_Name+"/"+repo_name:
return True
return False

View File

@ -5,7 +5,7 @@ from testutils import notary_url
def sign_image(registry_ip, project_name, image, tag):
try:
ret = subprocess.check_output(["./tests/apitests/python/sign_image.sh", registry_ip, project_name, image, tag, notary_url], shell=False)
print "sign_image return: ", ret
print("sign_image return: ", ret)
except subprocess.CalledProcessError, exc:
raise Exception("Failed to sign image error is {} {}.".format(exc.returncode, exc.output))

View File

@ -45,7 +45,6 @@ class User(base.Base):
client = self._get_client(**kwargs)
data, status_code, _ = client.users_user_id_get_with_http_info(user_id)
base._assert_status_code(200, status_code)
print "data in lib:", data
return data
@ -80,7 +79,6 @@ class User(base.Base):
def update_user_role_as_sysadmin(self, user_id, IsAdmin, **kwargs):
client = self._get_client(**kwargs)
sysadmin_flag = swagger_client.SysAdminFlag(IsAdmin)
print "sysadmin_flag:", sysadmin_flag
_, status_code, _ = client.users_user_id_sysadmin_put_with_http_info(user_id, sysadmin_flag)
base._assert_status_code(200, status_code)
return user_id

View File

@ -0,0 +1,77 @@
from __future__ import absolute_import
import unittest
import numpy
import threading
from datetime import *
from time import sleep, ctime
import library.repository
import library.docker_api
from library.base import _assert_status_code
from testutils import ADMIN_CLIENT
from testutils import harbor_server
from testutils import TEARDOWN
from library.project import Project
from library.repository import Repository
from library.artifact import Artifact
from library.repository import push_image_to_project
from library.repository import pull_harbor_image
from library.repository import push_special_image_to_project
import argparse
def do_populate(name_index, repo_count):
project= Project()
artifact = Artifact()
repo = Repository()
url = ADMIN_CLIENT["endpoint"]
ADMIN_CLIENT["password"] = "qA5ZgV"
#2. Create a new project(PA) by user(UA);
project_name = "project"+str(name_index)
if project.check_project_name_exist(name=project_name, **ADMIN_CLIENT) is not True:
project.create_project(name=project_name, metadata = {"public": "false"}, **ADMIN_CLIENT)
print("Create Project:", project_name)
tag = 'latest'
for repo_index in range(int(repo_count)):
repo_name = "image"+ str(repo_index)
if artifact.check_reference_exist(project_name, repo_name, tag, ignore_not_found=True, **ADMIN_CLIENT) is not True:
push_special_image_to_project(project_name, harbor_server, ADMIN_CLIENT["username"], ADMIN_CLIENT["password"], repo_name, [tag], size=repo_index*30)
print("Push Image:", repo_name)
for tag_index in numpy.arange(1, 2, 0.1):
artifact.create_tag(project_name, repo_name, tag, str(tag_index), ignore_conflict = True, **ADMIN_CLIENT)
print("Add Tag:", str(tag_index))
def get_parser():
""" return a parser """
parser = argparse.ArgumentParser("populate")
parser.add_argument('--project-count','-p', dest='project_count', required=False, default=100)
parser.add_argument('--repo-count','-r', dest='repo_count', required=False, default=100)
args = parser.parse_args()
return (args.project_count, args.repo_count)
def main():
""" main entrance """
project_count, repo_count = get_parser()
Threads = []
for i in range(int(project_count)):
t = threading.Thread(target=do_populate, args=(str(i), repo_count), name='T'+str(i))
t.setDaemon(True)
Threads.append(t)
sleep(3)
for t in Threads:
t.start()
for t in Threads:
t.join()
print('Job Finished:', ctime())
if __name__ == '__main__':
main()

View File

@ -20,7 +20,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -69,7 +69,6 @@ class TestProjects(unittest.TestCase):
#3. Create a new registry
TestProjects.registry_id, _ = self.registry.create_registry("https://" + harbor_server,**ADMIN_CLIENT)
print "TestProjects.registry_id:", TestProjects.registry_id
#4. Create a new rule for this registry;
TestProjects.rule_id, rule_name = self.replication.create_replication_policy(dest_registry=swagger_client.Registry(id=int(TestProjects.registry_id)), **ADMIN_CLIENT)

View File

@ -23,7 +23,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -15,7 +15,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -25,7 +25,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -30,7 +30,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -22,7 +22,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -16,11 +16,10 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
print "Clear trace"
#1. Delete project(PA);
self.project.delete_project(TestProjects.project_edit_project_creation_id, **TestProjects.USER_edit_project_creation_CLIENT)

View File

@ -29,7 +29,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == True, "Test data won't be erased.")
def test_ClearData(self):
@ -96,7 +96,6 @@ class TestProjects(unittest.TestCase):
self.system.validate_deletion_success(gc_id, **ADMIN_CLIENT)
artifacts = self.artifact.list_artifacts(TestProjects.project_gc_untag_name, self.repo_name_untag, **TestProjects.USER_GC_CLIENT)
print artifacts
_assert_status_code(len(artifacts), 1)
time.sleep(5)
@ -112,7 +111,6 @@ class TestProjects(unittest.TestCase):
#11. Repository with untag image should be still there;
repo_data_untag = self.repo.list_repositories(TestProjects.project_gc_untag_name, **TestProjects.USER_GC_CLIENT)
print "repo_data_untag:", repo_data_untag
_assert_status_code(len(repo_data_untag), 1)
self.assertEqual(TestProjects.project_gc_untag_name + "/" + self.repo_name_untag , repo_data_untag[0].name)

View File

@ -17,7 +17,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -19,7 +19,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -23,7 +23,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -15,7 +15,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(cls):
print "Case completed"
print("Case completed")
def testProjectQuota(self):
"""

View File

@ -31,7 +31,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -52,30 +52,27 @@ class TestProjects(unittest.TestCase):
1. Delete user(UA).
"""
print "#1. Create user(UA);"
#1. Create user(UA);
TestProjects.user_id, user_name = self.user.create_user(user_password = self.user_push_chart_password, **ADMIN_CLIENT)
TestProjects.USER_CLIENT=dict(endpoint = self.url, username = user_name, password = self.user_push_chart_password)
TestProjects.API_CHART_CLIENT=dict(endpoint = self.chart_api_url, username = user_name, password = self.user_push_chart_password)
print "#2. Create private project(PA) with user(UA);"
#2. Create private project(PA) with user(UA);
TestProjects.project_id, TestProjects.project_name = self.project.create_project(metadata = {"public": "false"}, **TestProjects.USER_CLIENT)
print "#3. Create a new robot account(RA) with full priviliges in project(PA) with user(UA);"
#3. Create a new robot account(RA) with full priviliges in project(PA) with user(UA);
robot_id, robot_account = self.project.add_project_robot_account(TestProjects.project_id, TestProjects.project_name,
2441000531 ,**TestProjects.USER_CLIENT)
print robot_account.name
print robot_account.token
print "#4. Push chart to project(PA) by Helm2 CLI with robot account(RA);"
#4. Push chart to project(PA) by Helm2 CLI with robot account(RA);"
library.helm.helm2_add_repo(self.chart_repo_name, "https://"+harbor_server, TestProjects.project_name, robot_account.name, robot_account.token)
library.helm.helm2_push(self.chart_repo_name, self.chart_file, TestProjects.project_name, robot_account.name, robot_account.token)
print "#5. Get chart repositry from project(PA) successfully;"
#5. Get chart repositry from project(PA) successfully;
self.chart.chart_should_exist(TestProjects.project_name, self.CHART_NAME, **TestProjects.API_CHART_CLIENT)
print "#6. Push chart to project(PA) by Helm3 CLI with robot account(RA);"
#6. Push chart to project(PA) by Helm3 CLI with robot account(RA);
chart_cli_ret = library.helm.helm_chart_push_to_harbor(self.chart_file, self.archive, harbor_server, TestProjects.project_name, self.repo_name, self.verion, robot_account.name, robot_account.token)
print "chart_cli_ret:", chart_cli_ret
if __name__ == '__main__':
unittest.main()

View File

@ -30,7 +30,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -69,7 +69,6 @@ class TestProjects(unittest.TestCase):
#3. Push an chart(CA) to Harbor by helm3 registry/chart CLI successfully;
chart_cli_ret = library.helm.helm_chart_push_to_harbor(self.chart_file, self.archive, harbor_server, TestProjects.project_push_chart_name, self.repo_name, self.verion, user_name, self.user_push_chart_password)
print "chart_cli_ret:", chart_cli_ret
#4. List artifacts successfully;
artifacts = self.artifact.list_artifacts(TestProjects.project_push_chart_name, self.repo_name, **TestProjects.USER_CLIENT)

View File

@ -30,7 +30,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -80,7 +80,6 @@ class TestProjects(unittest.TestCase):
#5. Get repository from Harbor successfully;
index_data = self.repo.get_repository(TestProjects.project_push_bundle_name, self.cnab_repo_name, **TestProjects.USER_CLIENT)
print "index_data:", index_data
#5.2 Cnab bundle can be pulled by ctr successfully;
# This step might not successful since ctr does't support cnab fully, it might be uncomment sometime in future.

View File

@ -25,7 +25,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -60,21 +60,17 @@ class TestProjects(unittest.TestCase):
#3. ORAS CLI push artifacts;
md5_list_push = library.oras.oras_push(harbor_server, user_name, user_001_password, TestProjects.project_name, self.repo_name, self.tag)
print "md5_list_push:",md5_list_push
#4. Get repository from Harbor successfully, and verfiy repository name is repo pushed by ORAS CLI;
repo_data = self.repo.get_repository(TestProjects.project_name, self.repo_name, **TestProjects.USER_CLIENT)
print "repo_data:", repo_data
self.assertEqual(repo_data.name, TestProjects.project_name + "/" + self.repo_name)
#5. Get and verify artifacts by tag;
artifact = self.artifact.get_reference_info(TestProjects.project_name, self.repo_name, self.tag, **TestProjects.USER_CLIENT)
print "artifact:", artifact
self.assertEqual(artifact[0].tags[0].name, self.tag)
#6. ORAS CLI pull artifacts index by tag;
md5_list_pull = library.oras.oras_pull(harbor_server, user_name, user_001_password, TestProjects.project_name, self.repo_name, self.tag)
print "md5_list_pull:",md5_list_pull
#7. Verfiy MD5 between artifacts pushed by ORAS and artifacts pulled by ORAS;
if set(md5_list_push) != set(md5_list_pull):

View File

@ -22,7 +22,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -80,7 +80,6 @@ class TestProjects(unittest.TestCase):
full_name = urllib.quote(profix+"/"+image,'utf-8')
artifact = self.artifact.get_reference_info(TestProjects.project_sign_image_name, (str(full_name)).encode(), tag, **TestProjects.USER_sign_image_CLIENT)
print artifact
self.assertEqual(artifact[0].type, 'IMAGE')
if __name__ == '__main__':

View File

@ -34,7 +34,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -25,7 +25,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -63,12 +63,10 @@ class TestProjects(unittest.TestCase):
#4. Get repository from Harbor successfully, and verfiy repository name is repo pushed by singularity CLI;
repo_data = self.repo.get_repository(TestProjects.project_name, self.repo_name, **TestProjects.USER_CLIENT)
print "repo_data:", repo_data
self.assertEqual(repo_data.name, TestProjects.project_name + "/" + self.repo_name)
#5. Get and verify artifacts by tag;
artifact = self.artifact.get_reference_info(TestProjects.project_name, self.repo_name, self.tag, **TestProjects.USER_CLIENT)
print "artifact:", artifact
self.assertEqual(artifact[0].tags[0].name, self.tag)
#6. Pull sif file from harbor by singularity;

View File

@ -29,7 +29,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -25,7 +25,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -80,7 +80,6 @@ class TestProjects(unittest.TestCase):
#3. Create a new registry;
TestProjects.registry_id, _ = self.registry.create_registry("https://hub.docker.com", registry_type="docker-hub", access_key = "", access_secret = "", insecure=False, **ADMIN_CLIENT)
print "TestProjects.registry_id:", TestProjects.registry_id
#4. Create a pull-based rule for this registry;
TestProjects.rule_id, rule_name = self.replication.create_replication_policy(src_registry=swagger_client.Registry(id=int(TestProjects.registry_id)),
@ -99,8 +98,6 @@ class TestProjects(unittest.TestCase):
#8. Check image is replicated into target project successfully.
artifact = self.artifact.get_reference_info(TestProjects.project_name, self.image, self.tag, **ADMIN_CLIENT)
print artifact
if __name__ == '__main__':
unittest.main()

View File

@ -64,10 +64,8 @@ class TestProjects(unittest.TestCase):
push_special_image_to_project(TestProjects.project_src_repo_name, harbor_server, user_ra_name, user_ra_password, "test4", ['1.0'])
tag_data_artifact3_image1 = self.artifact.get_reference_info(TestProjects.project_src_repo_name, self.repo_name_1, "3.0", **TestProjects.USER_RA_CLIENT)
print tag_data_artifact3_image1[0].digest
tag_data_artifact2_image2 = self.artifact.get_reference_info(TestProjects.project_src_repo_name, self.repo_name_2, "latest", **TestProjects.USER_RA_CLIENT)
print tag_data_artifact2_image2[0].digest
tags = list_image_tags(harbor_server, TestProjects.project_src_repo_name+"/"+self.repo_name_1, user_ra_name, user_ra_password)
#Delete all 2 tags of "artifact3" in repostory "image1";
@ -114,19 +112,17 @@ class TestProjects(unittest.TestCase):
#List artifacts successfully, and untagged artifact in test1 should be the only one retained;
artifacts_1 = self.artifact.list_artifacts(TestProjects.project_src_repo_name, self.repo_name_1, **TestProjects.USER_RA_CLIENT)
print artifacts_1[0].digest
self.assertTrue(len(artifacts_1)==1)
self.assertEqual(artifacts_1[0].digest, tag_data_artifact3_image1[0].digest)
#List artifacts successfully, and artifact with latest tag in test2 should be the only one retained;
artifacts_2 = self.artifact.list_artifacts(TestProjects.project_src_repo_name, self.repo_name_2, **TestProjects.USER_RA_CLIENT)
print artifacts_2[0].digest
self.assertTrue(len(artifacts_2)==1)
self.assertEqual(artifacts_2[0].digest, tag_data_artifact2_image2[0].digest)
@classmethod
def tearDownClass(self):
print "Case completed"
print("Case completed")
# TODO delete_repoitory will fail when no tags left anymore
# @unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")

View File

@ -21,7 +21,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
@ -74,58 +74,56 @@ class TestProjects(unittest.TestCase):
image_robot_account = "alpine"
tag = "latest"
print "#1. Create user(UA);"
#1. Create user(UA);"
TestProjects.user_ra_id, user_ra_name = self.user.create_user(user_password = user_ra_password, **ADMIN_CLIENT)
TestProjects.USER_RA_CLIENT=dict(endpoint = url, username = user_ra_name, password = user_ra_password)
print "#2. Create private project(PA), private project(PB) and public project(PC) by user(UA);"
#2. Create private project(PA), private project(PB) and public project(PC) by user(UA);
TestProjects.project_ra_id_a, TestProjects.project_ra_name_a = self.project.create_project(metadata = {"public": "false"}, **TestProjects.USER_RA_CLIENT)
TestProjects.project_ra_id_b, TestProjects.project_ra_name_b = self.project.create_project(metadata = {"public": "false"}, **TestProjects.USER_RA_CLIENT)
TestProjects.project_ra_id_c, TestProjects.project_ra_name_c = self.project.create_project(metadata = {"public": "true"}, **TestProjects.USER_RA_CLIENT)
print "#3. Push image(ImagePA) to project(PA), image(ImagePB) to project(PB) and image(ImagePC) to project(PC) by user(UA);"
#3. Push image(ImagePA) to project(PA), image(ImagePB) to project(PB) and image(ImagePC) to project(PC) by user(UA);
TestProjects.repo_name_in_project_a, tag_a = push_image_to_project(TestProjects.project_ra_name_a, harbor_server, user_ra_name, user_ra_password, image_project_a, tag)
TestProjects.repo_name_in_project_b, tag_b = push_image_to_project(TestProjects.project_ra_name_b, harbor_server, user_ra_name, user_ra_password, image_project_b, tag)
TestProjects.repo_name_in_project_c, tag_c = push_image_to_project(TestProjects.project_ra_name_c, harbor_server, user_ra_name, user_ra_password, image_project_c, tag)
print "#4. Create a new robot account(RA) with pull and push privilige in project(PA) by user(UA);"
#4. Create a new robot account(RA) with pull and push privilige in project(PA) by user(UA);
robot_id, robot_account = self.project.add_project_robot_account(TestProjects.project_ra_id_a, TestProjects.project_ra_name_a,
2441000531 ,**TestProjects.USER_RA_CLIENT)
print robot_account.name
print robot_account.token
print "#5. Check robot account info, it should has both pull and push priviliges;"
#5. Check robot account info, it should has both pull and push priviliges;
data = self.project.get_project_robot_account_by_id(TestProjects.project_ra_id_a, robot_id, **TestProjects.USER_RA_CLIENT)
_assert_status_code(robot_account.name, data.name)
print "#6. Pull image(ImagePA) from project(PA) by robot account(RA), it must be successful;"
#6. Pull image(ImagePA) from project(PA) by robot account(RA), it must be successful;
pull_harbor_image(harbor_server, robot_account.name, robot_account.token, TestProjects.repo_name_in_project_a, tag_a)
print "#7. Push image(ImageRA) to project(PA) by robot account(RA), it must be successful;"
#7. Push image(ImageRA) to project(PA) by robot account(RA), it must be successful;
TestProjects.repo_name_pa, _ = push_image_to_project(TestProjects.project_ra_name_a, harbor_server, robot_account.name, robot_account.token, image_robot_account, tag)
print "#8. Push image(ImageRA) to project(PB) by robot account(RA), it must be not successful;"
#8. Push image(ImageRA) to project(PB) by robot account(RA), it must be not successful;
push_image_to_project(TestProjects.project_ra_name_b, harbor_server, robot_account.name, robot_account.token, image_robot_account, tag, expected_error_message = "unauthorized to access repository")
print "#9. Pull image(ImagePB) from project(PB) by robot account(RA), it must be not successful;"
#9. Pull image(ImagePB) from project(PB) by robot account(RA), it must be not successful;
pull_harbor_image(harbor_server, robot_account.name, robot_account.token, TestProjects.repo_name_in_project_b, tag_b, expected_error_message = "unauthorized to access repository")
print "#10. Pull image from project(PC), it must be successful;"
#10. Pull image from project(PC), it must be successful;
pull_harbor_image(harbor_server, robot_account.name, robot_account.token, TestProjects.repo_name_in_project_c, tag_c)
print "#11. Push image(ImageRA) to project(PC) by robot account(RA), it must be not successful;"
#11. Push image(ImageRA) to project(PC) by robot account(RA), it must be not successful;
push_image_to_project(TestProjects.project_ra_name_c, harbor_server, robot_account.name, robot_account.token, image_robot_account, tag, expected_error_message = "unauthorized to access repository")
print "#12. Update action property of robot account(RA);"
#12. Update action property of robot account(RA);"
self.project.disable_project_robot_account(TestProjects.project_ra_id_a, robot_id, True, **TestProjects.USER_RA_CLIENT)
print "#13. Pull image(ImagePA) from project(PA) by robot account(RA), it must be not successful;"
#13. Pull image(ImagePA) from project(PA) by robot account(RA), it must be not successful;
pull_harbor_image(harbor_server, robot_account.name, robot_account.token, TestProjects.repo_name_in_project_a, tag_a, expected_login_error_message = "unauthorized: authentication required")
print "#14. Push image(ImageRA) to project(PA) by robot account(RA), it must be not successful;"
#14. Push image(ImageRA) to project(PA) by robot account(RA), it must be not successful;
push_image_to_project(TestProjects.project_ra_name_a, harbor_server, robot_account.name, robot_account.token, image_robot_account, tag, expected_login_error_message = "unauthorized: authentication required")
print "#15. Delete robot account(RA), it must be not successful."
#15. Delete robot account(RA), it must be not successful.
self.project.delete_project_robot_account(TestProjects.project_ra_id_a, robot_id, **TestProjects.USER_RA_CLIENT)
if __name__ == '__main__':

View File

@ -23,7 +23,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == True, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -23,7 +23,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -24,7 +24,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -34,7 +34,7 @@ class TestProjects(unittest.TestCase):
@classmethod
def tearDown(self):
self.test_result.get_final_result()
print "Case completed"
print("Case completed")
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):

View File

@ -53,7 +53,7 @@ class TestResult(object):
def get_final_result(self):
if self.num_errors > 0:
for each_err_msg in self.error_message:
print "Error message:", each_err_msg
print("Error message:", each_err_msg)
raise Exception(r"Test case failed with {} errors.".format(self.num_errors))
from contextlib import contextmanager

View File

@ -48,6 +48,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list && apt-get clean
RUN apt-get update -y && \
apt-get install -y zbar-tools libzbar-dev python-zbar
RUN dpkg -L libzbar-dev; ls -l /usr/include/zbar.h
RUN apt-get update -y
RUN apt-get install -y python3.5
RUN rm /usr/bin/python
RUN ln -s /usr/bin/python3.5 /usr/bin/python
RUN apt-get install -y python3-pip
RUN wget -N http://chromedriver.storage.googleapis.com/2.40/chromedriver_linux64.zip && \
unzip chromedriver_linux64.zip && \
chmod +x chromedriver && \
@ -62,7 +72,7 @@ RUN apt-get update && apt install libnss3-tools && \
RUN wget https://bootstrap.pypa.io/get-pip.py && \
python ./get-pip.py && \
pip install pyasn1 google-apitools==0.5.15 gsutil robotframework==3.0.4 robotframework-sshlibrary robotframework-httplibrary requests dbbot robotframework-selenium2library==4.4.0 robotframework-pabot robotframework-JSONLibrary --upgrade
pip install pyasn1 google-apitools==0.5.15 gsutil robotframework==3.2.1 robotframework-sshlibrary robotframework-httplibrary requests dbbot robotframework-seleniumlibrary==4.3.0 robotframework-pabot robotframework-JSONLibrary --upgrade
# Install docker, docker compose
RUN wget https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz && \

View File

@ -71,10 +71,11 @@ Cannot Pull Image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}=${null} ${err_msg}=${null}
${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
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
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}
@ -99,11 +100,12 @@ Cannot Push image
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
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
@ -127,10 +129,11 @@ Start Docker Daemon Locally
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
FOR ${IDX} IN RANGE 5
${pid}= Run pidof dockerd
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
[Return] ${handle}
@ -181,20 +184,22 @@ Docker Push Index
Docker Image Can Not Be Pulled
[Arguments] ${image}
:FOR ${idx} IN RANGE 0 30
\ ${out}= Run Keyword And Ignore Error Command Should be Failed docker pull ${image}
\ Exit For Loop If '${out[0]}'=='PASS'
\ Sleep 3
FOR ${idx} IN RANGE 0 30
${out}= Run Keyword And Ignore Error Command Should be Failed docker pull ${image}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 3
END
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}=10
:For ${n} IN RANGE 1 ${times}
\ Sleep ${period}
\ ${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
FOR ${n} IN RANGE 1 ${times}
Sleep ${period}
${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
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'

View File

@ -19,10 +19,11 @@ Documentation This resource provides keywords to interact with Github
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
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

@ -325,8 +325,9 @@ Add Items To System CVE Allowlist
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}
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

View File

@ -43,8 +43,9 @@ Go Into 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
FOR ${obj} IN @{obj}
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
#Retry Element Click xpath=${version_checkbox}
Capture Page Screenshot
Retry Double Keywords When Error Retry Element Click xpath=${version_delete} Retry Wait Until Page Contains Element ${version_confirm_delete}

View File

@ -21,8 +21,9 @@ View Repo Scan Details
[Arguments] @{vulnerabilities_level}
Retry Element Click xpath=${first_repo_xpath}
Capture Page Screenshot
:FOR ${item} IN @{vulnerabilities_level}
\ Retry Wait Until Page Contains Element //hbr-artifact-vulnerabilities//clr-dg-row[contains(.,'${item}')]
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 File

@ -81,10 +81,11 @@ Set Daily Schedule
Execute Result Should Be
[Arguments] ${result}
:FOR ${idx} IN RANGE 0 20
\ ${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element xpath=//clr-dg-cell[contains(., '${result}')]
\ Exit For Loop If '${out[0]}'=='PASS'
\ Sleep 6
FOR ${idx} IN RANGE 0 20
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element xpath=//clr-dg-cell[contains(., '${result}')]
Exit For Loop If '${out[0]}'=='PASS'
Sleep 6
END
Should Be Equal As Strings '${out[0]}' 'PASS'
Execute Dry Run

View File

@ -198,14 +198,16 @@ Do Log Advanced Search
Retry Click Repo Name
[Arguments] ${repo_name_element}
:For ${n} IN RANGE 1 10
\ ${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'
FOR ${n} IN RANGE 1 10
${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 10
\ ${out} Run Keyword And Ignore Error Retry Wait Until Page Not Contains Element ${repo_list_spinner}
\ Exit For Loop If '${out[0]}'=='PASS'
FOR ${n} IN RANGE 1 10
${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
@ -214,15 +216,16 @@ Go Into Repo
Retry Wait Until Page Not Contains Element ${repo_list_spinner}
${repo_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${repoName}')]/a
Retry Element Click ${repo_search_icon}
:For ${n} IN RANGE 1 10
\ 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
\ Continue For Loop If '${out[0]}'=='FAIL'
\ ${out} Retry Click Repo Name ${repo_name_element}
\ Sleep 2
\ Exit For Loop
FOR ${n} IN RANGE 1 10
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
Continue For Loop If '${out[0]}'=='FAIL'
${out} Retry Click Repo Name ${repo_name_element}
Sleep 2
Exit For Loop
END
Click Index Achieve
@ -232,11 +235,12 @@ Click Index Achieve
Go Into Index And Contain Artifacts
[Arguments] ${tag_name} ${limit}=3
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
\ ${out} Run Keyword And Ignore Error Page Should Contain Element ${artifact_rows} limit=${limit}
\ Exit For Loop If '${out[0]}'=='PASS'
\ Capture Page Screenshot gointo_${tag_name}.png
\ Sleep 3
FOR ${n} IN RANGE 1 10
${out} Run Keyword And Ignore Error Page Should Contain Element ${artifact_rows} limit=${limit}
Exit For Loop If '${out[0]}'=='PASS'
Capture Page Screenshot gointo_${tag_name}.png
Sleep 3
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'

View File

@ -30,10 +30,12 @@ Filter Replication Rule
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} ${ruleName}
Retry Text Input ${filter_registry_input} ${registry_name}
Retry Wait Until Page Contains Element ${registry_name_element}
Capture Page Screenshot filter_repistry_${ruleName}.png
Capture Page Screenshot filter_repistry_${registry_name}.png
Select Dest Registry
[Arguments] ${endpoint}
@ -249,15 +251,16 @@ Delete Replication Rule
Image Should Be Replicated To Project
[Arguments] ${project} ${image} ${period}=60 ${times}=3
:For ${n} IN RANGE 0 ${times}
\ Sleep ${period}
\ Go Into Project ${project}
\ Switch To Project Repo
\ #In AWS-ECR, under repository a, there're only several images: httpd,alpine,hello-world.
\ ${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
FOR ${n} IN RANGE 0 ${times}
Sleep ${period}
Go Into Project ${project}
Switch To Project Repo
#In AWS-ECR, under repository a, there're only several images: httpd,alpine,hello-world.
${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'

View File

@ -21,15 +21,17 @@ Resource ../../resources/Util.robot
*** 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']
FOR ${obj} IN @{obj}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='success-standard']
END
Sleep 1
Capture Page Screenshot
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']
FOR ${obj} IN @{obj}
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='error-standard']
END
Sleep 1
Capture Page Screenshot
@ -57,9 +59,10 @@ Select Object
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}
FOR ${obj} IN @{obj}
${element}= Set Variable xpath=//clr-dg-row[contains(.,'${obj}')]//label
Retry Element Click ${element}
END
Sleep 1
Capture Page Screenshot
Retry Element Click ${delete_btn}
@ -73,9 +76,10 @@ Multi-delete Object
# 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}
FOR ${obj} IN @{obj}
${element}= Set Variable xpath=//clr-dg-row[contains(.,'${obj}')]//label
Retry Element Click ${element}
END
Sleep 1
Capture Page Screenshot
Retry Element Click ${artifact_action_xpath}
@ -90,8 +94,9 @@ Multi-delete Artifact
Multi-delete User
[Arguments] @{obj}
:For ${obj} in @{obj}
\ Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
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}
@ -99,8 +104,9 @@ Multi-delete User
Multi-delete Member
[Arguments] @{obj}
:For ${obj} in @{obj}
\ Retry Element Click //clr-dg-row[contains(.,'${obj}')]//clr-checkbox-wrapper/label
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}
@ -108,8 +114,9 @@ Multi-delete Member
Multi-delete Object Without Confirmation
[Arguments] @{obj}
:For ${obj} in @{obj}
\ Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
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}

View File

@ -11,14 +11,16 @@ Verify User
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To User Tag
@{user}= Get Value From Json ${json} $.users..name
:FOR ${user} IN @{user}
\ Page Should Contain ${user}
FOR ${user} IN @{user}
Page Should Contain ${user}
END
Logout Harbor
#verify user can login
@{user}= Get Value From Json ${json} $.users..name
:FOR ${user} IN @{user}
\ Sign In Harbor ${HARBOR_URL} ${user} ${HARBOR_PASSWORD}
\ Logout Harbor
FOR ${user} IN @{user}
Sign In Harbor ${HARBOR_URL} ${user} ${HARBOR_PASSWORD}
Logout Harbor
END
Close Browser
Verify Project
@ -27,8 +29,9 @@ Verify Project
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:FOR ${project} IN @{project}
\ Retry Wait Until Page Contains ${project}
FOR ${project} IN @{project}
Retry Wait Until Page Contains ${project}
END
Verify Project Metadata ${json}
Close Browser
@ -38,13 +41,14 @@ Verify Image Tag
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:FOR ${project} IN @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ @{repo}= Get Value From Json ${json} $.projects[?(@.name=${project})]..repo..name
\ Run Keyword If ${has_image} == ${true} Loop Image Repo @{repo}
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
@{repo}= Get Value From Json ${json} $.projects[?(@.name=${project})]..repo..name
Run Keyword If ${has_image} == ${true} Loop Image Repo @{repo}
Navigate To Projects
END
Close Browser
Verify Project Metadata
@ -52,19 +56,20 @@ Verify Project Metadata
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:FOR ${project} IN @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Project Configuration
\ Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.public ${project_config_public_checkbox}
\ Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.enable_content_trust ${project_config_content_trust_checkbox}
\ Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.auto_scan ${project_config_scan_images_on_push_checkbox}
\ Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.prevent_vul ${project_config_prevent_vulnerable_images_from_running_checkbox}
\ ${ret} Get Selected List Value ${project_config_severity_select}
\ @{severity}= Get Value From Json ${json} $.projects[?(@.name=${project})].configuration.severity
\ Should Contain ${ret} @{severity}[0]
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Configuration
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.public ${project_config_public_checkbox}
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.enable_content_trust ${project_config_content_trust_checkbox}
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.auto_scan ${project_config_scan_images_on_push_checkbox}
Verify Checkbox ${json} $.projects[?(@.name=${project})].configuration.prevent_vul ${project_config_prevent_vulnerable_images_from_running_checkbox}
${ret} Get Selected List Value ${project_config_severity_select}
@{severity}= Get Value From Json ${json} $.projects[?(@.name=${project})].configuration.severity
Should Contain ${ret} @{severity}[0]
Navigate To Projects
END
Close Browser
Verify Checkbox
@ -77,8 +82,9 @@ Verify Checkbox
Loop Image Repo
[Arguments] @{repo}
:For ${repo} In @{repo}
\ Page Should Contain ${repo}
FOR ${repo} IN @{repo}
Page Should Contain ${repo}
END
Verify Member Exist
[Arguments] ${json}
@ -86,14 +92,15 @@ Verify Member Exist
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:For ${project} In @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Member
\ @{members}= Get Value From Json ${json} $.projects[?(@.name=${project})].member..name
\ Loop Member @{members}
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Member
@{members}= Get Value From Json ${json} $.projects[?(@.name=${project})].member..name
Loop Member @{members}
Navigate To Projects
END
Close Browser
Verify Webhook
@ -102,24 +109,25 @@ Verify Webhook
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:For ${project} In @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Project Webhooks
\ @{enabled}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.enabled
\ ${enable_count} Get Matching Xpath Count xpath=//span[contains(.,'Enabled')]
\ ${disable_count} Get Matching Xpath Count xpath=//span[contains(.,'Disabled')]
\ Log To Console '@{enabled}[0]'
\ Log To Console '${true}'
\ Run Keyword If '@{enabled}[0]' == '${true}' Page Should Contain Enabled
\ ... ELSE Page Should Contain Disabled
\ @{address}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.address
\ Log To Console '@{address}[0]'
\ Page Should Contain @{address}[0]
\ Page Should Contain policy
\ Page Should Contain http
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Webhooks
@{enabled}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.enabled
${enable_count} Get Matching Xpath Count xpath=//span[contains(.,'Enabled')]
${disable_count} Get Matching Xpath Count xpath=//span[contains(.,'Disabled')]
Log To Console '@{enabled}[0]'
Log To Console '${true}'
Run Keyword If '@{enabled}[0]' == '${true}' Page Should Contain Enabled
... ELSE Page Should Contain Disabled
@{address}= Get Value From Json ${json} $.projects[?(@.name=${project})].webhook.address
Log To Console '@{address}[0]'
Page Should Contain @{address}[0]
Page Should Contain policy
Page Should Contain http
Navigate To Projects
END
Close Browser
Verify Tag Retention Rule
@ -128,22 +136,23 @@ Verify Tag Retention Rule
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:For ${project} In @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Tag Retention
\ ${actions_count}= Set Variable 8
\ @{repository_patten}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.repository_patten
\ @{tag_decoration}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.tag_decoration
\ @{latestPushedK}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.latestPushedK
\ @{cron}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.cron
\ Log To Console '@{repository_patten}[0]'
\ Page Should Contain @{repository_patten}[0]
\ Page Should Contain @{tag_decoration}[0]
\ Page Should Contain @{latestPushedK}[0]
\ Page Should Contain @{cron}[0]
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Tag Retention
${actions_count}= Set Variable 8
@{repository_patten}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.repository_patten
@{tag_decoration}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.tag_decoration
@{latestPushedK}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.latestPushedK
@{cron}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_retention_rule.cron
Log To Console '@{repository_patten}[0]'
Page Should Contain @{repository_patten}[0]
Page Should Contain @{tag_decoration}[0]
Page Should Contain @{latestPushedK}[0]
Page Should Contain @{cron}[0]
Navigate To Projects
END
Close Browser
Verify Tag Immutability Rule
@ -152,27 +161,29 @@ Verify Tag Immutability Rule
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:For ${project} In @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Tag Immutability
\ @{repo_decoration}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.repo_decoration
\ @{tag_decoration}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.tag_decoration
\ @{repo_pattern}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.repo_pattern
\ @{tag_pattern}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.tag_pattern
\ Log To Console '@{repo_decoration}[0]'
#\ Page Should Contain @{repo_decoration}[0]
#\ Page Should Contain @{tag_decoration}[0]
\ Page Should Contain @{repo_pattern}[0]
\ Page Should Contain @{tag_pattern}[0]
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Tag Immutability
@{repo_decoration}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.repo_decoration
@{tag_decoration}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.tag_decoration
@{repo_pattern}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.repo_pattern
@{tag_pattern}= Get Value From Json ${json} $.projects[?(@.name=${project})].tag_immutability_rule.tag_pattern
Log To Console '@{repo_decoration}[0]'
#Page Should Contain @{repo_decoration}[0]
#Page Should Contain @{tag_decoration}[0]
Page Should Contain @{repo_pattern}[0]
Page Should Contain @{tag_pattern}[0]
Navigate To Projects
END
Close Browser
Loop Member
[Arguments] @{members}
:For ${member} In @{members}
\ Page Should Contain ${member}
FOR ${member} IN @{members}
Page Should Contain ${member}
END
Verify Robot Account Exist
[Arguments] ${json}
@ -180,30 +191,33 @@ Verify Robot Account Exist
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:For ${project} In @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Project Robot Account
\ @{robot_accounts}= Get Value From Json ${json} $.projects[?(@.name=${project})].robot_account..name
\ Loop Verify Robot Account @{robot_accounts}
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Robot Account
@{robot_accounts}= Get Value From Json ${json} $.projects[?(@.name=${project})].robot_account..name
Loop Verify Robot Account @{robot_accounts}
Navigate To Projects
END
Close Browser
Loop Verify Robot Account
[Arguments] @{robot_accounts}
:For ${robot_account} In @{robot_accounts}
\ Page Should Contain ${robot_account}
FOR ${robot_account} IN @{robot_accounts}
Page Should Contain ${robot_account}
END
Verify User System Admin Role
[Arguments] ${json}
Log To Console "Verify User System Admin Role..."
@{user}= Get Value From Json ${json} $.admin..name
Init Chrome Driver
:FOR ${user} IN @{user}
\ Sign In Harbor ${HARBOR_URL} ${user} ${HARBOR_PASSWORD}
\ Page Should Contain Administration
\ Logout Harbor
FOR ${user} IN @{user}
Sign In Harbor ${HARBOR_URL} ${user} ${HARBOR_PASSWORD}
Page Should Contain Administration
Logout Harbor
END
Close Browser
Verify System Label
@ -214,25 +228,28 @@ Verify System Label
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Configure
Switch To System Labels
:For ${label} In @{label}
\ Page Should Contain ${label}
FOR ${label} IN @{label}
Page Should Contain ${label}
END
Close Browser
Verify Project Label
[Arguments] ${json}
Log To Console "Verify Project Label..."
@{project}= Get Value From Json ${json} $.peoject.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:For ${project} In @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Project Label
\ @{projectlabel}= Get Value From Json ${json} $.projects[?(@.name=${project})]..labels..name
\ :For ${label} In @{label}
\ \ Page Should Contain ${projectlabel}
\ Navigate To Projects
[Arguments] ${json}
Log To Console "Verify Project Label..."
@{project}= Get Value From Json ${json} $.peoject.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Label
@{projectlabel}= Get Value From Json ${json} $.projects[?(@.name=${project})]..labels..name
FOR ${label} IN @{label}
Page Should Contain ${projectlabel}
END
Navigate To Projects
END
Close Browser
Verify Endpoint
@ -242,8 +259,9 @@ Verify Endpoint
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
:For ${endpoint} In @{endpoint}
\ Page Should Contain ${endpoint}
FOR ${endpoint} IN @{endpoint}
Page Should Contain ${endpoint}
END
Close Browser
Verify Replicationrule
@ -251,63 +269,65 @@ Verify Replicationrule
Log To Console "Verify Replicationrule..."
@{replicationrules}= Get Value From Json ${json} $.replicationrule.[*].rulename
@{endpoints}= Get Value From Json ${json} $.endpoint.[*].name
: FOR ${replicationrule} IN @{replicationrules}
\ Init Chrome Driver
\ Log To Console -----replicationrule-----"${replicationrule}"------------
\ Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
\ Switch To Replication Manage
\ Select Rule And Click Edit Button ${replicationrule}
\ @{is_src_registry}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].is_src_registry
\ @{trigger_type}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].trigger_type
\ @{name_filters}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].name_filters
\ @{tag_filters}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].tag_filters
\ @{dest_namespace}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].dest_namespace
\ @{cron}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].cron
\ @{is_src_registry}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].is_src_registry
\ Log To Console -----is_src_registry-----@{is_src_registry}[0]------------
\ @{endpoint}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].endpoint
\ Log To Console -----endpoint-----@{endpoint}------------
\ ${endpoint0}= Set Variable @{endpoint}[0]
\ Log To Console -----endpoint0-----${endpoint0}------------
\ @{endpoint_type}= Get Value From Json ${json} $.endpoint[?(@.name=${endpoint0})].type
\ Retry Textfield Value Should Be ${filter_name_id} @{name_filters}[0]
\ Retry Textfield Value Should Be ${filter_tag_id} @{tag_filters}[0]
\ Retry Textfield Value Should Be ${rule_name_input} ${replicationrule}
\ Retry Textfield Value Should Be ${dest_namespace_xpath} @{dest_namespace}[0]
\ Log To Console -----endpoint_type-----@{endpoint_type}[0]------------
\ ${registry}= Set Variable If "@{endpoint_type}[0]"=="harbor" ${endpoint0}-https://${IP} ${endpoint0}-https://hub.docker.com
\ Log To Console -------registry---${registry}------------
\ Run Keyword If '@{is_src_registry}[0]' == '${true}' Retry List Selection Should Be ${src_registry_dropdown_list} ${registry}
\ ... ELSE Retry List Selection Should Be ${dest_registry_dropdown_list} ${registry}
\ #\ Retry List Selection Should Be ${rule_resource_selector} ${resource_type}
\ Retry List Selection Should Be ${rule_trigger_select} @{trigger_type}[0]
\ Run Keyword If '@{trigger_type}[0]' == 'scheduled' Log To Console ----------@{trigger_type}[0]------------
\ Run Keyword If '@{trigger_type}[0]' == 'scheduled' Retry Textfield Value Should Be ${targetCron_id} @{cron}[0]
FOR ${replicationrule} IN @{replicationrules}
Init Chrome Driver
Log To Console -----replicationrule-----"${replicationrule}"------------
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Select Rule And Click Edit Button ${replicationrule}
@{is_src_registry}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].is_src_registry
@{trigger_type}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].trigger_type
@{name_filters}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].name_filters
@{tag_filters}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].tag_filters
@{dest_namespace}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].dest_namespace
@{cron}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].cron
@{is_src_registry}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].is_src_registry
Log To Console -----is_src_registry-----@{is_src_registry}[0]------------
@{endpoint}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].endpoint
Log To Console -----endpoint-----@{endpoint}------------
${endpoint0}= Set Variable @{endpoint}[0]
Log To Console -----endpoint0-----${endpoint0}------------
@{endpoint_type}= Get Value From Json ${json} $.endpoint[?(@.name=${endpoint0})].type
Retry Textfield Value Should Be ${filter_name_id} @{name_filters}[0]
Retry Textfield Value Should Be ${filter_tag_id} @{tag_filters}[0]
Retry Textfield Value Should Be ${rule_name_input} ${replicationrule}
Retry Textfield Value Should Be ${dest_namespace_xpath} @{dest_namespace}[0]
Log To Console -----endpoint_type-----@{endpoint_type}[0]------------
${registry}= Set Variable If "@{endpoint_type}[0]"=="harbor" ${endpoint0}-https://${IP} ${endpoint0}-https://hub.docker.com
Log To Console -------registry---${registry}------------
Run Keyword If '@{is_src_registry}[0]' == '${true}' Retry List Selection Should Be ${src_registry_dropdown_list} ${registry}
... ELSE Retry List Selection Should Be ${dest_registry_dropdown_list} ${registry}
#Retry List Selection Should Be ${rule_resource_selector} ${resource_type}
Retry List Selection Should Be ${rule_trigger_select} @{trigger_type}[0]
Run Keyword If '@{trigger_type}[0]' == 'scheduled' Log To Console ----------@{trigger_type}[0]------------
Run Keyword If '@{trigger_type}[0]' == 'scheduled' Retry Textfield Value Should Be ${targetCron_id} @{cron}[0]
END
Close Browser
Verify Project Setting
[Arguments] ${json}
Log To Console "Verify Project Setting..."
@{projects}= Get Value From Json ${json} $.projects.[*].name
:For ${project} In @{Projects}
\ ${public}= Get Value From Json ${json} $.projects[?(@.name=${project})].accesslevel
\ ${contenttrust}= Get Value From Json ${json} $.projects[?(@.name=${project})]..enable_content_trust
\ ${preventrunning}= Get Value From Json ${json} $.projects[?(@.name=${project})]..prevent_vulnerable_images_from_running
\ ${scanonpush}= Get Value From Json ${json} $.projects[?(@.name=${project})]..automatically_scan_images_on_push
\ Init Chrome Driver
\ Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Goto Project Config
\ Run Keyword If ${public} == "public" Checkbox Should Be Checked //clr-checkbox-wrapper[@name='public']//label
\ Run Keyword If ${contenttrust} == "true" Checkbox Should Be Checked //clr-checkbox-wrapper[@name='content-trust']//label
\ Run Keyword If ${contenttrust} == "false" Checkbox Should Not Be Checked //clr-checkbox-wrapper[@name='content-trust']//label
\ Run Keyword If ${preventrunning} == "true" Checkbox Should Be Checked //*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
\ Run Keyword If ${preventrunning} == "false" Checkbox Should Not Be Checked //*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
\ Run Keyword If ${scanonpush} == "true" Checkbox Should Be Checked //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
\ Run Keyword If ${scanonpush} == "true" Checkbox Should Not Be Checked //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
\ Close Browser
FOR ${project} IN @{Projects}
${public}= Get Value From Json ${json} $.projects[?(@.name=${project})].accesslevel
${contenttrust}= Get Value From Json ${json} $.projects[?(@.name=${project})]..enable_content_trust
${preventrunning}= Get Value From Json ${json} $.projects[?(@.name=${project})]..prevent_vulnerable_images_from_running
${scanonpush}= Get Value From Json ${json} $.projects[?(@.name=${project})]..automatically_scan_images_on_push
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Goto Project Config
Run Keyword If ${public} == "public" Checkbox Should Be Checked //clr-checkbox-wrapper[@name='public']//label
Run Keyword If ${contenttrust} == "true" Checkbox Should Be Checked //clr-checkbox-wrapper[@name='content-trust']//label
Run Keyword If ${contenttrust} == "false" Checkbox Should Not Be Checked //clr-checkbox-wrapper[@name='content-trust']//label
Run Keyword If ${preventrunning} == "true" Checkbox Should Be Checked //*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
Run Keyword If ${preventrunning} == "false" Checkbox Should Not Be Checked //*[@id='prevent-vulenrability-image']//clr-checkbox-wrapper//label
Run Keyword If ${scanonpush} == "true" Checkbox Should Be Checked //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Run Keyword If ${scanonpush} == "true" Checkbox Should Not Be Checked //clr-checkbox-wrapper[@id='scan-image-on-push-wrapper']//input
Close Browser
END
Verify Interrogation Services
[Arguments] ${json}
@ -358,23 +378,25 @@ Verify Project-level Allowlist
@{project}= Get Value From Json ${json} $.projects.[*].name
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
:FOR ${project} IN @{project}
\ @{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
\ ${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
\ Go Into Project ${project} has_image=${has_image}
\ Switch To Project Configuration
\ @{is_reuse_sys_cve_allowlist}= Get Value From Json ${json} $.projects[?(@.name=${project})].configuration.reuse_sys_cve_allowlist
\ Run Keyword If "@{is_reuse_sys_cve_allowlist}[0]" == "true" Retry Wait Element Should Be Disabled ${project_config_project_wl_add_btn}
\ ... ELSE Retry Wait Element ${project_config_project_wl_add_btn}
\ @{cve_ids}= Get Value From Json ${json} $.projects[?(@.name=${project})].configuration.cve
\ Loop Verifiy CVE_IDs @{cve_ids}
\ Navigate To Projects
FOR ${project} IN @{project}
@{out_has_image}= Get Value From Json ${json} $.projects[?(@.name=${project})].has_image
${has_image} Set Variable If @{out_has_image}[0] == ${true} ${true} ${false}
Go Into Project ${project} has_image=${has_image}
Switch To Project Configuration
@{is_reuse_sys_cve_allowlist}= Get Value From Json ${json} $.projects[?(@.name=${project})].configuration.reuse_sys_cve_allowlist
Run Keyword If "@{is_reuse_sys_cve_allowlist}[0]" == "true" Retry Wait Element Should Be Disabled ${project_config_project_wl_add_btn}
... ELSE Retry Wait Element ${project_config_project_wl_add_btn}
@{cve_ids}= Get Value From Json ${json} $.projects[?(@.name=${project})].configuration.cve
Loop Verifiy CVE_IDs @{cve_ids}
Navigate To Projects
END
Close Browser
Loop Verifiy CVE_IDs
[Arguments] @{cve_ids}
:For ${cve_id} In @{cve_ids}
\ Page Should Contain ${cve_id}
FOR ${cve_id} IN @{cve_ids}
Page Should Contain ${cve_id}
END
Verify System Setting Allowlist
[Arguments] ${json}

View File

@ -14,7 +14,7 @@
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
Library Selenium2Library
Library SeleniumLibrary
Library OperatingSystem
*** Variables ***
@ -148,14 +148,15 @@ Compile and Up Harbor With Source Code
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
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

View File

@ -37,12 +37,13 @@ Init Chrome Driver
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
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

@ -20,7 +20,7 @@ Library requests
Library Process
Library SSHLibrary 1 minute
Library DateTime
Library Selenium2Library 60 10
Library SeleniumLibrary 60 10
Library JSONLibrary
Resource Nimbus-Util.robot
Resource Vsphere-Util.robot
@ -206,16 +206,18 @@ Text Input
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
FOR ${index} IN RANGE ${character count}
Press Keys ${field} \\8
END
Wait Unitl Command Success
[Arguments] ${cmd} ${times}=8
: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
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}
@ -229,42 +231,45 @@ Command Should be Failed
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]}
\ Capture Page Screenshot record.png
\ 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
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]}
Capture Page Screenshot record.png
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
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}
\ Capture Page Screenshot
\ Sleep 1
\ ${out2} Run Keyword And Ignore Error ${keyword2} ${element2}
\ Capture Page Screenshot
\ Log To Console Return value is ${out1[0]} ${out2[0]}
\ Exit For Loop If '${out2[0]}'=='PASS'
\ Sleep 1
FOR ${n} IN RANGE 1 ${times}
Log To Console Trying ${keyword1} and ${keyword2} ${n} times ...
${out1} Run Keyword And Ignore Error ${keyword1} ${element1}
Capture Page Screenshot
Sleep 1
${out2} Run Keyword And Ignore Error ${keyword2} ${element2}
Capture Page Screenshot
Log To Console Return value is ${out1[0]} ${out2[0]}
Exit For Loop If '${out2[0]}'=='PASS'
Sleep 1
END
Return From Keyword If ${DoAssert} == ${false} '${out2[0]}'
Should Be Equal As Strings '${out2[0]}' 'PASS'

View File

@ -61,22 +61,24 @@ Reset VM
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
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
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