DateTimeParse failures in New Account Console tests (#16531)
Fixes #16514
This commit is contained in:
parent
8d05895adb
commit
7d6e22bedd
4 changed files with 13 additions and 13 deletions
|
@ -32,7 +32,7 @@ import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;
|
||||||
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||||
*/
|
*/
|
||||||
public class SigningInPage extends AbstractLoggedInPage {
|
public class SigningInPage extends AbstractLoggedInPage {
|
||||||
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("MMMM d, yyyy, h:mm a", Locale.ENGLISH);
|
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("MMMM d, yyyy 'at' h:mm a", Locale.ENGLISH);
|
||||||
|
|
||||||
private static final String CATEG_TITLE = "-categ-title";
|
private static final String CATEG_TITLE = "-categ-title";
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,9 @@ import org.keycloak.testsuite.ui.AbstractUiTest;
|
||||||
import org.keycloak.testsuite.ui.account2.page.PageNotFound;
|
import org.keycloak.testsuite.ui.account2.page.PageNotFound;
|
||||||
import org.keycloak.testsuite.ui.account2.page.WelcomeScreen;
|
import org.keycloak.testsuite.ui.account2.page.WelcomeScreen;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf;
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf;
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLo
|
||||||
@EnableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true)
|
@EnableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true)
|
||||||
public abstract class AbstractAccountTest extends AbstractUiTest {
|
public abstract class AbstractAccountTest extends AbstractUiTest {
|
||||||
public static final String ACCOUNT_THEME_NAME_KC = "keycloak.v2";
|
public static final String ACCOUNT_THEME_NAME_KC = "keycloak.v2";
|
||||||
public static final String ACCOUNT_THEME_NAME_RHSSO = "rh-sso.v2";
|
public static final DateTimeFormatter DEFAULT_TIME_FORMATTER = DateTimeFormatter.ofPattern("MMMM d, yyyy 'at' h:mm a", Locale.ENGLISH);
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
protected WelcomeScreen accountWelcomeScreen;
|
protected WelcomeScreen accountWelcomeScreen;
|
||||||
|
@ -67,6 +69,6 @@ public abstract class AbstractAccountTest extends AbstractUiTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getAccountThemeName() {
|
protected String getAccountThemeName() {
|
||||||
return getProjectName().equals(Profile.PRODUCT_NAME) ? ACCOUNT_THEME_NAME_RHSSO : ACCOUNT_THEME_NAME_KC;
|
return ACCOUNT_THEME_NAME_KC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,11 +230,10 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timesTests() {
|
public void timesTests() {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM d, yyyy, h:mm a", Locale.ENGLISH);
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime nowPlus1 = now.plusMinutes(1);
|
LocalDateTime nowPlus1 = now.plusMinutes(1);
|
||||||
String nowStr = now.format(formatter);
|
String nowStr = now.format(DEFAULT_TIME_FORMATTER);
|
||||||
String nowStrPlus1 = nowPlus1.format(formatter);
|
String nowStrPlus1 = nowPlus1.format(DEFAULT_TIME_FORMATTER);
|
||||||
|
|
||||||
String sessionId = createSession(Browsers.CHROME);
|
String sessionId = createSession(Browsers.CHROME);
|
||||||
|
|
||||||
|
@ -251,9 +250,9 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
assertThat(session.isPresent(), is(true));
|
assertThat(session.isPresent(), is(true));
|
||||||
|
|
||||||
String startedAtStr = session.get().getStarted();
|
String startedAtStr = session.get().getStarted();
|
||||||
LocalDateTime startedAt = LocalDateTime.parse(startedAtStr, formatter);
|
LocalDateTime startedAt = LocalDateTime.parse(startedAtStr, DEFAULT_TIME_FORMATTER);
|
||||||
LocalDateTime lastAccessed = LocalDateTime.parse(session.get().getLastAccess(), formatter);
|
LocalDateTime lastAccessed = LocalDateTime.parse(session.get().getLastAccess(), DEFAULT_TIME_FORMATTER);
|
||||||
LocalDateTime expiresAt = LocalDateTime.parse(session.get().getExpires(), formatter);
|
LocalDateTime expiresAt = LocalDateTime.parse(session.get().getExpires(), DEFAULT_TIME_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));
|
||||||
|
@ -276,7 +275,7 @@ public class DeviceActivityTest extends BaseAccountPageTest {
|
||||||
|
|
||||||
refreshPageAndWaitForLoad();
|
refreshPageAndWaitForLoad();
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d. MMMM yyyy, H:mm", locale);
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d. MMMM yyyy 'um' H:mm", locale);
|
||||||
Optional<DeviceActivityPage.Session> session = deviceActivityPage.getSession(sessionId);
|
Optional<DeviceActivityPage.Session> session = deviceActivityPage.getSession(sessionId);
|
||||||
assertThat(session.isPresent(), is(true));
|
assertThat(session.isPresent(), is(true));
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -112,9 +112,8 @@ public class InternationalizationTest extends AbstractAccountTest {
|
||||||
SigningInPage.UserCredential passwordCred =
|
SigningInPage.UserCredential passwordCred =
|
||||||
passwordCredentialType.getUserCredential(testUserResource().credentials().get(0).getId());
|
passwordCredentialType.getUserCredential(testUserResource().credentials().get(0).getId());
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM d, yyyy, h:mm a", Locale.ENGLISH);
|
|
||||||
try {
|
try {
|
||||||
LocalDateTime.parse(passwordCred.getCreatedAtStr(), formatter);
|
LocalDateTime.parse(passwordCred.getCreatedAtStr(), DEFAULT_TIME_FORMATTER);
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
fail("Time was not formatted with the locale");
|
fail("Time was not formatted with the locale");
|
||||||
}
|
}
|
||||||
|
@ -124,7 +123,7 @@ public class InternationalizationTest extends AbstractAccountTest {
|
||||||
loginPage.localeDropdown().selectAndAssert("Deutsch");
|
loginPage.localeDropdown().selectAndAssert("Deutsch");
|
||||||
loginPage.form().login(testUser);
|
loginPage.form().login(testUser);
|
||||||
|
|
||||||
DateTimeFormatter formatterDe = DateTimeFormatter.ofPattern("d. MMMM yyyy, H:mm", Locale.GERMAN);
|
DateTimeFormatter formatterDe = DateTimeFormatter.ofPattern("d. MMMM yyyy 'um' H:mm", Locale.GERMAN);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LocalDateTime.parse(passwordCred.getCreatedAtStr(), formatterDe);
|
LocalDateTime.parse(passwordCred.getCreatedAtStr(), formatterDe);
|
||||||
|
|
Loading…
Reference in a new issue