@Override public void afterRun(TestCaseRunner testRunner, SecurityTestRunContext runContext) { TestCase testCase = testRunner.getTestCase(); SecurityTest securityTest = ((SecurityTestRunner) testRunner).getSecurityTest(); JUnitReport report = new JUnitReport(); report.setIncludeTestProperties(includeTestPropertiesInReport); String reportName = securityTest.getName(); report.setTestSuiteName(reportName); report.setPackage(testCase.getTestSuite().getProject().getName()); int errorCount = 0; for (TestStep ts : testCase.getTestStepList()) { SecurityTestStepResult secuTestStepResult = securityTest.getSecurityTestStepResultMap().get(ts); if (secuTestStepResult != null) { for (SecurityScanResult scanResult : secuTestStepResult.getSecurityScanResultList()) { HashMap<String, String> testProperties = getTestPropertiesAsHashMap(securityTest); List<SecurityScanRequestResult> resultList = scanResult.getSecurityRequestResultList(); Testcase secTestCase = report.addTestCase( ts.getName() + " - " + scanResult.getSecurityScanName(), scanResult.getTimeTaken(), testProperties); secTestCase.setPackage(testCase.getTestSuite().getProject().getName()); for (int i = 0; i < resultList.size(); i++) { SecurityScanRequestResult scanRequestResult = resultList.get(i); if (scanRequestResult.getStatus() == ResultStatus.FAILED) { StringBuffer result = new StringBuffer(); result .append("<pre>") .append(XmlUtils.entitize(scanRequestResult.getChangedParamsInfo(i + 1))) .append("</pre>"); for (String message : scanRequestResult.getMessages()) { result.append("<pre>").append(XmlUtils.entitize(message)).append("</pre>"); } secTestCase.addNewError().setStringValue(result.toString()); errorCount++; } } } } report.setNoofErrorsInTestSuite(errorCount); report.setTotalTime(testRunner.getTimeTaken()); reports.put(reportName, report); } }
@Override public void afterSecurityScanRequest( TestCaseRunner testRunner, SecurityTestRunContext runContext, SecurityScanRequestResult securityCheckReqResult) { if (securityCheckReqResult.getSecurityScan().getTestStep().getId().equals(testStep.getId())) { if (securityCheckReqResult.getStatus() == ResultStatus.FAILED) { counterLabel.setOpaque(true); counterLabel.setBackground(FAILED_COLOR); totalAlertsCounter++; counterLabel.setText(" " + totalAlertsCounter + " "); ((DefaultTreeModel) tree.getModel()).nodeChanged(node); progressBar.setForeground(FAILED_COLOR); } } }