diff --git a/framework/src/modules/auth/schemas.ts b/framework/src/modules/auth/schemas.ts index a65e1c871c..1d42d14f67 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 e954bab8d8..32bf7be7c8 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: [