summaryrefslogtreecommitdiffstats
path: root/integration-test
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-06-23 12:49:27 +0100
committerdanielhanrahan <daniel.hanrahan@est.tech>2023-07-06 17:28:00 +0100
commit531bd1002a480728936f8fa29ce87d4418783878 (patch)
tree3fd51558f24bfdce9d131b48a291da4fb34f236c /integration-test
parentddb8fce4f4300bb7cd1f477d846269d93f5036ae (diff)
Escape SQL LIKE wildcards in queries (CPS-1760 #1)
If '%' and '_' are used in the contains-condition of a CpsPath query, incorrect results will be returned. For example: /bookstore/categories[contains(@code, "%")] Special characters in the contains-condition value must be escaped. Issue-ID: CPS-1762 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: I2fdd5a26433d510cd7d6af5b734a6779b537d63d
Diffstat (limited to 'integration-test')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy11
1 files changed, 11 insertions, 0 deletions
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
index fa0b820459..0cb3200f80 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
@@ -339,4 +339,15 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'incomplete absolute 1 list entry' | '/categories[@code="3"]' || 0
}
+ def 'Cps Path query should ignore special characters: #scenario.'() {
+ when: 'a query is executed to get data nodes by the given cps path'
+ def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, INCLUDE_ALL_DESCENDANTS)
+ then: 'no data nodes are returned'
+ assert result.isEmpty()
+ where:
+ scenario | cpsPath
+ ' sql wildcard in contains-condition' | '/bookstore/categories[@code="1"]/books[contains(@title, "%")]'
+ 'regex wildcard in contains-condition' | '/bookstore/categories[@code="1"]/books[contains(@title, ".*")]'
+ }
+
}