From f930d9ee670a6dce8977dcdb18643e48c7af33fd Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Thu, 5 Sep 2019 16:13:28 -0400 Subject: [PATCH] Move GRPC management api to designer api. Change-Id: I58ee303d361cf4f1996c966c094ec66886587b52 Issue-ID: CCSDK-1682 Signed-off-by: Brinda Santh --- .../blueprintsprocessor/BlueprintGRPCServer.java | 2 +- .../BlueprintsAcceptanceTest.kt | 2 +- .../api/BluePrintManagementGRPCHandler.kt | 5 +- .../designer/api/BlueprintModelController.kt | 27 +++- ...ler.kt => DesignerBlueprintExceptionHandler.kt} | 4 +- .../designer/api/handler/BluePrintModelHandler.kt | 62 +++++---- .../api/BluePrintManagementGRPCHandlerTest.kt | 2 +- .../designer/api/BlueprintModelControllerTest.kt | 33 ++++- .../designer-api/src/test/resources/test-cba.zip | Bin 0 -> 9554 bytes ms/blueprintsprocessor/modules/inbounds/pom.xml | 9 ++ .../modules/inbounds/selfservice-api/pom.xml | 10 -- .../selfservice/api/ExecutionServiceController.kt | 26 ---- .../selfservice/api/ExecutionServiceHandler.kt | 53 +------- .../selfservice/api/utils/Utils.kt | 10 -- .../api/ExecutionServiceControllerTest.kt | 95 +++++++------- .../selfservice/api/ExecutionServiceHandlerTest.kt | 139 --------------------- .../cba-for-kafka-integration_enriched.zip | Bin 9781 -> 0 bytes .../controllerblueprints/core/utils/DateUtils.kt | 27 ++++ 18 files changed, 198 insertions(+), 308 deletions(-) rename ms/blueprintsprocessor/modules/inbounds/{selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice => designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer}/api/BluePrintManagementGRPCHandler.kt (97%) rename ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/{ControllerBlueprintExceptionHandler.kt => DesignerBlueprintExceptionHandler.kt} (94%) rename ms/blueprintsprocessor/modules/inbounds/{selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice => designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer}/api/BluePrintManagementGRPCHandlerTest.kt (98%) create mode 100644 ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/test-cba.zip delete mode 100644 ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt delete mode 100755 ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/cba-for-kafka-integration_enriched.zip create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java index 5ad6ee205..9214121e4 100644 --- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java +++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java @@ -18,8 +18,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor; import io.grpc.Server; import io.grpc.ServerBuilder; +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.BluePrintManagementGRPCHandler; import org.onap.ccsdk.cds.blueprintsprocessor.security.BasicAuthServerInterceptor; -import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.BluePrintManagementGRPCHandler; import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.BluePrintProcessingGRPCHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt index dfa0a8563..ce7434f8e 100644 --- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt +++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt @@ -190,7 +190,7 @@ class BlueprintsAcceptanceTest(private val blueprintName: String, private val fi val body = toMultiValueMap("file", getBlueprintAsResource(blueprintName)) webTestClient .post() - .uri("/api/v1/execution-service/upload") + .uri("/api/v1/blueprint-model/publish") .header("Authorization", TestSecuritySettings.clientAuthToken()) .syncBody(body) .exchange() diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt similarity index 97% rename from ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt rename to ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt index 0116680cf..b7badb53b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt @@ -16,12 +16,11 @@ * limitations under the License. */ -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import io.grpc.StatusException import io.grpc.stub.StreamObserver import kotlinx.coroutines.runBlocking -import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.currentTimestamp import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.common.api.Status import org.onap.ccsdk.cds.controllerblueprints.core.* @@ -29,6 +28,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfigur import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.currentTimestamp import org.onap.ccsdk.cds.controllerblueprints.management.api.* import org.slf4j.LoggerFactory import org.springframework.security.access.prepost.PreAuthorize @@ -36,7 +36,6 @@ import org.springframework.stereotype.Service import java.io.File import java.util.* -// TODO("move to management-api or designer-api module") @Service open class BluePrintManagementGRPCHandler(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, private val blueprintsProcessorCatalogService: BluePrintCatalogService) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt index f67ed25c3..4d13486c3 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt @@ -17,14 +17,17 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import kotlinx.coroutines.runBlocking -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.BluePrintModelHandler +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.springframework.core.io.Resource import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.http.codec.multipart.FilePart +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* /** @@ -40,18 +43,21 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @PostMapping("", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) @ResponseBody @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun saveBlueprint(@RequestPart("file") filePart: FilePart): BlueprintModelSearch = runBlocking { bluePrintModelHandler.saveBlueprintModel(filePart) } @GetMapping("", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody + @PreAuthorize("hasRole('USER')") fun allBlueprintModel(): List { return this.bluePrintModelHandler.allBlueprintModel() } @DeleteMapping("/{id}") @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun deleteBlueprint(@PathVariable(value = "id") id: String) { this.bluePrintModelHandler.deleteBlueprintModel(id) } @@ -59,6 +65,7 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @GetMapping("/by-name/{name}/version/{version}", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun getBlueprintByNameAndVersion(@PathVariable(value = "name") name: String, @PathVariable(value = "version") version: String): BlueprintModelSearch { return this.bluePrintModelHandler.getBlueprintModelSearchByNameAndVersion(name, version) @@ -67,6 +74,7 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @GetMapping("/download/by-name/{name}/version/{version}", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun downloadBlueprintByNameAndVersion(@PathVariable(value = "name") name: String, @PathVariable(value = "version") version: String): ResponseEntity { return this.bluePrintModelHandler.downloadBlueprintModelFileByNameAndVersion(name, version) @@ -75,6 +83,7 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @GetMapping("/{id}", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun getBlueprintModel(@PathVariable(value = "id") id: String): BlueprintModelSearch { return this.bluePrintModelHandler.getBlueprintModelSearch(id) } @@ -82,6 +91,7 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @GetMapping("/download/{id}", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun downloadBluePrint(@PathVariable(value = "id") id: String): ResponseEntity { return this.bluePrintModelHandler.downloadBlueprintModelFile(id) } @@ -90,6 +100,7 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint .MULTIPART_FORM_DATA_VALUE]) @ResponseBody @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun enrichBlueprint(@RequestPart("file") file: FilePart): ResponseEntity = runBlocking { bluePrintModelHandler.enrichBlueprint(file) } @@ -97,13 +108,27 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @PostMapping("/publish", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @Throws(BluePrintException::class) + @PreAuthorize("hasRole('USER')") fun publishBlueprint(@RequestPart("file") file: FilePart): BlueprintModelSearch = runBlocking { bluePrintModelHandler.publishBlueprint(file) } @GetMapping("/search/{tags}", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody + @PreAuthorize("hasRole('USER')") fun searchBlueprintModels(@PathVariable(value = "tags") tags: String): List { return this.bluePrintModelHandler.searchBlueprintModels(tags) } + + @DeleteMapping("/name/{name}/version/{version}") + @ApiOperation(value = "Delete a CBA", + notes = "Delete the CBA package identified by its name and version.", + produces = MediaType.APPLICATION_JSON_VALUE) + @PreAuthorize("hasRole('USER')") + fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true) + @PathVariable(value = "name") name: String, + @ApiParam(value = "Version of the CBA.", required = true) + @PathVariable(value = "version") version: String) = runBlocking { + bluePrintModelHandler.deleteBlueprintModel(name, version) + } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ControllerBlueprintExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerBlueprintExceptionHandler.kt similarity index 94% rename from ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ControllerBlueprintExceptionHandler.kt rename to ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerBlueprintExceptionHandler.kt index 0d2a7b7dc..c140c9a07 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ControllerBlueprintExceptionHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerBlueprintExceptionHandler.kt @@ -32,10 +32,10 @@ import org.springframework.web.bind.annotation.RestControllerAdvice * @version 1.0 */ @RestControllerAdvice("org.onap.ccsdk.cds.controllerblueprints") -open class ControllerBlueprintExceptionHandler { +open class DesignerBlueprintExceptionHandler { companion object ControllerBlueprintExceptionHandler { - val LOG = LoggerFactory.getLogger(ControllerBlueprintExceptionHandler::class.java) + val LOG = LoggerFactory.getLogger(DesignerBlueprintExceptionHandler::class.java) } @ExceptionHandler diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt index c074573dd..af7b3fe8d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler +import kotlinx.coroutines.reactive.awaitSingle import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelContentRepository @@ -29,6 +30,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfigur import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.slf4j.LoggerFactory import org.springframework.core.io.ByteArrayResource import org.springframework.core.io.Resource @@ -50,7 +53,7 @@ import java.util.* */ @Service -open class BluePrintModelHandler(private val controllerBlueprintsCatalogService: BluePrintCatalogService, +open class BluePrintModelHandler(private val blueprintsProcessorCatalogService: BluePrintCatalogService, private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, private val blueprintModelSearchRepository: BlueprintModelSearchRepository, private val blueprintModelRepository: BlueprintModelRepository, @@ -77,29 +80,19 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService: */ @Throws(BluePrintException::class) open suspend fun saveBlueprintModel(filePart: FilePart): BlueprintModelSearch { - val saveId = UUID.randomUUID().toString() - val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId) try { - //Recreate the Dir - normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, saveId).reCreateDirs() - val deCompressedFile = normalizedFile(blueprintArchive, "cba.zip") - // Copy the File Part to Local File - BluePrintEnhancerUtils.copyFromFilePart(filePart, deCompressedFile) - // Save the Copied file to Database - val blueprintId = controllerBlueprintsCatalogService.saveToDatabase(saveId, deCompressedFile, false) + val blueprintId = upload(filePart, false) // Check and Return the Saved File val blueprintModelSearch = blueprintModelSearchRepository.findById(blueprintId) ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId)) - log.info("Save($saveId) successful for blueprint(${blueprintModelSearch.artifactName}) " + + log.info("Save successful for blueprint(${blueprintModelSearch.artifactName}) " + "version(${blueprintModelSearch.artifactVersion})") return blueprintModelSearch } catch (e: IOException) { throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, "Error in Save CBA: ${e.message}", e) - } finally { - deleteDir(blueprintArchive) } } @@ -261,6 +254,10 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService: } } + open suspend fun deleteBlueprintModel(name: String, version: String) { + blueprintsProcessorCatalogService.deleteFromDatabase(name, version) + } + /** * This is a CBA enrichBlueprint method * Save the Zip File in archive location and extract the cba content. @@ -303,14 +300,8 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService: */ @Throws(BluePrintException::class) open suspend fun publishBlueprint(filePart: FilePart): BlueprintModelSearch { - val publishId = UUID.randomUUID().toString() - val blueprintArchive = bluePrintLoadConfiguration.blueprintArchivePath.plus(File.separator).plus(publishId) - val blueprintWorkingDir = bluePrintLoadConfiguration.blueprintWorkingPath.plus(File.separator).plus(publishId) try { - val compressedFilePart = BluePrintEnhancerUtils - .extractCompressFilePart(filePart, blueprintArchive, blueprintWorkingDir) - - val blueprintId = controllerBlueprintsCatalogService.saveToDatabase(publishId, compressedFilePart, true) + val blueprintId = upload(filePart, true) return blueprintModelSearchRepository.findById(blueprintId) ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, @@ -319,11 +310,40 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService: } catch (e: Exception) { throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, "Error in Publishing CBA: ${e.message}", e) + } + } + + //TODO("Combine Rest and GRPC Handler") + suspend fun upload(filePart: FilePart, validate: Boolean): String { + val saveId = UUID.randomUUID().toString() + val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId) + val blueprintWorking = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId) + try { + val compressedFile = normalizedFile(blueprintArchive, "cba.zip") + compressedFile.parentFile.reCreateNBDirs() + // Copy the File Part to Local File + copyFromFilePart(filePart, compressedFile) + // Save the Copied file to Database + return blueprintsProcessorCatalogService.saveToDatabase(saveId, compressedFile, validate) + } catch (e: IOException) { + throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, + "Error in Upload CBA: ${e.message}", e) } finally { - BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir) + // Clean blueprint script cache + val cacheKey = BluePrintFileUtils + .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId)) + BluePrintCompileCache.cleanClassLoader(cacheKey) + deleteNBDir(blueprintArchive) + deleteNBDir(blueprintWorking) } } + private suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File { + return filePart.transferTo(targetFile) + .thenReturn(targetFile) + .awaitSingle() + } + companion object { private const val BLUEPRINT_MODEL_ID_FAILURE_MSG = "failed to get blueprint model id(%s) from repo" diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt similarity index 98% rename from ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt rename to ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt index 9629aa4b5..f0411b0d7 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import com.google.protobuf.ByteString import io.grpc.testing.GrpcServerRule diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt index 877584ed6..149108087 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt @@ -176,6 +176,31 @@ class BlueprintModelControllerTest { @Test fun test07_publishBlueprintModel() { + bp = runBlocking { + val body = MultipartBodyBuilder().apply { + part("file", object : ByteArrayResource(testZipFile!!.readBytes()) { + override fun getFilename(): String { + return "test.zip" + } + }) + }.build() + + val publishBP = webTestClient + .post() + .uri("/api/v1/blueprint-model/publish") + .body(BodyInserters.fromMultipartData(body)) + .exchange() + .expectStatus().isOk + .returnResult() + .responseBody + .awaitSingle() + + assertNotNull(publishBP, "failed to get response") + assertEquals("baseconfiguration", publishBP.artifactName, "mismatch artifact name") + assertEquals("1.0.0", publishBP.artifactVersion, "mismatch artifact version") + assertEquals("Y", publishBP.published, "mismatch publish") + publishBP + } } @Test @@ -196,7 +221,13 @@ class BlueprintModelControllerTest { @Test fun test10_deleteBluePrint() { - webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}") +// webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}") +// .header("Authorization", "Basic " + Base64Utils +// .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) +// .exchange() +// .expectStatus().is2xxSuccessful + + webTestClient.delete().uri("/api/v1/blueprint-model/name/${bp!!.artifactName}/version/${bp!!.artifactVersion}") .header("Authorization", "Basic " + Base64Utils .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) .exchange() diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/test-cba.zip new file mode 100644 index 0000000000000000000000000000000000000000..785ec6c00a26d4097cfe6abaeda335405c31a3f6 GIT binary patch literal 9554 zcmbVx1yoe)_x8{@bT>$dv>+XVbPwG*q=Z8a(jp~|v@}R}mx3rIQc5Y^AkrO@-*CMF zdVhNV-^@A;XU&@DdC$A|yW`o)@(74Pz~#%*z#a6*KY#wg0+0jLmDI#VSryHpU^6fj zd`Cn51^^*iCQ1LqI$7V@6%7D~xDN*aAmYP*q6`DN{6zf&NU=!Lu@H6#5Br+rXP`fD z*&f1he+Bt4>@{W!J38{AkR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3s&2VW;#= z_(52KAzt=kzlk{4WtFQ7_xJ(vUqzPRFZ*Zl;3~;6tgF1L2VL2p>r%q6i2gCdbs6C* zkq+Kzm&Arfp-0|4N`-kc}^zzxdFyZ;AbRrzNC literal 0 HcmV?d00001 diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml index 8afecab3c..ba1bbd185 100644 --- a/ms/blueprintsprocessor/modules/inbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml @@ -35,6 +35,10 @@ selfservice-api + + org.springframework.security + spring-security-core + org.onap.ccsdk.cds.blueprintsprocessor workflow-service @@ -80,6 +84,11 @@ kotlinx-coroutines-test test + + io.grpc + grpc-testing + test + io.projectreactor reactor-test diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml index 2c241cc4f..7abcfea5f 100755 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml @@ -32,15 +32,9 @@ - - org.springframework.security - spring-security-core - - org.onap.ccsdk.cds.components proto-definition - ${project.version} @@ -51,10 +45,6 @@ org.onap.ccsdk.cds.controllerblueprints blueprint-validation - - io.grpc - grpc-testing - diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt index d48f0c7e4..4441d2b4b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt @@ -27,11 +27,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.determineHttpStatusCode import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.http.codec.multipart.FilePart import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* @@ -53,30 +51,6 @@ open class ExecutionServiceController { "Success".asJsonPrimitive() } - @PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) - @ResponseBody - @PreAuthorize("hasRole('USER')") - @ApiOperation(value = "Upload a CBA", - notes = "Upload the CBA package. This will also run validation on the CBA.", - produces = MediaType.APPLICATION_JSON_VALUE) - fun upload(@ApiParam(value = "The ZIP file containing the overall CBA package.", required = true) - @RequestPart("file") filePart: FilePart): JsonNode = runBlocking { - val uploadId = executionServiceHandler.upload(filePart) - """{"upload-id" : "$uploadId"}""".asJsonType() - } - - @DeleteMapping("/name/{name}/version/{version}") - @ApiOperation(value = "Delete a CBA", - notes = "Delete the CBA package identified by its name and version.", - produces = MediaType.APPLICATION_JSON_VALUE) - @PreAuthorize("hasRole('USER')") - fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true) - @PathVariable(value = "name") name: String, - @ApiParam(value = "Version of the CBA.", required = true) - @PathVariable(value = "version") version: String) = runBlocking { - executionServiceHandler.remove(name, version) - } - @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE]) @ApiOperation(value = "Execute a CBA workflow (action)", notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.", diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt index 2f8878034..20af589a1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt @@ -21,24 +21,16 @@ import io.grpc.stub.StreamObserver import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -import kotlinx.coroutines.reactive.awaitSingle import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.* import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.toProto import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration -import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.slf4j.LoggerFactory -import org.springframework.http.codec.multipart.FilePart import org.springframework.stereotype.Service -import java.io.File -import java.io.IOException -import java.util.* import java.util.stream.Collectors @Service @@ -49,37 +41,6 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString()) - //TODO("Remove from self service api and move to designer api module") - suspend fun upload(filePart: FilePart): String { - val saveId = UUID.randomUUID().toString() - val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId) - val blueprintWorking = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId) - try { - - val compressedFile = normalizedFile(blueprintArchive, "cba.zip") - compressedFile.parentFile.reCreateNBDirs() - // Copy the File Part to Local File - copyFromFilePart(filePart, compressedFile) - // Save the Copied file to Database - return blueprintsProcessorCatalogService.saveToDatabase(saveId, compressedFile, true) - } catch (e: IOException) { - throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, - "Error in Upload CBA: ${e.message}", e) - } finally { - // Clean blueprint script cache - val cacheKey = BluePrintFileUtils - .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath,saveId)) - BluePrintCompileCache.cleanClassLoader(cacheKey) - deleteNBDir(blueprintArchive) - deleteNBDir(blueprintWorking) - } - } - - //TODO("Remove from self service api and move to designer api module") - suspend fun remove(name: String, version: String) { - blueprintsProcessorCatalogService.deleteFromDatabase(name, version) - } - suspend fun process(executionServiceInput: ExecutionServiceInput, responseObserver: StreamObserver) { when { @@ -97,8 +58,8 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL responseObserver.onCompleted() } else -> responseObserver.onNext(response(executionServiceInput, - "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", - true).toProto()); + "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", + true).toProto()); } } @@ -115,7 +76,7 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath.toString()) val output = bluePrintWorkflowExecutionService.executeBluePrintWorkflow(blueprintRuntimeService, - executionServiceInput, hashMapOf()) + executionServiceInput, hashMapOf()) val errors = blueprintRuntimeService.getBluePrintError().errors if (errors.isNotEmpty()) { @@ -129,12 +90,6 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL } } - private suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File { - return filePart.transferTo(targetFile) - .thenReturn(targetFile) - .awaitSingle() - } - private fun setErrorStatus(errorMessage: String, status: Status) { status.errorMessage = errorMessage status.eventType = EventType.EVENT_COMPONENT_FAILURE.name diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt index 2cf1c1dd0..16fe36cfe 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt @@ -22,20 +22,10 @@ import org.springframework.util.StringUtils import java.io.File import java.io.IOException import java.nio.file.Path -import java.time.LocalDateTime -import java.time.ZoneId -import java.time.format.DateTimeFormatter import java.util.* const val INTERNAL_SERVER_ERROR_HTTP_STATUS_CODE = 500 -fun currentTimestamp(): String { - val now = LocalDateTime.now(ZoneId.systemDefault()) - val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - return formatter.format(now) -} - - @Throws(BluePrintException::class, IOException::class) fun saveCBAFile(filePart: FilePart, targetDirectory: Path): Path { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt index fc6c4890c..e1a498a6f 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt @@ -1,5 +1,6 @@ /* - * Copyright © 2019 Bell Canada + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 Bell Canada. * Modifications Copyright © 2019 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,85 +17,93 @@ */ package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api -import kotlinx.coroutines.reactive.awaitSingle import kotlinx.coroutines.runBlocking -import org.junit.After -import org.junit.Before +import org.junit.Test import org.junit.runner.RunWith +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir -import org.slf4j.LoggerFactory +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.autoconfigure.security.SecurityProperties import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest import org.springframework.context.annotation.ComponentScan -import org.springframework.core.io.ByteArrayResource -import org.springframework.http.client.MultipartBodyBuilder -import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner import org.springframework.test.web.reactive.server.WebTestClient -import org.springframework.test.web.reactive.server.returnResult import org.springframework.web.reactive.function.BodyInserters import java.io.File -import java.nio.file.Files -import java.nio.file.Paths -import kotlin.test.Test +import java.util.* +import kotlin.test.AfterTest +import kotlin.test.BeforeTest +import kotlin.test.assertTrue @RunWith(SpringRunner::class) -@EnableAutoConfiguration -@ContextConfiguration(classes = [ExecutionServiceControllerTest::class, SecurityProperties::class]) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) -@TestPropertySource(locations = ["classpath:application-test.properties"]) -@DirtiesContext @WebFluxTest +@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, + BluePrintCatalogService::class, SecurityProperties::class]) +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", + "org.onap.ccsdk.cds.controllerblueprints"]) +@TestPropertySource(locations = ["classpath:application-test.properties"]) class ExecutionServiceControllerTest { - private val log = LoggerFactory.getLogger(ExecutionServiceControllerTest::class.java)!! - + @Autowired + lateinit var blueprintsProcessorCatalogService: BluePrintCatalogService @Autowired lateinit var webTestClient: WebTestClient - var event: ExecutionServiceInput? = null - - @Before - fun setup() { + @BeforeTest + fun init() { deleteDir("target", "blueprints") } - @After - fun clean() { + @AfterTest + fun cleanDir() { deleteDir("target", "blueprints") } @Test - fun uploadBluePrint() { + fun `test rest process`() { runBlocking { - val body = MultipartBodyBuilder().apply { - part("file", object : ByteArrayResource(Files.readAllBytes(loadCbaArchive().toPath())) { - override fun getFilename(): String { - return "test-cba.zip" - } - }) - }.build() + blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile()) + + val executionServiceInput = JacksonUtils + .readValueFromClassPathFile("execution-input/default-input.json", + ExecutionServiceInput::class.java)!! webTestClient .post() - .uri("/api/v1/execution-service/upload") - .body(BodyInserters.fromMultipartData(body)) + .uri("/api/v1/execution-service/process") + .body(BodyInserters.fromObject(executionServiceInput)) .exchange() .expectStatus().isOk - .returnResult() - .responseBody - .awaitSingle() } } - private fun loadCbaArchive(): File { - return Paths.get("./src/test/resources/cba-for-kafka-integration_enriched.zip").toFile() - } -} + @Test + fun `rest resource process should return status code 500 in case of server-side exception`() { + runBlocking { + blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile()) + + val executionServiceInput = JacksonUtils + .readValueFromClassPathFile("execution-input/faulty-input.json", + ExecutionServiceInput::class.java)!! + webTestClient + .post() + .uri("/api/v1/execution-service/process") + .body(BodyInserters.fromObject(executionServiceInput)) + .exchange() + .expectStatus().is5xxServerError + } + } + private fun loadTestCbaFile(): File { + val testCbaFile = normalizedFile("./src/test/resources/test-cba.zip") + assertTrue(testCbaFile.exists(), "couldn't get file ${testCbaFile.absolutePath}") + return testCbaFile + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt deleted file mode 100644 index a480b115b..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api - -import kotlinx.coroutines.reactive.awaitSingle -import kotlinx.coroutines.runBlocking -import org.junit.Test -import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.autoconfigure.security.SecurityProperties -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest -import org.springframework.context.annotation.ComponentScan -import org.springframework.core.io.ByteArrayResource -import org.springframework.http.client.MultipartBodyBuilder -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.TestPropertySource -import org.springframework.test.context.junit4.SpringRunner -import org.springframework.test.web.reactive.server.WebTestClient -import org.springframework.test.web.reactive.server.returnResult -import org.springframework.web.reactive.function.BodyInserters -import java.io.File -import java.nio.file.Files -import java.nio.file.Paths -import java.util.* -import kotlin.test.AfterTest -import kotlin.test.BeforeTest -import kotlin.test.assertTrue - -@RunWith(SpringRunner::class) -@WebFluxTest -@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, - BluePrintCatalogService::class, SecurityProperties::class]) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", - "org.onap.ccsdk.cds.controllerblueprints"]) -@TestPropertySource(locations = ["classpath:application-test.properties"]) -class ExecutionServiceHandlerTest { - - @Autowired - lateinit var blueprintsProcessorCatalogService: BluePrintCatalogService - @Autowired - lateinit var webTestClient: WebTestClient - - @BeforeTest - fun init() { - deleteDir("target", "blueprints") - } - - @AfterTest - fun cleanDir() { - deleteDir("target", "blueprints") - } - - - @Test - fun `test rest upload blueprint`() { - runBlocking { - val body = MultipartBodyBuilder().apply { - part("file", object : ByteArrayResource(Files.readAllBytes(loadTestCbaFile().toPath())) { - override fun getFilename(): String { - return "test-cba.zip" - } - }) - }.build() - - webTestClient - .post() - .uri("/api/v1/execution-service/upload") - .body(BodyInserters.fromMultipartData(body)) - .exchange() - .expectStatus().isOk - .returnResult() - .responseBody - .awaitSingle() - } - - } - - @Test - fun `test rest process`() { - runBlocking { - blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile()) - - val executionServiceInput = JacksonUtils - .readValueFromClassPathFile("execution-input/default-input.json", - ExecutionServiceInput::class.java)!! - - webTestClient - .post() - .uri("/api/v1/execution-service/process") - .body(BodyInserters.fromObject(executionServiceInput)) - .exchange() - .expectStatus().isOk - } - } - - @Test - fun `rest resource process should return status code 500 in case of server-side exception`() { - runBlocking { - blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile()) - - val executionServiceInput = JacksonUtils - .readValueFromClassPathFile("execution-input/faulty-input.json", - ExecutionServiceInput::class.java)!! - - webTestClient - .post() - .uri("/api/v1/execution-service/process") - .body(BodyInserters.fromObject(executionServiceInput)) - .exchange() - .expectStatus().is5xxServerError - } - } - - private fun loadTestCbaFile(): File { - val testCbaFile = Paths.get("./src/test/resources/test-cba.zip").toFile() - assertTrue(testCbaFile.exists(), "couldn't get file ${testCbaFile.absolutePath}") - return testCbaFile - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/cba-for-kafka-integration_enriched.zip b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/cba-for-kafka-integration_enriched.zip deleted file mode 100755 index 9581191d77a268b8c5ca857820b124259e03efb9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9781 zcmai)1yt1C*2YJ=8IT5%mM#Hl5s>Z_hK8YKND1jy8bK-P7L@Lg?v{}5ZcrM&;r;G+ zk-6`Ezgg=nW>{-}>+F60&pu~AXOv{&5%2&26cj)}>b}B&1qp2&003x#4ie~KQ&UtG zd%+?Pb~H3GbTs_mkF2kuAJs!&U^P|2BF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5BM;X}~ZB{ z$dmjqNmWElafJ_9wZ|RQSa{NRQCoZEIpC7>i5N7KN4~L}Z2Dotox7g4&!hKA;UHhp zsTC7TY%L!EA{9MPikp8*9*U@^mFYZ-(Djz7{>LaLuj;u_C6PJWMqO;;n7-pSedMMv zveH0RpktlyPsV_Y1IvmUR2qHLt&X-FZg*m~PfKTRJi1Lrs2|!c4J(paR*#P#v>$!j zzp}ozg_pWY7d#!FPRsVb%|u|0v$bt}UPvwH@X2QMuS4n7f$sKB;dG7%VfD=cd0q! zNlxh3ix=6L=7*e+*Z~Whnf?eB`EbP>(ha-dn*@iB*h~%mU~J7G_npQ0U%9e2R);Gn zV-;Ck2Q()o5+mnBQ;_~(ZI7YriQq!d%=Fk7=*t4|F7F&d9W8?cRX)I7#_@Z7%U0aNWLTaqQQ{< z##V-0?48jK|iOM*2x??}EFFr@!tcft~3oyR+(0Oo%X|IvqpCBr&?cjQM{ zFy#O6|6p0LF5ex?>6Ufp)BQi5A1oKv@w?+T-RJ(>68W>ghNZ!}X?L_z?0d8PZ{8X# z5Y`sE0}23Pfd9=TgGIvHK6l8k(4V>dk;#8Y{AYg;OM|sz?r0{s_h@fS|D51IB@x!{ zxI=0_yodaorT!-_tebJi9lX!|b8-GDcGw2~4#$VTM zdwCK4C-RSm1{MU{(AW3jhEB diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt new file mode 100644 index 000000000..e01ba805d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt @@ -0,0 +1,27 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.core.utils + +import java.time.LocalDateTime +import java.time.ZoneId +import java.time.format.DateTimeFormatter + +fun currentTimestamp(): String { + val now = LocalDateTime.now(ZoneId.systemDefault()) + val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + return formatter.format(now) +} -- 2.16.6