diff options
author | lukegleeson <luke.gleeson@est.tech> | 2022-07-11 10:55:53 +0100 |
---|---|---|
committer | lukegleeson <luke.gleeson@est.tech> | 2022-07-29 10:42:04 +0100 |
commit | 82a550f6b080cb50912d93f7b13ba0fc97a95470 (patch) | |
tree | 1bb3ca97c99e46c9b5a5654b2848038c37f20c4d /cps-service/src/test | |
parent | 054873c7c52bdb9fae718a0d7651d57b1a995dfc (diff) |
Query CmHandles using CPS path
Added withCpsPath condition parameter
Validated to prevent misuse and blocking of querying using private properties
Updated OpenAPI with examples and links to documentation
Moved methods related to cmHandle querying using cps path from InventoryPersistence to CmHandleQueries
Renamed private method deleteSchemaSetAndListElementByCmHandleId to deleteCmHandleByCmHandleId
Issue-ID: CPS-977
Change-Id: I83827215b7e58de74f8f62cd0140516d217d93f1
Signed-off-by: lukegleeson <luke.gleeson@est.tech>
Diffstat (limited to 'cps-service/src/test')
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/utils/CmHandleQueryRestParametersValidatorSpec.groovy | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/utils/CmHandleQueryRestParametersValidatorSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/utils/CmHandleQueryRestParametersValidatorSpec.groovy index a9b04c1ced..d5dcb7fc5c 100644 --- a/cps-service/src/test/groovy/org/onap/cps/utils/CmHandleQueryRestParametersValidatorSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/utils/CmHandleQueryRestParametersValidatorSpec.groovy @@ -88,4 +88,29 @@ class CmHandleQueryRestParametersValidatorSpec extends Specification { 'invalid value' | [moduleName: ''] 'invalid name' | [wrongName: 'value'] } + + def 'Validate CmHandle where an exception is thrown due to #scenario.'() { + when: 'the validator is called on a cps path condition property' + CmHandleQueryRestParametersValidator.validateCpsPathConditionProperties(conditionProperty) + then: 'a data validation exception is thrown' + def e = thrown(DataValidationException) + and: 'exception message matches the expected message' + e.details.contains(exceptionMessage) + where: + scenario | conditionProperty || exceptionMessage + 'more than one condition is supplied' | ['cpsPath':'some-path', 'cpsPath2':'some-path'] || 'Only one condition property is allowed for the CPS path query.' + 'cpsPath key not supplied' | ['wrong-key':'some-path'] || 'Wrong CPS path condition property. - expecting "cpsPath" as the condition property.' + 'cpsPath not supplied' | ['cpsPath':''] || 'Wrong CPS path. - please supply a valid CPS path.' + } + + def 'Validate CmHandle where #scenario.'() { + when: 'the validator is called on a cps path condition property' + def result = CmHandleQueryRestParametersValidator.validateCpsPathConditionProperties(['cpsPath':cpsPath]) + then: 'the expected boolean value is returned' + result == expectedBoolean + where: + scenario | cpsPath || expectedBoolean + 'cpsPath is valid' | '/some/valid/path' || true + 'cpsPath attempts to query private properties' | "//additional-properties[@some-property='some-value']" || false + } } |