fix: integration test and ascii documentation
This commit is contained in:
parent
9768a23690
commit
92dbf852ea
|
@ -72,12 +72,12 @@ class ProjectService(private val projectRepository: ProjectRepository) {
|
|||
* @return status code of deleted [Project]
|
||||
*/
|
||||
fun deleteProject(id: String): Mono<Project> {
|
||||
return projectRepository.findProjectById(id).switchIfEmpty{
|
||||
return projectRepository.findProjectById(id).switchIfEmpty {
|
||||
logger.info("Project with id $id not found. Deletion not necessary.")
|
||||
Mono.empty()
|
||||
}.flatMap{ projectEntity: ProjectEntity ->
|
||||
}.flatMap { projectEntity: ProjectEntity ->
|
||||
val project = projectEntity.toProject()
|
||||
projectRepository.deleteProjectById(id).map{project}
|
||||
projectRepository.deleteProjectById(id).map { project }
|
||||
}.onErrorMap {
|
||||
TransactionInterruptedException(
|
||||
"Deleting Project failed!",
|
||||
|
@ -101,15 +101,15 @@ class ProjectService(private val projectRepository: ProjectRepository) {
|
|||
"Project not valid.", Errorcode.ProjectInvalid
|
||||
)
|
||||
)
|
||||
return projectRepository.findProjectById(id).switchIfEmpty{
|
||||
return projectRepository.findProjectById(id).switchIfEmpty {
|
||||
logger.warn("Project with id $id not found. Updating not possible.")
|
||||
val msg = "Project with id $id not found."
|
||||
val ex = EntityNotFoundException(msg, Errorcode.ProjectNotFound)
|
||||
throw ex
|
||||
}.flatMap{projectEntity: ProjectEntity ->
|
||||
}.flatMap { projectEntity: ProjectEntity ->
|
||||
projectEntity.lastModified = Instant.now()
|
||||
projectEntity.data = buildProject(body, projectEntity)
|
||||
projectRepository.save(projectEntity).map{
|
||||
projectRepository.save(projectEntity).map {
|
||||
it.toProject()
|
||||
}.doOnError {
|
||||
throw wrappedException(
|
||||
|
@ -130,7 +130,10 @@ class ProjectService(private val projectRepository: ProjectRepository) {
|
|||
* @throws [TransactionInterruptedException] if the [Project] could not be updated
|
||||
* @return updated list of [ProjectPentest]s
|
||||
*/
|
||||
fun updateProjectTestingProgress(projectId: String, projectPentests: ProjectPentest)/*: Mono<List<ProjectPentest>>*/ {
|
||||
fun updateProjectTestingProgress(
|
||||
projectId: String,
|
||||
projectPentests: ProjectPentest
|
||||
)/*: Mono<List<ProjectPentest>>*/ {
|
||||
// ToDo: update Project Entity with progress
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,10 +81,10 @@ class PentestControllerDocumentationTest : BaseDocumentationIntTest() {
|
|||
.description("The reference number of the requested pentest according to the current OWASP Testing Guide"),
|
||||
PayloadDocumentation.fieldWithPath("[].status").type(JsonFieldType.STRING)
|
||||
.description("The status of the requested pentest"),
|
||||
PayloadDocumentation.fieldWithPath("[].findingIds").type(JsonFieldType.STRING)
|
||||
.description("The ids of the findings in the requested pentest"),
|
||||
PayloadDocumentation.fieldWithPath("[].commentIds").type(JsonFieldType.STRING)
|
||||
.description("The ids of the comments of the requested pentest")
|
||||
PayloadDocumentation.fieldWithPath("[].findingIds").type(JsonFieldType.ARRAY)
|
||||
.description("List of ids of the findings in the requested pentest"),
|
||||
PayloadDocumentation.fieldWithPath("[].commentIds").type(JsonFieldType.ARRAY)
|
||||
.description("List of ids of the comments of the requested pentest")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -74,7 +74,9 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
|
|||
PayloadDocumentation.fieldWithPath("[].tester").type(JsonFieldType.STRING)
|
||||
.description("The user that is assigned as a tester in the project"),
|
||||
PayloadDocumentation.fieldWithPath("[].createdBy").type(JsonFieldType.STRING)
|
||||
.description("The id of the user that created the project")
|
||||
.description("The id of the user that created the project"),
|
||||
PayloadDocumentation.fieldWithPath("[].testingProgress").type(JsonFieldType.NUMBER)
|
||||
.description("The progress of the project from completed pentests")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -139,7 +141,9 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
|
|||
PayloadDocumentation.fieldWithPath("tester").type(JsonFieldType.STRING)
|
||||
.description("The user that is assigned as a tester in the project"),
|
||||
PayloadDocumentation.fieldWithPath("createdBy").type(JsonFieldType.STRING)
|
||||
.description("The id of the user that created the project")
|
||||
.description("The id of the user that created the project"),
|
||||
PayloadDocumentation.fieldWithPath("testingProgress").type(JsonFieldType.NUMBER)
|
||||
.description("The progress of the project from completed pentests")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -231,11 +235,11 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
|
|||
fun updateProject() {
|
||||
webTestClient.patch().uri("/projects/${projectUpdate.id}")
|
||||
.header("Authorization", "Bearer $tokenAdmin")
|
||||
.body(Mono.just(projectUpdate), ProjectRequestBody::class.java)
|
||||
.body(Mono.just(projectUpdateRequest), ProjectRequestBody::class.java)
|
||||
.exchange()
|
||||
.expectStatus().isAccepted
|
||||
.expectHeader().valueEquals("Application-Name", "SecurityC4PO")
|
||||
.expectBody().json(Json.write(projectUpdate))
|
||||
.expectBody().json(Json.write(projectUpdate.toProjectResponseBody()))
|
||||
.consumeWith(
|
||||
WebTestClientRestDocumentation.document(
|
||||
"{methodName}",
|
||||
|
@ -259,12 +263,20 @@ class ProjectControllerDocumentationTest : BaseDocumentationIntTest() {
|
|||
PayloadDocumentation.fieldWithPath("tester").type(JsonFieldType.STRING)
|
||||
.description("The updated user that is assigned as a tester in the project"),
|
||||
PayloadDocumentation.fieldWithPath("createdBy").type(JsonFieldType.STRING)
|
||||
.description("The id of the user that created the project")
|
||||
.description("The id of the user that created the project"),
|
||||
PayloadDocumentation.fieldWithPath("testingProgress").type(JsonFieldType.NUMBER)
|
||||
.description("The progress of the project from completed pentests")
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val projectUpdateRequest = ProjectRequestBody(
|
||||
client = "Novatec_updated",
|
||||
title = "log4j Pentest_updated",
|
||||
tester = "Stipe_updated"
|
||||
)
|
||||
|
||||
val projectUpdate = Project(
|
||||
id = "4f6567a8-76fd-487b-8602-f82d0ca4d1f9",
|
||||
client = "Novatec_updated",
|
||||
|
|
Loading…
Reference in New Issue