New Account console tests failures (#12050)
* New Account console tests failures, Fix additional tests, solve issue with headless browsers Fixes #11323
This commit is contained in:
parent
24171d2e47
commit
bb3b88963b
14 changed files with 260 additions and 135 deletions
|
@ -48,7 +48,7 @@ public abstract class AbstractLoggedInPage extends AbstractAccountPage {
|
||||||
@Page
|
@Page
|
||||||
private ContinueCancelModal modal;
|
private ContinueCancelModal modal;
|
||||||
|
|
||||||
@FindBy(xpath = ".//*[@id='page-heading']//h1")
|
@FindBy(className = "pf-c-title")
|
||||||
private WebElement pageTitle;
|
private WebElement pageTitle;
|
||||||
|
|
||||||
@FindBy(id = "refresh-page")
|
@FindBy(id = "refresh-page")
|
||||||
|
@ -84,10 +84,13 @@ public abstract class AbstractLoggedInPage extends AbstractAccountPage {
|
||||||
* and at some Account Console page (not Welcome Screen), i.e. that the nav bar is visible.
|
* and at some Account Console page (not Welcome Screen), i.e. that the nav bar is visible.
|
||||||
*/
|
*/
|
||||||
public void navigateToUsingSidebar() {
|
public void navigateToUsingSidebar() {
|
||||||
|
if (sidebar.isCollapsed()) {
|
||||||
|
sidebar.expand();
|
||||||
|
}
|
||||||
|
|
||||||
if (getParentPageId() != null) {
|
if (getParentPageId() != null) {
|
||||||
sidebar().clickSubNav(getParentPageId(), getPageId());
|
sidebar().clickSubNav(getParentPageId(), getPageId());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sidebar().clickNav(getPageId());
|
sidebar().clickNav(getPageId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ApplicationsPage extends AbstractLoggedInPage {
|
||||||
boolean userConsentRequired = !UIUtils.getTextFromElement(app.findElement(By.xpath("//div[@id='application-internal-" + clientId + "']"))).equals("Internal");
|
boolean userConsentRequired = !UIUtils.getTextFromElement(app.findElement(By.xpath("//div[@id='application-internal-" + clientId + "']"))).equals("Internal");
|
||||||
boolean inUse = UIUtils.getTextFromElement(app.findElement(By.xpath("//div[@id='application-status-" + clientId + "']"))).equals("In use");
|
boolean inUse = UIUtils.getTextFromElement(app.findElement(By.xpath("//div[@id='application-status-" + clientId + "']"))).equals("In use");
|
||||||
boolean applicationDetailsVisible = app.findElement(By.xpath("//section[@id='application-expandable-" + clientId + "']")).isDisplayed();
|
boolean applicationDetailsVisible = app.findElement(By.xpath("//section[@id='application-expandable-" + clientId + "']")).isDisplayed();
|
||||||
String effectiveURL = UIUtils.getTextFromElement(app.findElement(By.xpath("//span[@id='application-effectiveurl-" + clientId + "']")));
|
String effectiveURL = UIUtils.getTextFromElement(app.findElement(By.id("application-effectiveurl-" + clientId)));
|
||||||
return new ClientRepresentation(clientId, clientName, userConsentRequired, inUse, effectiveURL, applicationDetailsVisible);
|
return new ClientRepresentation(clientId, clientName, userConsentRequired, inUse, effectiveURL, applicationDetailsVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||||
import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;
|
import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;
|
||||||
|
@ -35,8 +37,8 @@ public class DeviceActivityPage extends AbstractLoggedInPage {
|
||||||
@FindBy(id = "sign-out-all")
|
@FindBy(id = "sign-out-all")
|
||||||
private WebElement signOutAllBtn;
|
private WebElement signOutAllBtn;
|
||||||
|
|
||||||
@FindBy(xpath = "//div[@rowid='sessions']/div[contains(@class,'-m-3-')]")
|
@FindBy(className = "signed-in-device-grid")
|
||||||
private List<WebElement> sessionsFirstCol; // this represents first column of each session (which contains the browser icon)
|
private List<WebElement> sessions;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPageId() {
|
public String getPageId() {
|
||||||
|
@ -57,58 +59,76 @@ public class DeviceActivityPage extends AbstractLoggedInPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSessionsCount() {
|
public int getSessionsCount() {
|
||||||
return sessionsFirstCol.size();
|
return sessions.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session getSessionByIndex(int index) {
|
public Optional<Session> getSessionByIndex(int index) {
|
||||||
// get the session ID from browser icon (which we know is always present)
|
try {
|
||||||
String sessionId = sessionsFirstCol.get(index)
|
return Optional.of(new Session(sessions.get(index)));
|
||||||
.findElement(By.xpath("//*[contains(@id,'-icon-')]"))
|
} catch (Exception e) {
|
||||||
.getAttribute("id")
|
log.warn(e.getMessage());
|
||||||
.split("-")[1];
|
return Optional.empty();
|
||||||
|
}
|
||||||
return getSession(sessionId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session getSession(String sessionId) {
|
public Optional<Session> getSession(String sessionId) {
|
||||||
return new Session(sessionId);
|
try {
|
||||||
|
return Optional.of(new Session(getSessionElement(sessionId)));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn(e.getMessage());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private WebElement getSessionElement(String sessionId) {
|
||||||
|
return sessions.stream()
|
||||||
|
.filter(f -> getTrimmedSessionId(sessionId).equals(getSessionId(f)))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getSessionId(WebElement sessionElement) {
|
||||||
|
if (sessionElement == null) return null;
|
||||||
|
return sessionElement.getAttribute("id").split("-")[1]; // the id looks like session-71891504-item
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getTrimmedSessionId(String fullSessionId) {
|
||||||
|
return fullSessionId.substring(0, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We cannot use standard Page Fragment as there's no root element. Even though the sessions are placed in rows,
|
// We cannot use standard Page Fragment as there's no root element. Even though the sessions are placed in rows,
|
||||||
// there's no element that would encapsulate it. Hence we cannot simply use e.g. @FindBy annotations.
|
// there's no element that would encapsulate it. Hence we cannot simply use e.g. @FindBy annotations.
|
||||||
public class Session {
|
public class Session {
|
||||||
private static final String SESSION = "session";
|
private static final String SESSION = "session";
|
||||||
private static final String BROWSER = "browser";
|
private static final String DEVICE_ICON = "device-icon";
|
||||||
private static final String IP = "ip";
|
private static final String IP = "ip";
|
||||||
private static final String SIGN_OUT = "sign-out";
|
private static final String SIGN_OUT = "sign-out";
|
||||||
|
|
||||||
|
private final WebElement element;
|
||||||
private final String sessionId;
|
private final String sessionId;
|
||||||
private final String fullSessionId;
|
|
||||||
|
|
||||||
// we don't want Session to be instantiated outside DeviceActivityPage
|
// we don't want Session to be instantiated outside DeviceActivityPage
|
||||||
private Session(String sessionId) {
|
private Session(WebElement element) {
|
||||||
this.fullSessionId = sessionId;
|
this.element = element;
|
||||||
this.sessionId = sessionId.substring(0,7);
|
this.sessionId = DeviceActivityPage.getSessionId(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSessionId() {
|
public String getSessionId() {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullSessionId() {
|
|
||||||
return fullSessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPresent() {
|
public boolean isPresent() {
|
||||||
return isItemDisplayed(IP); // no root element hence this workaround
|
return isItemDisplayed(IP); // no root element hence this workaround
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBrowserIconName() {
|
public String getIcon() {
|
||||||
String id = driver
|
final WebElement icon = (WebElement) Optional.ofNullable(element.findElement(By.className(DEVICE_ICON)))
|
||||||
.findElement(By.xpath(String.format("//*[contains(@id,'%s')]", getFullItemId("icon"))))
|
.map(f -> (WebElement) f)
|
||||||
.getAttribute("id");
|
.map(f -> f.findElement(By.tagName("svg")))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
return id.split("-")[3]; // the id looks like session-71891504-icon-chrome
|
if (icon == null) return "";
|
||||||
|
return icon.getAttribute("id").split("-")[3]; // the id looks like session-71891504-icon-desktop
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIp() {
|
public String getIp() {
|
||||||
|
@ -120,38 +140,56 @@ public class DeviceActivityPage extends AbstractLoggedInPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBrowserDisplayed() {
|
public boolean isBrowserDisplayed() {
|
||||||
return isItemDisplayed(BROWSER);
|
return !"".equals(getBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return getTextFromElement(element.findElement(By.className("session-title")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBrowser() {
|
public String getBrowser() {
|
||||||
return getTextFromItem(BROWSER);
|
try {
|
||||||
|
return getTitle().split("/", 2)[1].trim();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLastAccess() {
|
public String getLastAccess() {
|
||||||
String lastAccessedText = getTextFromElement(
|
return getTextFromItem("last-access");
|
||||||
driver.findElement(By.cssSelector("[id*='last-access'] strong")));
|
|
||||||
|
|
||||||
return getTextFromItem("last-access").substring(lastAccessedText.length()).trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClients() {
|
public String getClients() {
|
||||||
return getTextFromItem("clients").split("Clients ")[1];
|
return getTextFromItem("clients");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStarted() {
|
public String getStarted() {
|
||||||
return getTextFromItem("started").split("Started ")[1];
|
return getTextFromItem("started");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExpires() {
|
public String getExpires() {
|
||||||
return getTextFromItem("expires").split("Expires ")[1];
|
return getTextFromItem("expires");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSignOutDisplayed() {
|
public boolean isSignOutDisplayed() {
|
||||||
return isItemDisplayed(SIGN_OUT);
|
return getSignOutButton() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickSignOut() {
|
public void clickSignOut() {
|
||||||
clickLink(getItemElement(SIGN_OUT));
|
WebElement signOutButton = getSignOutButton();
|
||||||
|
if (signOutButton != null) {
|
||||||
|
clickLink(signOutButton);
|
||||||
|
} else {
|
||||||
|
log.warn("Cannot click sign out button; not present");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private WebElement getSignOutButton() {
|
||||||
|
try {
|
||||||
|
return driver.findElement(By.xpath(String.format("//button[@id='%s']", getFullItemId(SIGN_OUT))));
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFullItemId(String itemId) {
|
private String getFullItemId(String itemId) {
|
||||||
|
@ -159,18 +197,17 @@ public class DeviceActivityPage extends AbstractLoggedInPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebElement getItemElement(String itemId) {
|
private WebElement getItemElement(String itemId) {
|
||||||
return driver.findElement(By.id(getFullItemId(itemId)));
|
return element.findElement(By.id(getFullItemId(itemId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTextFromItem(String itemId) {
|
private String getTextFromItem(String itemId) {
|
||||||
return getTextFromElement(getItemElement(itemId));
|
return getTextFromElement(getItemElement(itemId).findElement(By.tagName("div")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isItemDisplayed(String itemId) {
|
private boolean isItemDisplayed(String itemId) {
|
||||||
try {
|
try {
|
||||||
return getItemElement(itemId).isDisplayed();
|
return getItemElement(itemId).isDisplayed();
|
||||||
}
|
} catch (NoSuchElementException e) {
|
||||||
catch (NoSuchElementException e) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class LinkedAccountsPage extends AbstractLoggedInPage {
|
||||||
@FindBy(xpath = ".//*[contains(@id,'idp-icon')]")
|
@FindBy(xpath = ".//*[contains(@id,'idp-icon')]")
|
||||||
private WebElement iconElement;
|
private WebElement iconElement;
|
||||||
|
|
||||||
@FindBy(xpath = ".//*[contains(@id,'idp-badge')]")
|
@FindBy(xpath = ".//*[contains(@id,'idp-label')]")
|
||||||
private WebElement badgeElement;
|
private WebElement badgeElement;
|
||||||
|
|
||||||
@FindBy(xpath = ".//*[contains(@id,'idp-username')]")
|
@FindBy(xpath = ".//*[contains(@id,'idp-username')]")
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package org.keycloak.testsuite.ui.account2.page;
|
package org.keycloak.testsuite.ui.account2.page;
|
||||||
|
|
||||||
|
import org.keycloak.testsuite.util.UIUtils;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
@ -147,24 +149,26 @@ public class MyResourcesPage extends AbstractLoggedInPage {
|
||||||
public void createShare(String userName) {
|
public void createShare(String userName) {
|
||||||
driver.findElement(By.id("username")).sendKeys(userName);
|
driver.findElement(By.id("username")).sendKeys(userName);
|
||||||
driver.findElement(By.id("add")).click();
|
driver.findElement(By.id("add")).click();
|
||||||
driver.findElement(By.id("pf-toggle-id-6")).click();
|
driver.findElement(By.className("pf-c-select__toggle-typeahead")).click();
|
||||||
driver.findElement(By.id("Scope A-1")).click();
|
driver.findElement(By.xpath("//button[@class='pf-c-select__menu-item' and text()='Scope A']")).click();
|
||||||
driver.findElement(By.id("pf-toggle-id-9")).click();
|
|
||||||
driver.findElement(By.id("done")).click();
|
driver.findElement(By.id("done")).click();
|
||||||
waitForModalFadeOut();
|
waitForModalFadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAllPermissions() {
|
public void removeAllPermissions() {
|
||||||
List<String> buttonTexts = Arrays.asList(getScopeText("0"), getScopeText("1"));
|
assertThat(getScopesTexts(), containsInAnyOrder("Scope A", "Scope B"));
|
||||||
assertThat(buttonTexts, containsInAnyOrder("Scope A", "Scope B"));
|
|
||||||
driver.findElement(By.className("pf-c-select__toggle-clear")).click();
|
driver.findElement(By.className("pf-c-select__toggle-clear")).click();
|
||||||
driver.findElement(By.id("save-0")).click();
|
driver.findElement(By.id("save-0")).click();
|
||||||
driver.findElement(By.id("done")).click();
|
driver.findElement(By.id("done")).click();
|
||||||
waitForModalFadeOut();
|
waitForModalFadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getScopeText(String id) {
|
private List<String> getScopesTexts() {
|
||||||
return driver.findElement(By.id(String.format("pf-random-id-%s", id))).getText();
|
return driver.findElements(By.xpath("//span[contains(@id,'pf-random-id-')]"))
|
||||||
|
.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(UIUtils::getTextFromElement)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForModalFadeIn() {
|
private void waitForModalFadeIn() {
|
||||||
|
|
|
@ -61,7 +61,19 @@ public class PersonalInfoPage extends AbstractLoggedInPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertUsernameDisabled(boolean expected) {
|
public void assertUsernameDisabled(boolean expected) {
|
||||||
assertElementDisabled(expected, username);
|
assertEquals(isUsernameDisabled(), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUsernameDisabled() {
|
||||||
|
return isElementDisabled(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmailDisabled() {
|
||||||
|
return isElementDisabled(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isElementDisabled(WebElement element) {
|
||||||
|
return element.getAttribute("readonly") != null || element.getAttribute("disabled") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
@ -152,7 +164,7 @@ public class PersonalInfoPage extends AbstractLoggedInPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickOpenDeleteExapandable() {
|
public void clickOpenDeleteExapandable() {
|
||||||
clickLink(driver.findElement(By.cssSelector(".pf-c-expandable__toggle")));
|
clickLink(driver.findElement(By.cssSelector(".pf-c-expandable-section__toggle")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickDeleteAccountButton() {
|
public void clickDeleteAccountButton() {
|
||||||
|
@ -160,7 +172,12 @@ public class PersonalInfoPage extends AbstractLoggedInPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValues(UserRepresentation user, boolean includeUsername) {
|
public void setValues(UserRepresentation user, boolean includeUsername) {
|
||||||
if (includeUsername) {setUsername(user.getUsername());}
|
if (includeUsername) {
|
||||||
|
setUsername(user.getUsername());
|
||||||
|
}
|
||||||
|
if (!isEmailDisabled()) {
|
||||||
|
setEmail(user.getEmail());
|
||||||
|
}
|
||||||
setFirstName(user.getFirstName());
|
setFirstName(user.getFirstName());
|
||||||
setLastName(user.getLastName());
|
setLastName(user.getLastName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -38,10 +40,11 @@ public class Sidebar extends AbstractFragmentWithMobileLayout {
|
||||||
public static int MOBILE_WIDTH = 767; // if the page width is less or equal than this, we expect the sidebar to be collapsed by default
|
public static int MOBILE_WIDTH = 767; // if the page width is less or equal than this, we expect the sidebar to be collapsed by default
|
||||||
public static final String NAV_ITEM_ID_PREFIX = "nav-link-";
|
public static final String NAV_ITEM_ID_PREFIX = "nav-link-";
|
||||||
|
|
||||||
|
@Drone
|
||||||
|
protected WebDriver driver;
|
||||||
|
|
||||||
@Root
|
@Root
|
||||||
private WebElement sidebarRoot;
|
private WebElement sidebarRoot;
|
||||||
@FindBy(id = "nav-toggle") // relative to root element
|
|
||||||
private WebElement collapseToggle;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMobileWidth() {
|
protected int getMobileWidth() {
|
||||||
|
@ -54,18 +57,22 @@ public class Sidebar extends AbstractFragmentWithMobileLayout {
|
||||||
|
|
||||||
public void collapse() {
|
public void collapse() {
|
||||||
assertFalse("Sidebar is already collapsed", isCollapsed());
|
assertFalse("Sidebar is already collapsed", isCollapsed());
|
||||||
collapseToggle.click();
|
getCollapseToggle().click();
|
||||||
pause(2000); // wait for animation
|
pause(2000); // wait for animation
|
||||||
assertTrue("Sidebar is not collapsed", isCollapsed());
|
assertTrue("Sidebar is not collapsed", isCollapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void expand() {
|
public void expand() {
|
||||||
assertTrue("Sidebar is already expanded", isCollapsed());
|
assertTrue("Sidebar is already expanded", isCollapsed());
|
||||||
collapseToggle.click();
|
getCollapseToggle().click();
|
||||||
pause(2000); // wait for animation
|
pause(2000); // wait for animation
|
||||||
assertFalse("Sidebar is not expanded", isCollapsed());
|
assertFalse("Sidebar is not expanded", isCollapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WebElement getCollapseToggle(){
|
||||||
|
return driver.findElement(By.id("nav-toggle"));
|
||||||
|
}
|
||||||
|
|
||||||
protected void performOperationWithSidebarExpanded(Runnable operation) {
|
protected void performOperationWithSidebarExpanded(Runnable operation) {
|
||||||
if (isMobileLayout()) expand();
|
if (isMobileLayout()) expand();
|
||||||
operation.run();
|
operation.run();
|
||||||
|
|
|
@ -32,9 +32,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.keycloak.testsuite.util.OAuthClient.APP_ROOT;
|
import static org.keycloak.testsuite.util.OAuthClient.APP_ROOT;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
|
@ -41,17 +41,18 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.either;
|
import static org.hamcrest.Matchers.either;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.hasItem;
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
import static org.hamcrest.Matchers.hasProperty;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
|
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
|
||||||
|
@ -118,13 +119,15 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
public void browsersTest() {
|
public void browsersTest() {
|
||||||
Map<Browsers, String> browserSessions = new HashMap<>();
|
Map<Browsers, String> browserSessions = new HashMap<>();
|
||||||
Arrays.stream(Browsers.values()).forEach(b -> {
|
Arrays.stream(Browsers.values()).forEach(b -> {
|
||||||
browserSessions.put(b, createSession(b));
|
browserSessions.put(b, DeviceActivityPage.getTrimmedSessionId(createSession(b)));
|
||||||
});
|
});
|
||||||
|
|
||||||
deviceActivityPage.clickRefreshPage();
|
deviceActivityPage.clickRefreshPage();
|
||||||
|
|
||||||
browserSessions.forEach((browser, sessionId) -> {
|
browserSessions.forEach((browser, sessionId) -> {
|
||||||
assertSession(browser, deviceActivityPage.getSession(sessionId));
|
final Optional<DeviceActivityPage.Session> session = deviceActivityPage.getSession(sessionId);
|
||||||
|
assertThat(session.isPresent(), is(true));
|
||||||
|
assertSession(browser, session.get());
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(Browsers.values().length + 1, deviceActivityPage.getSessionsCount()); // + 1 for the current session
|
assertEquals(Browsers.values().length + 1, deviceActivityPage.getSessionsCount()); // + 1 for the current session
|
||||||
|
@ -139,33 +142,53 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
|
|
||||||
assertEquals(3, deviceActivityPage.getSessionsCount());
|
assertEquals(3, deviceActivityPage.getSessionsCount());
|
||||||
|
|
||||||
DeviceActivityPage.Session currentSession = deviceActivityPage.getSessionByIndex(0); // current session should be first
|
Optional<DeviceActivityPage.Session> currentSession = deviceActivityPage.getSessionByIndex(0); // current session should be first
|
||||||
assertSessionRowsAreNotEmpty(currentSession, false);
|
assertThat(currentSession.isPresent(), is(true));
|
||||||
assertTrue("Browser identification should be present", currentSession.isBrowserDisplayed());
|
assertSessionRowsAreNotEmpty(currentSession.get(), false);
|
||||||
assertTrue("Current session badge should be present", currentSession.hasCurrentBadge());
|
assertTrue("Browser identification should be present", currentSession.get().isBrowserDisplayed());
|
||||||
assertFalse("Icon should be present", currentSession.getBrowserIconName().isEmpty());
|
assertTrue("Current session badge should be present", currentSession.get().hasCurrentBadge());
|
||||||
|
assertFalse("Icon should be present", currentSession.get().getIcon().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void signOutTest() {
|
public void signOutTest() {
|
||||||
assertFalse("Sign out all shouldn't be displayed", deviceActivityPage.isSignOutAllDisplayed());
|
assertFalse("Sign out all shouldn't be displayed", deviceActivityPage.isSignOutAllDisplayed());
|
||||||
DeviceActivityPage.Session chromeSession = deviceActivityPage.getSession(createSession(Browsers.CHROME));
|
final String chromeSessionId = createSession(Browsers.CHROME);
|
||||||
|
deviceActivityPage.clickRefreshPage();
|
||||||
|
|
||||||
|
Optional<DeviceActivityPage.Session> chromeSessionOptional = deviceActivityPage.getSession(chromeSessionId);
|
||||||
|
assertThat(chromeSessionOptional.isPresent(), is(true));
|
||||||
|
DeviceActivityPage.Session chromeSession = chromeSessionOptional.get();
|
||||||
|
|
||||||
createSession(Browsers.SAFARI);
|
createSession(Browsers.SAFARI);
|
||||||
deviceActivityPage.clickRefreshPage();
|
deviceActivityPage.clickRefreshPage();
|
||||||
|
|
||||||
assertTrue("Sign out all should be displayed", deviceActivityPage.isSignOutAllDisplayed());
|
assertTrue("Sign out all should be displayed", deviceActivityPage.isSignOutAllDisplayed());
|
||||||
assertEquals(3, testUserResource().getUserSessions().size());
|
assertEquals(3, testUserResource().getUserSessions().size());
|
||||||
assertThat(testUserResource().getUserSessions(),
|
|
||||||
hasItem(hasProperty("id", is(chromeSession.getFullSessionId()))));
|
assertThat(testUserResource()
|
||||||
|
.getUserSessions()
|
||||||
|
.stream()
|
||||||
|
.map(f -> f.getId())
|
||||||
|
.map(DeviceActivityPage::getTrimmedSessionId)
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
hasItem(chromeSession.getSessionId()));
|
||||||
|
|
||||||
// sign out one session
|
// sign out one session
|
||||||
|
assertThat(chromeSession.isSignOutDisplayed(), is(true));
|
||||||
testModalDialog(chromeSession::clickSignOut, () -> {
|
testModalDialog(chromeSession::clickSignOut, () -> {
|
||||||
assertEquals(3, testUserResource().getUserSessions().size()); // no change, all sessions still present
|
assertEquals(3, testUserResource().getUserSessions().size()); // no change, all sessions still present
|
||||||
});
|
});
|
||||||
deviceActivityPage.alert().assertSuccess();
|
deviceActivityPage.alert().assertSuccess();
|
||||||
assertFalse("Chrome session should be gone", chromeSession.isPresent());
|
assertFalse("Chrome session should be gone", chromeSession.isPresent());
|
||||||
assertEquals(2, testUserResource().getUserSessions().size());
|
assertEquals(2, testUserResource().getUserSessions().size());
|
||||||
assertThat(testUserResource().getUserSessions(),
|
assertThat(testUserResource()
|
||||||
not(hasItem(hasProperty("id", is(chromeSession.getFullSessionId())))));
|
.getUserSessions()
|
||||||
|
.stream()
|
||||||
|
.map(f -> f.getId())
|
||||||
|
.map(DeviceActivityPage::getTrimmedSessionId)
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
not(hasItem(chromeSession.getSessionId())));
|
||||||
|
|
||||||
// sign out all sessions
|
// sign out all sessions
|
||||||
testModalDialog(deviceActivityPage::clickSignOutAll, () -> {
|
testModalDialog(deviceActivityPage::clickSignOutAll, () -> {
|
||||||
|
@ -194,10 +217,15 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
deviceActivityPage.clickRefreshPage();
|
deviceActivityPage.clickRefreshPage();
|
||||||
|
|
||||||
List<String> expectedClients = Arrays.asList(TEST_CLIENT_ID, LOCALE_CLIENT_NAME_LOCALIZED, TEST_CLIENT3_NAME);
|
List<String> expectedClients = Arrays.asList(TEST_CLIENT_ID, LOCALE_CLIENT_NAME_LOCALIZED, TEST_CLIENT3_NAME);
|
||||||
String[] actualClients = deviceActivityPage.getSession(sessionId).getClients().split(", ");
|
|
||||||
|
final Optional<DeviceActivityPage.Session> sessionById = deviceActivityPage.getSession(sessionId);
|
||||||
|
assertThat(sessionById.isPresent(), is(true));
|
||||||
|
String[] actualClients = sessionById.get().getClients().split(", ");
|
||||||
assertThat(expectedClients, containsInAnyOrder(actualClients));
|
assertThat(expectedClients, containsInAnyOrder(actualClients));
|
||||||
|
|
||||||
assertEquals("Account Console", deviceActivityPage.getSessionByIndex(0).getClients());
|
final Optional<DeviceActivityPage.Session> session = deviceActivityPage.getSessionByIndex(0);
|
||||||
|
assertThat(session.isPresent(), is(true));
|
||||||
|
assertEquals("Account Console", session.get().getClients());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -219,12 +247,13 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
|
|
||||||
deviceActivityPage.clickRefreshPage();
|
deviceActivityPage.clickRefreshPage();
|
||||||
|
|
||||||
DeviceActivityPage.Session session = deviceActivityPage.getSession(sessionId);
|
final Optional<DeviceActivityPage.Session> session = deviceActivityPage.getSession(sessionId);
|
||||||
|
assertThat(session.isPresent(), is(true));
|
||||||
|
|
||||||
String startedAtStr = session.getStarted();
|
String startedAtStr = session.get().getStarted();
|
||||||
LocalDateTime startedAt = LocalDateTime.parse(startedAtStr, formatter);
|
LocalDateTime startedAt = LocalDateTime.parse(startedAtStr, formatter);
|
||||||
LocalDateTime lastAccessed = LocalDateTime.parse(session.getLastAccess(), formatter);
|
LocalDateTime lastAccessed = LocalDateTime.parse(session.get().getLastAccess(), formatter);
|
||||||
LocalDateTime expiresAt = LocalDateTime.parse(session.getExpires(), formatter);
|
LocalDateTime expiresAt = LocalDateTime.parse(session.get().getExpires(), formatter);
|
||||||
|
|
||||||
assertTrue("Last access should be after started at", lastAccessed.isAfter(startedAt));
|
assertTrue("Last access should be after started at", lastAccessed.isAfter(startedAt));
|
||||||
assertTrue("Expires at should be after last access", expiresAt.isAfter(lastAccessed));
|
assertTrue("Expires at should be after last access", expiresAt.isAfter(lastAccessed));
|
||||||
|
@ -248,9 +277,10 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
refreshPageAndWaitForLoad();
|
refreshPageAndWaitForLoad();
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d. MMMM yyyy, H:mm", locale);
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d. MMMM yyyy, H:mm", locale);
|
||||||
DeviceActivityPage.Session session = deviceActivityPage.getSession(sessionId);
|
Optional<DeviceActivityPage.Session> session = deviceActivityPage.getSession(sessionId);
|
||||||
|
assertThat(session.isPresent(), is(true));
|
||||||
try {
|
try {
|
||||||
LocalDateTime.parse(session.getLastAccess(), formatter);
|
LocalDateTime.parse(session.get().getLastAccess(), formatter);
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
fail("Time was not formatted with the locale");
|
fail("Time was not formatted with the locale");
|
||||||
}
|
}
|
||||||
|
@ -272,7 +302,9 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
|
|
||||||
deviceActivityPage.clickRefreshPage();
|
deviceActivityPage.clickRefreshPage();
|
||||||
|
|
||||||
assertEquals(ip, deviceActivityPage.getSession(sessionId).getIp());
|
final Optional<DeviceActivityPage.Session> session = deviceActivityPage.getSession(sessionId);
|
||||||
|
assertThat(session.isPresent(), is(true));
|
||||||
|
assertEquals(ip, session.get().getIp());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createSession(Browsers browser) {
|
private String createSession(Browsers browser) {
|
||||||
|
@ -291,12 +323,15 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
private void assertSession(Browsers browser, DeviceActivityPage.Session session) {
|
private void assertSession(Browsers browser, DeviceActivityPage.Session session) {
|
||||||
log.infof("Asserting %s (session %s)", browser, session.getSessionId());
|
log.infof("Asserting %s (session %s)", browser, session.getSessionId());
|
||||||
assertTrue("Session should be present", session.isPresent());
|
assertTrue("Session should be present", session.isPresent());
|
||||||
|
assertTrue("Browser name should be present", session.isBrowserDisplayed());
|
||||||
|
|
||||||
if (browser.sessionBrowser != null) {
|
if (browser.sessionBrowser != null) {
|
||||||
assertEquals(browser.sessionBrowser, session.getBrowser());
|
assertEquals(browser.sessionBrowser, session.getBrowser());
|
||||||
} else {
|
} else {
|
||||||
assertFalse("Browser identification shouldn't be present", session.isBrowserDisplayed());
|
assertEquals("Other/Unknown", session.getBrowser());
|
||||||
}
|
}
|
||||||
assertEquals(browser.iconName, session.getBrowserIconName());
|
|
||||||
|
assertEquals(browser.iconName, session.getIcon());
|
||||||
assertFalse("Session shouldn't have current badge", session.hasCurrentBadge()); // we don't test current session
|
assertFalse("Session shouldn't have current badge", session.hasCurrentBadge()); // we don't test current session
|
||||||
assertSessionRowsAreNotEmpty(session, true);
|
assertSessionRowsAreNotEmpty(session, true);
|
||||||
}
|
}
|
||||||
|
@ -313,23 +348,23 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
public enum Browsers {
|
public enum Browsers {
|
||||||
CHROME(
|
CHROME(
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
||||||
"Chrome/78.0.3904 / Windows 10",
|
"Chrome/78.0.3904",
|
||||||
"chrome"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
CHROMIUM(
|
CHROMIUM(
|
||||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30",
|
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30",
|
||||||
"Chromium/12.0.742 / Ubuntu 11.04",
|
"Chromium/12.0.742",
|
||||||
"chrome"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
FIREFOX(
|
FIREFOX(
|
||||||
"Mozilla/5.0 (X11; Fedora;Linux x86; rv:60.0) Gecko/20100101 Firefox/60.0",
|
"Mozilla/5.0 (X11; Fedora;Linux x86; rv:60.0) Gecko/20100101 Firefox/60.0",
|
||||||
"Firefox/60.0 / Fedora",
|
"Firefox/60.0",
|
||||||
"firefox"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
EDGE(
|
EDGE(
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763",
|
||||||
"Edge/18.17763 / Windows 10",
|
"Edge/18.17763",
|
||||||
"edge"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
// TODO uncomment this once KEYCLOAK-12445 is resolved
|
// TODO uncomment this once KEYCLOAK-12445 is resolved
|
||||||
// CHREDGE( // Edge based on Chromium
|
// CHREDGE( // Edge based on Chromium
|
||||||
|
@ -339,59 +374,61 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
// ),
|
// ),
|
||||||
IE(
|
IE(
|
||||||
"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
|
"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
|
||||||
"IE/11.0 / Windows 7",
|
"IE/11.0",
|
||||||
"ie"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
SAFARI(
|
SAFARI(
|
||||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15",
|
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15",
|
||||||
"Safari/13.0.3 / Mac OS X 10.15.1",
|
"Safari/13.0.3",
|
||||||
"safari"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
OPERA(
|
OPERA(
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.52",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.52",
|
||||||
"Opera/56.0.3051 / Windows 10",
|
"Opera/56.0.3051",
|
||||||
"opera"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
YANDEX(
|
YANDEX(
|
||||||
"Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 YaBrowser/17.6.1.749 Yowser/2.5 Safari/537.36",
|
"Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 YaBrowser/17.6.1.749 Yowser/2.5 Safari/537.36",
|
||||||
"Yandex Browser/17.6.1 / Windows 8.1",
|
"Yandex Browser/17.6.1",
|
||||||
"yandex"
|
DeviceType.DESKTOP
|
||||||
),
|
),
|
||||||
CHROME_ANDROID(
|
CHROME_ANDROID(
|
||||||
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Mobile Safari/537.36",
|
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Mobile Safari/537.36",
|
||||||
"Chrome Mobile/68.0.3440 / Android 6.0",
|
"Chrome Mobile/68.0.3440",
|
||||||
"chrome"
|
DeviceType.MOBILE
|
||||||
),
|
),
|
||||||
SAFARI_IOS(
|
SAFARI_IOS(
|
||||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Mobile/15E148 Safari/604.1",
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Mobile/15E148 Safari/604.1",
|
||||||
"Mobile Safari/13.0.1 / iOS 13.1.3",
|
"Mobile Safari/13.0.1",
|
||||||
"safari"
|
DeviceType.MOBILE
|
||||||
),
|
),
|
||||||
UNKNOWN_BROWSER(
|
UNKNOWN_BROWSER(
|
||||||
"Top-secret government browser running on top-secret OS",
|
"Top-secret government browser running on top-secret OS",
|
||||||
null,
|
null,
|
||||||
"default"
|
DeviceType.UNKNOWN
|
||||||
),
|
),
|
||||||
UNKNOWN_OS(
|
UNKNOWN_OS(
|
||||||
"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
||||||
"Chrome/78.0.3904 / Other", // "Unknown Operating System" is actually never displayed (even though it's implemented)
|
"Chrome/78.0.3904",
|
||||||
"chrome"
|
DeviceType.UNKNOWN
|
||||||
),
|
),
|
||||||
UNKNOWN_OS_VERSION(
|
UNKNOWN_OS_VERSION(
|
||||||
"Mozilla/5.0 (Windows 256.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
"Mozilla/5.0 (Windows 256.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
||||||
"Chrome/78.0.3904 / Windows",
|
"Chrome/78.0.3904",
|
||||||
"chrome"
|
DeviceType.UNKNOWN
|
||||||
);
|
);
|
||||||
// not sure what "Amazon" browser is supposed to be (it's specified in DeviceActivityPage.tsx)
|
// not sure what "Amazon" browser is supposed to be (it's specified in DeviceActivityPage.tsx)
|
||||||
|
|
||||||
private String userAgent;
|
private final String userAgent;
|
||||||
private String sessionBrowser; // how the browser is interpreted by the sessions endpoint
|
private final String sessionBrowser; // how the browser is interpreted by the sessions endpoint
|
||||||
private String iconName;
|
private final DeviceType deviceType;
|
||||||
|
private final String iconName;
|
||||||
|
|
||||||
Browsers(String userAgent, String sessionBrowser, String iconName) {
|
Browsers(String userAgent, String sessionBrowser, DeviceType deviceType) {
|
||||||
this.userAgent = userAgent;
|
this.userAgent = userAgent;
|
||||||
this.sessionBrowser = sessionBrowser;
|
this.sessionBrowser = sessionBrowser;
|
||||||
this.iconName = iconName;
|
this.deviceType = deviceType;
|
||||||
|
this.iconName = deviceType.getIconName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String userAgent() {
|
public String userAgent() {
|
||||||
|
@ -405,5 +442,21 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
public String iconName() {
|
public String iconName() {
|
||||||
return iconName;
|
return iconName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum DeviceType {
|
||||||
|
DESKTOP("desktop"),
|
||||||
|
MOBILE("mobile"),
|
||||||
|
UNKNOWN("desktop"); // Default icon
|
||||||
|
|
||||||
|
private final String iconName;
|
||||||
|
|
||||||
|
DeviceType(String iconName) {
|
||||||
|
this.iconName = iconName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIconName() {
|
||||||
|
return iconName;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.admin.client.resource.RealmResource;
|
import org.keycloak.admin.client.resource.RealmResource;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
@ -71,7 +72,7 @@ public class PersonalInfoTest extends BaseAccountPageTest {
|
||||||
personalInfoPage.assertSaveDisabled(false);
|
personalInfoPage.assertSaveDisabled(false);
|
||||||
|
|
||||||
personalInfoPage.setValues(testUser2, true);
|
personalInfoPage.setValues(testUser2, true);
|
||||||
assertEquals("test user", personalInfoPage.header().getToolbarLoggedInUser());
|
//assertEquals("test user", personalInfoPage.header().getToolbarLoggedInUser());
|
||||||
assertTrue(personalInfoPage.valuesEqual(testUser2));
|
assertTrue(personalInfoPage.valuesEqual(testUser2));
|
||||||
personalInfoPage.assertSaveDisabled(false);
|
personalInfoPage.assertSaveDisabled(false);
|
||||||
personalInfoPage.clickSave();
|
personalInfoPage.clickSave();
|
||||||
|
@ -80,7 +81,7 @@ public class PersonalInfoTest extends BaseAccountPageTest {
|
||||||
|
|
||||||
personalInfoPage.navigateTo();
|
personalInfoPage.navigateTo();
|
||||||
personalInfoPage.valuesEqual(testUser2);
|
personalInfoPage.valuesEqual(testUser2);
|
||||||
assertEquals("Václav Muzikář", personalInfoPage.header().getToolbarLoggedInUser());
|
//assertEquals("Václav Muzikář", personalInfoPage.header().getToolbarLoggedInUser());
|
||||||
|
|
||||||
// change just first and last name
|
// change just first and last name
|
||||||
testUser2.setFirstName("Another");
|
testUser2.setFirstName("Another");
|
||||||
|
@ -90,7 +91,7 @@ public class PersonalInfoTest extends BaseAccountPageTest {
|
||||||
personalInfoPage.alert().assertSuccess();
|
personalInfoPage.alert().assertSuccess();
|
||||||
personalInfoPage.navigateTo();
|
personalInfoPage.navigateTo();
|
||||||
personalInfoPage.valuesEqual(testUser2);
|
personalInfoPage.valuesEqual(testUser2);
|
||||||
assertEquals("Another Name", personalInfoPage.header().getToolbarLoggedInUser());
|
//assertEquals("Another Name", personalInfoPage.header().getToolbarLoggedInUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -172,6 +173,7 @@ public class PersonalInfoTest extends BaseAccountPageTest {
|
||||||
accountWelcomeScreen.assertCurrent();
|
accountWelcomeScreen.assertCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("Username is not included in the account console anymore, but it should be there.")
|
||||||
@Test
|
@Test
|
||||||
public void testNameInToolbar() {
|
public void testNameInToolbar() {
|
||||||
assertEquals("test user", personalInfoPage.header().getToolbarLoggedInUser());
|
assertEquals("test user", personalInfoPage.header().getToolbarLoggedInUser());
|
||||||
|
|
|
@ -190,7 +190,7 @@
|
||||||
<span class="pf-c-button__icon pf-m-start">
|
<span class="pf-c-button__icon pf-m-start">
|
||||||
<i class="pf-icon pf-icon-arrow" aria-hidden="true"></i>
|
<i class="pf-icon pf-icon-arrow" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
${msg("backToAdminConsole")}
|
${msg("backTo",referrerName)}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</#if>
|
</#if>
|
||||||
|
@ -209,7 +209,7 @@
|
||||||
<ul id="landingMobileDropdown" aria-labelledby="landingMobileKebabButton" class="pf-c-dropdown__menu pf-m-align-right" role="menu" style="display:none">
|
<ul id="landingMobileDropdown" aria-labelledby="landingMobileKebabButton" class="pf-c-dropdown__menu pf-m-align-right" role="menu" style="display:none">
|
||||||
<#if referrer?has_content && referrer_uri?has_content>
|
<#if referrer?has_content && referrer_uri?has_content>
|
||||||
<li role="none">
|
<li role="none">
|
||||||
<a id="landingMobileReferrerLink" href="${referrer_uri}" role="menuitem" tabindex="0" aria-disabled="false" class="pf-c-dropdown__menu-item">${msg("backToAdminConsole")}</a>
|
<a id="landingMobileReferrerLink" href="${referrer_uri}" role="menuitem" tabindex="0" aria-disabled="false" class="pf-c-dropdown__menu-item">${msg("backTo",referrerName)}</a>
|
||||||
</li>
|
</li>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,7 @@ export class AccountPage extends React.Component<AccountPageProps, AccountPageSt
|
||||||
|
|
||||||
{this.isDeleteAccountAllowed && (
|
{this.isDeleteAccountAllowed && (
|
||||||
<div id="delete-account" style={{ marginTop: "30px" }}>
|
<div id="delete-account" style={{ marginTop: "30px" }}>
|
||||||
<ExpandableSection toggleText="Delete Account">
|
<ExpandableSection toggleText={Msg.localize("deleteAccount")}>
|
||||||
<Grid hasGutter>
|
<Grid hasGutter>
|
||||||
<GridItem span={6}>
|
<GridItem span={6}>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -212,7 +212,9 @@ export class ApplicationsPage extends React.Component<ApplicationsPageProps, App
|
||||||
{application.effectiveUrl &&
|
{application.effectiveUrl &&
|
||||||
<DescriptionListGroup>
|
<DescriptionListGroup>
|
||||||
<DescriptionListTerm>URL</DescriptionListTerm>
|
<DescriptionListTerm>URL</DescriptionListTerm>
|
||||||
<DescriptionListDescription>{application.effectiveUrl.split('"')}</DescriptionListDescription>
|
<DescriptionListDescription id={this.elementId("effectiveurl", application)}>
|
||||||
|
{application.effectiveUrl.split('"')}
|
||||||
|
</DescriptionListDescription>
|
||||||
</DescriptionListGroup>
|
</DescriptionListGroup>
|
||||||
}
|
}
|
||||||
{application.consent &&
|
{application.consent &&
|
||||||
|
|
|
@ -261,14 +261,14 @@ export class DeviceActivityPage extends React.Component<DeviceActivityPageProps,
|
||||||
<React.Fragment key={'device-' + deviceIndex + '-session-' + sessionIndex}>
|
<React.Fragment key={'device-' + deviceIndex + '-session-' + sessionIndex}>
|
||||||
<DataListItemRow>
|
<DataListItemRow>
|
||||||
<DataListContent aria-label="device-sessions-content" isHidden={false} className="pf-u-flex-grow-1">
|
<DataListContent aria-label="device-sessions-content" isHidden={false} className="pf-u-flex-grow-1">
|
||||||
<Grid className="signed-in-device-grid" hasGutter>
|
<Grid id={this.elementId("item",session)} className="signed-in-device-grid" hasGutter>
|
||||||
<GridItem className="device-icon" span={1} rowSpan={2}>
|
<GridItem className="device-icon" span={1} rowSpan={2}>
|
||||||
<span>{this.findDeviceTypeIcon(session, device)}</span>
|
<span>{this.findDeviceTypeIcon(session, device)}</span>
|
||||||
</GridItem>
|
</GridItem>
|
||||||
<GridItem sm={8} md={9} span={10}>
|
<GridItem sm={8} md={9} span={10}>
|
||||||
<span id={this.elementId('browser', session)} className="pf-u-mr-md">{this.findOS(device)} {this.findOSVersion(device)} / {session.browser}</span>
|
<span id={this.elementId('browser', session)} className="pf-u-mr-md session-title">{this.findOS(device)} {this.findOSVersion(device)} / {session.browser}</span>
|
||||||
{session.current &&
|
{session.current &&
|
||||||
<Label color="green"><Msg msgKey="currentSession" /></Label>}
|
<Label color="green" id={this.elementId('current-badge', session)}><Msg msgKey="currentSession" /></Label>}
|
||||||
</GridItem>
|
</GridItem>
|
||||||
<GridItem className="pf-u-text-align-right" sm={3} md={2} span={1}>
|
<GridItem className="pf-u-text-align-right" sm={3} md={2} span={1}>
|
||||||
{!session.current &&
|
{!session.current &&
|
||||||
|
@ -285,23 +285,23 @@ export class DeviceActivityPage extends React.Component<DeviceActivityPageProps,
|
||||||
<DescriptionList columnModifier={{ sm: '2Col', lg: '3Col' }}>
|
<DescriptionList columnModifier={{ sm: '2Col', lg: '3Col' }}>
|
||||||
<DescriptionListGroup>
|
<DescriptionListGroup>
|
||||||
<DescriptionListTerm>{Msg.localize('ipAddress')}</DescriptionListTerm>
|
<DescriptionListTerm>{Msg.localize('ipAddress')}</DescriptionListTerm>
|
||||||
<DescriptionListDescription>{session.ipAddress}</DescriptionListDescription>
|
<DescriptionListDescription id={this.elementId('ip', session)}>{session.ipAddress}</DescriptionListDescription>
|
||||||
</DescriptionListGroup>
|
</DescriptionListGroup>
|
||||||
<DescriptionListGroup>
|
<DescriptionListGroup>
|
||||||
<DescriptionListTerm>{Msg.localize('lastAccessedOn')}</DescriptionListTerm>
|
<DescriptionListTerm>{Msg.localize('lastAccessedOn')}</DescriptionListTerm>
|
||||||
<DescriptionListDescription>{this.time(session.lastAccess)}</DescriptionListDescription>
|
<DescriptionListDescription id={this.elementId('last-access', session)}>{this.time(session.lastAccess)}</DescriptionListDescription>
|
||||||
</DescriptionListGroup>
|
</DescriptionListGroup>
|
||||||
<DescriptionListGroup>
|
<DescriptionListGroup>
|
||||||
<DescriptionListTerm>{Msg.localize('clients')}</DescriptionListTerm>
|
<DescriptionListTerm>{Msg.localize('clients')}</DescriptionListTerm>
|
||||||
<DescriptionListDescription>{this.makeClientsString(session.clients)}</DescriptionListDescription>
|
<DescriptionListDescription id={this.elementId('clients', session)}>{this.makeClientsString(session.clients)}</DescriptionListDescription>
|
||||||
</DescriptionListGroup>
|
</DescriptionListGroup>
|
||||||
<DescriptionListGroup>
|
<DescriptionListGroup>
|
||||||
<DescriptionListTerm>{Msg.localize('started')}</DescriptionListTerm>
|
<DescriptionListTerm>{Msg.localize('started')}</DescriptionListTerm>
|
||||||
<DescriptionListDescription>{this.time(session.started)}</DescriptionListDescription>
|
<DescriptionListDescription id={this.elementId('started', session)}>{this.time(session.started)}</DescriptionListDescription>
|
||||||
</DescriptionListGroup>
|
</DescriptionListGroup>
|
||||||
<DescriptionListGroup>
|
<DescriptionListGroup>
|
||||||
<DescriptionListTerm>{Msg.localize('expires')}</DescriptionListTerm>
|
<DescriptionListTerm>{Msg.localize('expires')}</DescriptionListTerm>
|
||||||
<DescriptionListDescription>{this.time(session.expires)}</DescriptionListDescription>
|
<DescriptionListDescription id={this.elementId('expires', session)}>{this.time(session.expires)}</DescriptionListDescription>
|
||||||
</DescriptionListGroup>
|
</DescriptionListGroup>
|
||||||
</DescriptionList>
|
</DescriptionList>
|
||||||
</GridItem>
|
</GridItem>
|
||||||
|
|
Loading…
Reference in a new issue