@Override protected void execute( SecurityTestRunner securityTestRunner, TestStep testStep, SecurityTestRunContext context) { scriptEngine.setScript(groovyscc.getExecuteScript().getStringValue()); scriptEngine.setVariable("context", context); scriptEngine.setVariable("testStep", testStep); scriptEngine.setVariable("securityScan", this); scriptEngine.setVariable("parameters", parameters); scriptEngine.setVariable("log", SoapUI.ensureGroovyLog()); try { scriptResult = scriptEngine.run(); hasNext = castResultToBoolean(scriptResult); XmlObjectTreeModel model = null; for (SecurityCheckedParameter scp : getParameterHolder().getParameterList()) { if (parameters.containsKey(scp.getLabel()) && parameters.get(scp.getLabel()) != null) { if (scp.isChecked() && scp.getXpath().trim().length() > 0) { model = SecurityScanUtil.getXmlObjectTreeModel(testStep, scp); XmlTreeNode[] treeNodes = null; treeNodes = model.selectTreeNodes(context.expand(scp.getXpath())); if (treeNodes.length > 0) { XmlTreeNode mynode = treeNodes[0]; mynode.setValue(1, parameters.get(scp.getLabel())); } updateRequestProperty(testStep, scp.getName(), model.getXmlObject().toString()); } else { updateRequestProperty(testStep, scp.getName(), parameters.get(scp.getLabel())); } } else if (parameters.containsKey(scp.getLabel()) && parameters.get(scp.getLabel()) == null) { // clears null values form parameters parameters.remove(scp.getLabel()); } } MessageExchange message = (MessageExchange) testStep.run((TestCaseRunner) securityTestRunner, context); createMessageExchange(clearNullValues(parameters), message, context); } catch (Exception e) { SoapUI.logError(e); hasNext = false; } finally { // if( scriptResult != null ) // { // getTestStep().getProperty( "Request" ).setValue( ( String // )scriptResult ); // // getTestStep().run( ( TestCaseRunner )securityTestRunner, // ( TestCaseRunContext )securityTestRunner.getRunContext() ); // } } }
public GroovySecurityScan( TestStep testStep, SecurityScanConfig config, ModelItem parent, String icon) { super(testStep, config, parent, icon); if (config.getConfig() == null) { groovyscc = GroovySecurityScanConfig.Factory.newInstance(); groovyscc.setExecuteScript(ScriptConfig.Factory.newInstance()); groovyscc.getExecuteScript().setLanguage("groovy"); groovyscc.getExecuteScript().setStringValue(""); config.setConfig(groovyscc); } else { groovyscc = (GroovySecurityScanConfig) config.getConfig(); if (groovyscc.getExecuteScript() == null) { groovyscc.setExecuteScript(ScriptConfig.Factory.newInstance()); groovyscc.getExecuteScript().setLanguage("groovy"); groovyscc.getExecuteScript().setStringValue(""); } } scriptEngine = SoapUIScriptEngineRegistry.create(this); getExecutionStrategy().setImmutable(true); }
public String getExecuteScript() { return groovyscc.getExecuteScript().getStringValue(); }
public void setExecuteScript(String script) { String old = getExecuteScript(); groovyscc.getExecuteScript().setStringValue(script); notifyPropertyChanged(SCRIPT_PROPERTY, old, script); }