Exemplo n.º 1
0
    def disable_robot_account(self, robot_id, disable, expect_status_code = 200, **kwargs):
        data = self.get_robot_account_by_id(robot_id, **kwargs)
        robotAccountUpdate = v2_swagger_client.RobotCreate(name=data.name, description=data.description, duration=data.duration, level=data.level, permissions = data.permissions, disable = disable)

        _, status_code, _ = self._get_client(**kwargs).update_robot_with_http_info(robot_id, robotAccountUpdate)
        base._assert_status_code(expect_status_code, status_code)
        base._assert_status_code(200, status_code)
Exemplo n.º 2
0
    def create_system_robot(self,
                            permission_list,
                            duration,
                            robot_name=None,
                            robot_desc=None,
                            expect_status_code=201,
                            **kwargs):
        if robot_name is None:
            robot_name = base._random_name("robot")
        if robot_desc is None:
            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)
        client = self._get_client(**kwargs)
        data = []
        data, status_code, header = client.create_robot_with_http_info(
            robotAccountCreate)
        base._assert_status_code(expect_status_code, status_code)
        base._assert_status_code(201, status_code)
        return base._get_id_from_header(header), data
Exemplo n.º 3
0
    def create_project_robot(self,
                             project_name,
                             expires_at,
                             robot_name=None,
                             robot_desc=None,
                             has_pull_right=True,
                             has_push_right=True,
                             has_chart_read_right=True,
                             has_chart_create_right=True,
                             expect_status_code=201,
                             **kwargs):
        if robot_name is None:
            robot_name = base._random_name("robot")
        if robot_desc is None:
            robot_desc = base._random_name("robot_desc")
        if has_pull_right is False and has_push_right is False:
            has_pull_right = True
        access_list = []
        action_pull = "pull"
        action_push = "push"
        action_read = "read"
        action_create = "create"
        if has_pull_right is True:
            robotAccountAccess = v2_swagger_client.Access(
                resource="repository", action=action_pull)
            access_list.append(robotAccountAccess)
        if has_push_right is True:
            robotAccountAccess = v2_swagger_client.Access(
                resource="repository", action=action_push)
            access_list.append(robotAccountAccess)
        if has_chart_read_right is True:
            robotAccountAccess = v2_swagger_client.Access(
                resource="helm-chart", action=action_read)
            access_list.append(robotAccountAccess)
        if has_chart_create_right is True:
            robotAccountAccess = v2_swagger_client.Access(
                resource="helm-chart-version", action=action_create)
            access_list.append(robotAccountAccess)

        robotaccountPermissions = v2_swagger_client.Permission(
            kind="project", namespace=project_name, access=access_list)
        permission_list = []
        permission_list.append(robotaccountPermissions)
        robotAccountCreate = v2_swagger_client.RobotCreate(
            name=robot_name,
            description=robot_desc,
            expires_at=expires_at,
            level="project",
            permissions=permission_list)

        client = self._get_client(**kwargs)
        data = []
        data, status_code, header = client.create_robot_with_http_info(
            robotAccountCreate)
        base._assert_status_code(expect_status_code, status_code)
        base._assert_status_code(201, status_code)
        return base._get_id_from_header(header), data