Fix issues in python api test

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
Yang Jiao 2021-10-20 10:08:43 +08:00
parent 2ec8a41138
commit 9178ba1138
4 changed files with 0 additions and 10 deletions

View File

@ -6,7 +6,6 @@ import docker_api
def ctr_images_pull(username, password, oci):
command = ["ctr", "images", "pull","--snapshotter", "native", "-u", username+":"+password, oci]
print("Command: ", command)
ret = base.run_command(command)
print("Command return: ", ret)

View File

@ -23,7 +23,6 @@ def docker_login_cmd(harbor_host, username, password, cfg_file = "./tests/apites
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:
@ -79,7 +78,6 @@ def list_repositories(harbor_host, username, password, n = None, last = 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
@ -91,7 +89,6 @@ def list_image_tags(harbor_host, repository, username, password, n = None, last
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
@ -112,7 +109,6 @@ class DockerAPI(object):
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))

View File

@ -118,7 +118,6 @@ class Robot(base.Base, object):
robot_desc = base._random_name("robot_desc")
robotAccountCreate = v2_swagger_client.RobotCreate(name=robot_name, description=robot_desc, duration=duration, level="system", disable = False, permissions = permission_list)
print("robotAccountCreate:", robotAccountCreate)
data = []
data, status_code, header = self._get_client(**kwargs).create_robot_with_http_info(robotAccountCreate)
base._assert_status_code(expect_status_code, status_code)

View File

@ -385,7 +385,6 @@ class HarborAPI:
raise Exception(r"Error: Robot account count {} is not legal!".format(len(robot_account["access"])))
else:
raise Exception(r"Error: Feature {} has no branch {}.".format(sys._getframe().f_code.co_name, branch))
print(payload)
body=dict(body=payload)
request(url+"projects/"+projectid+"/robots", 'post', **body)
@ -507,7 +506,6 @@ class HarborAPI:
],
"enabled":webhook["enabled"]
}
print(payload)
body=dict(body=payload)
request(url+"projects/"+projectid+"/webhook/policies", 'post', **body)
elif kwargs["branch"] == 2:
@ -536,7 +534,6 @@ class HarborAPI:
"enabled":webhook["enabled"],
"name":webhook["name"]
}
print(payload)
body=dict(body=payload)
request(url+"projects/"+projectid+"/webhook/policies", 'post', **body)
else:
@ -606,7 +603,6 @@ def request(url, method, user = None, userp = None, **kwargs):
kwargs['headers']['Content-Type'] = 'application/json'
kwargs['data'] = json.dumps(kwargs['body'])
del kwargs['body']
print("url: ", url)
resp = requests.request(method, url, verify=False, auth=(user, userp), **kwargs)
if resp.status_code >= 400:
raise Exception("[Exception Message] - {}".format(resp.text))