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
10 changes: 10 additions & 0 deletions src/org/labkey/test/TestScrubber.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.labkey.test.util.LogMethod;
import org.labkey.test.util.PipelineToolsHelper;
import org.labkey.test.util.TestLogger;
import org.labkey.test.util.core.admin.CspConfigHelper;
import org.labkey.test.util.core.login.DbLoginUtils;
import org.labkey.test.util.login.AuthenticationAPIUtils;
import org.openqa.selenium.WebDriverException;
Expand Down Expand Up @@ -171,6 +172,15 @@ public void cleanSiteSettings()
TestLogger.error("Failed to disable pipeline triggers after test", e);
}

try
{
new CspConfigHelper(this::createDefaultConnection).setEnforceCsp(true);
}
catch (NullPointerException e)
{
TestLogger.error("Failed to enable CSP enforcement after test", e);
}

}

@LogMethod(quiet = true)
Expand Down
12 changes: 11 additions & 1 deletion src/org/labkey/test/pages/test/TestReauthPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.labkey.test.pages.LabKeyPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -56,7 +57,16 @@ public String getDescription()

public void clickReauth()
{
clickAndWait(elementCache().reauthLink);
WebElement link = elementCache().reauthLink;

shortWait().until(
ExpectedConditions.attributeContains(
link,
"href",
"returnUrl"
)
);
clickAndWait(link);
clearCache();
}

Expand Down
8 changes: 7 additions & 1 deletion src/org/labkey/test/tests/AbstractReauthTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.junit.Test;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.WebTestHelper;
import org.labkey.test.pages.test.TestReauthPage;

import java.util.Arrays;
Expand Down Expand Up @@ -122,12 +123,17 @@ private void signInAs(User user)
signOut();
clickSignIn();
authenticate(user.email, user.password);
// An IdP's SAML POST-binding page auto-submits to LabKey, so the browser can still be on the IdP
// origin here. getCurrentUser() copies only the cookies visible to the current URL, which excludes
// LabKey's session cookie, so wait for the browser to land back on LabKey before checking the user.
waitFor(() -> getDriver().getCurrentUrl().startsWith(WebTestHelper.getBaseURL()),
"Browser didn't return to LabKey after authenticating", WAIT_FOR_PAGE);
assertSignedInAs(user);
}

private void assertSignedInAs(User user)
{
if (!waitFor(() -> getCurrentUser().equals(user.email), 1_000))
if (!waitFor(() -> getCurrentUser().equals(user.email), WAIT_FOR_PAGE))
assertEquals("Signed in as", user.email, getCurrentUser());
}

Expand Down
13 changes: 11 additions & 2 deletions src/org/labkey/test/tests/AssayExportImportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ private Integer createSimpleProjectAndAssay(String projectName, String assayName
Connection cn = createDefaultConnection();
Protocol protocol = new GetProtocolCommand("General").execute(cn, projectName).getProtocol();
protocol.setName(assayName);
protocol.setProtocolTransformScripts(List.of(new File(SAMPLE_DATA_LOCATION, PERL_SCRIPT).getAbsolutePath()));
protocol.setSaveScriptFiles(true);
protocol.setEditableResults(true);
protocol.setEditableRuns(true);
Expand Down Expand Up @@ -199,7 +198,17 @@ private Integer createSimpleProjectAndAssay(String projectName, String assayName
resultsFields.add(new FieldDefinition("resultFileField", ColumnType.File));
domains.get("Data Fields").setFields(resultsFields);

return new SaveProtocolCommand(protocol).execute(cn, projectName).getProtocol().getProtocolId();
Integer protocolId = new SaveProtocolCommand(protocol).execute(cn, projectName).getProtocol().getProtocolId();

// GitHub Issue #159: The transform script must live in the assay's "@scripts" directory, so add it through the
// designer's file upload rather than setting an absolute path on the protocol via the API.
log("Add the transform script '" + PERL_SCRIPT + "' to the assay design using the designer's file upload.");
goToProjectHome(projectName);
ReactAssayDesignerPage assayDesignerPage = ReactAssayDesignerPage.beginAt(this, projectName, protocolId, "General", getURL().toString());
assayDesignerPage.addTransformScript(new File(SAMPLE_DATA_LOCATION, PERL_SCRIPT));
assayDesignerPage.clickFinish();

return protocolId;
}

public void addNewField(String projectName, String assayName, FieldDefinition newField)
Expand Down
1 change: 1 addition & 0 deletions src/org/labkey/test/tests/CrawlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected void doCleanup(boolean afterTest)
{
super.doCleanup(afterTest);
_userHelper.deleteUsers(afterTest, USER);
_cspConfigHelper.setEnforceCsp(true);
}

@BeforeClass
Expand Down
Loading