-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #671 from akto-api-security/hotfix/concat_vars
replace multiple differents vars
- Loading branch information
Showing
2 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
apps/testing/src/test/java/com/akto/test_editor/execution/TestVariableResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.akto.test_editor.execution; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
public class TestVariableResolver { | ||
|
||
@Test | ||
public void testResolveExpression() { | ||
Map<String, Object> varMap = new HashMap<>(); | ||
varMap.put("var1", "user1"); | ||
varMap.put("var2", "user2"); | ||
String result = VariableResolver.resolveExpression(varMap, "${var1}"); | ||
assertEquals("user1", result); | ||
result = VariableResolver.resolveExpression(varMap, "var1"); | ||
assertEquals("user1", result); | ||
|
||
result = VariableResolver.resolveExpression(varMap, "${var1}!!!"); | ||
assertEquals("user1!!!", result); | ||
result = VariableResolver.resolveExpression(varMap, "var1!!!"); | ||
assertEquals("var1!!!", result); | ||
|
||
result = VariableResolver.resolveExpression(varMap, "${var1}${var2}"); | ||
assertEquals("user1user2", result); | ||
result = VariableResolver.resolveExpression(varMap, "var1${var2}"); | ||
assertEquals("var1user2", result); | ||
|
||
result = VariableResolver.resolveExpression(varMap, "${var1}&${var2}"); | ||
assertEquals("user1&user2", result); | ||
result = VariableResolver.resolveExpression(varMap, "var1&${var2}"); | ||
assertEquals("var1&user2", result); | ||
|
||
result = VariableResolver.resolveExpression(varMap, "${var3}"); | ||
assertEquals("${var3}", result); | ||
|
||
result = VariableResolver.resolveExpression(varMap, "${var1}${var1}"); | ||
assertEquals("user1user1", result); | ||
|
||
result = VariableResolver.resolveExpression(varMap, "akto"); | ||
assertEquals("akto", result); | ||
} | ||
|
||
} |