Merge branch 'master' into fix/pluggable_scanner_improvments

This commit is contained in:
Steven Zou 2019-10-23 13:31:39 +08:00
commit ae3ff228e1
7 changed files with 49 additions and 41 deletions

View File

@ -253,7 +253,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
dest_registry: rule.dest_registry, dest_registry: rule.dest_registry,
trigger: rule.trigger, trigger: rule.trigger,
deletion: rule.deletion, deletion: rule.deletion,
enabled: true, enabled: rule.enabled,
override: rule.override override: rule.override
}); });
let filtersArray = this.getFilterArray(rule); let filtersArray = this.getFilterArray(rule);

View File

@ -24,7 +24,7 @@
<div *ngIf="withReplicationJob" class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div *ngIf="withReplicationJob" class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="row flex-items-xs-between jobsRow"> <div class="row flex-items-xs-between jobsRow">
<h5 class="flex-items-xs-bottom option-left-down">{{'REPLICATION.REPLICATION_EXECUTIONS' | translate}}</h5> <h5 class="flex-items-xs-bottom option-left-down">{{'REPLICATION.REPLICATION_EXECUTIONS' | translate}}</h5>
<div class="row flex-items-xs-between flex-items-xs-bottom"> <div class="row flex-items-xs-between flex-items-xs-bottom fiter-task">
<div class="execution-select"> <div class="execution-select">
<div class="select filter-tag" [hidden]="!isOpenFilterTag"> <div class="select filter-tag" [hidden]="!isOpenFilterTag">
<select (change)="doFilterJob($event)"> <select (change)="doFilterJob($event)">

View File

@ -49,7 +49,10 @@
.row-right { .row-right {
margin-left: 564px; margin-left: 564px;
} }
.fiter-task {
margin-left: .4rem;
margin-top: .05rem;
}
.replication-row { .replication-row {
position: relative; position: relative;
} }

View File

@ -158,6 +158,12 @@ describe('RepositoryComponent (inline template)', () => {
let mockHasRetagImagePermission: boolean = true; let mockHasRetagImagePermission: boolean = true;
let mockHasDeleteImagePermission: boolean = true; let mockHasDeleteImagePermission: boolean = true;
let mockHasScanImagePermission: boolean = true; let mockHasScanImagePermission: boolean = true;
const permissions = [
{resource: USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE},
{resource: USERSTATICPERMISSION.REPOSITORY.KEY, action: USERSTATICPERMISSION.REPOSITORY.VALUE.PULL},
{resource: USERSTATICPERMISSION.REPOSITORY_TAG.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG.VALUE.DELETE},
{resource: USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.VALUE.CREATE},
];
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
@ -213,16 +219,10 @@ describe('RepositoryComponent (inline template)', () => {
spyLabels = spyOn(labelService, 'getGLabels').and.returnValues(of(mockLabels).pipe(delay(0))); spyLabels = spyOn(labelService, 'getGLabels').and.returnValues(of(mockLabels).pipe(delay(0)));
spyLabels1 = spyOn(labelService, 'getPLabels').and.returnValues(of(mockLabels1).pipe(delay(0))); spyLabels1 = spyOn(labelService, 'getPLabels').and.returnValues(of(mockLabels1).pipe(delay(0)));
spyOn(userPermissionService, "getPermission") spyOn(userPermissionService, "hasProjectPermissions")
.withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE ) .withArgs(compRepo.projectId, permissions )
.and.returnValue(of(mockHasAddLabelImagePermission)) .and.returnValue(of([mockHasAddLabelImagePermission, mockHasRetagImagePermission,
.withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY.KEY, USERSTATICPERMISSION.REPOSITORY.VALUE.PULL ) mockHasDeleteImagePermission, mockHasScanImagePermission]));
.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();
}); });
let originalTimeout; let originalTimeout;

View File

