mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-16 07:15:13 +01:00
068d1d46ca
After debugging for issue of missing some http message logs, we found out that swagger client configuration will be re-initiated by calling models in swagger client, so in API python tests, defination for models must be in front of swagger client defination. Signed-off-by: danfengliu <danfengl@vmware.com>
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import time
|
|
import base
|
|
import v2_swagger_client
|
|
from v2_swagger_client.rest import ApiException
|
|
|
|
class ProjectV2(base.Base, object):
|
|
def __init__(self):
|
|
super(ProjectV2,self).__init__(api_type = "projectv2")
|
|
|
|
def get_project_log(self, project_name, expect_status_code = 200, **kwargs):
|
|
body, status_code, _ = self._get_client(**kwargs).get_logs_with_http_info(project_name)
|
|
base._assert_status_code(expect_status_code, status_code)
|
|
return body
|
|
|
|
def filter_project_logs(self, project_name, operator, resource, resource_type, operation, **kwargs):
|
|
access_logs = self.get_project_log(project_name, **kwargs)
|
|
count = 0
|
|
for each_access_log in list(access_logs):
|
|
if each_access_log.username == operator and \
|
|
each_access_log.resource_type == resource_type and \
|
|
each_access_log.resource == resource and \
|
|
each_access_log.operation == operation:
|
|
count = count + 1
|
|
return count
|
|
|