2021-06-23 08:16:51 +02:00
|
|
|
|
|
|
|
import type { KcContextBase } from "../KcContextBase";
|
|
|
|
import { getEvtKcLanguage } from "../../i18n/useKcLanguageTag";
|
|
|
|
import { getKcLanguageTagLabel } from "../../i18n/KcLanguageTag";
|
|
|
|
//NOTE: Aside because we want to be able to import them from node
|
|
|
|
import { resourcesCommonPath, resourcesPath } from "./urlResourcesPath";
|
|
|
|
import { id } from "tsafe/id";
|
2021-06-28 04:04:48 +02:00
|
|
|
import { join as pathJoin } from "path";
|
|
|
|
|
|
|
|
const PUBLIC_URL = process.env["PUBLIC_URL"] ?? "/";
|
2021-06-23 08:16:51 +02:00
|
|
|
|
|
|
|
export const kcContextCommonMock: KcContextBase.Common = {
|
|
|
|
"url": {
|
|
|
|
"loginAction": "#",
|
2021-06-28 04:04:48 +02:00
|
|
|
"resourcesPath": pathJoin(PUBLIC_URL, resourcesPath),
|
|
|
|
"resourcesCommonPath": pathJoin(PUBLIC_URL, resourcesCommonPath),
|
2021-06-23 08:16:51 +02:00
|
|
|
"loginRestartFlowUrl": "/auth/realms/myrealm/login-actions/restart?client_id=account&tab_id=HoAx28ja4xg",
|
|
|
|
"loginUrl": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg",
|
|
|
|
},
|
|
|
|
"realm": {
|
|
|
|
"displayName": "myrealm",
|
|
|
|
"displayNameHtml": "myrealm",
|
|
|
|
"internationalizationEnabled": true,
|
|
|
|
"registrationEmailAsUsername": true,
|
|
|
|
},
|
2021-10-11 03:41:05 +02:00
|
|
|
"messagesPerField": {
|
|
|
|
"printIfExists": (...[, x]) => x,
|
|
|
|
"existsError": ()=> true,
|
|
|
|
"get": key=> `Fake error for ${key}`,
|
|
|
|
"exists": ()=> true
|
|
|
|
},
|
2021-06-23 08:16:51 +02:00
|
|
|
"locale": {
|
|
|
|
"supported": [
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=de",
|
|
|
|
"languageTag": "de"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=no",
|
|
|
|
"languageTag": "no"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ru",
|
|
|
|
"languageTag": "ru"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=sv",
|
|
|
|
"languageTag": "sv"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=pt-BR",
|
|
|
|
"languageTag": "pt-BR"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=lt",
|
|
|
|
"languageTag": "lt"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=en",
|
|
|
|
"languageTag": "en"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=it",
|
|
|
|
"languageTag": "it"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=fr",
|
|
|
|
"languageTag": "fr"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=zh-CN",
|
|
|
|
"languageTag": "zh-CN"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=es",
|
|
|
|
"languageTag": "es"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=cs",
|
|
|
|
"languageTag": "cs"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ja",
|
|
|
|
"languageTag": "ja"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=sk",
|
|
|
|
"languageTag": "sk"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=pl",
|
|
|
|
"languageTag": "pl"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ca",
|
|
|
|
"languageTag": "ca"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=nl",
|
|
|
|
"languageTag": "nl"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=tr",
|
|
|
|
"languageTag": "tr"
|
|
|
|
}
|
|
|
|
],
|
2021-06-28 04:04:48 +02:00
|
|
|
//"current": null as any
|
|
|
|
"current": "English"
|
2021-06-23 08:16:51 +02:00
|
|
|
},
|
|
|
|
"auth": {
|
|
|
|
"showUsername": false,
|
|
|
|
"showResetCredentials": false,
|
|
|
|
"showTryAnotherWayLink": false
|
|
|
|
},
|
2021-07-12 15:33:50 +02:00
|
|
|
"client": {
|
|
|
|
"clientId": "myApp"
|
|
|
|
},
|
2021-06-23 08:16:51 +02:00
|
|
|
"scripts": [],
|
|
|
|
"message": {
|
|
|
|
"type": "success",
|
|
|
|
"summary": "This is a test message"
|
|
|
|
},
|
|
|
|
"isAppInitiatedAction": false,
|
|
|
|
};
|
|
|
|
|
2021-06-28 04:04:48 +02:00
|
|
|
|
2021-06-23 08:16:51 +02:00
|
|
|
Object.defineProperty(
|
|
|
|
kcContextCommonMock.locale!,
|
|
|
|
"current",
|
|
|
|
{
|
|
|
|
"get": () => getKcLanguageTagLabel(getEvtKcLanguage().state),
|
|
|
|
"enumerable": true
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const loginUrl = {
|
|
|
|
...kcContextCommonMock.url,
|
|
|
|
"loginResetCredentialsUrl": "/auth/realms/myrealm/login-actions/reset-credentials?client_id=account&tab_id=HoAx28ja4xg",
|
|
|
|
"registrationUrl": "/auth/realms/myrealm/login-actions/registration?client_id=account&tab_id=HoAx28ja4xg"
|
|
|
|
};
|
|
|
|
|
|
|
|
export const kcContextMocks: KcContextBase[] = [
|
|
|
|
id<KcContextBase.Login>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "login.ftl",
|
|
|
|
"url": loginUrl,
|
|
|
|
"realm": {
|
|
|
|
...kcContextCommonMock.realm,
|
|
|
|
"loginWithEmailAllowed": true,
|
|
|
|
"rememberMe": true,
|
|
|
|
"password": true,
|
|
|
|
"resetPasswordAllowed": true,
|
|
|
|
"registrationAllowed": true
|
|
|
|
},
|
|
|
|
"auth": kcContextCommonMock.auth!,
|
|
|
|
"social": {
|
|
|
|
"displayInfo": true
|
|
|
|
},
|
|
|
|
"usernameEditDisabled": false,
|
|
|
|
"login": {
|
|
|
|
"rememberMe": false
|
|
|
|
},
|
|
|
|
"registrationDisabled": false,
|
|
|
|
|
|
|
|
}),
|
|
|
|
id<KcContextBase.Register>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "register.ftl",
|
|
|
|
"url": {
|
|
|
|
...loginUrl,
|
|
|
|
"registrationAction": "http://localhost:8080/auth/realms/myrealm/login-actions/registration?session_code=gwZdUeO7pbYpFTRxiIxRg_QtzMbtFTKrNu6XW_f8asM&execution=12146ce0-b139-4bbd-b25b-0eccfee6577e&client_id=account&tab_id=uS8lYfebLa0"
|
|
|
|
},
|
|
|
|
"scripts": [],
|
|
|
|
"isAppInitiatedAction": false,
|
|
|
|
"register": {
|
|
|
|
"formData": {}
|
|
|
|
},
|
|
|
|
"passwordRequired": true,
|
|
|
|
"recaptchaRequired": false,
|
|
|
|
"social": {
|
|
|
|
"displayInfo": true
|
|
|
|
},
|
|
|
|
|
|
|
|
}),
|
|
|
|
id<KcContextBase.Info>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "info.ftl",
|
|
|
|
"messageHeader": "<Message header>",
|
|
|
|
"requiredActions": undefined,
|
|
|
|
"skipLink": false,
|
|
|
|
"actionUri": "#",
|
|
|
|
"client": {
|
2021-07-12 15:33:50 +02:00
|
|
|
"clientId": "myApp",
|
2021-06-23 08:16:51 +02:00
|
|
|
"baseUrl": "#"
|
|
|
|
}
|
|
|
|
|
|
|
|
}),
|
|
|
|
id<KcContextBase.Error>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "error.ftl",
|
|
|
|
"client": {
|
2021-07-12 15:33:50 +02:00
|
|
|
"clientId": "myApp",
|
2021-06-23 08:16:51 +02:00
|
|
|
"baseUrl": "#"
|
2021-06-28 04:04:48 +02:00
|
|
|
},
|
|
|
|
"message": {
|
|
|
|
"type": "error",
|
|
|
|
"summary": "This is the error message"
|
2021-06-23 08:16:51 +02:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
id<KcContextBase.LoginResetPassword>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "login-reset-password.ftl",
|
|
|
|
"realm": {
|
|
|
|
...kcContextCommonMock.realm,
|
|
|
|
"loginWithEmailAllowed": false
|
|
|
|
}
|
|
|
|
|
|
|
|
}),
|
|
|
|
id<KcContextBase.LoginVerifyEmail>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "login-verify-email.ftl"
|
|
|
|
}),
|
|
|
|
id<KcContextBase.Terms>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "terms.ftl"
|
|
|
|
|
|
|
|
}),
|
|
|
|
id<KcContextBase.LoginOtp>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "login-otp.ftl",
|
|
|
|
"otpLogin": {
|
|
|
|
"userOtpCredentials": [
|
|
|
|
{
|
|
|
|
"id": "id1",
|
|
|
|
"userLabel": "label1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": "id2",
|
|
|
|
"userLabel": "label2"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
}),
|
|
|
|
id<KcContextBase.LoginUpdateProfile>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "login-update-profile.ftl",
|
|
|
|
"user": {
|
|
|
|
"editUsernameAllowed": true,
|
|
|
|
"username": "anUsername",
|
|
|
|
"email": "foo@example.com",
|
|
|
|
"firstName": "aFirstName",
|
|
|
|
"lastName": "aLastName"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
id<KcContextBase.LoginIdpLinkConfirm>({
|
|
|
|
...kcContextCommonMock,
|
|
|
|
"pageId": "login-idp-link-confirm.ftl",
|
|
|
|
"idpAlias": "FranceConnect"
|
|
|
|
})
|
|
|
|
];
|