Skip to content

Commit 787d439

Browse files
Issue 53408: Encode field names in attachment download links (#2543)
1 parent efbfd7b commit 787d439

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

src/org/labkey/test/tests/AttachmentFieldTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.labkey.test.util.DataRegionTable;
2020
import org.labkey.test.util.PortalHelper;
2121
import org.labkey.test.util.SampleTypeHelper;
22+
import org.labkey.test.util.TestDataGenerator;
2223

2324
import java.io.File;
2425
import java.util.List;
@@ -96,8 +97,8 @@ public void testFileFieldInSampleType()
9697
@Test
9798
public void testAttachmentFieldInLists()
9899
{
99-
String listName = "List with attachment field";
100-
String fieldName = "testFile";
100+
String listName = TestDataGenerator.randomDomainName("List with attachment field");
101+
String fieldName = TestDataGenerator.randomFieldName("Test File");
101102
goToProjectHome();
102103
log("Creating the list");
103104
_listHelper.createList(getProjectName(), listName, "id");

src/org/labkey/test/tests/FileAttachmentColumnTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import org.labkey.test.pages.study.CreateStudyPage;
3636
import org.labkey.test.params.FieldDefinition;
3737
import org.labkey.test.params.FieldDefinition.ColumnType;
38+
import org.labkey.test.params.FieldInfo;
3839
import org.labkey.test.params.assay.GeneralAssayDesign;
3940
import org.labkey.test.params.experiment.SampleTypeDefinition;
4041
import org.labkey.test.util.DataRegionTable;
4142
import org.labkey.test.util.ListHelper;
4243
import org.labkey.test.util.PortalHelper;
4344
import org.labkey.test.util.SampleTypeHelper;
4445
import org.labkey.test.util.StudyHelper;
46+
import org.labkey.test.util.TestDataGenerator;
4547
import org.labkey.test.util.core.webdav.WebDavUploadHelper;
4648
import org.labkey.test.util.exp.SampleTypeAPIHelper;
4749
import org.openqa.selenium.By;
@@ -90,6 +92,7 @@ public class FileAttachmentColumnTest extends BaseWebDriverTest
9092
private final String RESULT_FILE_COL = "resultFile";
9193
private final String OTHER_RESULT_FILE_COL = "otherResultFile";
9294
private final String STUDY_DATASET_NAME = "ogreSpiteLevels";
95+
private static final FieldInfo LIST_ATTACHMENT_FIELD = new FieldInfo(TestDataGenerator.randomFieldName("File / Attachment"), ColumnType.Attachment);
9396

9497
@Override
9598
protected void doCleanup(boolean afterTest) throws TestTimeoutException
@@ -180,8 +183,8 @@ public void verifyFileDownloadOnClick()
180183
for (File testFile : downloadTestFiles)
181184
{
182185
int rowIndex = testListRegion.getRowIndex("Name", testFile.getName());
183-
var downloadLink = testListRegion.link(rowIndex, "File");
184-
doAndWaitForDownload(()-> downloadLink.click());
186+
var downloadLink = testListRegion.link(rowIndex, LIST_ATTACHMENT_FIELD.getName());
187+
doAndWaitForDownload(downloadLink::click);
185188
}
186189

187190
// verify popup/sprite for jpeg
@@ -428,13 +431,13 @@ private void createListWithData(String containerPath)
428431
String LIST_KEY = "TestListId";
429432
listHelper.createList(getProjectName() + "/" + EXPORT_FOLDER_NAME, LIST_NAME, LIST_KEY,
430433
new FieldDefinition("Name", ColumnType.String),
431-
new FieldDefinition("File", ColumnType.Attachment));
434+
LIST_ATTACHMENT_FIELD.getFieldDefinition());
432435
goToManageLists();
433436
listHelper.click(Locator.linkContainingText(LIST_NAME));
434437

435438
for (File file : SAMPLE_FILES)
436439
{
437-
Map<String, String> fileRow = Map.of("Name", file.getName(), "File", file.getAbsolutePath());
440+
Map<String, String> fileRow = Map.of("Name", file.getName(), LIST_ATTACHMENT_FIELD.getName(), file.getAbsolutePath());
438441
listHelper.insertNewRow(fileRow, false);
439442
}
440443
}
@@ -448,7 +451,7 @@ private void importSampleDataUI(String sampleTypeName, String containerPath, Lis
448451
for (File file : files)
449452
{
450453
sampleFileData.add(Map.of("Name", file.getName(), "Color", "green",
451-
"File", file.getName()));
454+
LIST_ATTACHMENT_FIELD.getName(), file.getName()));
452455
}
453456
helper.bulkImport(sampleFileData);
454457
}
@@ -513,7 +516,7 @@ private void validateListData(String listName, String folderPath, List<File> exp
513516
else
514517
{
515518
int rowIndex = testListRegion.getRowIndex("Name", testFile.getName());
516-
var downloadLink = testListRegion.link(rowIndex, "File");
519+
var downloadLink = testListRegion.link(rowIndex, LIST_ATTACHMENT_FIELD.getName());
517520
doAndWaitForDownload(() -> downloadLink.click());
518521
}
519522
}
@@ -539,7 +542,7 @@ private void validateSampleData(String sampleType, String folderPath, List<File>
539542
}
540543
else
541544
{
542-
WebElement fileLinkCell = samplesRegion.findCell(rowIndex, "file");
545+
WebElement fileLinkCell = samplesRegion.findCell(rowIndex, LIST_ATTACHMENT_FIELD.getName());
543546
Optional<WebElement> optionalFileLink = Locator.tag("a").findOptionalElement(fileLinkCell);
544547
checker().withScreenshot("unexpected_file_state")
545548
.awaiting(Duration.ofSeconds(2),

src/org/labkey/test/tests/InlineImagesListTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.labkey.test.util.DataRegionExportHelper;
3535
import org.labkey.test.util.DataRegionTable;
3636
import org.labkey.test.util.ExcelHelper;
37+
import org.labkey.test.util.TestDataGenerator;
3738
import org.openqa.selenium.By;
3839
import org.openqa.selenium.support.ui.ExpectedConditions;
3940

@@ -51,16 +52,16 @@
5152
@BaseWebDriverTest.ClassTimeout(minutes = 5)
5253
public class InlineImagesListTest extends BaseWebDriverTest
5354
{
54-
protected final static String LIST_NAME = "InlineImagesList";
55-
protected final static String LIST_KEY_NAME = "Key";
55+
protected final static String LIST_NAME = TestDataGenerator.randomDomainName("InlineImagesList");
56+
protected final static String LIST_KEY_NAME = TestDataGenerator.randomFieldName("Key");
5657
protected final static ColumnType LIST_KEY_TYPE = ColumnType.Integer;
5758

58-
protected final static String LIST_ATTACHMENT01_NAME = "Attachment01";
59-
protected final static String LIST_ATTACHMENT01_LABEL = "Attachment Column 01";
59+
protected final static String LIST_ATTACHMENT01_NAME = TestDataGenerator.randomFieldName("Attachment01");
60+
protected final static String LIST_ATTACHMENT01_LABEL = TestDataGenerator.randomFieldName("Attachment Column 01");
6061
protected final static String LIST_ATTACHMENT01_DESC = "An 1st attachment column.";
6162

62-
protected final static String LIST_ATTACHMENT02_NAME = "Attachment02";
63-
protected final static String LIST_ATTACHMENT02_LABEL = "Attachment Column 02";
63+
protected final static String LIST_ATTACHMENT02_NAME = TestDataGenerator.randomFieldName("Attachment02");
64+
protected final static String LIST_ATTACHMENT02_LABEL = TestDataGenerator.randomFieldName("Attachment Column 02");
6465
protected final static String LIST_ATTACHMENT02_DESC = "An 2nd attachment column.";
6566

6667
protected final static ColumnType LIST_ATTACHMENT_TYPE = ColumnType.Attachment;
@@ -132,7 +133,7 @@ private void doInit()
132133
}
133134

134135
@Test
135-
public final void ListTest() throws Exception
136+
public final void testList() throws Exception
136137
{
137138
DataRegionTable list;
138139
DataRegionExportHelper exportHelper;

0 commit comments

Comments
 (0)