@@ -775,6 +775,8 @@ describe('rest create', () => {
775775 } ) ;
776776
777777 it ( 'cannot get object in volatileClasses if not masterKey through pointer' , async ( ) => {
778+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
779+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
778780 const masterKeyOnlyClassObject = new Parse . Object ( '_PushStatus' ) ;
779781 await masterKeyOnlyClassObject . save ( null , { useMasterKey : true } ) ;
780782 const obj2 = new Parse . Object ( 'TestObject' ) ;
@@ -788,9 +790,12 @@ describe('rest create', () => {
788790 await expectAsync ( query . get ( obj2 . id ) ) . toBeRejectedWithError (
789791 'Permission denied'
790792 ) ;
793+ sanitizedErrorCall . checkMessage ( "Clients aren't allowed to perform the get operation on the _PushStatus collection." , callCountBefore ) ;
791794 } ) ;
792795
793796 it_id ( '3ce563bf-93aa-4d0b-9af9-c5fb246ac9fc' ) ( it ) ( 'cannot get object in _GlobalConfig if not masterKey through pointer' , async ( ) => {
797+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
798+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
794799 await Parse . Config . save ( { privateData : 'secret' } , { privateData : true } ) ;
795800 const obj2 = new Parse . Object ( 'TestObject' ) ;
796801 obj2 . set ( 'globalConfigPointer' , {
@@ -804,6 +809,7 @@ describe('rest create', () => {
804809 await expectAsync ( query . get ( obj2 . id ) ) . toBeRejectedWithError (
805810 'Permission denied'
806811 ) ;
812+ sanitizedErrorCall . checkMessage ( "Clients aren't allowed to perform the get operation on the _GlobalConfig collection." , callCountBefore ) ;
807813 } ) ;
808814
809815 it ( 'locks down session' , done => {
@@ -949,6 +955,8 @@ describe('rest update', () => {
949955
950956describe ( 'read-only masterKey' , ( ) => {
951957 it ( 'properly throws on rest.create, rest.update and rest.del' , ( ) => {
958+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
959+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
952960 const config = Config . get ( 'test' ) ;
953961 const readOnly = auth . readOnly ( config ) ;
954962 expect ( ( ) => {
@@ -959,6 +967,7 @@ describe('read-only masterKey', () => {
959967 'Permission denied'
960968 )
961969 ) ;
970+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to perform the create operation." , callCountBefore ) ;
962971 expect ( ( ) => {
963972 rest . update ( config , readOnly , 'AnObject' , { } ) ;
964973 } ) . toThrow ( ) ;
@@ -971,6 +980,8 @@ describe('read-only masterKey', () => {
971980 await reconfigureServer ( {
972981 readOnlyMasterKey : 'yolo-read-only' ,
973982 } ) ;
983+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
984+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
974985 try {
975986 await request ( {
976987 url : `${ Parse . serverURL } /classes/MyYolo` ,
@@ -988,6 +999,7 @@ describe('read-only masterKey', () => {
988999 expect ( res . data . error ) . toBe (
9891000 'Permission denied'
9901001 ) ;
1002+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to perform the create operation." , callCountBefore ) ;
9911003 }
9921004 await reconfigureServer ( ) ;
9931005 } ) ;
@@ -1015,18 +1027,20 @@ describe('read-only masterKey', () => {
10151027 } ) ;
10161028
10171029 it ( 'should throw when trying to create RestWrite' , ( ) => {
1030+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
1031+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
10181032 const config = Config . get ( 'test' ) ;
10191033 expect ( ( ) => {
10201034 new RestWrite ( config , auth . readOnly ( config ) ) ;
10211035 } ) . toThrow (
1022- new Parse . Error (
1023- Parse . Error . OPERATION_FORBIDDEN ,
1024- 'Cannot perform a write operation when using readOnlyMasterKey'
1025- )
1036+ new Parse . Error ( Parse . Error . OPERATION_FORBIDDEN , 'Permission denied' )
10261037 ) ;
1038+ sanitizedErrorCall . checkMessage ( "Cannot perform a write operation when using readOnlyMasterKey" , callCountBefore ) ;
10271039 } ) ;
10281040
10291041 it ( 'should throw when trying to create schema' , done => {
1042+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
1043+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
10301044 request ( {
10311045 method : 'POST' ,
10321046 url : `${ Parse . serverURL } /schemas` ,
@@ -1041,11 +1055,14 @@ describe('read-only masterKey', () => {
10411055 . catch ( res => {
10421056 expect ( res . data . code ) . toBe ( Parse . Error . OPERATION_FORBIDDEN ) ;
10431057 expect ( res . data . error ) . toBe ( 'Permission denied' ) ;
1058+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to create a schema." , callCountBefore ) ;
10441059 done ( ) ;
10451060 } ) ;
10461061 } ) ;
10471062
10481063 it ( 'should throw when trying to create schema with a name' , done => {
1064+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
1065+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
10491066 request ( {
10501067 url : `${ Parse . serverURL } /schemas/MyClass` ,
10511068 method : 'POST' ,
@@ -1060,11 +1077,14 @@ describe('read-only masterKey', () => {
10601077 . catch ( res => {
10611078 expect ( res . data . code ) . toBe ( Parse . Error . OPERATION_FORBIDDEN ) ;
10621079 expect ( res . data . error ) . toBe ( 'Permission denied' ) ;
1080+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to create a schema." , callCountBefore ) ;
10631081 done ( ) ;
10641082 } ) ;
10651083 } ) ;
10661084
10671085 it ( 'should throw when trying to update schema' , done => {
1086+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
1087+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
10681088 request ( {
10691089 url : `${ Parse . serverURL } /schemas/MyClass` ,
10701090 method : 'PUT' ,
@@ -1079,11 +1099,14 @@ describe('read-only masterKey', () => {
10791099 . catch ( res => {
10801100 expect ( res . data . code ) . toBe ( Parse . Error . OPERATION_FORBIDDEN ) ;
10811101 expect ( res . data . error ) . toBe ( 'Permission denied' ) ;
1102+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to update a schema." , callCountBefore ) ;
10821103 done ( ) ;
10831104 } ) ;
10841105 } ) ;
10851106
10861107 it ( 'should throw when trying to delete schema' , done => {
1108+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
1109+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
10871110 request ( {
10881111 url : `${ Parse . serverURL } /schemas/MyClass` ,
10891112 method : 'DELETE' ,
@@ -1098,11 +1121,14 @@ describe('read-only masterKey', () => {
10981121 . catch ( res => {
10991122 expect ( res . data . code ) . toBe ( Parse . Error . OPERATION_FORBIDDEN ) ;
11001123 expect ( res . data . error ) . toBe ( 'Permission denied' ) ;
1124+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to delete a schema." , callCountBefore ) ;
11011125 done ( ) ;
11021126 } ) ;
11031127 } ) ;
11041128
11051129 it ( 'should throw when trying to update the global config' , done => {
1130+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
1131+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
11061132 request ( {
11071133 url : `${ Parse . serverURL } /config` ,
11081134 method : 'PUT' ,
@@ -1117,11 +1143,14 @@ describe('read-only masterKey', () => {
11171143 . catch ( res => {
11181144 expect ( res . data . code ) . toBe ( Parse . Error . OPERATION_FORBIDDEN ) ;
11191145 expect ( res . data . error ) . toBe ( 'Permission denied' ) ;
1146+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to update the config." , callCountBefore ) ;
11201147 done ( ) ;
11211148 } ) ;
11221149 } ) ;
11231150
11241151 it ( 'should throw when trying to send push' , done => {
1152+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
1153+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
11251154 request ( {
11261155 url : `${ Parse . serverURL } /push` ,
11271156 method : 'POST' ,
@@ -1138,6 +1167,7 @@ describe('read-only masterKey', () => {
11381167 expect ( res . data . error ) . toBe (
11391168 'Permission denied'
11401169 ) ;
1170+ sanitizedErrorCall . checkMessage ( "read-only masterKey isn't allowed to send push notifications." , callCountBefore ) ;
11411171 done ( ) ;
11421172 } ) ;
11431173 } ) ;
0 commit comments