chore: display shared vault file usage (#2399)

* chore: display shared vault file usage

* fix: specs

* fix: reshape filtering result

* fix: resolving invalid server items

* fix: get revisions specs

* fix: processing issue

* fix: tests

---------

Co-authored-by: Mo <mo@standardnotes.com>
This commit is contained in:
Karol Sójko
2023-08-11 08:59:16 +02:00
committed by GitHub
parent 05f3672526
commit 5bca53736b
87 changed files with 505 additions and 169 deletions

View File

@@ -5,10 +5,10 @@ jest.mock('@standardnotes/models', () => {
return {
...original,
isRemotePayloadAllowed: jest.fn(),
checkRemotePayloadAllowed: jest.fn(),
}
})
const isRemotePayloadAllowed = require('@standardnotes/models').isRemotePayloadAllowed
const checkRemotePayloadAllowed = require('@standardnotes/models').checkRemotePayloadAllowed
import { Revision } from '../../Revision/Revision'
@@ -44,7 +44,7 @@ describe('GetRevision', () => {
encryptedPayload.copy = jest.fn().mockReturnValue(encryptedPayload)
encryptionService.decryptSplitSingle = jest.fn().mockReturnValue(encryptedPayload)
isRemotePayloadAllowed.mockImplementation(() => true)
checkRemotePayloadAllowed.mockImplementation(() => ({ allowed: {} }))
})
it('should get revision', async () => {
@@ -145,7 +145,7 @@ describe('GetRevision', () => {
})
it('should fail if remote payload is not allowed', async () => {
isRemotePayloadAllowed.mockImplementation(() => false)
checkRemotePayloadAllowed.mockImplementation(() => ({ disallowed: {} }))
const useCase = createUseCase()

View File

@@ -5,7 +5,7 @@ import {
EncryptedPayload,
HistoryEntry,
isErrorDecryptingPayload,
isRemotePayloadAllowed,
checkRemotePayloadAllowed,
NoteContent,
PayloadTimestampDefaults,
} from '@standardnotes/models'
@@ -71,7 +71,8 @@ export class GetRevision implements UseCaseInterface<HistoryEntry> {
uuid: sourceItemUuid || revision.item_uuid,
})
if (!isRemotePayloadAllowed(payload as ServerItemResponse)) {
const remotePayloadAllowedResult = checkRemotePayloadAllowed(payload as ServerItemResponse)
if (remotePayloadAllowedResult.disallowed !== undefined) {
return Result.fail(`Remote payload is disallowed: ${JSON.stringify(payload)}`)
}