@@ -22,15 +22,12 @@ const DEV_GROUP = "dev";
2222// tslint:disable-next-line mocha-no-side-effect-code
2323const execute = promisify ( exec ) ;
2424
25- // tslint:disable-next-line mocha-no-side-effect-code
26- const QUERY_PERMISSION_DENIED = new Error ( "7 PERMISSION_DENIED:\
27- unauthorized to query the predicate: unauthorized to do Read on predicate name" ) ;
2825 // tslint:disable-next-line mocha-no-side-effect-code
29- const MUTATE_PERMISSION_DENIED = new Error ( " 7 PERMISSION_DENIED:\
30- unauthorized to mutate the predicate: unauthorized to do Write on predicate name" ) ;
26+ const MUTATE_PERMISSION_DENIED = new Error ( ` 7 PERMISSION_DENIED:\
27+ unauthorized to mutate following predicates: ${ PRED } \n` ) ;
3128 // tslint:disable-next-line mocha-no-side-effect-code
32- const ALTER_PERMISSION_DENIED = new Error ( " 7 PERMISSION_DENIED:\
33- unauthorized to alter the predicate: unauthorized to do Modify on predicate name" ) ;
29+ const ALTER_PERMISSION_DENIED = new Error ( ` 7 PERMISSION_DENIED:\
30+ unauthorized to alter following predicates: ${ PRED } \n` ) ;
3431
3532async function cmd ( command : string ) {
3633 try {
@@ -104,17 +101,18 @@ async function tryReading(): Promise<Boolean> {
104101 const txn = aclClient . newTxn ( ) ;
105102 const query = `{
106103 me(func: has(${ PRED } )) {
107- uid
108104 ${ PRED }
109105 }
110106 }` ;
111- try {
112- const res : dgraph . Response = await txn . query ( query ) ;
113- expect ( res . getJson ( ) . me ) . not . toHaveLength ( 0 ) ;
114- success = true ;
115- } catch ( e ) {
116- expect ( e ) . toEqual ( QUERY_PERMISSION_DENIED ) ;
107+
108+ const res : dgraph . Response = await txn . query ( query ) ;
109+ const data = res . getJson ( ) ;
110+ if ( data . me === undefined ) {
111+ expect ( data ) . toEqual ( { } ) ;
117112 success = false ;
113+ } else {
114+ expect ( data . me ) . not . toHaveLength ( 0 ) ;
115+ success = true ;
118116 }
119117 return success ;
120118}
@@ -156,6 +154,13 @@ async function tryAltering(): Promise<Boolean> {
156154}
157155
158156describe ( "ACL tests" , ( ) => {
157+ it ( "has no access" , async ( ) => {
158+ await aclSetup ( ) ;
159+ await expect ( tryReading ( ) ) . resolves . toBe ( false ) ;
160+ await expect ( tryWriting ( ) ) . resolves . toBe ( false ) ;
161+ await expect ( tryAltering ( ) ) . resolves . toBe ( false ) ;
162+ } ) ;
163+
159164 it ( "only has read access" , async ( ) => {
160165 await aclSetup ( ) ;
161166 await changePermission ( 4 ) ;
0 commit comments