@@ -35,6 +35,7 @@ const { ParseServer } = require('../');
3535const { ParseGraphQLServer } = require ( '../lib/GraphQL/ParseGraphQLServer' ) ;
3636const { ReadPreference, Collection } = require ( 'mongodb' ) ;
3737const { v4 : uuidv4 } = require ( 'uuid' ) ;
38+ const { getSanitizedErrorCall } = require ( '../lib/TestUtils' ) ;
3839
3940function handleError ( e ) {
4041 if ( e && e . networkError && e . networkError . result && e . networkError . result . errors ) {
@@ -3488,6 +3489,9 @@ describe('ParseGraphQLServer', () => {
34883489 } ) ;
34893490
34903491 it ( 'should require master key to create a new class' , async ( ) => {
3492+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
3493+
3494+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
34913495 try {
34923496 await apolloClient . mutate ( {
34933497 mutation : gql `
@@ -3502,6 +3506,7 @@ describe('ParseGraphQLServer', () => {
35023506 } catch ( e ) {
35033507 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
35043508 expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
3509+ sanitizedErrorCall . checkMessage ( 'unauthorized: master key is required' , callCountBefore ) ;
35053510 }
35063511 } ) ;
35073512
@@ -3858,6 +3863,9 @@ describe('ParseGraphQLServer', () => {
38583863 handleError ( e ) ;
38593864 }
38603865
3866+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
3867+
3868+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
38613869 try {
38623870 await apolloClient . mutate ( {
38633871 mutation : gql `
@@ -3872,6 +3880,7 @@ describe('ParseGraphQLServer', () => {
38723880 } catch ( e ) {
38733881 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
38743882 expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
3883+ sanitizedErrorCall . checkMessage ( 'unauthorized: master key is required' , callCountBefore ) ;
38753884 }
38763885 } ) ;
38773886
@@ -4083,6 +4092,10 @@ describe('ParseGraphQLServer', () => {
40834092 handleError ( e ) ;
40844093 }
40854094
4095+ const { getSanitizedErrorCall } = require ( '../lib/TestUtils' ) ;
4096+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
4097+
4098+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
40864099 try {
40874100 await apolloClient . mutate ( {
40884101 mutation : gql `
@@ -4097,6 +4110,7 @@ describe('ParseGraphQLServer', () => {
40974110 } catch ( e ) {
40984111 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
40994112 expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
4113+ sanitizedErrorCall . checkMessage ( 'unauthorized: master key is required' , callCountBefore ) ;
41004114 }
41014115 } ) ;
41024116
@@ -4124,6 +4138,10 @@ describe('ParseGraphQLServer', () => {
41244138 } ) ;
41254139
41264140 it ( 'should require master key to get an existing class' , async ( ) => {
4141+ const { getSanitizedErrorCall } = require ( '../lib/TestUtils' ) ;
4142+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
4143+
4144+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
41274145 try {
41284146 await apolloClient . query ( {
41294147 query : gql `
@@ -4138,10 +4156,15 @@ describe('ParseGraphQLServer', () => {
41384156 } catch ( e ) {
41394157 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
41404158 expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
4159+ sanitizedErrorCall . checkMessage ( 'unauthorized: master key is required' , callCountBefore ) ;
41414160 }
41424161 } ) ;
41434162
41444163 it ( 'should require master key to find the existing classes' , async ( ) => {
4164+ const { getSanitizedErrorCall } = require ( '../lib/TestUtils' ) ;
4165+ const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
4166+
4167+ const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
41454168 try {
41464169 await apolloClient . query ( {
41474170 query : gql `
@@ -4156,6 +4179,7 @@ describe('ParseGraphQLServer', () => {
41564179 } catch ( e ) {
41574180 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
41584181 expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
4182+ sanitizedErrorCall . checkMessage ( 'unauthorized: master key is required' , callCountBefore ) ;
41594183 }
41604184 } ) ;
41614185 } ) ;
0 commit comments