Skip to content

Commit 3398567

Browse files
committed
Update sanitizeForRedis to handle trailing spaces and extend dataset search integration tests
- Enhanced `sanitizeForRedis` to escape trailing spaces properly. - Added test scenarios for datasets with tags containing spaces and special characters.
1 parent e8b4f9b commit 3398567

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

common/src/main/kotlin/com/cosmotech/common/utils/StringExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fun String.sanitizeForKubernetes(maxLength: Int = KUBERNETES_RESOURCE_NAME_MAX_L
2929

3030
fun String.sanitizeForRedis(): String {
3131
var sanitizedString = this
32-
",./;'[]-=<>?:{}|_+!@#%^&*()`~"
32+
",./;'[]-=<>?:{}|_+!@#%^&*()`~ "
3333
.forEach { sanitizedString = sanitizedString.replace(it.toString(), "\\\\$it") }
3434
"\"$".forEach { sanitizedString = sanitizedString.replace(it.toString(), "\\\\\\${it}") }
3535
return sanitizedString

dataset/src/integrationTest/kotlin/com/cosmotech/dataset/service/DatasetServiceIntegrationTest.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,12 +1047,21 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
10471047
tags = mutableListOf("dataset", "public", "other")),
10481048
arrayOf())
10491049

1050+
datasetApiService.createDataset(
1051+
organizationSaved.id,
1052+
workspaceSaved.id,
1053+
DatasetCreateRequest(
1054+
name = "Another Dataset",
1055+
description = "Another Dataset ",
1056+
tags = mutableListOf("dataset", "public", "other with blankspace 12 34")),
1057+
arrayOf())
1058+
10501059
val foundDatasets =
10511060
datasetApiService.searchDatasets(
10521061
organizationSaved.id,
10531062
workspaceSaved.id,
10541063
listOf(
1055-
"other",
1064+
"other with blankspace 12 34",
10561065
",",
10571066
".",
10581067
"/",

0 commit comments

Comments
 (0)