@@ -834,6 +834,116 @@ describe('ParseLiveQueryServer', function() {
834
834
} ) ;
835
835
} ) ;
836
836
837
+ it ( 'won\'t match ACL that doesn\'t have public read or any roles' , function ( done ) {
838
+
839
+ var parseLiveQueryServer = new ParseLiveQueryServer ( 10 , 10 , { } ) ;
840
+ var acl = new Parse . ACL ( ) ;
841
+ acl . setPublicReadAccess ( false ) ;
842
+ var client = {
843
+ getSubscriptionInfo : jasmine . createSpy ( 'getSubscriptionInfo' ) . and . returnValue ( {
844
+ sessionToken : 'sessionToken'
845
+ } )
846
+ } ;
847
+ var requestId = 0 ;
848
+
849
+ parseLiveQueryServer . _matchesACL ( acl , client , requestId ) . then ( function ( isMatched ) {
850
+ expect ( isMatched ) . toBe ( false ) ;
851
+ done ( ) ;
852
+ } ) ;
853
+
854
+ } ) ;
855
+
856
+ it ( 'won\'t match non-public ACL with role when there is no user' , function ( done ) {
857
+
858
+ var parseLiveQueryServer = new ParseLiveQueryServer ( 10 , 10 , { } ) ;
859
+ var acl = new Parse . ACL ( ) ;
860
+ acl . setPublicReadAccess ( false ) ;
861
+ acl . setRoleReadAccess ( "livequery" , true ) ;
862
+ var client = {
863
+ getSubscriptionInfo : jasmine . createSpy ( 'getSubscriptionInfo' ) . and . returnValue ( {
864
+ } )
865
+ } ;
866
+ var requestId = 0 ;
867
+
868
+ parseLiveQueryServer . _matchesACL ( acl , client , requestId ) . then ( function ( isMatched ) {
869
+ expect ( isMatched ) . toBe ( false ) ;
870
+ done ( ) ;
871
+ } ) ;
872
+
873
+ } ) ;
874
+
875
+ it ( 'won\'t match ACL with role based read access set to false' , function ( done ) {
876
+
877
+ var parseLiveQueryServer = new ParseLiveQueryServer ( 10 , 10 , { } ) ;
878
+ var acl = new Parse . ACL ( ) ;
879
+ acl . setPublicReadAccess ( false ) ;
880
+ acl . setRoleReadAccess ( "liveQueryRead" , false ) ;
881
+ var client = {
882
+ getSubscriptionInfo : jasmine . createSpy ( 'getSubscriptionInfo' ) . and . returnValue ( {
883
+ sessionToken : 'sessionToken'
884
+ } )
885
+ } ;
886
+ var requestId = 0 ;
887
+
888
+ spyOn ( Parse , "Query" ) . and . callFake ( function ( ) {
889
+ return {
890
+ equalTo ( relation , value ) {
891
+ // Nothing to do here
892
+ } ,
893
+ find ( ) {
894
+ //Return a role with the name "liveQueryRead" as that is what was set on the ACL
895
+ var liveQueryRole = new Parse . Role ( ) ;
896
+ liveQueryRole . set ( 'name' , 'liveQueryRead' ) ;
897
+ return [
898
+ liveQueryRole
899
+ ] ;
900
+ }
901
+ }
902
+ } ) ;
903
+
904
+ parseLiveQueryServer . _matchesACL ( acl , client , requestId ) . then ( function ( isMatched ) {
905
+ expect ( isMatched ) . toBe ( false ) ;
906
+ done ( ) ;
907
+ } ) ;
908
+
909
+ } ) ;
910
+
911
+ it ( 'will match ACL with role based read access set to true' , function ( done ) {
912
+
913
+ var parseLiveQueryServer = new ParseLiveQueryServer ( 10 , 10 , { } ) ;
914
+ var acl = new Parse . ACL ( ) ;
915
+ acl . setPublicReadAccess ( false ) ;
916
+ acl . setRoleReadAccess ( "liveQueryRead" , true ) ;
917
+ var client = {
918
+ getSubscriptionInfo : jasmine . createSpy ( 'getSubscriptionInfo' ) . and . returnValue ( {
919
+ sessionToken : 'sessionToken'
920
+ } )
921
+ } ;
922
+ var requestId = 0 ;
923
+
924
+ spyOn ( Parse , "Query" ) . and . callFake ( function ( ) {
925
+ return {
926
+ equalTo ( relation , value ) {
927
+ // Nothing to do here
928
+ } ,
929
+ find ( ) {
930
+ //Return a role with the name "liveQueryRead" as that is what was set on the ACL
931
+ var liveQueryRole = new Parse . Role ( ) ;
932
+ liveQueryRole . set ( 'name' , 'liveQueryRead' ) ;
933
+ return [
934
+ liveQueryRole
935
+ ] ;
936
+ }
937
+ }
938
+ } ) ;
939
+
940
+ parseLiveQueryServer . _matchesACL ( acl , client , requestId ) . then ( function ( isMatched ) {
941
+ expect ( isMatched ) . toBe ( true ) ;
942
+ done ( ) ;
943
+ } ) ;
944
+
945
+ } ) ;
946
+
837
947
it ( 'can validate key when valid key is provided' , function ( ) {
838
948
var parseLiveQueryServer = new ParseLiveQueryServer ( { } , {
839
949
keyPairs : {
0 commit comments