chore: Add serverPassword param to endpoints (#2919) [skip e2e]

* chore: send server password param to delete account endpoint

* chore: send server password param to disable mfa endpoint

* chore: modify tests

* chore: force challenge prompt for mfa disable

* chore: fix eslint errors

* chore: add server passsword to get recovery codes

* chore: fix tests

* chore: pass server password as header
This commit is contained in:
Antonella Sgarlatta
2025-08-26 09:04:03 -03:00
committed by GitHub
parent cf4d2196de
commit 54af28aa04
29 changed files with 298 additions and 62 deletions

View File

@@ -1,4 +1,4 @@
import { AuthClientInterface } from '@standardnotes/services'
import { AuthClientInterface, EncryptionService } from '@standardnotes/services'
import { SettingsClientInterface } from '@Lib/Services/Settings/SettingsClientInterface'
import { GetRecoveryCodes } from './GetRecoveryCodes'
@@ -6,8 +6,9 @@ import { GetRecoveryCodes } from './GetRecoveryCodes'
describe('GetRecoveryCodes', () => {
let authClient: AuthClientInterface
let settingsClient: SettingsClientInterface
let encryption: EncryptionService
const createUseCase = () => new GetRecoveryCodes(authClient, settingsClient)
const createUseCase = () => new GetRecoveryCodes(authClient, settingsClient, encryption)
beforeEach(() => {
authClient = {} as jest.Mocked<AuthClientInterface>
@@ -15,12 +16,16 @@ describe('GetRecoveryCodes', () => {
settingsClient = {} as jest.Mocked<SettingsClientInterface>
settingsClient.getSetting = jest.fn().mockResolvedValue('existing-recovery-codes')
encryption = {} as jest.Mocked<EncryptionService>
encryption.computeRootKey = jest.fn().mockResolvedValue({ serverPassword: 'test-server-password' })
encryption.getRootKeyParams = jest.fn().mockReturnValue({ algorithm: 'test-algorithm' })
})
it('should return existing recovery code if they exist', async () => {
const useCase = createUseCase()
const result = await useCase.execute()
const result = await useCase.execute({ password: 'test-password' })
expect(result.getValue()).toBe('existing-recovery-codes')
})
@@ -30,7 +35,7 @@ describe('GetRecoveryCodes', () => {
const useCase = createUseCase()
const result = await useCase.execute()
const result = await useCase.execute({ password: 'test-password' })
expect(result.getValue()).toBe('recovery-codes')
})
@@ -41,7 +46,7 @@ describe('GetRecoveryCodes', () => {
const useCase = createUseCase()
const result = await useCase.execute()
const result = await useCase.execute({ password: 'test-password' })
expect(result.isFailed()).toBe(true)
})