mirror of
https://github.com/goharbor/harbor
synced 2025-04-16 16:36:45 +00:00
rename permission of robot account (#14150)
* rename permission of robot account fixes #14060 Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
9cd33ac5e7
commit
885a268268
|
@ -3807,7 +3807,7 @@ definitions:
|
|||
permissions:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Permission'
|
||||
$ref: '#/definitions/RobotPermission'
|
||||
creation_time:
|
||||
type: string
|
||||
format: date-time
|
||||
|
@ -3842,7 +3842,7 @@ definitions:
|
|||
permissions:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Permission'
|
||||
$ref: '#/definitions/RobotPermission'
|
||||
RobotCreated:
|
||||
type: object
|
||||
description: The response for robot account creation.
|
||||
|
@ -3872,7 +3872,7 @@ definitions:
|
|||
secret:
|
||||
type: string
|
||||
description: The secret of the robot
|
||||
Permission:
|
||||
RobotPermission:
|
||||
type: object
|
||||
properties:
|
||||
kind:
|
||||
|
|
|
@ -3,13 +3,14 @@ import { Project } from "../../../../ng-swagger-gen/models/project";
|
|||
import { clone, CustomComparator } from "../../../lib/utils/utils";
|
||||
import { ClrDatagridComparatorInterface } from "@clr/angular";
|
||||
import { Router } from "@angular/router";
|
||||
import { Permission } from "../../../../ng-swagger-gen/models/permission";
|
||||
|
||||
import {
|
||||
ACTION_RESOURCE_I18N_MAP,
|
||||
FrontAccess,
|
||||
FrontProjectForAdd, INITIAL_ACCESSES,
|
||||
PermissionsKinds
|
||||
} from "../system-robot-util";
|
||||
import { RobotPermission } from "../../../../ng-swagger-gen/models";
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-all-projects',
|
||||
|
@ -19,7 +20,7 @@ import {
|
|||
export class ListAllProjectsComponent implements OnInit {
|
||||
cachedAllProjects: Project[];
|
||||
i18nMap = ACTION_RESOURCE_I18N_MAP;
|
||||
permissionsForAdd: Permission[] = [];
|
||||
permissionsForAdd: RobotPermission[] = [];
|
||||
selectedRow: FrontProjectForAdd[] = [];
|
||||
timeComparator: ClrDatagridComparatorInterface<Project> = new CustomComparator<Project>("creation_time", "date");
|
||||
projects: FrontProjectForAdd[] = [];
|
||||
|
|
|
@ -5,8 +5,8 @@ import { ClarityModule } from "@clr/angular";
|
|||
import { TranslateModule } from "@ngx-translate/core";
|
||||
import { RouterTestingModule } from "@angular/router/testing";
|
||||
import { Project } from "../../../../ng-swagger-gen/models/project";
|
||||
import { Permission } from "../../../../ng-swagger-gen/models/permission";
|
||||
import { Action, PermissionsKinds, Resource } from "../system-robot-util";
|
||||
import { RobotPermission } from "../../../../ng-swagger-gen/models";
|
||||
|
||||
describe('ProjectsModalComponent', () => {
|
||||
let component: ProjectsModalComponent;
|
||||
|
@ -19,7 +19,7 @@ describe('ProjectsModalComponent', () => {
|
|||
project_id: 2,
|
||||
name: 'project2'
|
||||
};
|
||||
const permissions: Permission[] = [
|
||||
const permissions: RobotPermission[] = [
|
||||
{
|
||||
kind: PermissionsKinds.PROJECT,
|
||||
namespace: project1.name,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { Permission } from "../../../../ng-swagger-gen/models/permission";
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Project } from "../../../../ng-swagger-gen/models/project";
|
||||
import { Router } from "@angular/router";
|
||||
import { ACTION_RESOURCE_I18N_MAP } from "../system-robot-util";
|
||||
import { RobotPermission } from "../../../../ng-swagger-gen/models";
|
||||
|
||||
@Component({
|
||||
selector: 'app-projects-modal',
|
||||
|
@ -13,7 +13,7 @@ export class ProjectsModalComponent implements OnInit {
|
|||
projectsModalOpened: boolean = false;
|
||||
robotName: string;
|
||||
cachedAllProjects: Project[];
|
||||
permissions: Permission[] = [];
|
||||
permissions: RobotPermission[] = [];
|
||||
i18nMap = ACTION_RESOURCE_I18N_MAP;
|
||||
constructor(private router: Router) { }
|
||||
|
||||
|
@ -22,7 +22,7 @@ export class ProjectsModalComponent implements OnInit {
|
|||
close() {
|
||||
this.projectsModalOpened = false;
|
||||
}
|
||||
getProject(p: Permission): Project {
|
||||
getProject(p: RobotPermission): Project {
|
||||
if (this.cachedAllProjects && this.cachedAllProjects.length) {
|
||||
for (let i = 0; i < this.cachedAllProjects.length; i++) {
|
||||
if (p.namespace === this.cachedAllProjects[i].name) {
|
||||
|
|
|
@ -14,7 +14,6 @@ import {
|
|||
PermissionsKinds
|
||||
} from "./system-robot-util";
|
||||
import { ProjectsModalComponent } from "./projects-modal/projects-modal.component";
|
||||
import { Permission } from "../../../ng-swagger-gen/models/permission";
|
||||
import { forkJoin, Observable, of, Subscription } from "rxjs";
|
||||
import { FilterComponent } from "../../lib/components/filter/filter.component";
|
||||
import { ProjectService } from "../../../ng-swagger-gen/services/project.service";
|
||||
|
@ -28,6 +27,7 @@ import { OperationService } from "../../lib/components/operation/operation.servi
|
|||
import { Project } from "../../../ng-swagger-gen/models/project";
|
||||
import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { RobotPermission } from "../../../ng-swagger-gen/models";
|
||||
const FIRST_PROJECTS_PAGE_SIZE: number = 100;
|
||||
@Component({
|
||||
selector: 'system-robot-accounts',
|
||||
|
@ -236,7 +236,7 @@ export class SystemRobotAccountsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
}
|
||||
}
|
||||
getProjects(r: FrontRobot): Permission[] {
|
||||
getProjects(r: FrontRobot): RobotPermission[] {
|
||||
const arr = [];
|
||||
if (r && r.permissions && r.permissions.length) {
|
||||
for (let i = 0 ; i < r.permissions.length; i++) {
|
||||
|
@ -248,7 +248,7 @@ export class SystemRobotAccountsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
return arr;
|
||||
}
|
||||
openProjectModal(permissions: Permission[], robotName: string) {
|
||||
openProjectModal(permissions: RobotPermission[], robotName: string) {
|
||||
this.projectsModalComponent.projectsModalOpened = true;
|
||||
this.projectsModalComponent.robotName = robotName;
|
||||
this.projectsModalComponent.permissions = permissions;
|
||||
|
|
|
@ -14,9 +14,9 @@ type Robot struct {
|
|||
|
||||
// ToSwagger ...
|
||||
func (r *Robot) ToSwagger() *models.Robot {
|
||||
perms := []*models.Permission{}
|
||||
perms := []*models.RobotPermission{}
|
||||
for _, p := range r.Permissions {
|
||||
temp := &models.Permission{}
|
||||
temp := &models.RobotPermission{}
|
||||
lib.JSONCopy(temp, p)
|
||||
perms = append(perms, temp)
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ func (rAPI *robotAPI) requireAccess(ctx context.Context, level string, projectID
|
|||
}
|
||||
|
||||
// more validation
|
||||
func (rAPI *robotAPI) validate(d int64, level string, permissions []*models.Permission) error {
|
||||
func (rAPI *robotAPI) validate(d int64, level string, permissions []*models.RobotPermission) error {
|
||||
if !isValidDuration(d) {
|
||||
return errors.New(nil).WithMessage("bad request error duration input: %d", d).WithCode(errors.BadRequestCode)
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class Robot(base.Base, object):
|
|||
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)
|
||||
robotaccountPermissions = v2_swagger_client.RobotPermission(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, duration=duration, level="project", permissions = permission_list)
|
||||
|
|
|
@ -204,7 +204,7 @@ class TestRobotAccount(unittest.TestCase):
|
|||
with created_user(TestRobotAccount.user_ra_password, _teardown = False) as (user_id, username):
|
||||
with created_project(metadata={"public": "false"}, user_id=user_id, _teardown = False) as (project_id, project_name):
|
||||
project_access_list.append(dict(project_name = project_name, project_id = project_id, check_list = check_list[i]))
|
||||
robot_account_Permissions = v2_swagger_client.Permission(kind = "project", namespace = project_name, access = access_list_list[i])
|
||||
robot_account_Permissions = v2_swagger_client.RobotPermission(kind = "project", namespace = project_name, access = access_list_list[i])
|
||||
robot_account_Permissions_list.append(robot_account_Permissions)
|
||||
|
||||
#3. Create a system robot account has permission for those projects;
|
||||
|
@ -301,7 +301,7 @@ class TestRobotAccount(unittest.TestCase):
|
|||
#12. List system robot account, then add a new project to the system robot account project permission list;
|
||||
self.robot.list_robot(**ADMIN_CLIENT)
|
||||
project_for_del_id, project_for_del_name = self.project.create_project(metadata = {"public": "true"}, **ADMIN_CLIENT)
|
||||
robot_account_Permissions = v2_swagger_client.Permission(kind = "project", namespace = project_for_del_name, access = access_list_list[0])
|
||||
robot_account_Permissions = v2_swagger_client.RobotPermission(kind = "project", namespace = project_for_del_name, access = access_list_list[0])
|
||||
robot_account_Permissions_list.append(robot_account_Permissions)
|
||||
self.robot.update_system_robot_account(system_robot_account_id, system_robot_account.name, robot_account_Permissions_list, **ADMIN_CLIENT)
|
||||
self.robot.list_robot(**ADMIN_CLIENT)
|
||||
|
@ -339,7 +339,7 @@ class TestRobotAccount(unittest.TestCase):
|
|||
#20. Add a system robot account with all projects coverd;
|
||||
all_true_access_list= self.robot.create_access_list( [True] * 10 )
|
||||
robot_account_Permissions_list = []
|
||||
robot_account_Permissions = v2_swagger_client.Permission(kind = "project", namespace = "*", access = all_true_access_list)
|
||||
robot_account_Permissions = v2_swagger_client.RobotPermission(kind = "project", namespace = "*", access = all_true_access_list)
|
||||
robot_account_Permissions_list.append(robot_account_Permissions)
|
||||
_, system_robot_account_cover_all = self.robot.create_system_robot(robot_account_Permissions_list, 300)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user