@ -112,6 +112,15 @@ describe("TagComponent (inline template)", () => {
let mockHasRetagImagePermission: boolean = true; let mockHasRetagImagePermission: boolean = true;
let mockHasDeleteImagePermission: boolean = true; let mockHasDeleteImagePermission: boolean = true;
let mockHasScanImagePermission: boolean = true; let mockHasScanImagePermission: boolean = true;
const mockErrorHandler = {
error: () => {}
};
const permissions = [
{resource: USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE},
{resource: USERSTATICPERMISSION.REPOSITORY.KEY, action: USERSTATICPERMISSION.REPOSITORY.VALUE.PULL},
{resource: USERSTATICPERMISSION.REPOSITORY_TAG.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG.VALUE.DELETE},
{resource: USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.VALUE.CREATE},
];
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
@ -141,6 +150,7 @@ describe("TagComponent (inline template)", () => {
{ provide: ScanningResultService, useClass: ScanningResultDefaultService }, { provide: ScanningResultService, useClass: ScanningResultDefaultService },
{ provide: LabelService, useClass: LabelDefaultService }, { provide: LabelService, useClass: LabelDefaultService },
{ provide: UserPermissionService, useClass: UserPermissionDefaultService }, { provide: UserPermissionService, useClass: UserPermissionDefaultService },
{ provide: mockErrorHandler, useValue: ErrorHandler },
{ provide: OperationService }, { provide: OperationService },
] ]
}).compileComponents(); }).compileComponents();
@ -169,15 +179,10 @@ describe("TagComponent (inline template)", () => {
let http: HttpClient; let http: HttpClient;
http = fixture.debugElement.injector.get(HttpClient); http = fixture.debugElement.injector.get(HttpClient);
spyScanner = spyOn(http, "get").and.returnValue(of(scannerMock)); spyScanner = spyOn(http, "get").and.returnValue(of(scannerMock));
spyOn(userPermissionService, "getPermission") spyOn(userPermissionService, "hasProjectPermissions")
.withArgs(comp.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE ) .withArgs(comp.projectId, permissions )
.and.returnValue(of(mockHasAddLabelImagePermission)) .and.returnValue(of([mockHasAddLabelImagePermission, mockHasRetagImagePermission,
.withArgs(comp.projectId, USERSTATICPERMISSION.REPOSITORY.KEY, USERSTATICPERMISSION.REPOSITORY.VALUE.PULL ) mockHasDeleteImagePermission, mockHasScanImagePermission]));
.and.returnValue(of(mockHasRetagImagePermission))
.withArgs(comp.projectId, USERSTATICPERMISSION.REPOSITORY_TAG.KEY, USERSTATICPERMISSION.REPOSITORY_TAG.VALUE.DELETE )
.and.returnValue(of(mockHasDeleteImagePermission))
.withArgs(comp.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.KEY, USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.VALUE.CREATE)
.and.returnValue(of(mockHasScanImagePermission));
labelService = fixture.debugElement.injector.get(LabelService); labelService = fixture.debugElement.injector.get(LabelService);

View File

@ -220,9 +220,6 @@ export class TagComponent implements OnInit, AfterViewInit {
} }
ngAfterViewInit() { ngAfterViewInit() {
if (!this.withAdmiral) {
this.getAllLabels();
}
} }
public get filterLabelPieceWidth() { public get filterLabelPieceWidth() {
@ -726,21 +723,24 @@ export class TagComponent implements OnInit, AfterViewInit {
return st !== VULNERABILITY_SCAN_STATUS.RUNNING; return st !== VULNERABILITY_SCAN_STATUS.RUNNING;
} }
getImagePermissionRule(projectId: number): void { getImagePermissionRule(projectId: number): void {
let hasAddLabelImagePermission = this.userPermissionService.getPermission(projectId, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, const permissions = [
USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE); {resource: USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE},
let hasRetagImagePermission = this.userPermissionService.getPermission(projectId, {resource: USERSTATICPERMISSION.REPOSITORY.KEY, action: USERSTATICPERMISSION.REPOSITORY.VALUE.PULL},
USERSTATICPERMISSION.REPOSITORY.KEY, USERSTATICPERMISSION.REPOSITORY.VALUE.PULL); {resource: USERSTATICPERMISSION.REPOSITORY_TAG.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG.VALUE.DELETE},
let hasDeleteImagePermission = this.userPermissionService.getPermission(projectId, {resource: USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.KEY, action: USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.VALUE.CREATE},
USERSTATICPERMISSION.REPOSITORY_TAG.KEY, USERSTATICPERMISSION.REPOSITORY_TAG.VALUE.DELETE); ];
let hasScanImagePermission = this.userPermissionService.getPermission(projectId, this.userPermissionService.hasProjectPermissions(this.projectId, permissions).subscribe((results: Array<boolean>) => {
USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.KEY, USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.VALUE.CREATE); this.hasAddLabelImagePermission = results[0];
forkJoin(hasAddLabelImagePermission, hasRetagImagePermission, hasDeleteImagePermission, hasScanImagePermission) this.hasRetagImagePermission = results[1];
.subscribe(permissions => { this.hasDeleteImagePermission = results[2];
this.hasAddLabelImagePermission = permissions[0] as boolean; this.hasScanImagePermission = results[3];
this.hasRetagImagePermission = permissions[1] as boolean; // only has label permission
this.hasDeleteImagePermission = permissions[2] as boolean; if (this.hasAddLabelImagePermission) {
this.hasScanImagePermission = permissions[3] as boolean; if (!this.withAdmiral) {
}, error => this.errorHandler.error(error)); this.getAllLabels();
}
}
}, error => this.errorHandler.error(error));
} }
// Trigger scan // Trigger scan
scanNow(t: Tag[]): void { scanNow(t: Tag[]): void {

View File

@ -54,6 +54,6 @@ Generate And Return Secret
Retry Element Click ${more_btn} Retry Element Click ${more_btn}
Retry Element Click ${generate_secret_btn} Retry Element Click ${generate_secret_btn}
Retry Double Keywords When Error Retry Element Click ${confirm_btn} Retry Wait Until Page Not Contains Element ${confirm_btn} Retry Double Keywords When Error Retry Element Click ${confirm_btn} Retry Wait Until Page Not Contains Element ${confirm_btn}
Retry Wait Until Page Contains generate CLI secret success Retry Wait Until Page Contains Cli secret setting is successful
${secret}= Get Secrete By API ${url} ${secret}= Get Secrete By API ${url}
[Return] ${secret} [Return] ${secret}