use of javax.script.ScriptContext in project zaproxy by zaproxy.
the class ScriptVarsUnitTest method shouldNotReturnScriptCustomVariablesFromOtherScriptsUsingScriptContext.
@Test
void shouldNotReturnScriptCustomVariablesFromOtherScriptsUsingScriptContext() {
// Given
ScriptContext scriptContext1 = createScriptContextWithName("ScriptName1");
ScriptContext scriptContext2 = createScriptContextWithName("ScriptName2");
String key = createKey();
// When
ScriptVars.setScriptCustomVar(scriptContext1, key, createCustomValue());
// Then
assertThat(ScriptVars.getScriptCustomVar(scriptContext2, key), is(nullValue()));
}
use of javax.script.ScriptContext in project zaproxy by zaproxy.
the class ScriptVarsUnitTest method shouldNotReturnScriptVariablesFromOtherScriptsUsingScriptContext.
@Test
void shouldNotReturnScriptVariablesFromOtherScriptsUsingScriptContext() {
// Given
ScriptContext scriptContext1 = createScriptContextWithName("ScriptName1");
ScriptContext scriptContext2 = createScriptContextWithName("ScriptName2");
String key = createKey();
// When
ScriptVars.setScriptVar(scriptContext1, key, createValue());
// Then
assertThat(ScriptVars.getScriptVar(scriptContext2, key), is(nullValue()));
}
use of javax.script.ScriptContext in project zaproxy by zaproxy.
the class ScriptVarsUnitTest method shouldSetScriptVariableUsingScriptContext.
@Test
void shouldSetScriptVariableUsingScriptContext() {
// Given
String key = createKey();
String value = createValue();
String scriptName = "ScriptName";
ScriptContext scriptContext = createScriptContextWithName(scriptName);
// When
ScriptVars.setScriptVar(scriptContext, key, value);
// Then
assertThat(ScriptVars.getScriptVars(scriptName), hasEntry(key, value));
assertThat(ScriptVars.getScriptVar(scriptContext, key), is(equalTo(value)));
}
use of javax.script.ScriptContext in project zaproxy by zaproxy.
the class ScriptVarsUnitTest method createScriptContextWithName.
private static ScriptContext createScriptContextWithName(Object scriptName) {
ScriptContext context = new SimpleScriptContext();
context.setAttribute(ExtensionScript.SCRIPT_NAME_ATT, scriptName, ScriptContext.ENGINE_SCOPE);
return context;
}
use of javax.script.ScriptContext in project zaproxy by zaproxy.
the class ScriptVarsUnitTest method shouldNotSetScriptVariableWithInvalidValueLengthUsingScriptContext.
@Test
void shouldNotSetScriptVariableWithInvalidValueLengthUsingScriptContext() {
// Given
ScriptContext scriptContext = createScriptContextWithName("ScriptName");
// When / Then
assertThrows(IllegalArgumentException.class, () -> ScriptVars.setScriptVar(scriptContext, createKey(), createValueWithInvalidLength()));
}
Aggregations