From 108b1ce451796b5a2e019f8c3705f73e48d8a552 Mon Sep 17 00:00:00 2001 From: Mitsuaki Uchimoto <36514357+mitsuaki-u@users.noreply.github.com> Date: Fri, 1 Sep 2023 07:31:09 +0200 Subject: [PATCH] Update required fields in multisig schema (#8917) Add required fields in sortMultisignatureGroupRequestSchema Co-authored-by: Mitsuaki Uchimoto --- framework/src/modules/auth/schemas.ts | 2 ++ .../test/unit/modules/auth/endpoint.spec.ts | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/framework/src/modules/auth/schemas.ts b/framework/src/modules/auth/schemas.ts index a65e1c871c8..1d42d14f677 100644 --- a/framework/src/modules/auth/schemas.ts +++ b/framework/src/modules/auth/schemas.ts @@ -73,6 +73,7 @@ export const sortMultisignatureGroupRequestSchema = { type: 'array', items: { type: 'object', + required: ['publicKey', 'signature'], properties: { publicKey: { type: 'string', @@ -95,6 +96,7 @@ export const sortMultisignatureGroupRequestSchema = { type: 'array', items: { type: 'object', + required: ['publicKey', 'signature'], properties: { publicKey: { type: 'string', diff --git a/framework/test/unit/modules/auth/endpoint.spec.ts b/framework/test/unit/modules/auth/endpoint.spec.ts index e954bab8d83..32bf7be7c84 100644 --- a/framework/test/unit/modules/auth/endpoint.spec.ts +++ b/framework/test/unit/modules/auth/endpoint.spec.ts @@ -675,6 +675,41 @@ describe('AuthEndpoint', () => { expect(sortedSignatures.signatures[4]).toEqual(inputData.optional[0].signature); }); + it('should throw a validation error when missing required fields', () => { + const inputData = { + mandatory: [ + { + publicKey: '3333333333333333333333333333333333333333333333333333333333333333', + }, + { + publicKey: '0000000000000000000000000000000000000000000000000000000000000000', + signature: + '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111', + }, + { + publicKey: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + signature: + '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + }, + ], + optional: [ + { + publicKey: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + signature: '', + }, + { + publicKey: '2222222222222222222222222222222222222222222222222222222222222222', + signature: + 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', + }, + ], + }; + + const context = createTransientModuleEndpointContext({ params: inputData }); + + expect(() => authEndpoint.sortMultisignatureGroup(context)).toThrow(LiskValidationError); + }); + it('should throw a validation error when provided invalid request', () => { const inputData = { mandatory: [