Merge e6a317220e
into e835cab139
This commit is contained in:
commit
ae6ea3fe1d
7 changed files with 21 additions and 81 deletions
|
@ -19,9 +19,6 @@ import { TestSdkContext } from "../../TestSdkContext";
|
|||
import defaultDispatcher from "../../../../src/dispatcher/dispatcher";
|
||||
import LogoutDialog from "../../../../src/components/views/dialogs/LogoutDialog";
|
||||
import Modal from "../../../../src/Modal";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import { Features } from "../../../../src/settings/Settings";
|
||||
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
||||
import { mockOpenIdConfiguration } from "../../../test-utils/oidc";
|
||||
import { Action } from "../../../../src/dispatcher/actions";
|
||||
import { UserTab } from "../../../../src/components/views/dialogs/UserTab";
|
||||
|
@ -137,7 +134,6 @@ describe("<UserMenu>", () => {
|
|||
isCrossSigningReady: jest.fn().mockResolvedValue(true),
|
||||
exportSecretsBundle: jest.fn().mockResolvedValue({}),
|
||||
} as unknown as CryptoApi);
|
||||
await SettingsStore.setValue(Features.OidcNativeFlow, null, SettingLevel.DEVICE, true);
|
||||
const spy = jest.spyOn(defaultDispatcher, "dispatch");
|
||||
|
||||
const UserMenu = wrapInSdkContext(UnwrappedUserMenu, sdkContext);
|
||||
|
|
|
@ -19,7 +19,6 @@ import { mkServerConfig, mockPlatformPeg, unmockPlatformPeg } from "../../../../
|
|||
import Login from "../../../../../src/components/structures/auth/Login";
|
||||
import BasePlatform from "../../../../../src/BasePlatform";
|
||||
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
||||
import { Features } from "../../../../../src/settings/Settings";
|
||||
import * as registerClientUtils from "../../../../../src/utils/oidc/registerClient";
|
||||
import { makeDelegatedAuthConfig } from "../../../../test-utils/oidc";
|
||||
|
||||
|
@ -371,9 +370,6 @@ describe("Login", function () {
|
|||
const delegatedAuth = makeDelegatedAuthConfig(issuer);
|
||||
beforeEach(() => {
|
||||
jest.spyOn(logger, "error");
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation(
|
||||
(settingName) => settingName === Features.OidcNativeFlow,
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -22,8 +22,6 @@ import {
|
|||
} from "../../../../test-utils";
|
||||
import Registration from "../../../../../src/components/structures/auth/Registration";
|
||||
import { makeDelegatedAuthConfig } from "../../../../test-utils/oidc";
|
||||
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
||||
import { Features } from "../../../../../src/settings/Settings";
|
||||
import { startOidcLogin } from "../../../../../src/utils/oidc/authorize";
|
||||
|
||||
jest.mock("../../../../../src/utils/oidc/authorize", () => ({
|
||||
|
@ -180,49 +178,29 @@ describe("Registration", function () {
|
|||
fetchMock.get(authConfig.metadata.jwks_uri!, { keys: [] });
|
||||
});
|
||||
|
||||
describe("when oidc native flow is not enabled in settings", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
|
||||
});
|
||||
it("should display oidc-native continue button", async () => {
|
||||
const { container } = getComponent(defaultHsUrl, defaultIsUrl, authConfig);
|
||||
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
|
||||
// no form
|
||||
expect(container.querySelector("form")).toBeFalsy();
|
||||
|
||||
it("should display user/pass registration form", async () => {
|
||||
const { container } = getComponent(defaultHsUrl, defaultIsUrl, authConfig);
|
||||
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
|
||||
expect(container.querySelector("form")).toBeTruthy();
|
||||
expect(mockClient.loginFlows).toHaveBeenCalled();
|
||||
expect(mockClient.registerRequest).toHaveBeenCalled();
|
||||
});
|
||||
expect(await screen.findByText("Continue")).toBeTruthy();
|
||||
});
|
||||
|
||||
describe("when oidc native flow is enabled in settings", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((key) => key === Features.OidcNativeFlow);
|
||||
});
|
||||
it("should start OIDC login flow as registration on button click", async () => {
|
||||
getComponent(defaultHsUrl, defaultIsUrl, authConfig);
|
||||
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
|
||||
|
||||
it("should display oidc-native continue button", async () => {
|
||||
const { container } = getComponent(defaultHsUrl, defaultIsUrl, authConfig);
|
||||
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
|
||||
// no form
|
||||
expect(container.querySelector("form")).toBeFalsy();
|
||||
fireEvent.click(await screen.findByText("Continue"));
|
||||
|
||||
expect(await screen.findByText("Continue")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should start OIDC login flow as registration on button click", async () => {
|
||||
getComponent(defaultHsUrl, defaultIsUrl, authConfig);
|
||||
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
|
||||
|
||||
fireEvent.click(await screen.findByText("Continue"));
|
||||
|
||||
expect(startOidcLogin).toHaveBeenCalledWith(
|
||||
authConfig,
|
||||
clientId,
|
||||
defaultHsUrl,
|
||||
defaultIsUrl,
|
||||
// isRegistration
|
||||
true,
|
||||
);
|
||||
});
|
||||
expect(startOidcLogin).toHaveBeenCalledWith(
|
||||
authConfig,
|
||||
clientId,
|
||||
defaultHsUrl,
|
||||
defaultIsUrl,
|
||||
// isRegistration
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
describe("when is mobile registeration", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue