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