Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Update required fields in multisig schema (#8917)
Browse files Browse the repository at this point in the history
Add required fields in sortMultisignatureGroupRequestSchema

Co-authored-by: Mitsuaki Uchimoto <mitsuaki-u@users.noreply.github.com>
  • Loading branch information
mitsuaki-u and mitsuaki-u authored Sep 1, 2023
1 parent e38b688 commit 108b1ce
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions framework/src/modules/auth/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const sortMultisignatureGroupRequestSchema = {
type: 'array',
items: {
type: 'object',
required: ['publicKey', 'signature'],
properties: {
publicKey: {
type: 'string',
Expand All @@ -95,6 +96,7 @@ export const sortMultisignatureGroupRequestSchema = {
type: 'array',
items: {
type: 'object',
required: ['publicKey', 'signature'],
properties: {
publicKey: {
type: 'string',
Expand Down
35 changes: 35 additions & 0 deletions framework/test/unit/modules/auth/endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 108b1ce

Please sign in to comment.