@@ -47,6 +47,8 @@ function handleError(e) {
4747describe ( 'ParseGraphQLServer' , ( ) => {
4848 let parseServer ;
4949 let parseGraphQLServer ;
50+ let loggerErrorSpy ;
51+
5052
5153 beforeEach ( async ( ) => {
5254 parseServer = await global . reconfigureServer ( {
@@ -58,6 +60,9 @@ describe('ParseGraphQLServer', () => {
5860 playgroundPath : '/playground' ,
5961 subscriptionsPath : '/subscriptions' ,
6062 } ) ;
63+
64+ const logger = require ( '../lib/logger' ) . default ;
65+ loggerErrorSpy = spyOn ( logger , 'error' ) . and . callThrough ( ) ;
6166 } ) ;
6267
6368 describe ( 'constructor' , ( ) => {
@@ -3488,6 +3493,7 @@ describe('ParseGraphQLServer', () => {
34883493 } ) ;
34893494
34903495 it ( 'should require master key to create a new class' , async ( ) => {
3496+ loggerErrorSpy . calls . reset ( ) ;
34913497 try {
34923498 await apolloClient . mutate ( {
34933499 mutation : gql `
@@ -3501,7 +3507,8 @@ describe('ParseGraphQLServer', () => {
35013507 fail ( 'should fail' ) ;
35023508 } catch ( e ) {
35033509 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
3504- expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'unauthorized: master key is required' ) ;
3510+ expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
3511+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( 'unauthorized: master key is required' ) ) ;
35053512 }
35063513 } ) ;
35073514
@@ -3858,6 +3865,7 @@ describe('ParseGraphQLServer', () => {
38583865 handleError ( e ) ;
38593866 }
38603867
3868+ loggerErrorSpy . calls . reset ( ) ;
38613869 try {
38623870 await apolloClient . mutate ( {
38633871 mutation : gql `
@@ -3871,7 +3879,8 @@ describe('ParseGraphQLServer', () => {
38713879 fail ( 'should fail' ) ;
38723880 } catch ( e ) {
38733881 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
3874- expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'unauthorized: master key is required' ) ;
3882+ expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
3883+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( 'unauthorized: master key is required' ) ) ;
38753884 }
38763885 } ) ;
38773886
@@ -4083,6 +4092,7 @@ describe('ParseGraphQLServer', () => {
40834092 handleError ( e ) ;
40844093 }
40854094
4095+ loggerErrorSpy . calls . reset ( ) ;
40864096 try {
40874097 await apolloClient . mutate ( {
40884098 mutation : gql `
@@ -4096,7 +4106,8 @@ describe('ParseGraphQLServer', () => {
40964106 fail ( 'should fail' ) ;
40974107 } catch ( e ) {
40984108 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
4099- expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'unauthorized: master key is required' ) ;
4109+ expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
4110+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( 'unauthorized: master key is required' ) ) ;
41004111 }
41014112 } ) ;
41024113
@@ -4124,6 +4135,7 @@ describe('ParseGraphQLServer', () => {
41244135 } ) ;
41254136
41264137 it ( 'should require master key to get an existing class' , async ( ) => {
4138+ loggerErrorSpy . calls . reset ( ) ;
41274139 try {
41284140 await apolloClient . query ( {
41294141 query : gql `
@@ -4137,11 +4149,13 @@ describe('ParseGraphQLServer', () => {
41374149 fail ( 'should fail' ) ;
41384150 } catch ( e ) {
41394151 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
4140- expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'unauthorized: master key is required' ) ;
4152+ expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
4153+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( 'unauthorized: master key is required' ) ) ;
41414154 }
41424155 } ) ;
41434156
41444157 it ( 'should require master key to find the existing classes' , async ( ) => {
4158+ loggerErrorSpy . calls . reset ( ) ;
41454159 try {
41464160 await apolloClient . query ( {
41474161 query : gql `
@@ -4155,7 +4169,8 @@ describe('ParseGraphQLServer', () => {
41554169 fail ( 'should fail' ) ;
41564170 } catch ( e ) {
41574171 expect ( e . graphQLErrors [ 0 ] . extensions . code ) . toEqual ( Parse . Error . OPERATION_FORBIDDEN ) ;
4158- expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'unauthorized: master key is required' ) ;
4172+ expect ( e . graphQLErrors [ 0 ] . message ) . toEqual ( 'Permission denied' ) ;
4173+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( 'unauthorized: master key is required' ) ) ;
41594174 }
41604175 } ) ;
41614176 } ) ;
@@ -6081,7 +6096,7 @@ describe('ParseGraphQLServer', () => {
60816096 }
60826097
60836098 await expectAsync ( createObject ( 'GraphQLClass' ) ) . toBeRejectedWith (
6084- jasmine . stringMatching ( 'Permission denied for action create on class GraphQLClass ' )
6099+ jasmine . stringMatching ( 'Permission denied' )
60856100 ) ;
60866101 await expectAsync ( createObject ( 'PublicClass' ) ) . toBeResolved ( ) ;
60876102 await expectAsync (
@@ -6115,7 +6130,7 @@ describe('ParseGraphQLServer', () => {
61156130 'X-Parse-Session-Token' : user4 . getSessionToken ( ) ,
61166131 } )
61176132 ) . toBeRejectedWith (
6118- jasmine . stringMatching ( 'Permission denied for action create on class GraphQLClass ' )
6133+ jasmine . stringMatching ( 'Permission denied' )
61196134 ) ;
61206135 await expectAsync (
61216136 createObject ( 'PublicClass' , {
@@ -7802,7 +7817,8 @@ describe('ParseGraphQLServer', () => {
78027817 } catch ( err ) {
78037818 const { graphQLErrors } = err ;
78047819 expect ( graphQLErrors . length ) . toBe ( 1 ) ;
7805- expect ( graphQLErrors [ 0 ] . message ) . toBe ( 'Invalid session token' ) ;
7820+ expect ( graphQLErrors [ 0 ] . message ) . toBe ( 'Permission denied' ) ;
7821+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( 'Invalid session token' ) ) ;
78067822 }
78077823 } ) ;
78087824
@@ -7840,7 +7856,8 @@ describe('ParseGraphQLServer', () => {
78407856 } catch ( err ) {
78417857 const { graphQLErrors } = err ;
78427858 expect ( graphQLErrors . length ) . toBe ( 1 ) ;
7843- expect ( graphQLErrors [ 0 ] . message ) . toBe ( 'Invalid session token' ) ;
7859+ expect ( graphQLErrors [ 0 ] . message ) . toBe ( 'Permission denied' ) ;
7860+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( 'Invalid session token' ) ) ;
78447861 }
78457862 } ) ;
78467863 } ) ;
0 commit comments