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
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