github.com/kaleido-io/firefly@v0.0.0-20210622132723-8b4b6aacb971/kat/src/test/corda/members/registration.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 nock from 'nock'; 17 import request from 'supertest'; 18 import assert from 'assert'; 19 import { IDBMember } from '../../../lib/interfaces'; 20 21 export const testMemberRegistration = async () => { 22 23 describe('Members - registration', async () => { 24 it('Checks that adding a member sends a request to API Gateway and updates the database', async () => { 25 26 nock('https://apigateway.kaleido.io') 27 .post('/registerMember') 28 .reply(200); 29 const addMemberResponse = await request(app) 30 .put('/api/v1/members') 31 .send({ 32 address: 'CN=Node of member1 for env1, O=Kaleido, L=Raleigh, C=US', 33 name: 'Member 1', 34 assetTrailInstanceID: 'service-id', 35 app2appDestination: 'kld://app2app/internal', 36 docExchangeDestination:'kld://docstore/dest' 37 }) 38 .expect(200); 39 assert.deepStrictEqual(addMemberResponse.body, { status: 'submitted' }); 40 41 const getMemberResponse = await request(app) 42 .get('/api/v1/members') 43 .expect(200); 44 const member = getMemberResponse.body.find((member: IDBMember) => member.address === 'CN=Node of member1 for env1, O=Kaleido, L=Raleigh, C=US'); 45 assert.strictEqual(member.address, 'CN=Node of member1 for env1, O=Kaleido, L=Raleigh, C=US'); 46 assert.strictEqual(member.name, 'Member 1'); 47 assert.strictEqual(member.assetTrailInstanceID, 'service-id'); 48 assert.strictEqual(member.app2appDestination, 'kld://app2app/internal'); 49 assert.strictEqual(member.docExchangeDestination, 'kld://docstore/dest'); 50 assert.strictEqual(typeof member.submitted, 'number'); 51 52 const getMemberByAddressResponse = await request(app) 53 .get('/api/v1/members/CN=Node of member1 for env1, O=Kaleido, L=Raleigh, C=US') 54 .expect(200); 55 assert.deepStrictEqual(member, getMemberByAddressResponse.body); 56 }); 57 58 it('Get member should return the confirmed member', async () => { 59 const getMemberResponse = await request(app) 60 .get('/api/v1/members') 61 .expect(200); 62 const member = getMemberResponse.body.find((member: IDBMember) => member.address === 'CN=Node of member1 for env1, O=Kaleido, L=Raleigh, C=US'); 63 assert.strictEqual(member.address, 'CN=Node of member1 for env1, O=Kaleido, L=Raleigh, C=US'); 64 assert.strictEqual(member.name, 'Member 1'); 65 assert.strictEqual(member.assetTrailInstanceID, 'service-id'); 66 assert.strictEqual(member.app2appDestination, 'kld://app2app/internal'); 67 assert.strictEqual(member.docExchangeDestination, 'kld://docstore/dest'); 68 69 const getMemberByAddressResponse = await request(app) 70 .get('/api/v1/members/CN=Node of member1 for env1, O=Kaleido, L=Raleigh, C=US') 71 .expect(200); 72 assert.deepStrictEqual(member, getMemberByAddressResponse.body); 73 }); 74 75 }); 76 };