Skip to content

Commit

Permalink
[Fix apache#3712] Allow concatenation of secrets and const (apache#3713)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado authored and rgdoliveira committed Oct 10, 2024
1 parent b887866 commit 6f869c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public JsonPathExpression(String expr) {

private static final String replaceMagic(String expr, String magic) {
magic = "$" + magic;
return expr.replace(magic, "@." + magic);
return expr.replace(magic, "$." + magic);
}

private Configuration getConfiguration(KogitoProcessContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,16 @@ void testWorkflowPropertyFromJsonAccessible() {
@MethodSource("provideMagicWordExpressionsToTest")
void testMagicWordsExpressions(String expression, String expectedResult, KogitoProcessContext context) {
Expression parsedExpression = ExpressionHandlerFactory.get("jsonpath", expression);
assertThat(parsedExpression.isValid()).isTrue();
assertThat(parsedExpression.isValid()).overridingErrorMessage(() -> parsedExpression.validationError().getMessage()).isTrue();
assertThat(parsedExpression.eval(getObjectNode(), String.class, context)).isEqualTo(expectedResult);
}

private static Stream<Arguments> provideMagicWordExpressionsToTest() {
return Stream.of(
Arguments.of("$WORKFLOW.instanceId", "1111-2222-3333", getContext()),
Arguments.of("$SECRET.lettersonly", "secretlettersonly", getContext()),
Arguments.of("$SECRET.lettersonly$SECRET.lettersonly", "secretlettersonlysecretlettersonly", getContext()),
Arguments.of("$.propertyString$.propertyNum", "string12", getContext()),
Arguments.of("$SECRET.none", "", getContext()),
Arguments.of("$SECRET.dot.secret", "secretdotsecret", getContext()),
Arguments.of("$SECRET[\"dot.secret\"]", "secretdotsecret", getContext()),
Expand Down

0 comments on commit 6f869c8

Please sign in to comment.