Throw error when setting authData to null (#6154)
* added ignore authData field * add fix for Postgres * add test for mongoDB * add test login with provider despite invalid authData * removed fit * fixed ignoring authData in postgres * Fix postgres test * Throw error instead of ignore * improve tests * Add mongo test * allow authData when not user class * fix tests * more tests * add condition to synthesize authData field only in _User class it is forbidden to add a custom field name beginning with `_`, so if the object is not `_User` , the transform should throw * add warning log when ignoring invalid `authData` in `_User` * add test to throw when custom field begins with underscore
This commit is contained in:
committed by
Diamond Lewis
parent
1c8d4a6519
commit
9d781c481f
@@ -479,6 +479,46 @@ describe('parseObjectToMongoObjectForCreate', () => {
|
||||
}).toThrow();
|
||||
done();
|
||||
});
|
||||
|
||||
it('ignores User authData field in DB so it can be synthesized in code', done => {
|
||||
const input = {
|
||||
_id: '123',
|
||||
_auth_data_acme: { id: 'abc' },
|
||||
authData: null,
|
||||
};
|
||||
const output = transform.mongoObjectToParseObject('_User', input, {
|
||||
fields: {},
|
||||
});
|
||||
expect(output.authData.acme.id).toBe('abc');
|
||||
done();
|
||||
});
|
||||
|
||||
it('can set authData when not User class', done => {
|
||||
const input = {
|
||||
_id: '123',
|
||||
authData: 'random',
|
||||
};
|
||||
const output = transform.mongoObjectToParseObject('TestObject', input, {
|
||||
fields: {},
|
||||
});
|
||||
expect(output.authData).toBe('random');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot have a custom field name beginning with underscore', done => {
|
||||
const input = {
|
||||
_id: '123',
|
||||
_thisFieldNameIs: 'invalid',
|
||||
};
|
||||
try {
|
||||
transform.mongoObjectToParseObject('TestObject', input, {
|
||||
fields: {},
|
||||
});
|
||||
} catch (e) {
|
||||
expect(e).toBeDefined();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
describe('transformUpdate', () => {
|
||||
|
||||
Reference in New Issue
Block a user