Skip to content

Commit fe5b792

Browse files
authored
Stop referencing removed setting (#2663)
1 parent 7f6b23d commit fe5b792

4 files changed

Lines changed: 52 additions & 7 deletions

File tree

src/org/labkey/test/TestProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ public static boolean isCheckerFatal()
262262
return "true".equals(System.getProperty("webtest.checker.fatal"));
263263
}
264264

265+
public static boolean isControllerFirstUrlFatal()
266+
{
267+
return getBooleanProperty("webtest.fatalControllerFirstUrl", false);
268+
}
269+
265270
public static boolean isAssayProductFeatureAvailable()
266271
{
267272
return isProductFeatureAvailable("assay");

src/org/labkey/test/WebDriverWrapper.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,25 @@ public long beginAt(String url, int millis, boolean acceptAlerts)
12061206
logMessage = "Navigating to " + relativeURL;
12071207
}
12081208

1209+
if (WebTestHelper.isUseContainerRelativeUrl())
1210+
{
1211+
try
1212+
{
1213+
if (new Crawler.ControllerActionId(relativeURL).isControllerFirstUrl())
1214+
{
1215+
RuntimeException ex = new RuntimeException("Controller first url found in URL: " + relativeURL);
1216+
if (TestProperties.isControllerFirstUrlFatal())
1217+
throw ex;
1218+
else
1219+
TestLogger.log().warn(ex.getMessage(), ex);
1220+
}
1221+
}
1222+
catch (IllegalArgumentException e)
1223+
{
1224+
TestLogger.warn("Unable to parse URL: " + relativeURL, e);
1225+
}
1226+
}
1227+
12091228
final String fullURL = WebTestHelper.getBaseURL() + relativeURL;
12101229
final boolean expectPageLoad = expectPageLoad(fullURL);
12111230

src/org/labkey/test/pages/core/admin/CustomizeSitePage.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ public String getBaseServerUrl()
7575
return elementCache().baseServerUrl.get();
7676
}
7777

78-
public CustomizeSitePage setContainerRelativeUrl(boolean enable)
79-
{
80-
elementCache().containerRelativeUrl.set(enable);
81-
return this;
82-
}
83-
8478
public CustomizeSitePage setUsageReportingLevel(ReportingLevel level)
8579
{
8680
elementCache().usageReportingLevel(level).check();
@@ -233,7 +227,6 @@ protected class ElementCache extends LabKeyPage.ElementCache
233227
// Site URLs
234228
protected final Input defaultDomain = Input(Locator.id("defaultDomain"), getDriver()).findWhenNeeded(this);
235229
protected final Input baseServerUrl = Input(Locator.id("baseServerURL"), getDriver()).findWhenNeeded(this);
236-
protected final Checkbox containerRelativeUrl = Checkbox(Locator.id("useContainerRelativeURL")).findWhenNeeded(this);
237230

238231
// Usage Reporting
239232
protected RadioButton usageReportingLevel(ReportingLevel level)

src/org/labkey/test/util/Crawler.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ else if (urlText.startsWith("?"))
527527
p += (_prioritizeAdminPages ? -1 : 1);
528528
priority = p + random.nextFloat();
529529

530+
checkControllerRelativeUrl();
531+
530532
try
531533
{
532534
isVisitableURL();
@@ -605,6 +607,18 @@ public boolean underCreatedProject()
605607
return _projects.contains(currentProject);
606608
}
607609

610+
private void checkControllerRelativeUrl()
611+
{
612+
if (_actionId != null && _actionId.isControllerFirstUrl() && WebTestHelper.isUseContainerRelativeUrl())
613+
{
614+
RuntimeException ex = new RuntimeException("Found a controller-first URL (%s) on %s".formatted(getUrlText(), getOrigin()));
615+
if (TestProperties.isControllerFirstUrlFatal())
616+
throw ex;
617+
else
618+
TestLogger.warn(ex.getMessage(), ex);
619+
}
620+
}
621+
608622
public boolean isVisitableURL()
609623
{
610624
if (StringUtils.isBlank(getRelativeURL()))
@@ -677,12 +691,14 @@ public static class ControllerActionId
677691
@NotNull private final String _controller;
678692
@NotNull private String _action = "";
679693
private final String _containerPath;
694+
private final boolean _controllerFirstUrl;
680695

681696
public ControllerActionId(@NotNull String controller, @NotNull String action)
682697
{
683698
_controller = controller;
684699
_action = action;
685700
_containerPath = null;
701+
_controllerFirstUrl = false;
686702
}
687703

688704
public ControllerActionId(@NotNull String url)
@@ -691,6 +707,7 @@ public ControllerActionId(@NotNull String url)
691707

692708
if (rootRelativeURL.startsWith("_webdav/"))
693709
{
710+
_controllerFirstUrl = false;
694711
_controller = "_webdav";
695712
String path = EscapeUtil.decode(rootRelativeURL.substring("_webdav/".length()));
696713
if (path.startsWith("@"))
@@ -711,6 +728,7 @@ public ControllerActionId(@NotNull String url)
711728
}
712729
if (rootRelativeURL.startsWith("_webfiles/"))
713730
{
731+
_controllerFirstUrl = false;
714732
_controller = "_webfiles";
715733
_containerPath = EscapeUtil.decode(rootRelativeURL.substring("_webfiles/".length()));
716734
return;
@@ -735,6 +753,7 @@ public ControllerActionId(@NotNull String url)
735753
int dash = _action.lastIndexOf("-");
736754
_controller = _action.substring(0,dash);
737755
_action = _action.substring(dash+1);
756+
_controllerFirstUrl = false;
738757
}
739758
else
740759
{
@@ -744,6 +763,7 @@ public ControllerActionId(@NotNull String url)
744763
throw new IllegalArgumentException("Unable to parse folder out of relative URL: \"" + rootRelativeURL + "\"");
745764
_controller = rootRelativeURL.substring(0, postControllerSlashIdx);
746765
rootRelativeURL = rootRelativeURL.substring(postControllerSlashIdx+1);
766+
_controllerFirstUrl = true;
747767
}
748768
_containerPath = EscapeUtil.decode(StringUtils.strip(rootRelativeURL, "/"));
749769
}
@@ -768,6 +788,14 @@ public String getContainerPath()
768788
return _containerPath;
769789
}
770790

791+
/**
792+
* Allows us to track down pages that still create controller-first URLs
793+
*/
794+
public boolean isControllerFirstUrl()
795+
{
796+
return _controllerFirstUrl;
797+
}
798+
771799
@Override
772800
public String toString()
773801
{

0 commit comments

Comments
 (0)