github.com/kaleido-io/firefly@v0.0.0-20210622132723-8b4b6aacb971/kat/src/test/ethereum/members/argument-validation.ts (about) 1 // Copyright © 2021 Kaleido, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 import { app } from '../../common'; 16 import request from 'supertest'; 17 import assert from 'assert'; 18 19 export const testMembersArgumentValidation = async () => { 20 21 describe('Members - argument validation', async () => { 22 23 it('Attempting to add a member without an address should raise an error', async () => { 24 const result = await request(app) 25 .put('/api/v1/members') 26 .send({ 27 name: 'Member A', 28 app2appDestination: 'kld://app2app', 29 docExchangeDestination: 'kld://docexchange' 30 }) 31 .expect(400); 32 assert.deepStrictEqual(result.body, { error: 'Missing member address' }); 33 }); 34 35 it('Attempting to add a member without a name should raise an error', async () => { 36 const result = await request(app) 37 .put('/api/v1/members') 38 .send({ 39 address: '0x0000000000000000000000000000000000000001', 40 app2appDestination: 'kld://app2app', 41 docExchangeDestination: 'kld://docexchange' 42 }) 43 .expect(400); 44 assert.deepStrictEqual(result.body, { error: 'Missing member name' }); 45 }); 46 47 it('Attempting to get a member that does not exist should raise an error', async () => { 48 const result = await request(app) 49 .get('/api/v1/members/0x0000000000000000000000000000000000000099') 50 .expect(404); 51 assert.deepStrictEqual(result.body, { error: 'Member not found' }); 52 }); 53 54 }); 55 };