MCPcopy
hub / github.com/deepstreamIO/deepstream.io / testPermission

Function testPermission

src/test/helper/test-helper.ts:138–157  ·  view source on GitHub ↗
(options: { config: DeepstreamConfig, services: DeepstreamServices })

Source from the content-addressed store, hash-verified

136const ConfigPermission = require('../../services/permission/valve/config-permission').ConfigPermission
137
138export const testPermission = function (options: { config: DeepstreamConfig, services: DeepstreamServices }) {
139 return function (permissions: any, message: Message, username?: string, userdata?: any, callback?: PermissionCallback) {
140 options.config.permission.options.permissions = permissions
141 const permission = new ConfigPermission(options.config.permission.options, options.services, options.config)
142 permission.setRecordHandler({
143 removeRecordRequest: () => {},
144 runWhenRecordStable: (r: any, c: any) => { c(r) }
145 })
146 let permissionResult
147
148 const socketWrapper = SocketWrapperFactoryMock.createSocketWrapper()
149 socketWrapper.userId = username || 'someUser'
150 socketWrapper.serverData = userdata
151 callback = callback || function (sw: SocketWrapper, msg: Message, passItOn: any, error: any, result: boolean) {
152 permissionResult = result
153 }
154 permission.canPerformAction(socketWrapper, message, callback)
155 return permissionResult
156 }
157}

Calls 3

setRecordHandlerMethod · 0.95
canPerformActionMethod · 0.95
createSocketWrapperMethod · 0.80

Tested by

no test coverage detected