@@ -981,7 +981,7 @@ describe('schemas', () => {
981
981
} ) ;
982
982
} ) ;
983
983
} ) ;
984
-
984
+
985
985
it ( 'should not be able to add a field' , done => {
986
986
request . post ( {
987
987
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1010,7 +1010,7 @@ describe('schemas', () => {
1010
1010
} )
1011
1011
} )
1012
1012
} ) ;
1013
-
1013
+
1014
1014
it ( 'should not be able to add a field' , done => {
1015
1015
request . post ( {
1016
1016
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1038,7 +1038,7 @@ describe('schemas', () => {
1038
1038
} )
1039
1039
} )
1040
1040
} ) ;
1041
-
1041
+
1042
1042
it ( 'should throw with invalid userId (>10 chars)' , done => {
1043
1043
request . post ( {
1044
1044
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1056,7 +1056,7 @@ describe('schemas', () => {
1056
1056
done ( ) ;
1057
1057
} )
1058
1058
} ) ;
1059
-
1059
+
1060
1060
it ( 'should throw with invalid userId (<10 chars)' , done => {
1061
1061
request . post ( {
1062
1062
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1074,7 +1074,7 @@ describe('schemas', () => {
1074
1074
done ( ) ;
1075
1075
} )
1076
1076
} ) ;
1077
-
1077
+
1078
1078
it ( 'should throw with invalid userId (invalid char)' , done => {
1079
1079
request . post ( {
1080
1080
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1092,7 +1092,7 @@ describe('schemas', () => {
1092
1092
done ( ) ;
1093
1093
} )
1094
1094
} ) ;
1095
-
1095
+
1096
1096
it ( 'should throw with invalid * (spaces)' , done => {
1097
1097
request . post ( {
1098
1098
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1110,7 +1110,7 @@ describe('schemas', () => {
1110
1110
done ( ) ;
1111
1111
} )
1112
1112
} ) ;
1113
-
1113
+
1114
1114
it ( 'should throw with invalid * (spaces)' , done => {
1115
1115
request . post ( {
1116
1116
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1128,7 +1128,7 @@ describe('schemas', () => {
1128
1128
done ( ) ;
1129
1129
} )
1130
1130
} ) ;
1131
-
1131
+
1132
1132
it ( 'should throw with invalid value' , done => {
1133
1133
request . post ( {
1134
1134
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1146,7 +1146,7 @@ describe('schemas', () => {
1146
1146
done ( ) ;
1147
1147
} )
1148
1148
} ) ;
1149
-
1149
+
1150
1150
it ( 'should throw with invalid value' , done => {
1151
1151
request . post ( {
1152
1152
url : 'http://localhost:8378/1/schemas/AClass' ,
@@ -1164,10 +1164,10 @@ describe('schemas', () => {
1164
1164
done ( ) ;
1165
1165
} )
1166
1166
} ) ;
1167
-
1167
+
1168
1168
function setPermissionsOnClass ( className , permissions , doPut ) {
1169
1169
let op = request . post ;
1170
- if ( doPut )
1170
+ if ( doPut )
1171
1171
{
1172
1172
op = request . put ;
1173
1173
}
@@ -1190,18 +1190,18 @@ describe('schemas', () => {
1190
1190
} )
1191
1191
} ) ;
1192
1192
}
1193
-
1193
+
1194
1194
it ( 'validate CLP 1' , done => {
1195
1195
let user = new Parse . User ( ) ;
1196
1196
user . setUsername ( 'user' ) ;
1197
1197
user . setPassword ( 'user' ) ;
1198
-
1198
+
1199
1199
let admin = new Parse . User ( ) ;
1200
1200
admin . setUsername ( 'admin' ) ;
1201
1201
admin . setPassword ( 'admin' ) ;
1202
-
1202
+
1203
1203
let role = new Parse . Role ( 'admin' , new Parse . ACL ( ) ) ;
1204
-
1204
+
1205
1205
setPermissionsOnClass ( 'AClass' , {
1206
1206
'find' : {
1207
1207
'role:admin' : true
@@ -1239,18 +1239,18 @@ describe('schemas', () => {
1239
1239
done ( ) ;
1240
1240
} )
1241
1241
} ) ;
1242
-
1242
+
1243
1243
it ( 'validate CLP 2' , done => {
1244
1244
let user = new Parse . User ( ) ;
1245
1245
user . setUsername ( 'user' ) ;
1246
1246
user . setPassword ( 'user' ) ;
1247
-
1247
+
1248
1248
let admin = new Parse . User ( ) ;
1249
1249
admin . setUsername ( 'admin' ) ;
1250
1250
admin . setPassword ( 'admin' ) ;
1251
-
1251
+
1252
1252
let role = new Parse . Role ( 'admin' , new Parse . ACL ( ) ) ;
1253
-
1253
+
1254
1254
setPermissionsOnClass ( 'AClass' , {
1255
1255
'find' : {
1256
1256
'role:admin' : true
@@ -1304,18 +1304,18 @@ describe('schemas', () => {
1304
1304
done ( ) ;
1305
1305
} )
1306
1306
} ) ;
1307
-
1307
+
1308
1308
it ( 'validate CLP 3' , done => {
1309
1309
let user = new Parse . User ( ) ;
1310
1310
user . setUsername ( 'user' ) ;
1311
1311
user . setPassword ( 'user' ) ;
1312
-
1312
+
1313
1313
let admin = new Parse . User ( ) ;
1314
1314
admin . setUsername ( 'admin' ) ;
1315
1315
admin . setPassword ( 'admin' ) ;
1316
-
1316
+
1317
1317
let role = new Parse . Role ( 'admin' , new Parse . ACL ( ) ) ;
1318
-
1318
+
1319
1319
setPermissionsOnClass ( 'AClass' , {
1320
1320
'find' : {
1321
1321
'role:admin' : true
@@ -1362,18 +1362,18 @@ describe('schemas', () => {
1362
1362
done ( ) ;
1363
1363
} ) ;
1364
1364
} ) ;
1365
-
1365
+
1366
1366
it ( 'validate CLP 4' , done => {
1367
1367
let user = new Parse . User ( ) ;
1368
1368
user . setUsername ( 'user' ) ;
1369
1369
user . setPassword ( 'user' ) ;
1370
-
1370
+
1371
1371
let admin = new Parse . User ( ) ;
1372
1372
admin . setUsername ( 'admin' ) ;
1373
1373
admin . setPassword ( 'admin' ) ;
1374
-
1374
+
1375
1375
let role = new Parse . Role ( 'admin' , new Parse . ACL ( ) ) ;
1376
-
1376
+
1377
1377
setPermissionsOnClass ( 'AClass' , {
1378
1378
'find' : {
1379
1379
'role:admin' : true
@@ -1400,7 +1400,7 @@ describe('schemas', () => {
1400
1400
// borked CLP should not affec security
1401
1401
return setPermissionsOnClass ( 'AClass' , {
1402
1402
'found' : {
1403
- 'role:admin' : true
1403
+ 'role:admin' : true
1404
1404
}
1405
1405
} , true ) . then ( ( ) => {
1406
1406
fail ( "Should not be able to save a borked CLP" ) ;
@@ -1430,21 +1430,21 @@ describe('schemas', () => {
1430
1430
done ( ) ;
1431
1431
} )
1432
1432
} ) ;
1433
-
1433
+
1434
1434
it ( 'validate CLP 5' , done => {
1435
1435
let user = new Parse . User ( ) ;
1436
1436
user . setUsername ( 'user' ) ;
1437
1437
user . setPassword ( 'user' ) ;
1438
-
1438
+
1439
1439
let user2 = new Parse . User ( ) ;
1440
1440
user2 . setUsername ( 'user2' ) ;
1441
1441
user2 . setPassword ( 'user2' ) ;
1442
1442
let admin = new Parse . User ( ) ;
1443
1443
admin . setUsername ( 'admin' ) ;
1444
1444
admin . setPassword ( 'admin' ) ;
1445
-
1445
+
1446
1446
let role = new Parse . Role ( 'admin' , new Parse . ACL ( ) ) ;
1447
-
1447
+
1448
1448
Promise . resolve ( ) . then ( ( ) => {
1449
1449
return Parse . Object . saveAll ( [ user , user2 , admin , role ] , { useMasterKey : true } ) ;
1450
1450
} ) . then ( ( ) => {
@@ -1495,5 +1495,21 @@ describe('schemas', () => {
1495
1495
} ) . then ( ( ) => {
1496
1496
done ( ) ;
1497
1497
} ) ;
1498
- } ) ;
1498
+ } ) ;
1499
+
1500
+ it ( 'can add field as master (issue #1257)' , ( done ) => {
1501
+ setPermissionsOnClass ( 'AClass' , {
1502
+ 'addField' : { }
1503
+ } ) . then ( ( ) => {
1504
+ var obj = new Parse . Object ( 'AClass' ) ;
1505
+ obj . set ( 'key' , 'value' ) ;
1506
+ return obj . save ( null , { useMasterKey : true } )
1507
+ } ) . then ( ( obj ) => {
1508
+ expect ( obj . get ( 'key' ) ) . toEqual ( 'value' ) ;
1509
+ done ( ) ;
1510
+ } , ( err ) => {
1511
+ fail ( 'should not fail' ) ;
1512
+ done ( ) ;
1513
+ } ) ;
1514
+ } )
1499
1515
} ) ;
0 commit comments