diff --git a/security-c4po-angular/src/app/app.module.ts b/security-c4po-angular/src/app/app.module.ts index 3d73de7..bc93689 100644 --- a/security-c4po-angular/src/app/app.module.ts +++ b/security-c4po-angular/src/app/app.module.ts @@ -12,7 +12,7 @@ import { NbSelectModule, NbThemeModule, NbOverlayContainerAdapter, - NbDialogModule, + NbDialogModule, NbMenuModule, } from '@nebular/theme'; import {TranslateLoader, TranslateModule} from '@ngx-translate/core'; import {HttpClient, HttpClientModule} from '@angular/common/http'; @@ -58,6 +58,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms'; FontAwesomeModule, BrowserAnimationsModule, ThemeModule.forRoot(), + NbMenuModule.forRoot(), NbSelectModule, NgxsModule.forRoot([SessionState, ProjectState], {developmentMode: !environment.production}), NgxsLoggerPluginModule.forRoot({developmentMode: !environment.production}), diff --git a/security-c4po-angular/src/app/common-app.module.ts b/security-c4po-angular/src/app/common-app.module.ts index f9b32a8..6415f6c 100644 --- a/security-c4po-angular/src/app/common-app.module.ts +++ b/security-c4po-angular/src/app/common-app.module.ts @@ -7,7 +7,7 @@ import {FontAwesomeModule} from '@fortawesome/angular-fontawesome'; import {FlexLayoutModule, FlexModule} from '@angular/flex-layout'; import {MomentModule} from 'ngx-moment'; import {NotificationService} from '@shared/services/toaster-service/notification.service'; -import {NbOverlayContainerAdapter, NbSpinnerModule, NbToastrModule} from '@nebular/theme'; +import {NbMenuModule, NbOverlayContainerAdapter, NbSpinnerModule, NbToastrModule} from '@nebular/theme'; import {ThemeModule} from '@assets/@theme/theme.module'; import {LoadingSpinnerComponent} from '@shared/widgets/loading-spinner/loading-spinner.component'; @@ -26,6 +26,7 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { FontAwesomeModule, FlexLayoutModule, ThemeModule.forRoot(), + NbMenuModule.forRoot(), FlexModule, HttpClientModule, TranslateModule.forChild({ diff --git a/security-c4po-angular/src/app/header/header.component.html b/security-c4po-angular/src/app/header/header.component.html index 2b64594..27306f8 100644 --- a/security-c4po-angular/src/app/header/header.component.html +++ b/security-c4po-angular/src/app/header/header.component.html @@ -11,6 +11,7 @@
+ - + + +
+ + + + {{'languageKeys.' + language | translate}} + + +
+
+ + + + + +
-
- - - - {{'languageKeys.' + language | translate}} - - -
diff --git a/security-c4po-angular/src/app/header/header.component.spec.ts b/security-c4po-angular/src/app/header/header.component.spec.ts index cf48777..02544a2 100644 --- a/security-c4po-angular/src/app/header/header.component.spec.ts +++ b/security-c4po-angular/src/app/header/header.component.spec.ts @@ -3,17 +3,30 @@ import {ComponentFixture, TestBed} from '@angular/core/testing'; import {HeaderComponent} from './header.component'; import {CommonModule} from '@angular/common'; import {FontAwesomeTestingModule} from '@fortawesome/angular-fontawesome/testing'; -import {NbActionsModule, NbSelectModule} from '@nebular/theme'; +import {NbActionsModule, NbMenuModule, NbMenuService, NbSelectModule} from '@nebular/theme'; import {ThemeModule} from '@assets/@theme/theme.module'; import {TranslateLoader, TranslateModule} from '@ngx-translate/core'; import {HttpLoaderFactory} from '../common-app.module'; import {HttpClient} from '@angular/common/http'; import {RouterTestingModule} from '@angular/router/testing'; import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {NgxsModule, Store} from '@ngxs/store'; +import {KeycloakService} from 'keycloak-angular'; +import {SESSION_STATE_NAME, SessionState, SessionStateModel} from '@shared/stores/session-state/session-state'; +import {User} from '@shared/models/user.model'; + +const DESIRED_STORE_STATE_SESSION: SessionStateModel = { + userAccount: { + ...new User('ttt', 'test', 'user', 'default.user@test.de', 'en-US'), + id: '11c47c56-3bcd-45f1-a05b-c197dbd33110' + }, + isAuthenticated: true +}; describe('HeaderComponent', () => { let component: HeaderComponent; let fixture: ComponentFixture; + let store: Store; beforeEach(async () => { await TestBed.configureTestingModule({ @@ -26,6 +39,7 @@ describe('HeaderComponent', () => { NbSelectModule, FontAwesomeTestingModule, HttpClientTestingModule, + NbMenuModule, ThemeModule.forRoot(), TranslateModule.forRoot({ loader: { @@ -34,14 +48,23 @@ describe('HeaderComponent', () => { deps: [HttpClient] } }), - RouterTestingModule.withRoutes([]) + RouterTestingModule.withRoutes([]), + NgxsModule.forRoot([SessionState]) + ], + providers: [ + NbMenuService, + KeycloakService ] - }) - .compileComponents(); + }).compileComponents(); }); beforeEach(() => { fixture = TestBed.createComponent(HeaderComponent); + store = TestBed.inject(Store); + store.reset({ + ...store.snapshot(), + [SESSION_STATE_NAME]: DESIRED_STORE_STATE_SESSION + }); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/security-c4po-angular/src/app/header/header.component.ts b/security-c4po-angular/src/app/header/header.component.ts index 23ece2a..bd5ccd6 100644 --- a/security-c4po-angular/src/app/header/header.component.ts +++ b/security-c4po-angular/src/app/header/header.component.ts @@ -1,19 +1,29 @@ -import {Component, OnDestroy, OnInit} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import * as FA from '@fortawesome/free-solid-svg-icons'; -import {NbThemeService} from '@nebular/theme'; +import {NbMenuItem, NbMenuService, NbThemeService} from '@nebular/theme'; import {map} from 'rxjs/operators'; import {GlobalTitlesVariables} from '@shared/config/global-variables'; import {TranslateService} from '@ngx-translate/core'; import {UntilDestroy, untilDestroyed} from '@ngneat/until-destroy'; +import {KeycloakService} from 'keycloak-angular'; +import {Store} from '@ngxs/store'; +import {ResetSession} from '@shared/stores/session-state/session-state.actions'; +import {UserService} from '@shared/services/user-service/user.service'; +import {User} from '@shared/models/user.model'; +import {BehaviorSubject} from 'rxjs'; +import {Route} from '@shared/models/route.enum'; +import {environment} from '../../environments/environment'; +import {Router} from '@angular/router'; -@UntilDestroy() @Component({ selector: 'app-header', templateUrl: './header.component.html', styleUrls: ['./header.component.scss'] }) -export class HeaderComponent implements OnInit{ +@UntilDestroy() +export class HeaderComponent implements OnInit { + // HTML only readonly fa = FA; readonly SECURITYC4PO_TITLE: string = GlobalTitlesVariables.SECURITYC4PO_TITLE; @@ -21,16 +31,59 @@ export class HeaderComponent implements OnInit{ languages = ['en-US', 'de-DE']; selectedLanguage = ''; - constructor(private themeService: NbThemeService, private translateService: TranslateService) { } + // User Menu Properties + userPictureOnly = false; + user: BehaviorSubject = new BehaviorSubject(null); + userMenu: NbMenuItem[] = [{title: '', pathMatch: 'prefix'}]; + readonly FALLBACK_IMG = 'assets/images/demo/anon-user-icon.png'; + + constructor( + private store: Store, + private router: Router, + private themeService: NbThemeService, + private translateService: TranslateService, + private menuService: NbMenuService, + private userService: UserService, + protected keycloakService: KeycloakService) { + } ngOnInit(): void { + // Handle theme selection this.themeService.onThemeChange() .pipe( - map(({ name }) => name), + map(({name}) => name), untilDestroyed(this), - ) - .subscribe(themeName => this.currentTheme = themeName); + ).subscribe(themeName => this.currentTheme = themeName); + this.selectedLanguage = this.translateService.currentLang; + // Load user profile + this.userService.loadUserProfile().pipe( + untilDestroyed(this) + ).subscribe({ + next: (user: User) => { + this.user.next(user); + }, + error: err => { + console.error(err); + } + }); + // Handle user profile manu selection + this.menuService.onItemClick() + .pipe( + untilDestroyed(this) + ) + .subscribe((menuBag) => { + if (menuBag.item.pathMatch === 'prefix') { + this.onClickLogOut(); + } + }); + // Setup stream to translate menu item + this.translateService.stream('global.action.logout') + .pipe( + untilDestroyed(this) + ).subscribe((text: string) => { + this.userMenu[0].title = text; + }); } // HTML only @@ -46,6 +99,22 @@ export class HeaderComponent implements OnInit{ } } + onClickLogOut(): void { + // ToDo: Redirect user to Landing page from Issue #142 https://github.com/Marcel-Haag/security-c4po/issues/143 + // ToDo: Fix Redirect URI in Keycloak Setting + this.keycloakService.logout(`http://auth-server/realms/${environment.keycloakclientId}/protocol/openid-connect/logout`).then(() => { + // Route user back to default page + this.router.navigate([Route.HOME]).then(() => { + // Reset User props from store + this.store.dispatch(new ResetSession()); + }, err => { + console.error(err); + }); + }, err => { + console.error(err); + }); + } + onClickLanguage(language: string): void { this.translateService.use(language); } diff --git a/security-c4po-angular/src/app/header/header.module.ts b/security-c4po-angular/src/app/header/header.module.ts index 99eb429..a310865 100644 --- a/security-c4po-angular/src/app/header/header.module.ts +++ b/security-c4po-angular/src/app/header/header.module.ts @@ -1,7 +1,14 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {HeaderComponent} from './header.component'; -import {NbActionsModule, NbButtonModule, NbCardModule, NbSelectModule} from '@nebular/theme'; +import { + NbActionsModule, + NbButtonModule, + NbCardModule, + NbContextMenuModule, NbMenuModule, + NbSelectModule, + NbUserModule +} from '@nebular/theme'; import {FontAwesomeModule} from '@fortawesome/angular-fontawesome'; import {FlexLayoutModule} from '@angular/flex-layout'; import {TranslateModule} from '@ngx-translate/core'; @@ -13,16 +20,20 @@ import {TranslateModule} from '@ngx-translate/core'; exports: [ HeaderComponent ], - imports: [ - CommonModule, - NbButtonModule, - FontAwesomeModule, - NbCardModule, - NbActionsModule, - FlexLayoutModule, - NbSelectModule, - TranslateModule - ] + imports: [ + CommonModule, + NbButtonModule, + FontAwesomeModule, + NbCardModule, + NbActionsModule, + FlexLayoutModule, + NbSelectModule, + TranslateModule, + NbUserModule, + NbContextMenuModule + ], + providers: [ + ] }) export class HeaderModule { } diff --git a/security-c4po-angular/src/app/login/login.component.spec.ts b/security-c4po-angular/src/app/login/login.component.spec.ts index 121a25d..fd2ee06 100644 --- a/security-c4po-angular/src/app/login/login.component.spec.ts +++ b/security-c4po-angular/src/app/login/login.component.spec.ts @@ -81,7 +81,6 @@ describe('LoginComponent', () => { ...store.snapshot(), [SESSION_STATE_NAME]: DESIRED_STORE_STATE_SESSION }); - fixture = TestBed.createComponent(LoginComponent); component = fixture.componentInstance; httpMock = TestBed.inject(HttpTestingController); diff --git a/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.html b/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.html index 66c9acb..6c51964 100644 --- a/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.html +++ b/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.html @@ -1,5 +1,5 @@
- +
diff --git a/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.ts b/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.ts index 6089dbb..6350c31 100644 --- a/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.ts +++ b/security-c4po-angular/src/app/objective-overview/objective-categories/objective-categories.component.ts @@ -54,10 +54,10 @@ export class ObjectiveCategoriesComponent implements OnInit, OnDestroy { category.selected = false; }); menuBag.item.selected = true; - this.store.dispatch(new ChangeCategory(this.selectedCategory)); + if (this.selectedCategory) { + this.store.dispatch(new ChangeCategory(this.selectedCategory)); + } }); - - } private initTranslation(): void { diff --git a/security-c4po-angular/src/app/objective-overview/objective-overview.module.ts b/security-c4po-angular/src/app/objective-overview/objective-overview.module.ts index 84946c4..1528af1 100644 --- a/security-c4po-angular/src/app/objective-overview/objective-overview.module.ts +++ b/security-c4po-angular/src/app/objective-overview/objective-overview.module.ts @@ -37,7 +37,6 @@ import {CommentWidgetModule} from '@shared/widgets/comment-widget/comment-widget CommonAppModule, NbLayoutModule, NbCardModule, - NbMenuModule.forRoot(), NbButtonModule, // nbTooltip crashes app right now if used in component, // workaround: use title in html for now @@ -46,7 +45,6 @@ import {CommentWidgetModule} from '@shared/widgets/comment-widget/comment-widget TranslateModule, StatusTagModule, RouterModule, - NbMenuModule, FormsModule, NbListModule, FontAwesomeModule, @@ -57,7 +55,8 @@ import {CommentWidgetModule} from '@shared/widgets/comment-widget/comment-widget ObjectiveOverviewRoutingModule, // Table Widgets FindigWidgetModule, - CommentWidgetModule + CommentWidgetModule, + NbMenuModule ], exports: [ ObjectiveHeaderComponent, diff --git a/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.html b/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.html index 128d54c..fa5dd94 100644 --- a/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.html +++ b/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.html @@ -25,7 +25,7 @@ status="success" [disabled]="!pentestStatusChanged() || !pentestHasFindingsOrComments()" title="{{ 'global.action.save' | translate }}" - (click)="onClickCompletePentestAndRouteBack()"> + (click)="onClickCompletePentest()"> {{ 'global.action.complete' | translate }} diff --git a/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.ts b/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.ts index 3841a15..d1e4a15 100644 --- a/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.ts +++ b/security-c4po-angular/src/app/pentest/pentest-header/pentest-header.component.ts @@ -95,7 +95,7 @@ export class PentestHeaderComponent implements OnInit, OnDestroy { ).finally(); } - onClickCompletePentestAndRouteBack(): void { + onClickCompletePentest(): void { // Update existing Pentest this.pentest$.next({...this.pentest$.getValue(), status: PentestStatus.COMPLETED, timeSpent: this.currentTimeSpent}); this.updatePentest(); @@ -107,11 +107,11 @@ export class PentestHeaderComponent implements OnInit, OnDestroy { next: (pentest: Pentest) => { this.store.dispatch(new ChangePentest(pentest)); this.initialTimeSpent = pentest.timeSpent; - this.notificationService.showPopup('pentest.popup.update.success', PopupType.SUCCESS); + this.notificationService.showPopup('pentest.popup.complete.success', PopupType.SUCCESS); }, error: err => { console.log(err); - this.notificationService.showPopup('pentest.popup.update.failed', PopupType.FAILURE); + this.notificationService.showPopup('pentest.popup.complete.failed', PopupType.FAILURE); } }); } diff --git a/security-c4po-angular/src/assets/i18n/de-DE.json b/security-c4po-angular/src/assets/i18n/de-DE.json index ecaf71c..161496a 100644 --- a/security-c4po-angular/src/assets/i18n/de-DE.json +++ b/security-c4po-angular/src/assets/i18n/de-DE.json @@ -1,6 +1,7 @@ { "global": { "action.login": "Einloggen", + "action.logout": "Ausloggen", "action.retry": "Erneut Versuchen", "action.info": "Info", "action.save": "Speichern", @@ -233,6 +234,8 @@ "initial.save.failed": "Initialer Pentest konnte nicht aufgesetzt werden", "save.success": "Pentest erfolgreich gespeichert", "save.failed": "Pentest konnte nicht gespeichert werden", + "complete.success": "Pentest erfolgreich vervollständigt", + "complete.failed": "Pentest konnte nicht vervollständigt werden", "update.success": "Pentest erfolgreich aktualisiert", "update.failed": "Pentest konnte nicht aktualisiert werden", "delete.success": "Pentest erfolgreich gelöscht", diff --git a/security-c4po-angular/src/assets/i18n/en-US.json b/security-c4po-angular/src/assets/i18n/en-US.json index afd7e66..a77c870 100644 --- a/security-c4po-angular/src/assets/i18n/en-US.json +++ b/security-c4po-angular/src/assets/i18n/en-US.json @@ -1,6 +1,7 @@ { "global": { "action.login": "Login", + "action.logout": "Logout", "action.retry": "Try again", "action.info": "Info", "action.confirm": "Confirm", @@ -233,6 +234,8 @@ "initial.save.failed": "Initial Pentest could not be setup", "save.success": "Pentest saved successfully", "save.failed": "Pentest could not be saved", + "complete.success": "Pentest completed successfully", + "complete.failed": "Pentest could not be completed", "update.success": "Pentest updated successfully", "update.failed": "Pentest could not be updated", "delete.success": "Pentest deleted successfully", diff --git a/security-c4po-angular/src/assets/images/demo/anon-user-icon.png b/security-c4po-angular/src/assets/images/demo/anon-user-icon.png new file mode 100644 index 0000000..991d63b Binary files /dev/null and b/security-c4po-angular/src/assets/images/demo/anon-user-icon.png differ diff --git a/security-c4po-angular/src/shared/modules/comment-dialog/comment-dialog.component.spec.ts b/security-c4po-angular/src/shared/modules/comment-dialog/comment-dialog.component.spec.ts index 0b919bb..b185913 100644 --- a/security-c4po-angular/src/shared/modules/comment-dialog/comment-dialog.component.spec.ts +++ b/security-c4po-angular/src/shared/modules/comment-dialog/comment-dialog.component.spec.ts @@ -133,8 +133,7 @@ export const createSpyObj = (baseName, methodNames): { [key: string]: Mock export const mockComment: Comment = { id: '11-22-33', title: 'Test Finding', - description: 'Test Description', - relatedFindings: ['68c47c56-3bcd-45f1-a05b-c197dbd33224'] + description: 'Test Description' }; export const mockedCommentDialogData = { @@ -164,19 +163,6 @@ export const mockedCommentDialogData = { errors: [ {errorCode: 'required', translationKey: 'comment.validationMessage.descriptionRequired'} ] - }, - commentRelatedFindings: { - fieldName: 'commentRelatedFindings', - type: 'text', - labelKey: 'comment.relatedFindings.label', - placeholder: 'comment.relatedFindingsPlaceholder', - controlsConfig: [ - {value: mockComment ? mockComment.relatedFindings : [], disabled: false}, - [] - ], - errors: [ - {errorCode: 'required', translationKey: 'finding.validationMessage.relatedFindings'} - ] } }, options: [ diff --git a/security-c4po-angular/src/shared/modules/comment-dialog/service/comment-dialog.service.mock.ts b/security-c4po-angular/src/shared/modules/comment-dialog/service/comment-dialog.service.mock.ts index aa90573..853f3ec 100644 --- a/security-c4po-angular/src/shared/modules/comment-dialog/service/comment-dialog.service.mock.ts +++ b/security-c4po-angular/src/shared/modules/comment-dialog/service/comment-dialog.service.mock.ts @@ -2,7 +2,7 @@ import {CommentDialogService} from '@shared/modules/comment-dialog/service/comme import {ComponentType} from '@angular/cdk/overlay'; import {NbDialogConfig} from '@nebular/theme'; import {Observable, of} from 'rxjs'; -import {Comment, RelatedFindingOption} from '@shared/models/comment.model'; +import {Comment} from '@shared/models/comment.model'; export class CommentDialogServiceMock implements Required { @@ -11,7 +11,6 @@ export class CommentDialogServiceMock implements Required openCommentDialog( componentOrTemplateRef: ComponentType, findingIds: [], - relatedFindings: RelatedFindingOption[], comment: Comment | undefined, config: Partial | string>> | undefined): Observable { return of(undefined); diff --git a/security-c4po-angular/src/shared/pipes/timer-duration.pipe.ts b/security-c4po-angular/src/shared/pipes/timer-duration.pipe.ts index 991567d..45d3363 100644 --- a/security-c4po-angular/src/shared/pipes/timer-duration.pipe.ts +++ b/security-c4po-angular/src/shared/pipes/timer-duration.pipe.ts @@ -18,7 +18,7 @@ export class TimerDurationPipe implements PipeTransform { let seconds: string | number = 0; if (time) { // tslint:disable-next-line:variable-name - const sec_num = parseInt(time, 10); // don't forget the second param + const sec_num = parseInt(time, 10); hours = Math.floor(sec_num / 3600); minutes = Math.floor((sec_num - (hours * 3600)) / 60); seconds = sec_num - (hours * 3600) - (minutes * 60); diff --git a/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerDocumentationTest.kt b/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerDocumentationTest.kt index d76f4df..13be660 100644 --- a/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerDocumentationTest.kt +++ b/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerDocumentationTest.kt @@ -81,9 +81,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { PayloadDocumentation.fieldWithPath("[].title").type(JsonFieldType.STRING) .description("The title of the requested comment"), PayloadDocumentation.fieldWithPath("[].description").type(JsonFieldType.STRING) - .description("The description number of the comment"), - PayloadDocumentation.fieldWithPath("[].relatedFindings").type(JsonFieldType.ARRAY) - .description("List of related Findings of the comment") + .description("The description number of the comment") ) ) ) @@ -93,7 +91,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { id = "ab62d365-1b1d-4da1-89bc-5496616e220f", title = "Found Bug", description = "OTG-INFO-002 Bug", - relatedFindings = emptyList() + attachments = emptyList() ) private fun getCommentsResponse() = listOf( @@ -133,9 +131,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { PayloadDocumentation.fieldWithPath("title").type(JsonFieldType.STRING) .description("The title of the requested comment"), PayloadDocumentation.fieldWithPath("description").type(JsonFieldType.STRING) - .description("The description number of the comment"), - PayloadDocumentation.fieldWithPath("relatedFindings").type(JsonFieldType.ARRAY) - .description("List of related findings of the comment") + .description("The description number of the comment") ) ) ) @@ -145,7 +141,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { id = "ab62d365-1b1d-4da1-89bc-5496616e220f", title = "Found Bug", description = "OTG-INFO-002 Bug", - relatedFindings = emptyList() + attachments = emptyList() ) } @@ -182,9 +178,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { PayloadDocumentation.fieldWithPath("title").type(JsonFieldType.STRING) .description("The title of the comment"), PayloadDocumentation.fieldWithPath("description").type(JsonFieldType.STRING) - .description("The description of the comment"), - PayloadDocumentation.fieldWithPath("relatedFindings").type(JsonFieldType.ARRAY) - .description("List of related findings of the comment") + .description("The description of the comment") ) ) ) @@ -192,8 +186,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { private val commentBody = CommentRequestBody( title = "Found another Bug", - description = "Another OTG-INFO-002 Bug", - relatedFindings = emptyList() + description = "Another OTG-INFO-002 Bug" ) } @@ -230,9 +223,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { PayloadDocumentation.fieldWithPath("title").type(JsonFieldType.STRING) .description("The title of the requested comment"), PayloadDocumentation.fieldWithPath("description").type(JsonFieldType.STRING) - .description("The description number of the comment"), - PayloadDocumentation.fieldWithPath("relatedFindings").type(JsonFieldType.ARRAY) - .description("List of related findings of the comment") + .description("The description number of the comment") ) ) ) @@ -240,8 +231,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { private val commentBody = CommentRequestBody( title = "Updated Comment", - description = "Updated Description", - relatedFindings = emptyList() + description = "Updated Description" ) } @@ -330,7 +320,7 @@ class CommentControllerDocumentationTest : BaseDocumentationIntTest() { id = "ab62d365-1b1d-4da1-89bc-5496616e220f", title = "Found Bug", description = "OTG-INFO-002 Bug", - relatedFindings = emptyList() + attachments = emptyList() ) // persist test data in database mongoTemplate.save(ProjectEntity(projectOne)) diff --git a/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerIntTest.kt b/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerIntTest.kt index 0d64ffe..2cbd1f2 100644 --- a/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerIntTest.kt +++ b/security-c4po-api/src/test/kotlin/com/securityc4po/api/pentest/comment/CommentControllerIntTest.kt @@ -77,7 +77,7 @@ class CommentControllerIntTest : BaseIntTest() { id = "ab62d365-1b1d-4da1-89bc-5496616e220f", title = "Found Bug", description = "OTG-INFO-002 Bug", - relatedFindings = emptyList() + attachments = emptyList() ) private fun getComments() = listOf( @@ -103,7 +103,7 @@ class CommentControllerIntTest : BaseIntTest() { id = "ab62d365-1b1d-4da1-89bc-5496616e220f", title = "Found Bug", description = "OTG-INFO-002 Bug", - relatedFindings = emptyList() + attachments = emptyList() ) } @@ -122,13 +122,11 @@ class CommentControllerIntTest : BaseIntTest() { .expectBody() .jsonPath("$.title").isEqualTo("Found another Bug") .jsonPath("$.description").isEqualTo("Another OTG-INFO-002 Bug") - .jsonPath("$.relatedFindings").isEmpty } private val commentBody = CommentRequestBody( title = "Found another Bug", - description = "Another OTG-INFO-002 Bug", - relatedFindings = emptyList() + description = "Another OTG-INFO-002 Bug" ) } @@ -147,13 +145,11 @@ class CommentControllerIntTest : BaseIntTest() { .expectBody() .jsonPath("$.title").isEqualTo("Updated Comment") .jsonPath("$.description").isEqualTo("Updated Description") - .jsonPath("$.relatedFindings").isEmpty } private val commentBody = CommentRequestBody( title = "Updated Comment", - description = "Updated Description", - relatedFindings = emptyList() + description = "Updated Description" ) } @@ -221,7 +217,7 @@ class CommentControllerIntTest : BaseIntTest() { id = "ab62d365-1b1d-4da1-89bc-5496616e220f", title = "Found Bug", description = "OTG-INFO-002 Bug", - relatedFindings = emptyList() + attachments = emptyList() ) // persist test data in database mongoTemplate.save(ProjectEntity(projectOne))