fix: test robot account permission (#20240)

Signed-off-by: Shengwen Yu <yshengwen@vmware.com>
This commit is contained in:
Shengwen YU 2024-04-08 12:57:38 +08:00 committed by GitHub
parent c12064df4e
commit c8370faeeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -1243,6 +1243,8 @@ paths:
description: Successfully get scan log file
schema:
type: string
'400':
$ref: '#/responses/400'
'401':
$ref: '#/responses/401'
'403':

View File

@ -91,7 +91,7 @@ delete_artifact = Permission("{}/projects/{}/repositories/target_repo/artifacts/
# 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)
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']
tag_payload = { "name": "test-{}".format(int(random.randint(1000, 9999))) }
@ -249,16 +249,22 @@ resource_permissions = {
"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]
}
resource_permissions["all"] = [item for sublist in resource_permissions.values() for item in sublist]
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 permission in resource_permissions[resource]:
print("=================================================")
print("call: {} {}".format(permission.method, permission.url))
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")