diff --git a/tests/resources/Docker-Util.robot b/tests/resources/Docker-Util.robot index 03ea839bc..bf2d989a6 100644 --- a/tests/resources/Docker-Util.robot +++ b/tests/resources/Docker-Util.robot @@ -41,7 +41,7 @@ Push image Wait Unitl Command Success docker logout ${ip} Push Image With Tag -#tag1 is tag of image on docker hub,default latest,use a version existing if you do not want to use latest +#tag1 is tag of image on docker hub,default latest,use a version existing if you do not want to use latest [Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag} ${tag1}=latest Log To Console \nRunning docker push ${image}... Wait Unitl Command Success docker pull ${image}:${tag1} diff --git a/tests/robot-cases/Group3-Upgrade/data.json b/tests/robot-cases/Group3-Upgrade/data.json index 20f27cf84..2bdb73941 100644 --- a/tests/robot-cases/Group3-Upgrade/data.json +++ b/tests/robot-cases/Group3-Upgrade/data.json @@ -30,8 +30,8 @@ { "url":"http://url", "name":"endpoint1", - "user":"endpointuser", - "pass":"endpointpass" + "user":"admin", + "pass":"Harbor12345" } ], "replicationrule":[ diff --git a/tests/robot-cases/Group3-Upgrade/prepare.py b/tests/robot-cases/Group3-Upgrade/prepare.py index 8589f20d4..bcb9407f1 100644 --- a/tests/robot-cases/Group3-Upgrade/prepare.py +++ b/tests/robot-cases/Group3-Upgrade/prepare.py @@ -12,6 +12,7 @@ parser.add_argument('--version', '-v', dest='version', required=False, help='The args = parser.parse_args() url = "https://"+args.endpoint+"/api/" +endpoint_url = "https://"+args.endpoint print url class HarborAPI: @@ -45,18 +46,27 @@ class HarborAPI: request(url+"projects/"+projectid+"/members", 'post', **body) def add_endpoint(self, endpointurl, endpointname, username, password, insecure): - payload = {"endpoint": ""+endpointurl+"", "name": ""+endpointname+"", "username": ""+username+"", "password": ""+password+"", "insecure": insecure} + payload = { + "credential":{ + "access_key":""+username+"", + "access_secret":""+password+"", + "type":"basic" + }, + "insecure":insecure, + "name":""+endpointname+"", + "type":"harbor", + "url":""+endpoint_url+"" + } body=dict(body=payload) - request(url+"targets", 'post', **body) + print body + request(url+"/registries", 'post', **body) def add_replication_rule(self, project, target, trigger, rulename): - r = request(url+"projects?name="+project+"", 'get') - projectid = r.json()[0]['project_id'] - r = request(url+"targets?name="+target+"", 'get') + r = request(url+"registries?name="+target+"", 'get') targetid = r.json()[0]['id'] - payload = {"name": ""+rulename+"", "description": "string", "projects": [{"project_id": projectid,}], "targets": [{"id": targetid,}], "trigger": {"kind": ""+trigger+"", "schedule_param": {"type": "weekly", "weekday": 1, "offtime": 0}}} + payload = {"name": ""+rulename+"", "deletion": False, "enabled": True, "description": "string", "dest_registry": {"id": targetid},"trigger": {"type": "manual"}} body=dict(body=payload) - request(url+"policies/replication", 'post', **body) + request(url+"replication/policies", 'post', **body) def update_project_setting(self, project, contenttrust, preventrunning, preventseverity, scanonpush): r = request(url+"projects?name="+project+"", 'get') @@ -171,7 +181,7 @@ def do_data_creation(): push_signed_image("alpine", data["projects"][0]["name"], "latest") for endpoint in data["endpoint"]: - harborAPI.add_endpoint(endpoint["url"], endpoint["name"], endpoint["user"], endpoint["pass"], False) + harborAPI.add_endpoint(endpoint["url"], endpoint["name"], endpoint["user"], endpoint["pass"], True) for replicationrule in data["replicationrule"]: harborAPI.add_replication_rule(replicationrule["project"], replicationrule["endpoint"], replicationrule["trigger"], @@ -180,7 +190,7 @@ def do_data_creation(): harborAPI.update_project_setting(project["name"], project["configuration"]["enable_content_trust"], project["configuration"]["prevent_vulnerable_images_from_running"], - project["configuration"]["prevent_vlunerable_images_from_running_severity"], + project["configuration"]["prevent_vlunerable_images_from_running_severity"], project["configuration"]["automatically_scan_images_on_push"]) harborAPI.update_systemsetting(data["configuration"]["emailsetting"]["emailfrom"], data["configuration"]["emailsetting"]["emailserver"],