@@ -232,7 +232,7 @@ describe('ParseLiveQueryServer', function () {
232
232
classNames : [ 'Yolo' ] ,
233
233
} ,
234
234
} )
235
- . then ( parseServer => {
235
+ . then ( ( parseServer ) => {
236
236
saveSpy = spyOn ( parseServer . config . liveQueryController , 'onAfterSave' ) ;
237
237
deleteSpy = spyOn (
238
238
parseServer . config . liveQueryController ,
@@ -247,7 +247,7 @@ describe('ParseLiveQueryServer', function () {
247
247
const obj = new Parse . Object ( 'Yolo' ) ;
248
248
return obj . save ( ) ;
249
249
} )
250
- . then ( obj => {
250
+ . then ( ( obj ) => {
251
251
return obj . destroy ( ) ;
252
252
} )
253
253
. then ( ( ) => {
@@ -1546,7 +1546,7 @@ describe('ParseLiveQueryServer', function () {
1546
1546
} ) ;
1547
1547
1548
1548
describe ( 'class level permissions' , ( ) => {
1549
- it ( 'matches CLP when find is closed' , done => {
1549
+ it ( 'matches CLP when find is closed' , ( done ) => {
1550
1550
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1551
1551
const acl = new Parse . ACL ( ) ;
1552
1552
acl . setReadAccess ( testUserId , true ) ;
@@ -1571,13 +1571,13 @@ describe('ParseLiveQueryServer', function () {
1571
1571
requestId ,
1572
1572
'find'
1573
1573
)
1574
- . then ( isMatched => {
1574
+ . then ( ( isMatched ) => {
1575
1575
expect ( isMatched ) . toBe ( false ) ;
1576
1576
done ( ) ;
1577
1577
} ) ;
1578
1578
} ) ;
1579
1579
1580
- it ( 'matches CLP when find is open' , done => {
1580
+ it ( 'matches CLP when find is open' , ( done ) => {
1581
1581
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1582
1582
const acl = new Parse . ACL ( ) ;
1583
1583
acl . setReadAccess ( testUserId , true ) ;
@@ -1602,13 +1602,13 @@ describe('ParseLiveQueryServer', function () {
1602
1602
requestId ,
1603
1603
'find'
1604
1604
)
1605
- . then ( isMatched => {
1605
+ . then ( ( isMatched ) => {
1606
1606
expect ( isMatched ) . toBe ( true ) ;
1607
1607
done ( ) ;
1608
1608
} ) ;
1609
1609
} ) ;
1610
1610
1611
- it ( 'matches CLP when find is restricted to userIds' , done => {
1611
+ it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
1612
1612
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1613
1613
const acl = new Parse . ACL ( ) ;
1614
1614
acl . setReadAccess ( testUserId , true ) ;
@@ -1633,13 +1633,13 @@ describe('ParseLiveQueryServer', function () {
1633
1633
requestId ,
1634
1634
'find'
1635
1635
)
1636
- . then ( isMatched => {
1636
+ . then ( ( isMatched ) => {
1637
1637
expect ( isMatched ) . toBe ( true ) ;
1638
1638
done ( ) ;
1639
1639
} ) ;
1640
1640
} ) ;
1641
1641
1642
- it ( 'matches CLP when find is restricted to userIds' , done => {
1642
+ it ( 'matches CLP when find is restricted to userIds' , ( done ) => {
1643
1643
const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
1644
1644
const acl = new Parse . ACL ( ) ;
1645
1645
acl . setReadAccess ( testUserId , true ) ;
@@ -1664,7 +1664,7 @@ describe('ParseLiveQueryServer', function () {
1664
1664
requestId ,
1665
1665
'find'
1666
1666
)
1667
- . then ( isMatched => {
1667
+ . then ( ( isMatched ) => {
1668
1668
expect ( isMatched ) . toBe ( false ) ;
1669
1669
done ( ) ;
1670
1670
} ) ;
@@ -2001,7 +2001,7 @@ describe('LiveQueryController', () => {
2001
2001
classNames : [ 'Yolo' ] ,
2002
2002
} ,
2003
2003
} )
2004
- . then ( parseServer => {
2004
+ . then ( ( parseServer ) => {
2005
2005
saveSpy = spyOn (
2006
2006
parseServer . config . liveQueryController ,
2007
2007
'onAfterSave'
@@ -2019,7 +2019,7 @@ describe('LiveQueryController', () => {
2019
2019
const obj = new Parse . Object ( 'Yolo' ) ;
2020
2020
return obj . save ( ) ;
2021
2021
} )
2022
- . then ( obj => {
2022
+ . then ( ( obj ) => {
2023
2023
return obj . destroy ( ) ;
2024
2024
} )
2025
2025
. then ( ( ) => {
@@ -2099,3 +2099,49 @@ describe('LiveQueryController', () => {
2099
2099
} ) ;
2100
2100
} ) ;
2101
2101
} ) ;
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