Add test for _-prefixed methods
This commit is contained in:
parent
c4ae271604
commit
0a1eabadd9
@ -57,7 +57,9 @@ describe('jsonrpc', () => {
|
|||||||
addWithContext = (ctx: IContext, a: number, b: number) => {
|
addWithContext = (ctx: IContext, a: number, b: number) => {
|
||||||
return a + b + ctx.userId
|
return a + b + ctx.userId
|
||||||
}
|
}
|
||||||
|
_private = () => {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
@ensureLoggedIn
|
@ensureLoggedIn
|
||||||
addWithContext2(ctx: IContext, a: number, b: number) {
|
addWithContext2(ctx: IContext, a: number, b: number) {
|
||||||
return Promise.resolve(a + b + ctx!.userId)
|
return Promise.resolve(a + b + ctx!.userId)
|
||||||
@ -214,6 +216,19 @@ describe('jsonrpc', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('cannot call private _-prefixed methods', async () => {
|
||||||
|
await request(createApp())
|
||||||
|
.post('/myService')
|
||||||
|
.send({
|
||||||
|
id: 123,
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
method: '_private',
|
||||||
|
params: [],
|
||||||
|
})
|
||||||
|
.expect(404)
|
||||||
|
.expect(/Method not found/)
|
||||||
|
})
|
||||||
|
|
||||||
it('cannot call any other methods in objects prototype', async () => {
|
it('cannot call any other methods in objects prototype', async () => {
|
||||||
await request(createApp())
|
await request(createApp())
|
||||||
.post('/myService')
|
.post('/myService')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user