mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 07:05:24 +00:00
feat: move totp and passkeys into plugins (C1)
This commit is contained in:
1 parent
f4f26a9b8b
commit
5c18435105
235 files changed
+22545
-5610
No files matched your search
@@ -22,9 +22,9 @@ describe("AdminSecondFactorsSection", () => {
|
||||
it("shows a factor whose plugin is off and resets after confirming", async () => {
|
||||
api.getUserSecondFactors.mockResolvedValue([
|
||||
{
|
||||
pluginId: "core",
|
||||
pluginId: "totp",
|
||||
factorId: "totp",
|
||||
labelKey: "auth.totpFactor",
|
||||
labelKey: "factor",
|
||||
available: true,
|
||||
},
|
||||
{ pluginId: "yubi", factorId: "otp", labelKey: null, available: false },
|
||||
@@ -46,6 +46,8 @@ describe("AdminSecondFactorsSection", () => {
|
||||
expect(
|
||||
await screen.findByText("admin.secondFactorUnavailable:yubi"),
|
||||
).toBeTruthy();
|
||||
// A plugin's label resolves in its own namespace.
|
||||
expect(screen.getByText("totp:factor")).toBeTruthy();
|
||||
fireEvent.click(screen.getByText("admin.resetSecondFactors"));
|
||||
expect(requestConfirm).toHaveBeenCalled();
|
||||
await waitFor(() =>
|
||||
|
||||
@@ -15,7 +15,6 @@ const api = vi.hoisted(() => ({
|
||||
adminUpdateUserSnippet: vi.fn(async () => ({})),
|
||||
adminDeleteUserSnippet: vi.fn(async () => ({})),
|
||||
adminResetUserPassword: vi.fn(async () => ({ dataWiped: false })),
|
||||
adminDisableUserTotp: vi.fn(async () => ({})),
|
||||
adminExportUserData: vi.fn(async () => ({})),
|
||||
getSessions: vi.fn(async () => ({ sessions: [] as unknown[] })),
|
||||
revokeSession: vi.fn(async () => ({})),
|
||||
@@ -56,7 +55,6 @@ function makeUser(overrides: Partial<AdminUser> = {}): AdminUser {
|
||||
isOidc: false,
|
||||
passwordHash: "hash",
|
||||
dataUnlocked: true,
|
||||
totpEnabled: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -72,7 +70,7 @@ function renderPanel(
|
||||
onBack={callbacks.onBack ?? vi.fn()}
|
||||
onOpenHostTab={callbacks.onOpenHostTab as never}
|
||||
onUserDeleted={callbacks.onUserDeleted ?? vi.fn()}
|
||||
onTotpDisabled={callbacks.onTotpDisabled ?? vi.fn()}
|
||||
onSecondFactorsReset={callbacks.onSecondFactorsReset ?? vi.fn()}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
@@ -144,21 +142,6 @@ describe("AdminUserManagePanel", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("disables TOTP through the confirm dialog", async () => {
|
||||
const onTotpDisabled = vi.fn();
|
||||
renderPanel(makeUser({ totpEnabled: true }), { onTotpDisabled });
|
||||
|
||||
expect(screen.getByText("admin.totpStatusEnabled")).toBeTruthy();
|
||||
await userEvent.click(screen.getByText("admin.disableTotp"));
|
||||
await userEvent.click(screen.getByText("common.confirm"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(api.adminDisableUserTotp).toHaveBeenCalledWith("u2");
|
||||
expect(onTotpDisabled).toHaveBeenCalled();
|
||||
});
|
||||
expect(screen.getByText("admin.totpStatusDisabled")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("creates a snippet for the target user", async () => {
|
||||
renderPanel(makeUser());
|
||||
|
||||
|
||||
Reference in new issue
Block a user