@@ -26,6 +26,12 @@ const hasAllPODobject = () => {
2626} ;
2727
2828const defaultClassLevelPermissions = {
29+ ACL : {
30+ '*' : {
31+ read : true ,
32+ write : true ,
33+ } ,
34+ } ,
2935 find : {
3036 '*' : true ,
3137 } ,
@@ -2058,12 +2064,70 @@ describe('schemas', () => {
20582064 } ,
20592065 } ) . then ( fail , response => {
20602066 expect ( response . data . error ) . toEqual (
2061- "'1' is not a valid value for class level permissions find:*:1 "
2067+ "'1' is not a valid value for class level permissions acl find:*"
20622068 ) ;
20632069 done ( ) ;
20642070 } ) ;
20652071 } ) ;
20662072
2073+ it ( 'should validate defaultAcl with class level permissions when request is not an object' , async ( ) => {
2074+ const response = await request ( {
2075+ method : 'POST' ,
2076+ url : 'http://localhost:8378/1/schemas/AClass' ,
2077+ headers : masterKeyHeaders ,
2078+ json : true ,
2079+ body : {
2080+ classLevelPermissions : {
2081+ ACL : {
2082+ '*' : true ,
2083+ } ,
2084+ } ,
2085+ } ,
2086+ } ) . catch ( error => error . data ) ;
2087+
2088+ expect ( response . error ) . toEqual ( `'true' is not a valid value for class level permissions acl` ) ;
2089+ } ) ;
2090+
2091+ it ( 'should validate defaultAcl with class level permissions when request is an object and invalid key' , async ( ) => {
2092+ const response = await request ( {
2093+ method : 'POST' ,
2094+ url : 'http://localhost:8378/1/schemas/AClass' ,
2095+ headers : masterKeyHeaders ,
2096+ json : true ,
2097+ body : {
2098+ classLevelPermissions : {
2099+ ACL : {
2100+ '*' : {
2101+ foo : true ,
2102+ } ,
2103+ } ,
2104+ } ,
2105+ } ,
2106+ } ) . catch ( error => error . data ) ;
2107+
2108+ expect ( response . error ) . toEqual ( `'foo' is not a valid key for class level permissions acl` ) ;
2109+ } ) ;
2110+
2111+ it ( 'should validate defaultAcl with class level permissions when request is an object and invalid value' , async ( ) => {
2112+ const response = await request ( {
2113+ method : 'POST' ,
2114+ url : 'http://localhost:8378/1/schemas/AClass' ,
2115+ headers : masterKeyHeaders ,
2116+ json : true ,
2117+ body : {
2118+ classLevelPermissions : {
2119+ ACL : {
2120+ '*' : {
2121+ read : 1 ,
2122+ } ,
2123+ } ,
2124+ } ,
2125+ } ,
2126+ } ) . catch ( error => error . data ) ;
2127+
2128+ expect ( response . error ) . toEqual ( `'1' is not a valid value for class level permissions acl` ) ;
2129+ } ) ;
2130+
20672131 it ( 'should throw if permission is empty string' , done => {
20682132 request ( {
20692133 method : 'POST' ,
@@ -2079,7 +2143,7 @@ describe('schemas', () => {
20792143 } ,
20802144 } ) . then ( fail , response => {
20812145 expect ( response . data . error ) . toEqual (
2082- " '' is not a valid value for class level permissions find:*:"
2146+ ` '' is not a valid value for class level permissions acl find:*`
20832147 ) ;
20842148 done ( ) ;
20852149 } ) ;
@@ -2690,6 +2754,12 @@ describe('schemas', () => {
26902754 setPermissionsOnClass (
26912755 '_Role' ,
26922756 {
2757+ ACL : {
2758+ '*' : {
2759+ read : true ,
2760+ write : true ,
2761+ } ,
2762+ } ,
26932763 get : { '*' : true } ,
26942764 find : { '*' : true } ,
26952765 count : { '*' : true } ,
@@ -2710,6 +2780,12 @@ describe('schemas', () => {
27102780 } )
27112781 . then ( res => {
27122782 expect ( res . data . classLevelPermissions ) . toEqual ( {
2783+ ACL : {
2784+ '*' : {
2785+ read : true ,
2786+ write : true ,
2787+ } ,
2788+ } ,
27132789 get : { '*' : true } ,
27142790 find : { '*' : true } ,
27152791 count : { '*' : true } ,
0 commit comments