From 693308e5d6dedc5f39472df6ed18b7a98f703e60 Mon Sep 17 00:00:00 2001 From: joerger Date: Tue, 3 Dec 2024 11:59:41 -0800 Subject: [PATCH] Fix lint; Fix test. --- .../src/components/AuthnDialog/AuthnDialog.test.tsx | 3 ++- web/packages/teleport/src/services/mfa/mfaOptions.test.ts | 8 ++++---- web/packages/teleport/src/services/mfa/mfaOptions.ts | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/web/packages/teleport/src/components/AuthnDialog/AuthnDialog.test.tsx b/web/packages/teleport/src/components/AuthnDialog/AuthnDialog.test.tsx index 5066113d24400..e4752390357e7 100644 --- a/web/packages/teleport/src/components/AuthnDialog/AuthnDialog.test.tsx +++ b/web/packages/teleport/src/components/AuthnDialog/AuthnDialog.test.tsx @@ -20,7 +20,8 @@ import React from 'react'; import { render, screen, fireEvent } from 'design/utils/testing'; import { makeDefaultMfaState, MfaState } from 'teleport/lib/useMfa'; -import { SSOChallenge } from 'teleport/services/auth'; + +import { SSOChallenge } from 'teleport/services/mfa'; import AuthnDialog from './AuthnDialog'; diff --git a/web/packages/teleport/src/services/mfa/mfaOptions.test.ts b/web/packages/teleport/src/services/mfa/mfaOptions.test.ts index 6b274d2bb3cb8..903cd39becf3e 100644 --- a/web/packages/teleport/src/services/mfa/mfaOptions.test.ts +++ b/web/packages/teleport/src/services/mfa/mfaOptions.test.ts @@ -76,7 +76,7 @@ describe('test retrieving mfa options from MFA Challenge', () => { { name: 'challenge webauthn', challenge: { - webauthnPublicKey: Object.create(PublicKeyCredential), + webauthnPublicKey: {} as PublicKeyCredentialRequestOptions, }, expect: ['webauthn'], }, @@ -85,16 +85,16 @@ describe('test retrieving mfa options from MFA Challenge', () => { challenge: { ssoChallenge: Object.create(SSOChallenge), }, - expect: ['webauthn', 'totp'], + expect: ['sso'], }, { name: 'challenge all', challenge: { totpChallenge: true, - webauthnPublicKey: Object.create(PublicKeyCredential), + webauthnPublicKey: {} as PublicKeyCredentialRequestOptions, ssoChallenge: Object.create(SSOChallenge), }, - expect: ['webauthn', 'totp'], + expect: ['webauthn', 'totp', 'sso'], }, ]; diff --git a/web/packages/teleport/src/services/mfa/mfaOptions.ts b/web/packages/teleport/src/services/mfa/mfaOptions.ts index d24f74337b9b8..c897863566099 100644 --- a/web/packages/teleport/src/services/mfa/mfaOptions.ts +++ b/web/packages/teleport/src/services/mfa/mfaOptions.ts @@ -49,6 +49,9 @@ const totpOption: MfaOption = { value: 'totp', label: 'Authenticator App' }; const getSsoOption = (ssoChallenge: SSOChallenge): MfaOption => { return { value: 'sso', - label: ssoChallenge.device.displayName || ssoChallenge.device.connectorId, + label: + ssoChallenge.device?.displayName || + ssoChallenge.device?.connectorId || + 'SSO', }; };