@@ -232,7 +232,7 @@ describe('ParseLiveQueryServer', function () {
232232 classNames : [ 'Yolo' ] ,
233233 } ,
234234 } )
235- . then ( parseServer => {
235+ . then ( ( parseServer ) => {
236236 saveSpy = spyOn ( parseServer . config . liveQueryController , 'onAfterSave' ) ;
237237 deleteSpy = spyOn (
238238 parseServer . config . liveQueryController ,
@@ -247,7 +247,7 @@ describe('ParseLiveQueryServer', function () {
247247 const obj = new Parse . Object ( 'Yolo' ) ;
248248 return obj . save ( ) ;
249249 } )
250- . then ( obj => {
250+ . then ( ( obj ) => {
251251 return obj . destroy ( ) ;
252252 } )
253253 . then ( ( ) => {
@@ -1546,7 +1546,7 @@ describe('ParseLiveQueryServer', function () {
15461546 } ) ;
15471547
15481548 describe ( 'class level permissions' , ( ) => {
1549- it ( 'matches CLP when find is closed' , done => {
1549+ it ( 'matches CLP when find is closed' , ( done ) => {
15501550 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
15511551 const acl = new Parse . ACL ( ) ;
15521552 acl . setReadAccess ( testUserId , true ) ;
@@ -1571,13 +1571,13 @@ describe('ParseLiveQueryServer', function () {
15711571 requestId ,
15721572 'find'
15731573 )
1574- . then ( isMatched => {
1574+ . then ( ( isMatched ) => {
15751575 expect ( isMatched ) . toBe ( false ) ;
15761576 done ( ) ;
15771577 } ) ;
15781578 } ) ;
15791579
1580- it ( 'matches CLP when find is open' , done => {
1580+ it ( 'matches CLP when find is open' , ( done ) => {
15811581 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
15821582 const acl = new Parse . ACL ( ) ;
15831583 acl . setReadAccess ( testUserId , true ) ;
@@ -1602,13 +1602,13 @@ describe('ParseLiveQueryServer', function () {
16021602 requestId ,
16031603 'find'
16041604 )
1605- . then ( isMatched => {
1605+ . then ( ( isMatched ) => {
16061606 expect ( isMatched ) . toBe ( true ) ;
16071607 done ( ) ;
16081608 } ) ;
16091609 } ) ;
16101610
1611- it ( 'matches CLP when find is restricted to userIds' , done => {
1611+ it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
16121612 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
16131613 const acl = new Parse . ACL ( ) ;
16141614 acl . setReadAccess ( testUserId , true ) ;
@@ -1633,13 +1633,13 @@ describe('ParseLiveQueryServer', function () {
16331633 requestId ,
16341634 'find'
16351635 )
1636- . then ( isMatched => {
1636+ . then ( ( isMatched ) => {
16371637 expect ( isMatched ) . toBe ( true ) ;
16381638 done ( ) ;
16391639 } ) ;
16401640 } ) ;
16411641
1642- it ( 'matches CLP when find is restricted to userIds' , done => {
1642+ it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
16431643 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
16441644 const acl = new Parse . ACL ( ) ;
16451645 acl . setReadAccess ( testUserId , true ) ;
@@ -1664,7 +1664,7 @@ describe('ParseLiveQueryServer', function () {
16641664 requestId ,
16651665 'find'
16661666 )
1667- . then ( isMatched => {
1667+ . then ( ( isMatched ) => {
16681668 expect ( isMatched ) . toBe ( false ) ;
16691669 done ( ) ;
16701670 } ) ;
@@ -2001,7 +2001,7 @@ describe('LiveQueryController', () => {
20012001 classNames : [ 'Yolo' ] ,
20022002 } ,
20032003 } )
2004- . then ( parseServer => {
2004+ . then ( ( parseServer ) => {
20052005 saveSpy = spyOn (
20062006 parseServer . config . liveQueryController ,
20072007 'onAfterSave'
@@ -2019,7 +2019,7 @@ describe('LiveQueryController', () => {
20192019 const obj = new Parse . Object ( 'Yolo' ) ;
20202020 return obj . save ( ) ;
20212021 } )
2022- . then ( obj => {
2022+ . then ( ( obj ) => {
20232023 return obj . destroy ( ) ;
20242024 } )
20252025 . then ( ( ) => {
@@ -2099,3 +2099,49 @@ describe('LiveQueryController', () => {
20992099 } ) ;
21002100 } ) ;
21012101} ) ;
2102+
2103+ it ( 'basic beforeConnect rejection' , async ( ) => {
2104+ Parse . Cloud . beforeConnect ( function ( ) {
2105+ throw new Error ( 'You shall not pass!' ) ;
2106+ } ) ;
2107+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
2108+ const parseWebSocket = {
2109+ clientId : - 1 ,
2110+ } ;
2111+ await parseLiveQueryServer . _handleConnect ( parseWebSocket , {
2112+ sessionToken : 'token' ,
2113+ } ) ;
2114+ expect ( parseLiveQueryServer . clients . size ) . toBe ( 0 ) ;
2115+ const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
2116+ expect ( Client . pushError ) . toHaveBeenCalled ( ) ;
2117+ } ) ;
2118+
2119+ it ( 'basic beforeSubscribe rejection' , async ( ) => {
2120+ Parse . Cloud . beforeSubscribe ( 'test' , function ( ) {
2121+ throw new Error ( 'You shall not pass!' ) ;
2122+ } ) ;
2123+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
2124+ const parseWebSocket = {
2125+ clientId : - 1 ,
2126+ } ;
2127+ await parseLiveQueryServer . _handleConnect ( parseWebSocket , {
2128+ sessionToken : 'token' ,
2129+ } ) ;
2130+ const query = {
2131+ className : 'test' ,
2132+ where : {
2133+ key : 'value' ,
2134+ } ,
2135+ fields : [ 'test' ] ,
2136+ } ;
2137+ const requestId = 2 ;
2138+ const request = {
2139+ query : query ,
2140+ requestId : requestId ,
2141+ sessionToken : 'sessionToken' ,
2142+ } ;
2143+ await parseLiveQueryServer . _handleSubscribe ( parseWebSocket , request ) ;
2144+ expect ( parseLiveQueryServer . clients . size ) . toBe ( 0 ) ;
2145+ const Client = require ( '../lib/LiveQuery/Client' ) . Client ;
2146+ expect ( Client . pushError ) . toHaveBeenCalled ( ) ;
2147+ } ) ;
0 commit comments