mirror of https://github.com/goharbor/harbor.git
fix: test robot account permission (#20240)
Signed-off-by: Shengwen Yu <yshengwen@vmware.com>
This commit is contained in:
parent
c12064df4e
commit
c8370faeeb
|
@ -1243,6 +1243,8 @@ paths:
|
||||||
description: Successfully get scan log file
|
description: Successfully get scan log file
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
'400':
|
||||||
|
$ref: '#/responses/400'
|
||||||
'401':
|
'401':
|
||||||
$ref: '#/responses/401'
|
$ref: '#/responses/401'
|
||||||
'403':
|
'403':
|
||||||
|
|
|
@ -91,7 +91,7 @@ delete_artifact = Permission("{}/projects/{}/repositories/target_repo/artifacts/
|
||||||
# 6. Resource scan actions: ['read', 'create', 'stop']
|
# 6. Resource scan actions: ['read', 'create', 'stop']
|
||||||
create_scan = Permission("{}/projects/{}/repositories/{}/artifacts/{}/scan".format(harbor_base_url, project_name, source_artifact_name, source_artifact_tag), "POST", 202)
|
create_scan = Permission("{}/projects/{}/repositories/{}/artifacts/{}/scan".format(harbor_base_url, project_name, source_artifact_name, source_artifact_tag), "POST", 202)
|
||||||
stop_scan = Permission("{}/projects/{}/repositories/{}/artifacts/{}/scan/stop".format(harbor_base_url, project_name, source_artifact_name, source_artifact_tag), "POST", 202)
|
stop_scan = Permission("{}/projects/{}/repositories/{}/artifacts/{}/scan/stop".format(harbor_base_url, project_name, source_artifact_name, source_artifact_tag), "POST", 202)
|
||||||
read_scan = Permission("{}/projects/{}/repositories/{}/artifacts/{}/scan/0/log".format(harbor_base_url, project_name, source_artifact_name, source_artifact_tag), "get", 404)
|
read_scan = Permission("{}/projects/{}/repositories/{}/artifacts/{}/scan/83be44fd-1234-5678-b49f-4b6d6e8f5730/log".format(harbor_base_url, project_name, source_artifact_name, source_artifact_tag), "get", 404)
|
||||||
|
|
||||||
# 7. Resource tag actions: ['list', 'create', 'delete']
|
# 7. Resource tag actions: ['list', 'create', 'delete']
|
||||||
tag_payload = { "name": "test-{}".format(int(random.randint(1000, 9999))) }
|
tag_payload = { "name": "test-{}".format(int(random.randint(1000, 9999))) }
|
||||||
|
@ -249,16 +249,22 @@ resource_permissions = {
|
||||||
"log": [list_log],
|
"log": [list_log],
|
||||||
"notification-policy": [create_webhook, list_webhook, read_webhook, update_webhook, list_webhook_executions, list_webhook_executions_tasks, read_webhook_executions_tasks, list_webhook_events, delete_webhook]
|
"notification-policy": [create_webhook, list_webhook, read_webhook, update_webhook, list_webhook_executions, list_webhook_executions_tasks, read_webhook_executions_tasks, list_webhook_events, delete_webhook]
|
||||||
}
|
}
|
||||||
resource_permissions["all"] = [item for sublist in resource_permissions.values() for item in sublist]
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
global resources # Declare resources as a global variable
|
||||||
|
|
||||||
|
if str(resources) == "all":
|
||||||
|
resources = ','.join(str(key) for key in resource_permissions.keys())
|
||||||
|
|
||||||
for resource in resources.split(","):
|
for resource in resources.split(","):
|
||||||
for permission in resource_permissions[resource]:
|
for permission in resource_permissions[resource]:
|
||||||
print("=================================================")
|
print("=================================================")
|
||||||
print("call: {} {}".format(permission.method, permission.url))
|
print("call: {} {}".format(permission.method, permission.url))
|
||||||
print("payload: {}".format(json.dumps(permission.payload)))
|
print("payload: {}".format(json.dumps(permission.payload)))
|
||||||
print("response: {}".format(permission.call().text))
|
resp = permission.call()
|
||||||
|
print("response: {}".format(resp.text))
|
||||||
|
print("response status code: {}".format(resp.status_code))
|
||||||
print("=================================================\n")
|
print("=================================================\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue