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
5 changes: 5 additions & 0 deletions src/org/labkey/test/TestProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ public static boolean isCheckerFatal()
return "true".equals(System.getProperty("webtest.checker.fatal"));
}

public static boolean isControllerFirstUrlFatal()
{
return getBooleanProperty("webtest.fatalControllerFirstUrl", false);
}

public static boolean isAssayProductFeatureAvailable()
{
return isProductFeatureAvailable("assay");
Expand Down
19 changes: 19 additions & 0 deletions src/org/labkey/test/WebDriverWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,25 @@ public long beginAt(String url, int millis, boolean acceptAlerts)
logMessage = "Navigating to " + relativeURL;
}

if (WebTestHelper.isUseContainerRelativeUrl())
{
try
{
if (new Crawler.ControllerActionId(relativeURL).isControllerFirstUrl())
{
RuntimeException ex = new RuntimeException("Controller first url found in URL: " + relativeURL);
if (TestProperties.isControllerFirstUrlFatal())
throw ex;
else
TestLogger.log().warn(ex.getMessage(), ex);
}
}
catch (IllegalArgumentException e)
{
TestLogger.warn("Unable to parse URL: " + relativeURL, e);
}
}

final String fullURL = WebTestHelper.getBaseURL() + relativeURL;
final boolean expectPageLoad = expectPageLoad(fullURL);

Expand Down
7 changes: 0 additions & 7 deletions src/org/labkey/test/pages/core/admin/CustomizeSitePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ public String getBaseServerUrl()
return elementCache().baseServerUrl.get();
}

public CustomizeSitePage setContainerRelativeUrl(boolean enable)
{
elementCache().containerRelativeUrl.set(enable);
return this;
}

public CustomizeSitePage setUsageReportingLevel(ReportingLevel level)
{
elementCache().usageReportingLevel(level).check();
Expand Down Expand Up @@ -233,7 +227,6 @@ protected class ElementCache extends LabKeyPage.ElementCache
// Site URLs
protected final Input defaultDomain = Input(Locator.id("defaultDomain"), getDriver()).findWhenNeeded(this);
protected final Input baseServerUrl = Input(Locator.id("baseServerURL"), getDriver()).findWhenNeeded(this);
protected final Checkbox containerRelativeUrl = Checkbox(Locator.id("useContainerRelativeURL")).findWhenNeeded(this);

// Usage Reporting
protected RadioButton usageReportingLevel(ReportingLevel level)
Expand Down
28 changes: 28 additions & 0 deletions src/org/labkey/test/util/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ else if (urlText.startsWith("?"))
p += (_prioritizeAdminPages ? -1 : 1);
priority = p + random.nextFloat();

checkControllerRelativeUrl();

try
{
isVisitableURL();
Expand Down Expand Up @@ -605,6 +607,18 @@ public boolean underCreatedProject()
return _projects.contains(currentProject);
}

private void checkControllerRelativeUrl()
{
if (_actionId != null && _actionId.isControllerFirstUrl() && WebTestHelper.isUseContainerRelativeUrl())
{
RuntimeException ex = new RuntimeException("Found a controller-first URL (%s) on %s".formatted(getUrlText(), getOrigin()));
if (TestProperties.isControllerFirstUrlFatal())
throw ex;
else
TestLogger.warn(ex.getMessage(), ex);
}
}

public boolean isVisitableURL()
{
if (StringUtils.isBlank(getRelativeURL()))
Expand Down Expand Up @@ -677,12 +691,14 @@ public static class ControllerActionId
@NotNull private final String _controller;
@NotNull private String _action = "";
private final String _containerPath;
private final boolean _controllerFirstUrl;

public ControllerActionId(@NotNull String controller, @NotNull String action)
{
_controller = controller;
_action = action;
_containerPath = null;
_controllerFirstUrl = false;
}

public ControllerActionId(@NotNull String url)
Expand All @@ -691,6 +707,7 @@ public ControllerActionId(@NotNull String url)

if (rootRelativeURL.startsWith("_webdav/"))
{
_controllerFirstUrl = false;
_controller = "_webdav";
String path = EscapeUtil.decode(rootRelativeURL.substring("_webdav/".length()));
if (path.startsWith("@"))
Expand All @@ -711,6 +728,7 @@ public ControllerActionId(@NotNull String url)
}
if (rootRelativeURL.startsWith("_webfiles/"))
{
_controllerFirstUrl = false;
_controller = "_webfiles";
_containerPath = EscapeUtil.decode(rootRelativeURL.substring("_webfiles/".length()));
return;
Expand All @@ -735,6 +753,7 @@ public ControllerActionId(@NotNull String url)
int dash = _action.lastIndexOf("-");
_controller = _action.substring(0,dash);
_action = _action.substring(dash+1);
_controllerFirstUrl = false;
}
else
{
Expand All @@ -744,6 +763,7 @@ public ControllerActionId(@NotNull String url)
throw new IllegalArgumentException("Unable to parse folder out of relative URL: \"" + rootRelativeURL + "\"");
_controller = rootRelativeURL.substring(0, postControllerSlashIdx);
rootRelativeURL = rootRelativeURL.substring(postControllerSlashIdx+1);
_controllerFirstUrl = true;
}
_containerPath = EscapeUtil.decode(StringUtils.strip(rootRelativeURL, "/"));
}
Expand All @@ -768,6 +788,14 @@ public String getContainerPath()
return _containerPath;
}

/**
* Allows us to track down pages that still create controller-first URLs
*/
public boolean isControllerFirstUrl()
{
return _controllerFirstUrl;
}

@Override
public String toString()
{
Expand Down