Enable API related tests for Postgres (#2970)
This commit is contained in:
committed by
Florent Vilmart
parent
edf6ab6875
commit
78646a3e91
@@ -1306,7 +1306,7 @@ it('ensure that if you try to sign up a user with a unique username and email, b
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it_exclude_dbs(['postgres'])('bans interior keys containing . or $', done => {
|
it('bans interior keys containing . or $', done => {
|
||||||
new Parse.Object('Obj').save({innerObj: {'key with a $': 'fails'}})
|
new Parse.Object('Obj').save({innerObj: {'key with a $': 'fails'}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fail('should not succeed')
|
fail('should not succeed')
|
||||||
|
|||||||
@@ -136,6 +136,20 @@ const handleDotFields = (object) => {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const validateKeys = (object) => {
|
||||||
|
if (typeof object == 'object') {
|
||||||
|
for (const key in object) {
|
||||||
|
if (typeof object[key] == 'object') {
|
||||||
|
validateKeys(object[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(key.includes('$') || key.includes('.')){
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the list of join tables on a schema
|
// Returns the list of join tables on a schema
|
||||||
const joinTablesForSchema = (schema) => {
|
const joinTablesForSchema = (schema) => {
|
||||||
let list = [];
|
let list = [];
|
||||||
@@ -649,6 +663,8 @@ export class PostgresStorageAdapter {
|
|||||||
|
|
||||||
object = handleDotFields(object);
|
object = handleDotFields(object);
|
||||||
|
|
||||||
|
validateKeys(object);
|
||||||
|
|
||||||
Object.keys(object).forEach(fieldName => {
|
Object.keys(object).forEach(fieldName => {
|
||||||
var authDataMatch = fieldName.match(/^_auth_data_([a-zA-Z0-9_]+)$/);
|
var authDataMatch = fieldName.match(/^_auth_data_([a-zA-Z0-9_]+)$/);
|
||||||
if (authDataMatch) {
|
if (authDataMatch) {
|
||||||
|
|||||||
Reference in New Issue
Block a user