Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/org/labkey/test/tests/flow/BaseFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
import org.junit.BeforeClass;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
Expand Down Expand Up @@ -46,6 +47,7 @@
abstract public class BaseFlowTest extends BaseWebDriverTest
{
protected static final File PIPELINE_PATH = TestFileUtils.getSampleData("flow");
protected static final String DEFAULT_BACKGROUND_FILTER_VALUE = "Neg Cont";

@Override
public List<String> getAssociatedModules()
Expand Down Expand Up @@ -264,6 +266,12 @@ protected void uploadSampleDescriptions(File sampleFile, Map<String, FieldDefini
}

protected void setProtocolMetadata(String specimenIdColumn, String participantColumn, String dateColumn, String visitColumn, boolean setBackground)
{
setProtocolMetadata(specimenIdColumn, participantColumn, dateColumn, visitColumn, setBackground ? DEFAULT_BACKGROUND_FILTER_VALUE : null);
}

/** A null backgroundValue leaves the match column and background filter settings untouched. */
protected void setProtocolMetadata(String specimenIdColumn, String participantColumn, String dateColumn, String visitColumn, @Nullable String backgroundValue)
{
log("** Specify metadata");
goToFlowDashboard();
Expand All @@ -280,7 +288,7 @@ protected void setProtocolMetadata(String specimenIdColumn, String participantCo
if (visitColumn != null)
selectOptionByText(Locator.name("ff_visitColumn"), visitColumn);

if (setBackground)
if (backgroundValue != null)
{
// specify forground-background match columns
Locator loc1 = Locator.name("ff_matchColumn").index(0);
Expand All @@ -291,7 +299,7 @@ protected void setProtocolMetadata(String specimenIdColumn, String participantCo
selectOptionByText(Locator.name("ff_backgroundFilterField").index(0), "Sample Stim");
Locator loc = Locator.name("ff_backgroundFilterOp").index(0);
assertEquals("eq", getFormElement(loc));
setFormElement(Locator.name("ff_backgroundFilterValue").index(0), "Neg Cont");
setFormElement(Locator.name("ff_backgroundFilterValue").index(0), backgroundValue);
}

clickButton("Set Metadata");
Expand Down
38 changes: 37 additions & 1 deletion src/org/labkey/test/tests/flow/FlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class FlowTest extends BaseFlowTest
private static final String FCS_FILE_1 = "L02-060120-QUV-JS";
private static final String FCS_FILE_2 = "L04-060120-QUV-JS";
private static final String QUV_ANALYSIS_NAME = "QUV analysis";
private static final String PTID_COLUMN = "Sample PTID";
private static final String VISIT_COLUMN = "Sample Visit";

@BeforeClass
public static void initR()
Expand Down Expand Up @@ -100,6 +102,7 @@ public void _doTestSteps()
sampleTypeAndMetadataTest();
customGraphQuery();
positivityReportTest();
backgroundFilterRInjectionTest();
qcReportTest();
copyAnalysisScriptTest();
removeAnalysisFilter();
Expand Down Expand Up @@ -498,7 +501,7 @@ protected void configureSampleTypeAndMetadata()
fields.put("Comment", FieldDefinition.ColumnType.String);

uploadSampleDescriptions(TestFileUtils.getSampleData("flow/8color/sample-set.tsv"), fields, new String[]{"Exp Name", "Well Id"}, new String[]{"EXPERIMENT NAME", "WELL ID"});
setProtocolMetadata(null, "Sample PTID", null, "Sample Visit", true);
setProtocolMetadata(null, PTID_COLUMN, null, VISIT_COLUMN, true);

goToFlowDashboard();
clickAndWait(Locator.linkContainingText("49 sample descriptions"));
Expand Down Expand Up @@ -619,6 +622,39 @@ public void positivityReportTest()
verifyDeleted(reportName);
}

/**
* GH Issue 1525: a background filter value reaches the generated R script as data, not code. The payload closes the
* generated string literal and both enclosing list() calls, so an unescaped value aborts qc.R before it emits output.
*/
@LogMethod
public void backgroundFilterRInjectionTest()
{
final String marker = "R_INJECTION_1525";
final String reportName = "R injection QC report";

setProtocolMetadata(null, PTID_COLUMN, null, VISIT_COLUMN,
DEFAULT_BACKGROUND_FILTER_VALUE + "\")); stop(\"" + marker + "\"); #");

log("** Creating QC report '" + reportName + "'");
goToFlowDashboard();

final QCReportEditorPage qcReport = new FlowReportsWebpart(getDriver()).createQCReport();
qcReport.setName(reportName);
qcReport.setSubset("Singlets/L/Live/3+/4+/(IFNg+|IL2+)");
qcReport.setStatistic(QCReportEditorPage.Stat.Freq_Of_Parent);
qcReport.addFieldFilter("Name", "Contains", "L02");
qcReport.save();

clickAndWait(Locator.linkWithText(reportName));
WebElement reportView = Locator.id("report-view").findElement(getDriver());

Locator.tagWithClass("table", "labkey-r-tsvout").waitForElement(reportView, WAIT_FOR_PAGE);
assertTextNotPresent(marker);

deleteReport(reportName);
setProtocolMetadata(null, PTID_COLUMN, null, VISIT_COLUMN, DEFAULT_BACKGROUND_FILTER_VALUE);
}

@LogMethod
public void qcReportTest()
{
Expand Down
Loading