Ejemplo n.º 1
0
  @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() );
      // }

    }
  }
Ejemplo n.º 2
0
  protected void initWSDL(StringToStringMap values, WsdlInterface iface) {
    boolean cached = iface.isCached();
    if (useCached != null) useCached.setEnabled(cached);

    if (!values.containsKey(CACHED_WSDL)) values.put(CACHED_WSDL, Boolean.toString(cached));

    if (values.getBoolean(CACHED_WSDL) || !values.hasValue(WSDL))
      values.put(WSDL, PathUtils.expandPath(iface.getDefinition(), iface));
  }
Ejemplo n.º 3
0
 private static boolean checkIfJMS(MessageExchangeModelItem messageExchange) {
   try {
     MessageExchange me = ((MessageExchangeModelItem) messageExchange).getMessageExchange();
     if (me != null) {
       StringToStringMap strmap = me.getProperties();
       if (strmap != null && strmap.containsKey("Endpoint")) {
         String r = me.getProperty("Endpoint");
         return r != null && r.startsWith(JMSEndpoint.JMS_ENDPIONT_PREFIX);
       } else {
         return false;
       }
     } else {
       return false;
     }
   } catch (NullPointerException e) {
     SoapUI.logError(e);
   }
   return false;
 }