Pass login realm to WhoAmI (#989)
Co-authored-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
54dca4df65
commit
71b1c4a444
2 changed files with 24 additions and 2 deletions
|
@ -20,7 +20,9 @@ describe("Realms test", () => {
|
|||
|
||||
after(async () => {
|
||||
const client = new AdminClient();
|
||||
await client.deleteRealm(testRealmName);
|
||||
[testRealmName, "one", "two"].map(
|
||||
async (realm) => await client.deleteRealm(realm)
|
||||
);
|
||||
});
|
||||
|
||||
it("should fail creating Master realm", () => {
|
||||
|
@ -39,6 +41,25 @@ describe("Realms test", () => {
|
|||
masthead.checkNotificationMessage("Realm created");
|
||||
});
|
||||
|
||||
it("should create realm from new a realm", () => {
|
||||
sidebarPage.goToCreateRealm();
|
||||
createRealmPage.fillRealmName("one").createRealm();
|
||||
|
||||
const fetchUrl = "/auth/admin/realms";
|
||||
cy.intercept(fetchUrl).as("fetch");
|
||||
|
||||
masthead.checkNotificationMessage("Realm created");
|
||||
|
||||
cy.wait(["@fetch"]);
|
||||
|
||||
sidebarPage.goToCreateRealm();
|
||||
createRealmPage.fillRealmName("two").createRealm();
|
||||
|
||||
masthead.checkNotificationMessage("Realm created");
|
||||
|
||||
cy.wait(["@fetch"]);
|
||||
});
|
||||
|
||||
it("should change to Test realm", () => {
|
||||
sidebarPage.getCurrentRealm().should("eq", "Master");
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import type WhoAmIRepresentation from "keycloak-admin/lib/defs/whoAmIRepresentation";
|
||||
import type { AccessType } from "keycloak-admin/lib/defs/whoAmIRepresentation";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import environment from "../../environment";
|
||||
import i18n from "../../i18n";
|
||||
import useRequiredContext from "../../utils/useRequiredContext";
|
||||
import { useAdminClient, useFetch } from "../auth/AdminClient";
|
||||
|
@ -56,7 +57,7 @@ export const WhoAmIContextProvider: FunctionComponent = ({ children }) => {
|
|||
const [key, setKey] = useState(0);
|
||||
|
||||
useFetch(
|
||||
() => adminClient.whoAmI.find(),
|
||||
() => adminClient.whoAmI.find({ realm: environment.loginRealm }),
|
||||
(me) => {
|
||||
const whoAmI = new WhoAmI(me);
|
||||
setWhoAmI(whoAmI);
|
||||
|
|
Loading…
Reference in a new issue