From 7e301b523d66508f8493f6873e36f0d60e8caaf4 Mon Sep 17 00:00:00 2001 From: "aravind.est" Date: Thu, 22 Feb 2024 16:01:11 +0000 Subject: [PATCH 1/1] Add validation for asd descriptor and invariant id ASD package validation has been added for descriptor and invariant id. This validates based on the rApp already created. If the application restarts the cache gets cleared. Issue-ID: NONRTRIC-984 Change-Id: Icf76553dbe5dca710801fefa551ae9e81d986ca5 Signed-off-by: aravind.est --- .../src/test/resources/valid-rapp-package.csar | Bin 16136 -> 16156 bytes .../oransc/rappmanager/rest/RappController.java | 1 + .../service/DeploymentArtifactsService.java | 7 +- .../rappmanager/rest/RappControllerTest.java | 29 +++- .../service/DeploymentArtifactsServiceTest.java | 19 ++- .../src/test/resources/invalid-rapp-package.csar | Bin 6759 -> 6780 bytes .../src/test/resources/valid-rapp-package.csar | Bin 23557 -> 23577 bytes .../valid-rapp-package-new-info-type.csar | Bin 21309 -> 21277 bytes .../src/test/resources/valid-rapp-package.csar | Bin 20892 -> 20860 bytes .../rappmanager/models/csar/AsdMetadata.java | 42 ++++++ .../models/csar/RappCsarConfigurationHandler.java | 52 ++++--- .../models/csar/RappCsarPathProvider.java | 11 +- .../validator/ArtifactDefinitionValidator.java | 31 ++-- .../csar/validator/AsdDescriptorValidator.java | 89 +++++++++++ .../com/oransc/rappmanager/models/rapp/Rapp.java | 2 + .../models/{cache => }/BeanTestConfiguration.java | 6 +- .../models/cache/RappCacheServiceTest.java | 1 + .../csar/RappCsarConfigurationHandlerTest.java | 40 ++++- .../validator/ArtifactDefinitionValidatorTest.java | 24 +-- .../csar/validator/AsdDescriptorValidatorTest.java | 165 +++++++++++++++++++++ .../csar/validator/RappValidationHandlerTest.java | 8 +- .../csar/validator/RappValidationUtilsTest.java | 2 +- .../invalid-rapp-package-missing-artifact.csar | Bin 19724 -> 19749 bytes .../invalid-rapp-package-no-acm-composition.csar | Bin 21885 -> 21910 bytes .../resources/invalid-rapp-package-no-tosca.csar | Bin 23167 -> 23192 bytes .../src/test/resources/invalid-rapp-package.csar | Bin 13209 -> 13233 bytes .../src/test/resources/valid-rapp-package.csar | Bin 23557 -> 23577 bytes .../src/test/resources/valid-rapp-package.csar | Bin 13160 -> 13180 bytes .../rapp-all/Definitions/asd.yaml | 2 +- 29 files changed, 437 insertions(+), 94 deletions(-) create mode 100755 rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/AsdMetadata.java create mode 100755 rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidator.java rename rapp-manager-models/src/test/java/com/oransc/rappmanager/models/{cache => }/BeanTestConfiguration.java (88%) create mode 100755 rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidatorTest.java diff --git a/rapp-manager-acm/src/test/resources/valid-rapp-package.csar b/rapp-manager-acm/src/test/resources/valid-rapp-package.csar index 4856dab049eca7056d3c05b6103315153e3bbf1b..b6318e88480ff318394d1084e5308cf20ffd328d 100755 GIT binary patch delta 1146 zcmV-=1cm#Eew===YcLW300;m`UsYIhsqCxg0{{RQ50iZ`9DiGH(=Zf%N8&$3eNSl8 ztlRnq0>s2cNCRH2Q~RW|=Geh;2Ibdt++5qFWekSMOA~+Re)Fj_B?l%jlUh1ybjj|} zmh`d;YN(WXp^$AMS1e}9(VN5zAP55}1#{a1%gBrNxHE-OX0v4uNhLVkQEDTwJE@riC<-MxcmuA{ z-bs!x8~(GRtVIj*2Cb8gzJ{e!!K7FPak9YlYsgy~k|meV4Mqp=aqLaVG`ZRq*QiQ**qZ0Hz_w zPD)6~B-zlUMNfg>9pi-<#@QFgF2LQzZnx6I<#N?OcO zyH$W%e19gEeR7TNo3Xc)7l$?jj>H2>{@9s4GwG0Fg^~^9N9OZs2nT6LVwP3sv4;`W5LRRSc4+t(6XzKzVfM- zqV$jszmqo_6wypucNQ(9^XOsSDcC|h!)1!e$gZLzx9FbQC!b z1+1l_&FH{|TxxbpQA0Jni0iAZdzz{j4W%#fO7(*JJ}s8a!J42$gxhW5_9}`S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bXeHZQH2ia3983KmVr?zQEc2r$tzvt z!+eH%Bs@H=-`YeQ5HC9@^}BQtegDCm=$(3HM7NV@@t^d{2jYM9@;>Ul7R~3I{c^%i zlKUh+&+gZIW;*y*I%@FqJ(K*qra`j{8IxS-vY@1J0Xb}xR)bZ5u}m5MLRmxIeTaKc zTe!Yvy=*m!;-wztg8DRHat|944JE==x$iMbSd-G5>M5FUnKdb8$xk{YC_J0-HWg#+ zi!w4~>lZa9G~|Ek6m(X7ZoZzg@QmcLe1n}val%?#3=JF9V^{0r;n;1DlgaRNU2fH| z>F2E3WEx={I5qV6e5r@<@80!I|~XMIIQ z4y~t_xz-JCUA deploymentItems = rappCsarConfigurationHandler.getDeploymentItems(rapp); - return deploymentItems.stream().filter(deploymentItem -> deploymentItem.getArtifactType() - .equals(DeploymentItemArtifactType.HELMCHART)) + return rapp.getAsdMetadata().getDeploymentItems().stream() + .filter(deploymentItem -> deploymentItem.getArtifactType() + .equals(DeploymentItemArtifactType.HELMCHART)) .allMatch(deploymentItem -> uploadHelmChart(rapp, deploymentItem)); } diff --git a/rapp-manager-application/src/test/java/com/oransc/rappmanager/rest/RappControllerTest.java b/rapp-manager-application/src/test/java/com/oransc/rappmanager/rest/RappControllerTest.java index 51fc204..6e7566d 100755 --- a/rapp-manager-application/src/test/java/com/oransc/rappmanager/rest/RappControllerTest.java +++ b/rapp-manager-application/src/test/java/com/oransc/rappmanager/rest/RappControllerTest.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START====================================================================== - * Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved. + * Copyright (C) 2023-2024 OpenInfra Foundation Europe. All rights reserved. * =============================================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.oransc.rappmanager.acm.service.AcmDeployer; import com.oransc.rappmanager.dme.service.DmeDeployer; import com.oransc.rappmanager.models.cache.RappCacheService; +import com.oransc.rappmanager.models.csar.AsdMetadata; import com.oransc.rappmanager.models.rapp.PrimeOrder; import com.oransc.rappmanager.models.rapp.Rapp; import com.oransc.rappmanager.models.rapp.RappPrimeOrder; @@ -35,6 +36,7 @@ import com.oransc.rappmanager.models.rapp.RappState; import com.oransc.rappmanager.sme.service.SmeLifecycleManager; import java.io.File; import java.io.FileInputStream; +import java.util.List; import java.util.UUID; import org.apache.http.entity.ContentType; import org.junit.jupiter.api.Test; @@ -82,6 +84,11 @@ class RappControllerTest { UUID rappId = UUID.randomUUID(); Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); + AsdMetadata asdMetadata = new AsdMetadata(); + asdMetadata.setDescriptorId(UUID.randomUUID().toString()); + asdMetadata.setDescriptorInvariantId(UUID.randomUUID().toString()); + asdMetadata.setDeploymentItems(List.of()); + rapp.setAsdMetadata(asdMetadata); rappCacheService.putRapp(rapp); mockMvc.perform(MockMvcRequestBuilders.get("/rapps")).andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(1))); @@ -92,6 +99,11 @@ class RappControllerTest { UUID rappId = UUID.randomUUID(); Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); + AsdMetadata asdMetadata = new AsdMetadata(); + asdMetadata.setDescriptorId(UUID.randomUUID().toString()); + asdMetadata.setDescriptorInvariantId(UUID.randomUUID().toString()); + asdMetadata.setDeploymentItems(List.of()); + rapp.setAsdMetadata(asdMetadata); rappCacheService.putRapp(rapp); mockMvc.perform(MockMvcRequestBuilders.get("/rapps/{rapp_id}", rappId)).andExpect(status().isOk()) .andExpect(jsonPath("$.rappId").value(rappId.toString())) @@ -129,6 +141,11 @@ class RappControllerTest { UUID rappId = UUID.randomUUID(); Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); + AsdMetadata asdMetadata = new AsdMetadata(); + asdMetadata.setDescriptorId(UUID.randomUUID().toString()); + asdMetadata.setDescriptorInvariantId(UUID.randomUUID().toString()); + asdMetadata.setDeploymentItems(List.of()); + rapp.setAsdMetadata(asdMetadata); rappCacheService.putRapp(rapp); when(acmDeployer.primeRapp(any())).thenReturn(true); when(dmeDeployer.primeRapp(any())).thenReturn(true); @@ -154,6 +171,11 @@ class RappControllerTest { UUID rappId = UUID.randomUUID(); Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.PRIMED).build(); + AsdMetadata asdMetadata = new AsdMetadata(); + asdMetadata.setDescriptorId(UUID.randomUUID().toString()); + asdMetadata.setDescriptorInvariantId(UUID.randomUUID().toString()); + asdMetadata.setDeploymentItems(List.of()); + rapp.setAsdMetadata(asdMetadata); rappCacheService.putRapp(rapp); when(acmDeployer.deprimeRapp(any())).thenReturn(true); when(dmeDeployer.deprimeRapp(any())).thenReturn(true); @@ -168,6 +190,11 @@ class RappControllerTest { UUID rappId = UUID.randomUUID(); Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); + AsdMetadata asdMetadata = new AsdMetadata(); + asdMetadata.setDescriptorId(UUID.randomUUID().toString()); + asdMetadata.setDescriptorInvariantId(UUID.randomUUID().toString()); + asdMetadata.setDeploymentItems(List.of()); + rapp.setAsdMetadata(asdMetadata); rappCacheService.putRapp(rapp); mockMvc.perform(MockMvcRequestBuilders.delete("/rapps/{rapp_id}", rappId)).andExpect(status().isOk()); } diff --git a/rapp-manager-application/src/test/java/com/oransc/rappmanager/service/DeploymentArtifactsServiceTest.java b/rapp-manager-application/src/test/java/com/oransc/rappmanager/service/DeploymentArtifactsServiceTest.java index 4a3a08a..5de2050 100755 --- a/rapp-manager-application/src/test/java/com/oransc/rappmanager/service/DeploymentArtifactsServiceTest.java +++ b/rapp-manager-application/src/test/java/com/oransc/rappmanager/service/DeploymentArtifactsServiceTest.java @@ -80,8 +80,10 @@ class DeploymentArtifactsServiceTest { @EnumSource(value = HttpStatus.class, names = {"CREATED", "CONFLICT"}) void testChartUpload(HttpStatus status) { Rapp rapp = Rapp.builder().rappId(UUID.randomUUID()).name("").packageName(validRappFile) - .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); - List deploymentItems = rappCsarConfigurationHandler.getDeploymentItems(rapp); + .packageLocation(validCsarFileLocation) + .state(RappState.COMMISSIONED).build(); + rapp.setAsdMetadata(rappCsarConfigurationHandler.getAsdMetadata(rapp)); + List deploymentItems = rapp.getAsdMetadata().getDeploymentItems(); deploymentItems.forEach(deploymentItem -> mockServer.expect(ExpectedCount.once(), requestTo(deploymentItem.getTargetServerUri())).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(status))); @@ -94,6 +96,7 @@ class DeploymentArtifactsServiceTest { String invalidRappFile = "invalid-rapp-package.csar"; Rapp rapp = Rapp.builder().rappId(UUID.randomUUID()).name("").packageName(invalidRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); + rapp.setAsdMetadata(rappCsarConfigurationHandler.getAsdMetadata(rapp)); assertTrue(deploymentArtifactsService.configureDeploymentArtifacts(rapp)); } @@ -101,7 +104,8 @@ class DeploymentArtifactsServiceTest { void testChartUploadFailure() { Rapp rapp = Rapp.builder().rappId(UUID.randomUUID()).name("").packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); - List deploymentItems = rappCsarConfigurationHandler.getDeploymentItems(rapp); + rapp.setAsdMetadata(rappCsarConfigurationHandler.getAsdMetadata(rapp)); + List deploymentItems = rapp.getAsdMetadata().getDeploymentItems(); deploymentItems.stream().findFirst().ifPresent(deploymentItem -> mockServer.expect(ExpectedCount.once(), requestTo(deploymentItem.getTargetServerUri())).andExpect(method(HttpMethod.POST)) .andRespond(withServerError())); @@ -115,7 +119,8 @@ class DeploymentArtifactsServiceTest { void testChartUploadFailureWithNotFound() { Rapp rapp = Rapp.builder().rappId(UUID.randomUUID()).name("").packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); - List deploymentItems = rappCsarConfigurationHandler.getDeploymentItems(rapp); + rapp.setAsdMetadata(rappCsarConfigurationHandler.getAsdMetadata(rapp)); + List deploymentItems = rapp.getAsdMetadata().getDeploymentItems(); deploymentItems.stream().findFirst().ifPresent(deploymentItem -> mockServer.expect(ExpectedCount.once(), requestTo(deploymentItem.getTargetServerUri())).andExpect(method(HttpMethod.POST)).andRespond( withStatus(HttpStatus.NOT_FOUND))); @@ -127,7 +132,8 @@ class DeploymentArtifactsServiceTest { void testChartUploadFailureWithException() { Rapp rapp = Rapp.builder().rappId(UUID.randomUUID()).name("").packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); - List deploymentItems = rappCsarConfigurationHandler.getDeploymentItems(rapp); + rapp.setAsdMetadata(rappCsarConfigurationHandler.getAsdMetadata(rapp)); + List deploymentItems = rapp.getAsdMetadata().getDeploymentItems(); deploymentItems.stream().findFirst().ifPresent(deploymentItem -> mockServer.expect(ExpectedCount.once(), requestTo(deploymentItem.getTargetServerUri())).andExpect(method(HttpMethod.POST)).andRespond( withException(new IOException()))); @@ -141,7 +147,8 @@ class DeploymentArtifactsServiceTest { void testChartUploadFailureWithTooManyRequests() { Rapp rapp = Rapp.builder().rappId(UUID.randomUUID()).name("").packageName(validRappFile) .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); - List deploymentItems = rappCsarConfigurationHandler.getDeploymentItems(rapp); + rapp.setAsdMetadata(rappCsarConfigurationHandler.getAsdMetadata(rapp)); + List deploymentItems = rapp.getAsdMetadata().getDeploymentItems(); deploymentItems.stream().findFirst().ifPresent(deploymentItem -> mockServer.expect(ExpectedCount.once(), requestTo(deploymentItem.getTargetServerUri())).andExpect(method(HttpMethod.POST)) .andRespond(withTooManyRequests())); diff --git a/rapp-manager-application/src/test/resources/invalid-rapp-package.csar b/rapp-manager-application/src/test/resources/invalid-rapp-package.csar index 97efcb5f5da02471f7c1d896ee60e353d023a53f..81d084b39630ece9631f02a7c777a892fd4e225a 100755 GIT binary patch delta 929 zcmV;S177^+H2gHMq7w-@UsYJj#7AI8ldBUUf6K1ZFc94%@edaJL`|C8+uI!okPs3= zy1>?&+LL0{v4iat%GWb)+9XZWil;<3O?}S1&dkIO)(hYgOJ!70)_A@{=jma^TF9%a z*2wozX`b=?>652VBzoag9S*G5%K5;gvo*6ND;?t9MldjvHR!;QIeY&2GMbSi>w;fB ze|^GO!oW)&_BHx6x{i3TwbgdB=K(1s1UxW}mDruM#tiCOD*-WqM|3+S@Z~Wj>muXu ziO!Ejq~wGGQOFZ`R>HH_ZPw3DXie3i3+fo}Xwrq?O0HOz&#|~$+$XqvSSML7=Lyj7 zq{tVGtjO+**=#m#Yo($&LAnEER(e?7Rmfx;CwlI$RCz>Q*Qb; zW$7S}7oV|$9?XYe*%%Qk=ELf{mJJT0NvFh4Npvgr>hZ(z_`Ct!K!u%`gpf(vFr|6V zz;A(zS`KxN!*LL}JG$)HS6tVy!Nj-SKWFZg3k_(lmDzHKUmE4GLK9XDjr>R^f9#xZ zFnqOcON|NWN)Sj!pw;(7-a`kcEc;Jz4aKOej0%AEI3}nXsui=2+Tw$w36^6H}DWBTMYaSkva+W{grzK8!JGDc@8uewJ zhhvsaALo~nF}-Ay3mQBi5ElRdVRK|IZDvqQ1qJ{B000F51psOR008_L00000 DIK0WJ delta 887 zcmV--1Bm?mH0Lz1q7w<3Voq2t?L0&=ldBUUe@&0mFc7`3wEw~4-e{AS0=&;BuXoCPQaiffi%9_CU=mR~hSOW!B zI*q)BQuCY_w>P&p5`*x{#RKcD@*y(mtz&k>HXiZmRxmJ9p>tk5m zf8H=QV-O^dwZo7l*9ni-S#7s9k4PaQ;(=+b#O|aqX5gGw0#X9^==VzC>oz6p6XWnn z&f6j~azcS9nBIlQ8nnJYU8ygT?nq^isi)|7f+YZX88QYdX^V*J_Gta zTNKM>zQ~^~?(XiUjm;js0uy^TbzNU{e*M{0LU?7(S=L60HhfsIi7<&kUCb{-^d>pYz*Uhu@KExS z=0=(Ax!l@S)ONkk>&HV zqCp;}ebQ$_SwdNU6)i4$bs(t!W&Pp!9-z|yWR2+gKi{H%wJh_?(BiKw%L^Ln<@1a#j9*@uf8I8~4i~?< zH1n(I;_*vU{Mpu^c}R*$E_4+lDJQ_eT50-oG%BG~hVMu<)Wf^Dx!t-?JNB|=rWvm^ z_G8d*s$231Yr@8e@U@F4GbOCq(7hU|oUz}rvDuJJaWW%8_1TiQT1@4%Q${Ae-qZIH z>#ufoEIU!YG>?}&+#}^IH6P)pAx?NZwnM`j^?99#W0p@J7nAinU2T;)^VIyEX}~;9 z)i~qRW?wTeu9`10x`l3Uegd-)7svt$nPN^@F6}%-F_YmLIR+f3xIRE%lOP&A0{a$| NUK$t%=NJG0006YGyDtC$ diff --git a/rapp-manager-application/src/test/resources/valid-rapp-package.csar b/rapp-manager-application/src/test/resources/valid-rapp-package.csar index 526d5d9b878410fac90ae4277116126e92c950f7..1dddd4a45398630e2e399271d954f51cc94d5b2c 100755 GIT binary patch delta 1124 zcmY+Bc}&xH6u^JSiqvptP+Ce$O2suuiySS~7F!O5a5#GW~vr>i>>}0d9vv&eh+_|eP|bL>X4-1r{CP>#?5uv?`wGGOoBYH z=V5(Rf8n+prPWy1RGd=76N@lS_!Boz?u2ExwN>88_cWpxDz<4u2Xp)nhUS!y4{5p= zR2JNrvc0lB8bmbKR9c5Q38FIDA6kNjD z=oFR5`L)USOxP}#ly;iVt?HR+ous!&8m9F@DwGiKpPC|4Sv$%7Wfi@H9lx(*Z>ChF zdf%RoZZk8FY7O_USv(?c?l7GiT;21y-$*-RI9s{-V_ie*S;I?Ah3%;{##UuP)fk z{uFK1mM!}2X69Vz*yPi=OUh zNaV3z{SsYI4rw7`7M;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z{vEZWpk1COD3ilEt_NY z4ly#m-K=0>CXE!;@!pnf3*+?;+>D)k!C!20ogc^KJ>GJRl9O+HXERSwVwikTNptdo zAhyXDd_*QIgz+(6nLOJkoLNShVe$fHvB})NUd;Jmw)^A)ADPK}!}*x}G$$Jxh)tfN zsWjQgn+xca$^3pYObZ~Q&oqT6@AKzjRp^ZHk)C|sUmRp5(3z7vfNFxY!8-T&$+G@* zmk&b7zi65KA1H6D2b33|Y~nA&+9?wj4wqMW+Y%BX@PGc7$BYaN!7L068Vo875TF30 z7!82hw7}MKZ|IBxX|rY2n#>yz&R8`0e1QDq14c?fKk`lf8zRMc1}M_ablG_Fg#fw9 zd#&{*`>m2kNKtv!{mi#l9QE9AsP&Wq?q+hA!3!L=93Kq1tzZpiWQiF#Qfp< zHkdO^erRqDwq!!E6f>Izh%Y%gz`_QsM<_&!ncET~<`I(0$TxXiNG5ZJ6)=#kWhYA+ z>rZ}dEeuqt#hh;q5{m9IRG2LW=R?WW9)LCRWGE`Vr!jeH<;pnz$pSm{^^_LUxhK z%&g8JJ))Dno$WyW5fozpg((F5ca(Mky2nL)vULBU(c(e~2pC?E+0Ejup?EnA( diff --git a/rapp-manager-dme/src/test/resources/valid-rapp-package-new-info-type.csar b/rapp-manager-dme/src/test/resources/valid-rapp-package-new-info-type.csar index f51cfb2076435ef6f27f4af928b9e567d8526ed9..36dd2e9718e67ffad4551c889fc1d73a121655c8 100755 GIT binary patch delta 1173 zcmV;G1Zw-erU9L%0kD)Re*gdo03}~lSaYfDtLFm%02dDc02BZK07PYGX>MtBX>V?G zFJW_JE_q>XY|U3&Z__Xoen;XzM14`f%(3bSF3Tmj7d7+SPAy+JBf63D)PoD@Zxs`?6 zQN5P7bb+v@2uv1a7V&Ju1JEL<(1IrR;Q94S&qjibb>-^mlOPBKCJwjlPDZe^bGvSOsyi!1Qc+9^%F2I*b#s2!X!CG+8d=G(Jz~^Z7Khz5^>k zyPcSMI>#(aAjEYHVG3Cmu0^^G7v~%o7xT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Xhnb}$D{OvuH{JW+>^Bf{3xzJ@n zLE!>&SSzi1s{mt}GW><2hPr(bcdoXeepmIf;iM8T^&l41r}=_=SQDvF5w6O8r=o;4 zDcz}_ym?KmNhwNx)F46b*^D=#7-C#aqjar+oQos2= zX~ReN;I_^Cc{_PVoquuhOvjVnup)z2W6NA)2DfgvUiKI?b*88U{dnvK9a8>>Gi1sp z(O1wVt@ayjY1~C7+22D^2BBtF>EsQd*?U0q_kb2>K+W&c^nXkKK_mSoMDhFs)1SPS z{^W;B|K-I$P)i304Rq~`+XDaq7Y_gcP)h>@6aWYS2mncmJCjfb3A4Q}fFqNTO$;&( zbnT1V0{{RQ4*&oZ03ZMW000000002CfsQHw07PYGX>MtBX>V?GFJW_JE_q>XY?DA1 hAd}!i2$K*_2$Qc;8Uf3b%2G)R=@9?`K0yEg0036}Cu0Br diff --git a/rapp-manager-dme/src/test/resources/valid-rapp-package.csar b/rapp-manager-dme/src/test/resources/valid-rapp-package.csar index 3454443da921bd54629e797a0e15b29d0fc7e8cb..45a40e47f57e338a4e2cd610613247af5b4b3ee8 100755 GIT binary patch delta 1191 zcmV;Y1X%l=qXGP)0kC~3e*gdo02^ObSaYfDtLFm%02dDc02BZK07PYGX>MtBX>V?G zFJW_JE_q>XY|U3&Z__Xoen;XzM14`f%(3bSF3Tmj7d7+SPAy+JBf63D)PoD@Zxs`?6 zQN5P7bb+v@2uv1a7V&Ju1JEL<(1IrR;Q94S&qjibb>-^mlOPBKCJwjlPDZe^bGvSOsyi!1Qc+9^%F2I*b#s2!X!CG+8d=G(Jz~^Z7Khz5^>k zyPcSMI>#(aAjEYHVG3Cmu0^^G7v~%o7xT;H^5SetOrNGW8t5tc4d&2;$q>vc&ArEL z=zW*6!J%jAB5@}L+EwuC`crefp8%#I$4*K}$Ryd&q(x7Gf8QPBg&4-!7soEZ-O)H> z-*8>P2E($>{yycMw5|fhl+?G(;@3)A%u%~lfLeSemVI)K?whf+kV>>p<ST>5D+$nf8?0U><}2bE-EcR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whgd#F!~H3ejxU@!u{jwtxdEB@$w9%{*W%B_aD58KB!k_ zr%Chwq*p#sO)u`Ef6i@DKd<)75gVT;C-3Z;*;(rR?LCwHyQV?&93m#U&}BhE;R144 zE3JB~0Aral{Dq>1x_uFMuC}0lSM{>tq!KUnAQsf8`GR{`6RA%TuF8FNJMNF&<~SL3KiB0(nPI?on@mlNLrwK9KAq}5JUI)WM|1@>RG=wC^Q1Ev_uEv* z!uCFUz=WMPl9+2-h2grQMY)Yhl_t#OzG1(5IIv#*{Q1}4u9~%tTAQv?zxh6C!$L}g}aZfSIBZ*FrhVRK}YK~X1@a7zx84pABd hv@HOWtt~qiP)h{{00000C;%t`Ul9NRCqMuI000e0BJuzL diff --git a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/AsdMetadata.java b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/AsdMetadata.java new file mode 100755 index 0000000..bc97d1e --- /dev/null +++ b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/AsdMetadata.java @@ -0,0 +1,42 @@ +/* + * ============LICENSE_START====================================================================== + * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved. + * =============================================================================================== + * 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. + * ============LICENSE_END======================================================================== + * + */ +package com.oransc.rappmanager.models.csar; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class AsdMetadata { + + String description; + String descriptorId; + String descriptorInvariantId; + String descriptorVersion; + String schemaVersion; + String functionDescription; + String provider; + String applicationName; + String applicationVersion; + List deploymentItems; +} diff --git a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandler.java b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandler.java index 1babdd2..f71315f 100755 --- a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandler.java +++ b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandler.java @@ -138,27 +138,7 @@ public class RappCsarConfigurationHandler { return asdLocation; } - public List getDeploymentItems(Rapp rApp) { - List deploymentItems = new ArrayList<>(); - File csarFile = getCsarFile(rApp); - String asdDefinitionLocation = getAsdDefinitionLocation(csarFile); - if (asdDefinitionLocation != null && !asdDefinitionLocation.isEmpty()) { - try { - String asdContent = getFileFromCsar(csarFile, asdDefinitionLocation).toString(); - JsonNode jsonNode = getAsdContentNode(asdContent); - JsonNode artifactsJsonNode = jsonNode.at(RappCsarPathProvider.ARTIFACTS_LOCATION_JSON_POINTER); - artifactsJsonNode.forEach(artifactJsonNode -> { - DeploymentItem deploymentItem = - objectMapper.convertValue(artifactJsonNode.at("/properties"), DeploymentItem.class); - deploymentItem.setFile(artifactJsonNode.at("/file").asText()); - deploymentItems.add(deploymentItem); - }); - } catch (Exception e) { - logger.warn("Unable to get the deployment items", e); - } - } - return deploymentItems; - } + public String getSmeProviderDomainPayload(Rapp rapp, RappSMEInstance rappSMEInstance) { @@ -232,6 +212,36 @@ public class RappCsarConfigurationHandler { return rappResources; } + public AsdMetadata getAsdMetadata(Rapp rApp) { + AsdMetadata asdMetadata = new AsdMetadata(); + File csarFile = getCsarFile(rApp); + String asdDefinitionLocation = getAsdDefinitionLocation(csarFile); + if (asdDefinitionLocation != null && !asdDefinitionLocation.isEmpty()) { + try { + String asdContent = getFileFromCsar(csarFile, asdDefinitionLocation).toString(); + if (asdContent != null && !asdContent.isEmpty()) { + JsonNode jsonNode = getAsdContentNode(asdContent); + JsonNode asdJsonNode = jsonNode.at(RappCsarPathProvider.ASD_LOCATION_JSON_POINTER); + asdMetadata = objectMapper.convertValue(asdJsonNode.at("/properties"), AsdMetadata.class); + asdMetadata.setDescription(asdJsonNode.at("/description").asText()); + + JsonNode artifactsJsonNode = jsonNode.at(RappCsarPathProvider.ASD_ARTIFACTS_LOCATION_JSON_POINTER); + final List deploymentItems = new ArrayList<>(); + artifactsJsonNode.forEach(artifactJsonNode -> { + DeploymentItem deploymentItem = + objectMapper.convertValue(artifactJsonNode.at("/properties"), DeploymentItem.class); + deploymentItem.setFile(artifactJsonNode.at("/file").asText()); + deploymentItems.add(deploymentItem); + }); + asdMetadata.setDeploymentItems(deploymentItems); + } + } catch (Exception e) { + logger.warn("Unable to get the asd metadata items", e); + } + } + return asdMetadata; + } + Set getFileListFromCsar(File csarFile, String dirLocation) { try (ZipFile zipFile = new ZipFile(csarFile)) { return zipFile.stream().filter(Predicate.not(ZipEntry::isDirectory)).map(ZipEntry::getName) diff --git a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarPathProvider.java b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarPathProvider.java index 745ae14..57a650c 100755 --- a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarPathProvider.java +++ b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/RappCsarPathProvider.java @@ -36,6 +36,11 @@ public class RappCsarPathProvider { public static final String DME_CONSUMER_INFO_TYPES_LOCATION = "Files/Dme/consumerinfotypes"; public static final String DME_INFO_PRODUCERS_LOCATION = "Files/Dme/infoproducers"; public static final String DME_INFO_CONSUMERS_LOCATION = "Files/Dme/infoconsumers"; - public static final String ARTIFACTS_LOCATION_JSON_POINTER = - "/topology_template/node_templates/applicationServiceDescriptor/artifacts"; -} \ No newline at end of file + public static final String ASD_LOCATION_JSON_POINTER = + "/topology_template/node_templates/applicationServiceDescriptor"; + public static final String ASD_PROPERTIES_JSON_POINTER = ASD_LOCATION_JSON_POINTER + "/properties"; + public static final String ASD_ARTIFACTS_LOCATION_JSON_POINTER = ASD_LOCATION_JSON_POINTER + "/artifacts"; + public static final String ASD_DESCRIPTOR_JSON_POINTER = ASD_PROPERTIES_JSON_POINTER + "/descriptor_id"; + public static final String ASD_DESCRIPTOR_VARIANT_LOCATION_JSON_POINTER = + ASD_PROPERTIES_JSON_POINTER + "/descriptor_invariant_id"; +} diff --git a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidator.java b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidator.java index ac00e95..082a156 100755 --- a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidator.java +++ b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidator.java @@ -36,7 +36,7 @@ public class ArtifactDefinitionValidator implements RappValidator { private final RappCsarConfigurationHandler rappCsarConfigurationHandler; private final RappValidationUtils rappValidationUtils; String invalidAsdErrorMsg = "ASD definition in rApp package is invalid."; - private static final int VALIDATION_ORDER = 10; + private static final int VALIDATION_ORDER = 15; @Override public int getOrder() { @@ -47,25 +47,16 @@ public class ArtifactDefinitionValidator implements RappValidator { public void validate(Object target, Errors errors) { MultipartFile multipartFile = (MultipartFile) target; String asdLocation = rappValidationUtils.getAsdDefinitionLocation(multipartFile); - if (asdLocation != null && !asdLocation.isEmpty() && rappValidationUtils.isFileExistsInCsar(multipartFile, - asdLocation)) { - try { - String asdContent = rappValidationUtils.getFileFromCsar(multipartFile, asdLocation).toString(); - if(asdContent != null && !asdContent.isEmpty()) { - JsonNode jsonNode = rappCsarConfigurationHandler.getAsdContentNode(asdContent); - List artifactFileList = - jsonNode.at(RappCsarPathProvider.ARTIFACTS_LOCATION_JSON_POINTER).findValuesAsText("file"); - artifactFileList.forEach( - artifactFile -> rappValidationUtils.isFileExistsInCsar(multipartFile, artifactFile)); - } else { - throw new RappValidationException(invalidAsdErrorMsg); - } - } catch (RappValidationException e) { - throw new RappValidationException(e.getMessage()); - } catch (Exception e) { - throw new RappValidationException(invalidAsdErrorMsg); - } - } else { + try { + String asdContent = rappValidationUtils.getFileFromCsar(multipartFile, asdLocation).toString(); + JsonNode jsonNode = rappCsarConfigurationHandler.getAsdContentNode(asdContent); + List artifactFileList = + jsonNode.at(RappCsarPathProvider.ASD_ARTIFACTS_LOCATION_JSON_POINTER).findValuesAsText("file"); + artifactFileList.forEach( + artifactFile -> rappValidationUtils.isFileExistsInCsar(multipartFile, artifactFile)); + } catch (RappValidationException e) { + throw new RappValidationException(e.getMessage()); + } catch (Exception e) { throw new RappValidationException(invalidAsdErrorMsg); } } diff --git a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidator.java b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidator.java new file mode 100755 index 0000000..643714e --- /dev/null +++ b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidator.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START====================================================================== + * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved. + * =============================================================================================== + * 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. + * ============LICENSE_END======================================================================== + * + */ + +package com.oransc.rappmanager.models.csar.validator; + +import com.fasterxml.jackson.databind.JsonNode; +import com.oransc.rappmanager.models.cache.RappCacheService; +import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler; +import com.oransc.rappmanager.models.csar.RappCsarPathProvider; +import com.oransc.rappmanager.models.exception.RappValidationException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.validation.Errors; +import org.springframework.web.multipart.MultipartFile; + +@Component +@RequiredArgsConstructor +public class AsdDescriptorValidator implements RappValidator { + + private final RappCacheService rappCacheService; + private final RappValidationUtils rappValidationUtils; + private final RappCsarConfigurationHandler rappCsarConfigurationHandler; + String invalidAsdErrorMsg = "ASD definition in rApp package is invalid."; + + private static final int VALIDATION_ORDER = 10; + + @Override + public int getOrder() { + return VALIDATION_ORDER; + } + + @Override + public void validate(Object target, Errors errors) { + MultipartFile multipartFile = (MultipartFile) target; + String asdLocation = rappValidationUtils.getAsdDefinitionLocation(multipartFile); + if (asdLocation != null && !asdLocation.isEmpty() && rappValidationUtils.isFileExistsInCsar(multipartFile, + asdLocation)) { + try { + String asdContent = rappValidationUtils.getFileFromCsar(multipartFile, asdLocation).toString(); + if (asdContent != null && !asdContent.isEmpty()) { + JsonNode jsonNode = rappCsarConfigurationHandler.getAsdContentNode(asdContent); + checkAsdDescriptorExists(jsonNode.at(RappCsarPathProvider.ASD_DESCRIPTOR_JSON_POINTER).asText()); + checkAsdDescriptorVariantExists( + jsonNode.at(RappCsarPathProvider.ASD_DESCRIPTOR_VARIANT_LOCATION_JSON_POINTER).asText()); + } else { + throw new RappValidationException(invalidAsdErrorMsg); + } + } catch (RappValidationException e) { + throw new RappValidationException(e.getMessage()); + } catch (Exception e) { + throw new RappValidationException(invalidAsdErrorMsg); + } + } else { + throw new RappValidationException(invalidAsdErrorMsg); + } + } + + boolean checkAsdDescriptorExists(String descriptorId) { + if (rappCacheService.getAllRapp().stream() + .anyMatch(rapp -> rapp.getAsdMetadata().getDescriptorId().equals(descriptorId))) { + throw new RappValidationException("ASD descriptor already exists."); + } + return true; + } + + boolean checkAsdDescriptorVariantExists(String descriptorVariantId) { + if (rappCacheService.getAllRapp().stream() + .anyMatch(rapp -> rapp.getAsdMetadata().getDescriptorInvariantId().equals(descriptorVariantId))) { + throw new RappValidationException("ASD descriptor invariant already exists."); + } + return true; + } +} diff --git a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/rapp/Rapp.java b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/rapp/Rapp.java index d061602..6619061 100755 --- a/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/rapp/Rapp.java +++ b/rapp-manager-models/src/main/java/com/oransc/rappmanager/models/rapp/Rapp.java @@ -20,6 +20,7 @@ package com.oransc.rappmanager.models.rapp; +import com.oransc.rappmanager.models.csar.AsdMetadata; import com.oransc.rappmanager.models.rappinstance.RappInstance; import java.beans.Transient; import java.util.HashMap; @@ -41,6 +42,7 @@ public class Rapp { String packageLocation; String packageName; RappResources rappResources; + AsdMetadata asdMetadata; @Builder.Default Map rappInstances = new HashMap<>(); diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/cache/BeanTestConfiguration.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/BeanTestConfiguration.java similarity index 88% rename from rapp-manager-models/src/test/java/com/oransc/rappmanager/models/cache/BeanTestConfiguration.java rename to rapp-manager-models/src/test/java/com/oransc/rappmanager/models/BeanTestConfiguration.java index ebe8f7b..8089502 100755 --- a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/cache/BeanTestConfiguration.java +++ b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/BeanTestConfiguration.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START====================================================================== - * Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved. + * Copyright (C) 2023-2024 OpenInfra Foundation Europe. All rights reserved. * =============================================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ * ============LICENSE_END======================================================================== */ -package com.oransc.rappmanager.models.cache; +package com.oransc.rappmanager.models; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.cache.CacheManager; @@ -24,7 +24,7 @@ import org.springframework.cache.concurrent.ConcurrentMapCacheManager; import org.springframework.context.annotation.Bean; @TestConfiguration -class BeanTestConfiguration { +public class BeanTestConfiguration { @Bean public CacheManager cacheManager() { diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/cache/RappCacheServiceTest.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/cache/RappCacheServiceTest.java index d2f5a8d..a89f344 100755 --- a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/cache/RappCacheServiceTest.java +++ b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/cache/RappCacheServiceTest.java @@ -22,6 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import com.oransc.rappmanager.models.BeanTestConfiguration; import com.oransc.rappmanager.models.rapp.Rapp; import java.util.UUID; import org.junit.jupiter.api.Test; diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandlerTest.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandlerTest.java index 2325789..9f1893b 100755 --- a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandlerTest.java +++ b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/RappCsarConfigurationHandlerTest.java @@ -24,7 +24,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -36,9 +38,10 @@ import com.oransc.rappmanager.models.rappinstance.RappDMEInstance; import com.oransc.rappmanager.models.rappinstance.RappSMEInstance; import java.io.ByteArrayOutputStream; import java.io.File; -import java.util.List; +import java.io.IOException; import java.util.Set; import java.util.UUID; +import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.json.JSONException; import org.json.JSONObject; import org.junit.jupiter.api.Test; @@ -95,6 +98,14 @@ class RappCsarConfigurationHandlerTest { assertThat(fileByteArray.size()).isZero(); } + @Test + void testInvalidZipStreamGetFromCsar() throws IOException { + ZipArchiveInputStream zipArchiveInputStream = mock(ZipArchiveInputStream.class); + doThrow(new IOException()).when(zipArchiveInputStream).getNextEntry(); + ByteArrayOutputStream fileByteArray = rappCsarConfigurationHandler.getFileFromCsar(zipArchiveInputStream, null); + assertThat(fileByteArray.size()).isZero(); + } + @Test void testListResources() { UUID rappId = UUID.randomUUID(); @@ -241,24 +252,37 @@ class RappCsarConfigurationHandlerTest { } @Test - void testListDeploymentItems() { + void testGetAsdMetadata() { Rapp rapp = Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build(); - List deploymentItems = rappCsarConfigurationHandler.getDeploymentItems(rapp); - assertEquals(2, deploymentItems.size()); + AsdMetadata asdMetadata = rappCsarConfigurationHandler.getAsdMetadata(rapp); + assertEquals("123e4567-e89b-12d3-a456-426614174000", asdMetadata.getDescriptorId()); + assertEquals("040eff2a-eb1a-4aff-bd46-37ce38092985", asdMetadata.getDescriptorInvariantId()); + assertEquals(2, asdMetadata.getDeploymentItems().size()); } @ParameterizedTest @ValueSource(strings = {invalidRappNoAsdFile, invalidRappEmptyAsdFile}) - void testListDeploymentItemsNoAsd(String packageName) { + void testGetAsdMetadataNoAsd(String packageName) { Rapp rapp = Rapp.builder().name("").packageName(packageName).packageLocation(validCsarFileLocation).build(); - assertThat(rappCsarConfigurationHandler.getDeploymentItems(rapp)).isEmpty(); + assertThat(rappCsarConfigurationHandler.getAsdMetadata(rapp)).isNotNull(); } @Test - void testListDeploymentItemsWithException() throws JsonProcessingException { + void testGetAsdMetadataException() throws JsonProcessingException { Rapp rapp = Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build(); doThrow(new JsonSyntaxException("")).when(rappCsarConfigurationHandler).getAsdContentNode(any()); - assertThat(rappCsarConfigurationHandler.getDeploymentItems(rapp)).isEmpty(); + assertNull(rappCsarConfigurationHandler.getAsdMetadata(rapp).getDescriptorId()); + assertNull(rappCsarConfigurationHandler.getAsdMetadata(rapp).getDescriptorInvariantId()); + assertThat(rappCsarConfigurationHandler.getAsdMetadata(rapp).getDeploymentItems()).isNull(); + } + + @Test + void testGetAsdMetadataNullAsdContent() throws JsonProcessingException { + Rapp rapp = Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build(); + doReturn(null).when(rappCsarConfigurationHandler).getAsdContentNode(any()); + assertNull(rappCsarConfigurationHandler.getAsdMetadata(rapp).getDescriptorId()); + assertNull(rappCsarConfigurationHandler.getAsdMetadata(rapp).getDescriptorInvariantId()); + assertThat(rappCsarConfigurationHandler.getAsdMetadata(rapp).getDeploymentItems()).isNull(); } @Test diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidatorTest.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidatorTest.java index 7348116..b0c2f43 100755 --- a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidatorTest.java +++ b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/ArtifactDefinitionValidatorTest.java @@ -83,33 +83,11 @@ class ArtifactDefinitionValidatorTest { assertTrue(exception.getMessage().startsWith("rApp package missing a file")); } - @Test - void testCsarNoAsdFailure() { - MultipartFile multipartFile = mock(MultipartFile.class); - RappValidationException exception = assertThrows(RappValidationException.class, - () -> artifactDefinitionValidator.validate(multipartFile, null)); - assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); - assertEquals("ASD definition in rApp package is invalid.", exception.getMessage()); - } - @ParameterizedTest - @NullSource - @ValueSource(strings = {""}) - void testCsarAsdLocationNullFailure(String asdLocation) throws IOException { - String rappCsarPath = validCsarFileLocation + File.separator + invalidRappAsdEmptyFile; - MultipartFile multipartFile = - new MockMultipartFile(rappCsarPath, rappCsarPath, ContentType.MULTIPART_FORM_DATA.getMimeType(), - new FileInputStream(rappCsarPath)); - doReturn(asdLocation).when(rappValidationUtils).getAsdDefinitionLocation(any()); - RappValidationException exception = assertThrows(RappValidationException.class, - () -> artifactDefinitionValidator.validate(multipartFile, null)); - assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); - assertEquals("ASD definition in rApp package is invalid.", exception.getMessage()); - } @ParameterizedTest @NullSource - @ValueSource(strings = {"", "{asasdasd"}) + @ValueSource(strings = {"{asasdasd"}) void testCsarAsdContentInvalidFailure(String asdContent) throws IOException { String rappCsarPath = validCsarFileLocation + File.separator + validRappFile; MultipartFile multipartFile = diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidatorTest.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidatorTest.java new file mode 100755 index 0000000..1d9079b --- /dev/null +++ b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/AsdDescriptorValidatorTest.java @@ -0,0 +1,165 @@ +/* + * ============LICENSE_START====================================================================== + * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved. + * =============================================================================================== + * 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. + * ============LICENSE_END======================================================================== + * + */ + +package com.oransc.rappmanager.models.csar.validator; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.Mockito.doReturn; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.oransc.rappmanager.models.BeanTestConfiguration; +import com.oransc.rappmanager.models.cache.RappCacheService; +import com.oransc.rappmanager.models.csar.AsdMetadata; +import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler; +import com.oransc.rappmanager.models.exception.RappValidationException; +import com.oransc.rappmanager.models.rapp.Rapp; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.UUID; +import org.apache.http.entity.ContentType; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.cache.CacheManager; +import org.springframework.http.HttpStatus; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.web.multipart.MultipartFile; + +@SpringBootTest +@ContextConfiguration(classes = {BeanTestConfiguration.class, AsdDescriptorValidator.class, RappValidationUtils.class, + ObjectMapper.class, RappCsarConfigurationHandler.class, RappCacheService.class, CacheManager.class}) +class AsdDescriptorValidatorTest { + + @Autowired + AsdDescriptorValidator asdDescriptorValidator; + @SpyBean + RappValidationUtils rappValidationUtils; + @Autowired + RappCacheService rappCacheService; + + String validCsarFileLocation = "src/test/resources/"; + String validRappFile = "valid-rapp-package.csar"; + String invalidRappAsdEmptyFile = "invalid-rapp-package-empty-asd-yaml.csar"; + + @Test + void testCsarContainsValidAsdFile() throws IOException { + String rappCsarPath = validCsarFileLocation + File.separator + validRappFile; + MultipartFile multipartFile = + new MockMultipartFile(rappCsarPath, rappCsarPath, ContentType.MULTIPART_FORM_DATA.getMimeType(), + new FileInputStream(rappCsarPath)); + assertDoesNotThrow(() -> asdDescriptorValidator.validate(multipartFile, null)); + } + + @Test + void testCsarContainsDuplicateDescriptorId() throws IOException { + String rappCsarPath = validCsarFileLocation + File.separator + validRappFile; + AsdMetadata asdMetadata = new AsdMetadata(); + asdMetadata.setDescriptorId("123e4567-e89b-12d3-a456-426614174000"); + asdMetadata.setDescriptorInvariantId(UUID.randomUUID().toString()); + Rapp rapp = Rapp.builder().name("").asdMetadata(asdMetadata).build(); + rappCacheService.putRapp(rapp); + MultipartFile multipartFile = + new MockMultipartFile(rappCsarPath, rappCsarPath, ContentType.MULTIPART_FORM_DATA.getMimeType(), + new FileInputStream(rappCsarPath)); + RappValidationException exception = + assertThrows(RappValidationException.class, () -> asdDescriptorValidator.validate(multipartFile, null)); + assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); + assertEquals("ASD descriptor already exists.", exception.getMessage()); + rappCacheService.deleteRapp(rapp); + } + + @Test + void testCsarContainsDuplicateDescriptorInvariantId() throws IOException { + String rappCsarPath = validCsarFileLocation + File.separator + validRappFile; + AsdMetadata asdMetadata = new AsdMetadata(); + asdMetadata.setDescriptorId(""); + asdMetadata.setDescriptorInvariantId("040eff2a-eb1a-4aff-bd46-37ce38092985"); + Rapp rapp = Rapp.builder().name("").asdMetadata(asdMetadata).build(); + rappCacheService.putRapp(rapp); + MultipartFile multipartFile = + new MockMultipartFile(rappCsarPath, rappCsarPath, ContentType.MULTIPART_FORM_DATA.getMimeType(), + new FileInputStream(rappCsarPath)); + RappValidationException exception = + assertThrows(RappValidationException.class, () -> asdDescriptorValidator.validate(multipartFile, null)); + assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); + assertEquals("ASD descriptor invariant already exists.", exception.getMessage()); + rappCacheService.deleteRapp(rapp); + } + + @Test + void testCsarContainsValidAsdFileFailure() throws IOException { + String rappCsarPath = validCsarFileLocation + File.separator + invalidRappAsdEmptyFile; + MultipartFile multipartFile = + new MockMultipartFile(rappCsarPath, rappCsarPath, ContentType.MULTIPART_FORM_DATA.getMimeType(), + new FileInputStream(rappCsarPath)); + RappValidationException exception = + assertThrows(RappValidationException.class, () -> asdDescriptorValidator.validate(multipartFile, null)); + assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); + assertEquals("ASD definition in rApp package is invalid.", exception.getMessage()); + } + + @ParameterizedTest + @NullSource + @ValueSource(strings = {""}) + void testCsarAsdLocationNullFailure(String asdLocation) throws IOException { + String rappCsarPath = validCsarFileLocation + File.separator + invalidRappAsdEmptyFile; + MultipartFile multipartFile = + new MockMultipartFile(rappCsarPath, rappCsarPath, ContentType.MULTIPART_FORM_DATA.getMimeType(), + new FileInputStream(rappCsarPath)); + doReturn(asdLocation).when(rappValidationUtils).getAsdDefinitionLocation(any()); + RappValidationException exception = + assertThrows(RappValidationException.class, () -> asdDescriptorValidator.validate(multipartFile, null)); + assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); + assertEquals("ASD definition in rApp package is invalid.", exception.getMessage()); + } + + @ParameterizedTest + @NullSource + @ValueSource(strings = {"", "{asasdasd"}) + void testCsarAsdContentInvalidFailure(String asdContent) throws IOException { + String rappCsarPath = validCsarFileLocation + File.separator + validRappFile; + MultipartFile multipartFile = + new MockMultipartFile(rappCsarPath, rappCsarPath, ContentType.MULTIPART_FORM_DATA.getMimeType(), + new FileInputStream(rappCsarPath)); + if (asdContent != null) { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + byteArrayOutputStream.write(asdContent.getBytes(), 0, asdContent.getBytes().length); + doCallRealMethod().doReturn(byteArrayOutputStream).when(rappValidationUtils) + .getFileFromCsar(any(MultipartFile.class), any()); + } else { + doCallRealMethod().doReturn(asdContent).when(rappValidationUtils) + .getFileFromCsar(any(MultipartFile.class), any()); + } + RappValidationException exception = + assertThrows(RappValidationException.class, () -> asdDescriptorValidator.validate(multipartFile, null)); + assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); + assertEquals("ASD definition in rApp package is invalid.", exception.getMessage()); + } +} diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationHandlerTest.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationHandlerTest.java index 9edfe34..2166419 100755 --- a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationHandlerTest.java +++ b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationHandlerTest.java @@ -24,6 +24,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import com.fasterxml.jackson.databind.ObjectMapper; +import com.oransc.rappmanager.models.BeanTestConfiguration; +import com.oransc.rappmanager.models.cache.RappCacheService; import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler; import com.oransc.rappmanager.models.exception.RappValidationException; import java.io.File; @@ -43,9 +45,9 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.web.multipart.MultipartFile; @SpringBootTest -@ContextConfiguration(classes = {RappValidationHandler.class, NamingValidator.class, FileExistenceValidator.class, - ArtifactDefinitionValidator.class, RappValidationUtils.class, RappCsarConfigurationHandler.class, - ObjectMapper.class}) +@ContextConfiguration(classes = {BeanTestConfiguration.class, RappValidationHandler.class, NamingValidator.class, + FileExistenceValidator.class, ArtifactDefinitionValidator.class, AsdDescriptorValidator.class, + RappValidationUtils.class, RappCsarConfigurationHandler.class, ObjectMapper.class, RappCacheService.class}) class RappValidationHandlerTest { @Autowired diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationUtilsTest.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationUtilsTest.java index 7f1d8de..da575dd 100755 --- a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationUtilsTest.java +++ b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/csar/validator/RappValidationUtilsTest.java @@ -87,7 +87,7 @@ class RappValidationUtilsTest { RappValidationException exception = assertThrows(RappValidationException.class, () -> rappValidationUtils.getFileFromCsar(multipartFile, null)); assertEquals(HttpStatus.BAD_REQUEST, exception.getStatusCode()); - assertEquals(String.format("Unable to get file %s from the multipart CSAR file", null), exception.getMessage()); + assertEquals(String.format("Unable to get file %s from the multipart CSAR file", (Object) null), exception.getMessage()); } @Test diff --git a/rapp-manager-models/src/test/resources/invalid-rapp-package-missing-artifact.csar b/rapp-manager-models/src/test/resources/invalid-rapp-package-missing-artifact.csar index c82fce6a3125dfc6b69ffd388ade415768496eaa..39dd3633296df0e1bb2cf48682e90d96643f057b 100755 GIT binary patch delta 866 zcmeB~#kh19w^?PTE88b`l-x)c*LZbI z`iZVd+w?uN&ObBm3}ks5e4cClz4Qbhc7dy{BHuqpPTR<{=*h~j65=ZFK0euF{BHGA zPEAdfH#6(6dG2x3d&INHJjx;cW9P#)towME>6P^SdpU_eRZoLca^h2td!jShy-ut+ zRnt;iAm@Ck`Qd_{RRy}=BO}*tsEf>($SY?L3oAO>urD%p?e)~yyjP1f=5@c7Y+{@J z%fvNyL6E3{&6ERK0bQ~wd(&3;9=N*gM(FOhr#G8y_ngw*S?@36p7Ve$EI459niuQN z$fuihmi)<$$hrrjQb})vrS?W5}oX2 zSH$#DYO;d8*kmqgrOEa-T$AkO7@a4}+gC7sl>v&2Pu^f3$M|3}ze5?*62-{^4&syN zIV3Wko#YtKB&ssm-$`zAxuX|TK7=_z#cA>bSAoejZc>b8ll`2!7;7fmJ4;WVsirhp z!H#dTinA2sC7?(Rld#5Q2WP3t1{!8S4IGpIyNOIb<;2GntT|cHRcdm9CPaO+ixksJ zh|o@#G{$w46>em z&9uU3@&OOA$y+>Am{u5rnFd}!rU{t2#w&wqpXuZ`-V&4byuFx&%z#XV$+Nrz7>`YU Z?On)NH96KNhVl61T|Pc+8?6|C007d6Zj}H4 delta 931 zcmZ2Fi?L@G@6i}@9?r$;>*f;x!JV$v*L|FOGnHihZcB_BC zcg4tK@+Gre)x`S0d?$<_1@4$K^Sxm|+j5=7Dy==r zItl5DpLXS%Cb=%Q*{FK0t(MDNhZRQW)K0fPXO-KkSvZw#w^PyNaxd+L>qHA17F}^{ zo}$%iS6`%F9g=-ea;@&U1g~=sF3i#jR-Uz7EdO-OLJp~gsnh3(yp$H<+2FO`JA1K- z#PR6E(=JyF%u|b#*z5Rb-(A)ZA1gTzY1DFS)Ug+Cx!YE_quYG;S)0gdR|>T5Dg=jK z4VJ7*EH*l*5zM4b3n7hDl z{d=L_O?McAcXYmbD$DXH{(=1FJ%Y=$km4oV#*+2yl)n6s$rG*RC!es9V_ZD>xlJ~+ zlnBG*01?f}0$vkV#!X&s8_u|F@_*YT#-Bh^Vse#TG}8^K$%3+Cli%8T zF==PL8Ox|c;#&ldBENAZ!&(y65W^QvxV%#!W(lMOrkMiU@j&hSHIC?RL zO)hklpZv=)hbdMSEVx0{ak7BBjGzRA0s{>EcT84em~5aSIhohli+LxM&7p2Sd4r?C zy#5I*^hW6x* zZgP`fYbyag%{TdgqZHF8h|n)b{mFmbq$h9i;h5~>B*pYo2dJ`>>A&t|8}~3~cRhy5 zwR&b?O*h@8m}da_=k#2`c6fV8F<;OJ@#QDCdjv3Z8Zu0tXec`Qy@wZbG??uVRyW&I zin-qiBquicoM$p~zcGY;+t?B;KiLZ?ZvxSK%ft@k!^!gAe2hyc>v<;w<3i6{a+YBpEfC2!0d1@&D diff --git a/rapp-manager-models/src/test/resources/invalid-rapp-package-no-acm-composition.csar b/rapp-manager-models/src/test/resources/invalid-rapp-package-no-acm-composition.csar index 30a7f04bf2c961f7ce5c4d4a86fa537b282c7cb7..03e466f8494d75fec600ed06188d3578c0d8449a 100755 GIT binary patch delta 948 zcmeynigDU%#toKoLT}{aNYrJsx^o4}_*}v&u|Y zwomRTxsfie@#>iL6J3+G>3e3Ke`een$nrM$JlFbr=?OmU0#{o_zJHFKwvlJila*g3 z#8uvXe6q**-Rh^Dnwl#0Z)RTe+~cPAh-Z&^ltcQ*&WCGQ_wg>%E9v?7auR>4o(8An z#HSqhL}#*lomg?Irlqz(&iPXF!v#C53Ut3mMy}mZ7nv`SSI!<5R&=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TPd=zDHaX7Si>U|1)SPVX$us%ByAzY0Dv&Ea*~%l1NmFC8pr`oc zQVjvH>{$;drnj0vp$bN^$z7h|%yBvlli%scPG%6^~rS(DVfXNMk0+Y3Uq?lt2Aabh>%qIEC2ud(00Mi`={CAvV$S_&gSaR}R zA1~%lP`0yg8uND}ka)->KP~28#y}66%1-t*QJTEKn{RTJpA>V52}F!rSATMzzx3pW zAdbm%=2PZQ}+W{SC2eB+FM2eZ;0mPS|JS`-E@$ls5Au)^slU+i6*nT;ILID7z Ci)3p6 diff --git a/rapp-manager-models/src/test/resources/invalid-rapp-package-no-tosca.csar b/rapp-manager-models/src/test/resources/invalid-rapp-package-no-tosca.csar index e03ad3a4ac3a15ab4f3578860918e01cab5d282a..406a56dad20ade363584b8a83d06bf2f986e5bd1 100755 GIT binary patch delta 978 zcmeyrg>lAK#toKo^>^b!Bf(W^|% z&Dk2_o4?pVV6XeBdWSo685aKB6`Hkl?Uw3S_ttjW=IKb@-Zaw^?PTE88b`l-x)c*LZbI`iZVd+w?uN&ObBm46J8)8+@K?{k`-A zA9jJOts>t)M^4+wv*^jnuM*-a?>;`+WBhLQQ%+4yl{Yi5dG2x3d&INHJjx;cW9P#) ztowME>6P^SdpU_eRZoLca^h2td!jShy-ut+Rnt;iAm@Ck`Qd_{RRy}=BO}*tsEf>( z$SY?L3oAO>urD%p?e)~yyjP1f>gRR8m26_0{maBPc0rJ+fz6ZySpi+LDSOja_a3;q z?MCSCx2HFoZ1$u zOn>DkDacGd>gC5=qQo${LP>LSL73F!w;_DYJAnK>O1dDvfGC3kFa zq^JiJ5}$0XCjb_b^>bo;Iyu3wl8Mh~@@>B`#<0nA{N*Q?8!1ix5WqM2RIn7|2B1hc z({|&@bN%He-!OIr*(oT2;;y|W43iI2osoG9Vo>dVg?c0 z7?{93#hhXCJ9Ej&xlf|*|Fj%lKFo-ZPFu0_qW#(m;Waj4;>n9ec=v5}> z=4=h|?r$;>*f;x!JV$v*L|FOGnHihZcB_BCcg4tK@+Gre)x`S0d?$<_1@4$K^Sxm| z+j5=7Dy==rItl5DpLXS%Cb=%Qx!$OHt*w^JT!$4# z=hRNOK4+ENs#!RdZMRd=_Vh3iBM8x~!0Y@VXkYFDIQ9g=-ea;@&U1g~=sF3i#j zR-Uz7EdO-OLJp~gsnh3(yp$H<+2FO`JA1K-#PR6E(=JyF%u|b#*z5Rb-(A)ZA1gTz zY1DFS)Ug+Cx!YE_quYG;S)0iEX;%ug?kWU_UJaJ4N-Q=ytaj+?iQ}7OxU5tb7aHyM z4BPG_S8mdEn}^IZ(7fS!}YgvJy~+ZSsd8j>(EXQp{G$AaVCeK{EUzU_(HLF);jhl$^Z5 zCy^;zb26iW*kn!LL?&5nFf&72aI%dr&*c5SPD~tnKq2wTQhsqvXY_$gEwIc6KPTp| zh76OnjdX!laZT3omt(Y@?Cqb)Jl%+4@>!$!$qN1)U=@9+yu^fIa-o^z z&fc_s~M{&PYjZte99c*^s*o+#*0AFM&@f443jsSOHS4cPG!Dn z3G|G$>|`A)gvwd|QjErv{{?q5TUmo-_{p5+^Vv|pXc`?laF~ukAgeNmzm^>l8n(2ZgSU|?f67I9y z2q~ruPGBwbBQltuIRmYB5ue-~YA`u45*X?(AigVH`Qb<@rgyHB??)CeE}9$=<;3>h H9TW=y&{%L? diff --git a/rapp-manager-models/src/test/resources/invalid-rapp-package.csar b/rapp-manager-models/src/test/resources/invalid-rapp-package.csar index c48da0fa80455029fdea43ad05e9f8555be0c177..d2d9e5e6f956ac9a67a01a9671b69a03f2440a24 100755 GIT binary patch delta 1211 zcmbQ4zA=4+l2$zf0|&#^xX=g@-tE)gF*7j8@G~%oFfcH-=N0QG7N_V{ zCg$dx4Uf*hY#>tS{>VO})<5IYn%lqFn2sEA^*dtQ0Zju=v{#S&^k#=7rnPlBZ|;d*h_tl1cXi3)4Mr{uC9S_%R<$G@T(fvf$h|<;)3sfW z*})qoP2rTkp0d28Yf;&pgJu_BaJDhDNeGy=)r&-|sFA->7JJRDN$@o*^Fw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PEVt&v}r}mrPM5^`1KTvy^`ha?pN7K#M<6g!K6} z_^-z8u`nK7#yFr5Q}SEmcSk|r%Nk>@L>oDx3p2n}0Ye69S-v91VOa|A5W!-^akAO~ zR-iHN;}ZQ8PGZ(B3z#MwLxzyRkOOI^C^_UZyR6fJD79dkS1ZD}e`ZDTlhGruwd6A&k5(7TW^LAfdm zObX@9vW--7uniEBOHKEfHBjBVxOck+^EK>6%ZV5-6^vkjoobiVvklUQ6z(ePdzj)z zXLzrA3}=6+cPOkgOp~AVh+}*vr)@4KeA-JbLcV^HV@xwE&td1)m*(}7h8IAe#T)cA zj1$`0awxU|HIB1B9!}o&IGv2&s&XrbeIJo#ooR?kK-JLW%f%jwr>}}HV!VY~D#Jm8 zBc(SRk1JKr!|qahk_n4#EWj#Lh55S1ZMiFxNrithv&WYG=IO+G^Yh1Ff4gaSH*9Xa zP5t)UtSdgb40nA#j@;P}R8IL0k7s>Gi4Lu&HoDdgYFxcz4j2^nCa*aDebl24u>RvI z5|LT_g{czv`>irK@M4`FucA0-0W<4t_6DK(_XsV%M`-zqQ2Wmm{cpuTS;Sw3I9a@7 z`9~Ow$guqB4_5xa0Z>Z^2y1*Tkm>^f02~jK@BtjNRxYmuJ`?~H00;;O07FW`R%?7M zkm>^f02~hh02BZK00000000000000SDgXdPWoBt^X>@6CZgVeTb7U@gVQp-aXEQ1w jNG<>XVRK|IZDvqQ1qJ{B000aC3;<69001;F00000)sP(_ diff --git a/rapp-manager-models/src/test/resources/valid-rapp-package.csar b/rapp-manager-models/src/test/resources/valid-rapp-package.csar index a045a6a0de9a35eb30970d6181e733d8e5a38081..1dddd4a45398630e2e399271d954f51cc94d5b2c 100755 GIT binary patch delta 995 zcmZqO!8mgV;|5DP&NFeL5lpAoHl3O5B&Ss0KifcHuluQbhdaD8HnbE(XNG4j{kCOq zbf2VqW^QAL!pJxtT5|CALplJ&b!?6ZnKK#Jn?ezJeBu% zJSL}bUMW4rDWj<_xjwsS&89hTzA=@#7J2X=J#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cSE) zU?IE6WM)=pkRH*=-p+O){|JgPC@{dle@AH-pnF`zCtF7WV+zcM*nBriidoqWBqu*v YGCF|q`sA$W7)F)J$D@7N_&h=S0Tx@E!2kdN diff --git a/rapp-manager-sme/src/test/resources/valid-rapp-package.csar b/rapp-manager-sme/src/test/resources/valid-rapp-package.csar index e1c17c684823226e6af902949696bb2501f96725..a269a486996c1821a2bb9d5be613a68caf0d30c5 100755 GIT binary patch delta 1187 zcmV;U1YG;*X8dNb#3z3M00;mMUsYIhsqCxg0{{RQ4*&oZ0000)WoBt^X>@6CZgVeT zb7U@gVQp;9S6gq>Fcf}A;y*-vPiWGt+xi9q#Kc8N1759D`=qnx*uilI<=1oET-&5& z42H-{6MyG^^Qki>2PQC+S~_WT$?njW^s)+SsFZo3kZmDXEM|Yn(gkgp2m>eubK3&T$cy&4GlfxR zvtj$86|* zm$Jd3XXzqwCk5J7@apzZnx6I<#N?OcOyH$W%d?uECa*ghrvA2{Lhc*L_!~;tH*qJ@# zZ;k99XDd>X8{q>0s>DMASwOxDjHRrU&Qbx3LyBH&U9WGwG0Fg^~^9N9OZs2nT6 zLe6rk8mTv9!ODPGgCgV5va652@~M`h^pFm}lQ$X^(M(%+7A>Rm=wb?r=TRI-aT3Lg zkX^!`1Q{8`hWzVQ(gjH{}26gdtBtfivO=)i?sYIaLeLp8jJ>#MDMnyMEKr7!VH z^@4x;J}s8a!J42$gxhW5_9}`Sozb1@$eUk@)fq*}O&Y|>J(IIG6l307sfCZ$Tl#IW z{#KW*)1Kr@{d!EoHIm8V9&&2J32ALI6s%E=P2C*_@$_*r>3*TAjnpGa^(Iq;v9GB^ zi}zD~iaj~Wo*_LOw(?$XdWww5}UeTgF@6CZgVeTb7U@gVQp;9S4(f>HW0oC z$bTSww-PCill3h{c2T1b1W3DAVoZ)~A{41ol(*Vn-=SpLdN~_xn__*kIr9zY@y&4T zZ6Sb5OqEeySyS*mx`Mu}n6E{J%5sgof=u(6CzltO7ZMBMRPJl7Ps)E4o=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