mirror of
https://github.com/goharbor/harbor.git
synced 2024-08-19 02:22:48 +02:00
Merge pull request #6918 from jwangyangls/privilege_escalation
fixed_ciIssue
This commit is contained in:
commit
faaa531558
|
@ -28,6 +28,8 @@ import { LabelDefaultService, LabelService } from "../service/label.service";
|
||||||
import { OperationService } from "../operation/operation.service";
|
import { OperationService } from "../operation/operation.service";
|
||||||
import { ProjectDefaultService, ProjectService, RetagDefaultService, RetagService } from "../service";
|
import { ProjectDefaultService, ProjectService, RetagDefaultService, RetagService } from "../service";
|
||||||
import { UserPermissionDefaultService, UserPermissionService } from "../service/permission.service";
|
import { UserPermissionDefaultService, UserPermissionService } from "../service/permission.service";
|
||||||
|
import { USERSTATICPERMISSION } from "../service/permission-static";
|
||||||
|
import { of } from "rxjs";
|
||||||
|
|
||||||
|
|
||||||
class RouterStub {
|
class RouterStub {
|
||||||
|
@ -40,6 +42,7 @@ describe('RepositoryComponent (inline template)', () => {
|
||||||
let fixture: ComponentFixture<RepositoryComponent>;
|
let fixture: ComponentFixture<RepositoryComponent>;
|
||||||
let repositoryService: RepositoryService;
|
let repositoryService: RepositoryService;
|
||||||
let systemInfoService: SystemInfoService;
|
let systemInfoService: SystemInfoService;
|
||||||
|
let userPermissionService: UserPermissionService;
|
||||||
let tagService: TagService;
|
let tagService: TagService;
|
||||||
let labelService: LabelService;
|
let labelService: LabelService;
|
||||||
|
|
||||||
|
@ -150,7 +153,10 @@ describe('RepositoryComponent (inline template)', () => {
|
||||||
systemInfoEndpoint: '/api/systeminfo/testing',
|
systemInfoEndpoint: '/api/systeminfo/testing',
|
||||||
targetBaseEndpoint: '/api/tag/testing'
|
targetBaseEndpoint: '/api/tag/testing'
|
||||||
};
|
};
|
||||||
|
let mockHasAddLabelImagePermission: boolean = true;
|
||||||
|
let mockHasRetagImagePermission: boolean = true;
|
||||||
|
let mockHasDeleteImagePermission: boolean = true;
|
||||||
|
let mockHasScanImagePermission: boolean = true;
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -197,6 +203,7 @@ describe('RepositoryComponent (inline template)', () => {
|
||||||
repositoryService = fixture.debugElement.injector.get(RepositoryService);
|
repositoryService = fixture.debugElement.injector.get(RepositoryService);
|
||||||
systemInfoService = fixture.debugElement.injector.get(SystemInfoService);
|
systemInfoService = fixture.debugElement.injector.get(SystemInfoService);
|
||||||
tagService = fixture.debugElement.injector.get(TagService);
|
tagService = fixture.debugElement.injector.get(TagService);
|
||||||
|
userPermissionService = fixture.debugElement.injector.get(UserPermissionService);
|
||||||
labelService = fixture.debugElement.injector.get(LabelService);
|
labelService = fixture.debugElement.injector.get(LabelService);
|
||||||
|
|
||||||
spyRepos = spyOn(repositoryService, 'getRepositories').and.returnValues(Promise.resolve(mockRepo));
|
spyRepos = spyOn(repositoryService, 'getRepositories').and.returnValues(Promise.resolve(mockRepo));
|
||||||
|
@ -205,6 +212,16 @@ describe('RepositoryComponent (inline template)', () => {
|
||||||
|
|
||||||
spyLabels = spyOn(labelService, 'getGLabels').and.returnValues(Promise.resolve(mockLabels));
|
spyLabels = spyOn(labelService, 'getGLabels').and.returnValues(Promise.resolve(mockLabels));
|
||||||
spyLabels1 = spyOn(labelService, 'getPLabels').and.returnValues(Promise.resolve(mockLabels1));
|
spyLabels1 = spyOn(labelService, 'getPLabels').and.returnValues(Promise.resolve(mockLabels1));
|
||||||
|
spyOn(userPermissionService, "getPermission")
|
||||||
|
.withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE )
|
||||||
|
.and.returnValue(of(mockHasAddLabelImagePermission))
|
||||||
|
.withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY.KEY, USERSTATICPERMISSION.REPOSITORY.VALUE.PULL )
|
||||||
|
.and.returnValue(of(mockHasRetagImagePermission))
|
||||||
|
.withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG.KEY, USERSTATICPERMISSION.REPOSITORY_TAG.VALUE.DELETE )
|
||||||
|
.and.returnValue(of(mockHasDeleteImagePermission))
|
||||||
|
.withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.KEY
|
||||||
|
, USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.VALUE.CREATE)
|
||||||
|
.and.returnValue(of(mockHasScanImagePermission));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user