|
| 1 | +import 'should'; |
| 2 | +import * as http from 'http'; |
| 3 | +import { app as awmApp } from '../../advancedWalletManagerApp'; |
| 4 | +import { app as mbeApp } from '../../masterBitGoExpressApp'; |
| 5 | +import { AppMode, TlsMode, SigningMode } from '../../shared/types'; |
| 6 | +import { listen, close } from './helpers/servers'; |
| 7 | + |
| 8 | +describe('integration — health checks', () => { |
| 9 | + let awmServer: http.Server; |
| 10 | + let mbeServer: http.Server; |
| 11 | + let awmPort: number; |
| 12 | + let mbePort: number; |
| 13 | + |
| 14 | + before(async () => { |
| 15 | + awmServer = http.createServer( |
| 16 | + awmApp({ |
| 17 | + appMode: AppMode.ADVANCED_WALLET_MANAGER, |
| 18 | + tlsMode: TlsMode.DISABLED, |
| 19 | + signingMode: SigningMode.LOCAL, |
| 20 | + port: 0, |
| 21 | + bind: '127.0.0.1', |
| 22 | + timeout: 30000, |
| 23 | + httpLoggerFile: '', |
| 24 | + keyProviderUrl: 'http://127.0.0.1:3082', |
| 25 | + }), |
| 26 | + ); |
| 27 | + awmPort = await listen(awmServer); |
| 28 | + |
| 29 | + mbeServer = http.createServer( |
| 30 | + mbeApp({ |
| 31 | + appMode: AppMode.MASTER_EXPRESS, |
| 32 | + tlsMode: TlsMode.DISABLED, |
| 33 | + port: 0, |
| 34 | + bind: '127.0.0.1', |
| 35 | + timeout: 30000, |
| 36 | + httpLoggerFile: '', |
| 37 | + env: 'test', |
| 38 | + disableEnvCheck: true, |
| 39 | + advancedWalletManagerUrl: `http://127.0.0.1:${awmPort}`, |
| 40 | + awmServerCertAllowSelfSigned: true, |
| 41 | + }), |
| 42 | + ); |
| 43 | + mbePort = await listen(mbeServer); |
| 44 | + }); |
| 45 | + |
| 46 | + after(async () => { |
| 47 | + await close(awmServer); |
| 48 | + await close(mbeServer); |
| 49 | + }); |
| 50 | + |
| 51 | + it('AWM /ping returns 200', async () => { |
| 52 | + const res = await fetch(`http://127.0.0.1:${awmPort}/ping`, { method: 'POST' }); |
| 53 | + res.status.should.equal(200); |
| 54 | + }); |
| 55 | + |
| 56 | + it('MBE /advancedwallet/ping returns 200', async () => { |
| 57 | + const res = await fetch(`http://127.0.0.1:${mbePort}/advancedwallet/ping`, { method: 'POST' }); |
| 58 | + res.status.should.equal(200); |
| 59 | + }); |
| 60 | +}); |
0 commit comments