| 39 | } |
| 40 | |
| 41 | export const getDeepstreamOptions = (serverName?: string): { config: DeepstreamConfig, services: DeepstreamServices } => { |
| 42 | const config = { ...get(), ...{ |
| 43 | serverName: serverName || 'server-name-a', |
| 44 | |
| 45 | cluster: { |
| 46 | state: { |
| 47 | options: { |
| 48 | reconciliationTimeout: 50 |
| 49 | } |
| 50 | } |
| 51 | }, |
| 52 | permission: { |
| 53 | options: { |
| 54 | cacheEvacuationInterval: 60000, |
| 55 | maxRuleIterations: 3 |
| 56 | } |
| 57 | }, |
| 58 | rpc: { |
| 59 | provideRequestorData: true, |
| 60 | provideRequestorName: true, |
| 61 | ackTimeout: 10, |
| 62 | responseTimeout: 20, |
| 63 | }, |
| 64 | record: { |
| 65 | cacheRetrievalTimeout: 30, |
| 66 | storageRetrievalTimeout: 50, |
| 67 | storageExclusionPrefixes: ['no-storage'], |
| 68 | storageHotPathPrefixes: [], |
| 69 | } |
| 70 | }} as never as DeepstreamConfig |
| 71 | |
| 72 | class PermissionHandler extends DeepstreamPlugin implements PermissionHandler { |
| 73 | public lastArgs: any[] |
| 74 | public description: string |
| 75 | public nextResult: boolean |
| 76 | public nextError: string | null |
| 77 | |
| 78 | constructor () { |
| 79 | super() |
| 80 | this.description = 'Test Permission Handler' |
| 81 | this.nextResult = true |
| 82 | this.nextError = null |
| 83 | this.lastArgs = [] |
| 84 | } |
| 85 | |
| 86 | public canPerformAction (socketWrapper: SocketWrapper, message: Message, callback: PermissionCallback, passItOn: any) { |
| 87 | this.lastArgs.push([socketWrapper.userId, message, callback]) |
| 88 | callback(socketWrapper, message, passItOn, this.nextError, this.nextResult) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // tslint:disable-next-line: max-classes-per-file |
| 93 | class MonitoringMock extends DeepstreamPlugin implements DeepstreamMonitoring { |
| 94 | public description = 'monitoring mock' |
| 95 | public onErrorLog (loglevel: LOG_LEVEL, event: EVENT, logMessage: string): void { |
| 96 | } |
| 97 | public onLogin (allowed: boolean, endpointType: string): void { |
| 98 | } |