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
15 changes: 15 additions & 0 deletions src/org/labkey/test/tests/DataClassTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.labkey.test.tests;

import org.hamcrest.CoreMatchers;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand All @@ -26,6 +27,7 @@
import org.labkey.test.categories.Daily;
import org.labkey.test.components.domain.AdvancedSettingsDialog;
import org.labkey.test.components.domain.BaseDomainDesigner;
import org.labkey.test.components.domain.DomainFieldRow;
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.pages.core.admin.BaseSettingsPage.DATE_FORMAT;
import org.labkey.test.pages.core.admin.BaseSettingsPage.TIME_FORMAT;
Expand Down Expand Up @@ -180,6 +182,19 @@ public void testReservedFieldNames()
"'Name Expression' is a reserved field name in 'Reserved Field Names Test'.",
"Please correct errors in Reserved Field Names Test before saving."),
createPage.clickSaveExpectingErrors());
domainFormPanel.removeAllFields(false);

log("Verify a reserved field name cannot be used as a field import alias. GH Issue 1474");
String aliasHostField = "AliasHostField";
DomainFieldRow fieldRow = domainFormPanel.manuallyDefineFields(aliasHostField);
for (String reservedName : Arrays.asList("Container", "Folder", "genId", "runid", "DataFileUrl", "NameExpression"))
{
fieldRow.setImportAliases(reservedName);
checker().verifyThat("Expected an error when an import alias matches reserved field name '" + reservedName + "'",
String.join("\n", createPage.clickSaveExpectingErrors()),
CoreMatchers.containsString("Import alias '" + reservedName + "' on field '" + aliasHostField + "' conflicts with a reserved field name."));
checker().screenShotIfNewError("importAliasConflictsWithReservedName_" + reservedName);
}

createPage.clickCancel();
}
Expand Down
15 changes: 15 additions & 0 deletions src/org/labkey/test/tests/SampleTypeParentColumnTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,21 @@ public void testAliasNameConflictsWithFieldName()
assertThat("Error message", String.join("\n", errors), CoreMatchers.containsString(errorMsgExpectedTxt));

updatePage.clickCancel();

// GH Issue 1474: import aliases must not collide with a reserved field name
clickFolder(SUB_FOLDER_NAME);
updatePage = sampleHelper.goToEditSampleType(SAMPLE_TYPE_NAME);
log("Check that an import alias cannot collide with a reserved field name.");
for (String reservedName : Arrays.asList("Folder", "Container", "genId", "CpasType", "FreezeThawCount"))
{
updatePage.getFieldsPanel().getField("DupeAliasCheck").setImportAliases(reservedName);
errors = updatePage.clickSaveExpectingErrors();
errorMsgExpectedTxt = "Import alias '" + reservedName + "' on field 'DupeAliasCheck' conflicts with a reserved field name.";
assertThat("Error message for reserved import alias '" + reservedName + "'",
String.join("\n", errors), CoreMatchers.containsString(errorMsgExpectedTxt));

}
updatePage.clickCancel();
}

@Test
Expand Down
12 changes: 12 additions & 0 deletions src/org/labkey/test/tests/SampleTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,18 @@ public void testOverlappingAliases()
containsString("Import alias '" + fieldTwo.toLowerCase() + "' on field '" + fieldOne + "' conflicts with a field name."));
checker().screenShotIfNewError("importAliasConflictsWithFieldNameIgnoringCase");

// GH Issue 1474: import aliases must not collide with a reserved field name
log("Verify an import alias cannot collide with a reserved field name. GH Issue 1474");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there also be a test added DataClassTest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test added

for (String reservedName : Arrays.asList("Folder", "Container", "genId", "CpasType", "FreezeThawCount"))
{
createPage = new CreateSampleTypePage(this.getDriver());
fieldsPanel.getField(fieldOne).setImportAliases(reservedName);
checker().verifyThat("Expected an error when an import alias matches reserved field name '" + reservedName + "'",
String.join("\n", createPage.clickSaveExpectingErrors()),
containsString("Import alias '" + reservedName + "' on field '" + fieldOne + "' conflicts with a reserved field name."));
checker().screenShotIfNewError("importAliasConflictsWithReservedName_" + reservedName);
}

log("An alias that repeats its own field's name is redundant but not ambiguous, so it should be allowed.");
fieldsPanel.getField(fieldOne).setImportAliases(fieldOne);
createPage.clickSave();
Expand Down
Loading