refactor: replace hardcoded error codes with references (#7546)
This commit is contained in:
@@ -1750,7 +1750,7 @@ describe('microsoft graph auth adapter', () => {
|
|||||||
access_token: 'very.long.bad.token',
|
access_token: 'very.long.bad.token',
|
||||||
};
|
};
|
||||||
microsoft.validateAuthData(authData).then(done.fail, err => {
|
microsoft.validateAuthData(authData).then(done.fail, err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
expect(err.message).toBe('Microsoft Graph auth is invalid for this user.');
|
expect(err.message).toBe('Microsoft Graph auth is invalid for this user.');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ describe('Cloud Code', () => {
|
|||||||
|
|
||||||
it('is cleared cleared after the previous test', done => {
|
it('is cleared cleared after the previous test', done => {
|
||||||
Parse.Cloud.run('hello', {}).catch(error => {
|
Parse.Cloud.run('hello', {}).catch(error => {
|
||||||
expect(error.code).toEqual(141);
|
expect(error.code).toEqual(Parse.Error.SCRIPT_FAILED);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -109,7 +109,7 @@ describe('Cloud Code', () => {
|
|||||||
Parse.Cloud.run('cloudCodeWithError').then(
|
Parse.Cloud.run('cloudCodeWithError').then(
|
||||||
() => done.fail('should not succeed'),
|
() => done.fail('should not succeed'),
|
||||||
e => {
|
e => {
|
||||||
expect(e).toEqual(new Parse.Error(141, 'foo is not defined'));
|
expect(e).toEqual(new Parse.Error(Parse.Error.SCRIPT_FAILED, 'foo is not defined'));
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -123,7 +123,7 @@ describe('Cloud Code', () => {
|
|||||||
Parse.Cloud.run('cloudCodeWithError').then(
|
Parse.Cloud.run('cloudCodeWithError').then(
|
||||||
() => done.fail('should not succeed'),
|
() => done.fail('should not succeed'),
|
||||||
e => {
|
e => {
|
||||||
expect(e.code).toEqual(141);
|
expect(e.code).toEqual(Parse.Error.SCRIPT_FAILED);
|
||||||
expect(e.message).toEqual('Script failed.');
|
expect(e.message).toEqual('Script failed.');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ describe('Cloud Code', () => {
|
|||||||
const query = new Parse.Query('beforeFind');
|
const query = new Parse.Query('beforeFind');
|
||||||
await query.first();
|
await query.first();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.code).toBe(141);
|
expect(e.code).toBe(Parse.Error.SCRIPT_FAILED);
|
||||||
expect(e.message).toBe('throw beforeFind');
|
expect(e.message).toBe('throw beforeFind');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ describe('Cloud Code', () => {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
catched = true;
|
catched = true;
|
||||||
expect(e.code).toBe(101);
|
expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
expect(catched).toBe(true);
|
expect(catched).toBe(true);
|
||||||
expect(called).toBe(7);
|
expect(called).toBe(7);
|
||||||
@@ -479,7 +479,7 @@ describe('Cloud Code', () => {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
catched = true;
|
catched = true;
|
||||||
expect(e.code).toBe(101);
|
expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
expect(catched).toBe(true);
|
expect(catched).toBe(true);
|
||||||
expect(called).toBe(7);
|
expect(called).toBe(7);
|
||||||
@@ -491,7 +491,7 @@ describe('Cloud Code', () => {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
catched = true;
|
catched = true;
|
||||||
expect(e.code).toBe(101);
|
expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
expect(catched).toBe(true);
|
expect(catched).toBe(true);
|
||||||
expect(called).toBe(7);
|
expect(called).toBe(7);
|
||||||
@@ -1761,7 +1761,7 @@ describe('Cloud Code', () => {
|
|||||||
|
|
||||||
it('should set the failure message on the job error', async () => {
|
it('should set the failure message on the job error', async () => {
|
||||||
Parse.Cloud.job('myJobError', () => {
|
Parse.Cloud.job('myJobError', () => {
|
||||||
throw new Parse.Error(101, 'Something went wrong');
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Something went wrong');
|
||||||
});
|
});
|
||||||
const job = await Parse.Cloud.startJob('myJobError');
|
const job = await Parse.Cloud.startJob('myJobError');
|
||||||
let jobStatus, status;
|
let jobStatus, status;
|
||||||
@@ -2038,7 +2038,7 @@ describe('beforeFind hooks', () => {
|
|||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(141);
|
expect(err.code).toBe(Parse.Error.SCRIPT_FAILED);
|
||||||
expect(err.message).toEqual('Do not run that query');
|
expect(err.message).toEqual('Do not run that query');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ describe('Cloud Code Logger', () => {
|
|||||||
expect(log[0]).toEqual('error');
|
expect(log[0]).toEqual('error');
|
||||||
const error = log[2].error;
|
const error = log[2].error;
|
||||||
expect(error instanceof Parse.Error).toBeTruthy();
|
expect(error instanceof Parse.Error).toBeTruthy();
|
||||||
expect(error.code).toBe(141);
|
expect(error.code).toBe(Parse.Error.SCRIPT_FAILED);
|
||||||
expect(error.message).toBe('uh oh!');
|
expect(error.message).toBe('uh oh!');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -199,7 +199,9 @@ describe('Cloud Code Logger', () => {
|
|||||||
expect(log[1]).toMatch(
|
expect(log[1]).toMatch(
|
||||||
/Failed running cloud function aFunction for user [^ ]* with:\n {2}Input: {"foo":"bar"}\n {2}Error:/
|
/Failed running cloud function aFunction for user [^ ]* with:\n {2}Input: {"foo":"bar"}\n {2}Error:/
|
||||||
);
|
);
|
||||||
const errorString = JSON.stringify(new Parse.Error(141, 'it failed!'));
|
const errorString = JSON.stringify(
|
||||||
|
new Parse.Error(Parse.Error.SCRIPT_FAILED, 'it failed!')
|
||||||
|
);
|
||||||
expect(log[1].indexOf(errorString)).toBeGreaterThan(0);
|
expect(log[1].indexOf(errorString)).toBeGreaterThan(0);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1015,7 +1015,7 @@ describe('miscellaneous', function () {
|
|||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
e => {
|
e => {
|
||||||
expect(e.code).toEqual(141);
|
expect(e.code).toEqual(Parse.Error.SCRIPT_FAILED);
|
||||||
expect(e.message).toEqual('noway');
|
expect(e.message).toEqual('noway');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ describe('Hooks', () => {
|
|||||||
expect(err).not.toBe(undefined);
|
expect(err).not.toBe(undefined);
|
||||||
expect(err).not.toBe(null);
|
expect(err).not.toBe(null);
|
||||||
if (err) {
|
if (err) {
|
||||||
expect(err.code).toBe(141);
|
expect(err.code).toBe(Parse.Error.SCRIPT_FAILED);
|
||||||
expect(err.message.code).toEqual(1337);
|
expect(err.message.code).toEqual(1337);
|
||||||
expect(err.message.error).toEqual('hacking that one!');
|
expect(err.message.error).toEqual('hacking that one!');
|
||||||
}
|
}
|
||||||
@@ -536,7 +536,7 @@ describe('Hooks', () => {
|
|||||||
expect(err).not.toBe(undefined);
|
expect(err).not.toBe(undefined);
|
||||||
expect(err).not.toBe(null);
|
expect(err).not.toBe(null);
|
||||||
if (err) {
|
if (err) {
|
||||||
expect(err.code).toBe(141);
|
expect(err.code).toBe(Parse.Error.SCRIPT_FAILED);
|
||||||
expect(err.message).toEqual('incorrect key provided');
|
expect(err.message).toEqual('incorrect key provided');
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ describe('Parse Role testing', () => {
|
|||||||
},
|
},
|
||||||
e => {
|
e => {
|
||||||
if (e) {
|
if (e) {
|
||||||
expect(e.code).toEqual(101);
|
expect(e.code).toEqual(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
} else {
|
} else {
|
||||||
fail('should return an error');
|
fail('should return an error');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ describe('Parse.User testing', () => {
|
|||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
expect(err.status).toBe(404);
|
expect(err.status).toBe(404);
|
||||||
expect(err.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(err.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -99,7 +101,9 @@ describe('Parse.User testing', () => {
|
|||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
expect(err.status).toBe(404);
|
expect(err.status).toBe(404);
|
||||||
expect(err.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(err.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ describe('Pointer Permissions', () => {
|
|||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
// User 1 should not be able to update obj2
|
// User 1 should not be able to update obj2
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -203,7 +203,7 @@ describe('Pointer Permissions', () => {
|
|||||||
fail('User 2 should not get the obj1 object');
|
fail('User 2 should not get the obj1 object');
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
expect(err.message).toBe('Object not found.');
|
expect(err.message).toBe('Object not found.');
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
@@ -530,7 +530,7 @@ describe('Pointer Permissions', () => {
|
|||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -583,7 +583,7 @@ describe('Pointer Permissions', () => {
|
|||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -695,7 +695,7 @@ describe('Pointer Permissions', () => {
|
|||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -819,7 +819,7 @@ describe('Pointer Permissions', () => {
|
|||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -848,7 +848,7 @@ describe('Pointer Permissions', () => {
|
|||||||
.then(
|
.then(
|
||||||
() => {},
|
() => {},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -891,7 +891,7 @@ describe('Pointer Permissions', () => {
|
|||||||
.then(
|
.then(
|
||||||
() => {},
|
() => {},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -934,7 +934,7 @@ describe('Pointer Permissions', () => {
|
|||||||
.then(
|
.then(
|
||||||
() => {},
|
() => {},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -977,7 +977,7 @@ describe('Pointer Permissions', () => {
|
|||||||
fail();
|
fail();
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1111,7 +1111,7 @@ describe('Pointer Permissions', () => {
|
|||||||
done.fail('User should not be able to update obj2');
|
done.fail('User should not be able to update obj2');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// User 1 should not be able to update obj2
|
// User 1 should not be able to update obj2
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.set('hello', 'world');
|
obj.set('hello', 'world');
|
||||||
@@ -1186,7 +1186,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await q.get(obj.id);
|
await q.get(obj.id);
|
||||||
done.fail('User 3 should not get the obj1 object');
|
done.fail('User 3 should not get the obj1 object');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
expect(err.message).toBe('Object not found.');
|
expect(err.message).toBe('Object not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1541,7 +1541,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await obj.save({ key: 'value' });
|
await obj.save({ key: 'value' });
|
||||||
done.fail('Should not succeed saving');
|
done.fail('Should not succeed saving');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1590,7 +1590,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await obj.save({ key: 'value' });
|
await obj.save({ key: 'value' });
|
||||||
done.fail('Should not succeed saving');
|
done.fail('Should not succeed saving');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
@@ -1692,7 +1692,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await obj.fetch();
|
await obj.fetch();
|
||||||
done.fail('Should not succeed fetching');
|
done.fail('Should not succeed fetching');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
@@ -1811,7 +1811,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await obj.fetch();
|
await obj.fetch();
|
||||||
done.fail('Should not succeed fetching');
|
done.fail('Should not succeed fetching');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
@@ -1863,7 +1863,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await q.get(object.id);
|
await q.get(object.id);
|
||||||
done.fail();
|
done.fail();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1894,7 +1894,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await object.save({ hello: 'bar' });
|
await object.save({ hello: 'bar' });
|
||||||
done.fail();
|
done.fail();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1925,7 +1925,7 @@ describe('Pointer Permissions', () => {
|
|||||||
await object.destroy();
|
await object.destroy();
|
||||||
done.fail();
|
done.fail();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).toBe(101);
|
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await object.destroy({ useMasterKey: true });
|
await object.destroy({ useMasterKey: true });
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ describe('PushWorker', () => {
|
|||||||
// should not be deleted
|
// should not be deleted
|
||||||
transmitted: false,
|
transmitted: false,
|
||||||
device: {
|
device: {
|
||||||
deviceToken: 101,
|
deviceToken: Parse.Error.OBJECT_NOT_FOUND,
|
||||||
deviceType: 'ios',
|
deviceType: 'ios',
|
||||||
},
|
},
|
||||||
response: { error: 'invalid error...' },
|
response: { error: 'invalid error...' },
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ describe('Regex Vulnerabilities', function () {
|
|||||||
await Parse.User.logIn('someemail@somedomain.com', 'newpassword');
|
await Parse.User.logIn('someemail@somedomain.com', 'newpassword');
|
||||||
fail('should not work');
|
fail('should not work');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.code).toEqual(101);
|
expect(e.code).toEqual(Parse.Error.OBJECT_NOT_FOUND);
|
||||||
expect(e.message).toEqual('Invalid username/password.');
|
expect(e.message).toEqual('Invalid username/password.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,7 +79,9 @@ describe('Verify User Password', () => {
|
|||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
expect(err.status).toBe(404);
|
expect(err.status).toBe(404);
|
||||||
expect(err.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(err.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -221,7 +223,9 @@ describe('Verify User Password', () => {
|
|||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
expect(res.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(res.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -242,7 +246,9 @@ describe('Verify User Password', () => {
|
|||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
expect(res.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(res.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -263,7 +269,9 @@ describe('Verify User Password', () => {
|
|||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
expect(res.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(res.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -284,7 +292,9 @@ describe('Verify User Password', () => {
|
|||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
expect(res.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(res.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -305,7 +315,9 @@ describe('Verify User Password', () => {
|
|||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
expect(res.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(res.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -317,7 +329,9 @@ describe('Verify User Password', () => {
|
|||||||
verifyPassword('mytestuser', 'mypass')
|
verifyPassword('mytestuser', 'mypass')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
expect(res.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(res.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -329,7 +343,9 @@ describe('Verify User Password', () => {
|
|||||||
verifyPassword('my@user.com', 'mypass', true)
|
verifyPassword('my@user.com', 'mypass', true)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
expect(res.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
expect(res.text).toMatch(
|
||||||
|
`{"code":${Parse.Error.OBJECT_NOT_FOUND},"error":"Invalid username/password."}`
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export class AccountLockout {
|
|||||||
err &&
|
err &&
|
||||||
err.code &&
|
err.code &&
|
||||||
err.message &&
|
err.message &&
|
||||||
err.code === 101 &&
|
err.code === Parse.Error.OBJECT_NOT_FOUND &&
|
||||||
err.message === 'Object not found.'
|
err.message === 'Object not found.'
|
||||||
) {
|
) {
|
||||||
return; // nothing to update so we are good
|
return; // nothing to update so we are good
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ class ParseLiveQueryServer {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
Client.pushError(
|
Client.pushError(
|
||||||
client.parseWebSocket,
|
client.parseWebSocket,
|
||||||
error.code || 141,
|
error.code || Parse.Error.SCRIPT_FAILED,
|
||||||
error.message || error,
|
error.message || error,
|
||||||
false,
|
false,
|
||||||
requestId
|
requestId
|
||||||
@@ -361,7 +361,7 @@ class ParseLiveQueryServer {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
Client.pushError(
|
Client.pushError(
|
||||||
client.parseWebSocket,
|
client.parseWebSocket,
|
||||||
error.code || 141,
|
error.code || Parse.Error.SCRIPT_FAILED,
|
||||||
error.message || error,
|
error.message || error,
|
||||||
false,
|
false,
|
||||||
requestId
|
requestId
|
||||||
@@ -682,7 +682,12 @@ class ParseLiveQueryServer {
|
|||||||
client.pushConnect();
|
client.pushConnect();
|
||||||
runLiveQueryEventHandlers(req);
|
runLiveQueryEventHandlers(req);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Client.pushError(parseWebsocket, error.code || 141, error.message || error, false);
|
Client.pushError(
|
||||||
|
parseWebsocket,
|
||||||
|
error.code || Parse.Error.SCRIPT_FAILED,
|
||||||
|
error.message || error,
|
||||||
|
false
|
||||||
|
);
|
||||||
logger.error(
|
logger.error(
|
||||||
`Failed running beforeConnect for session ${request.sessionToken} with:\n Error: ` +
|
`Failed running beforeConnect for session ${request.sessionToken} with:\n Error: ` +
|
||||||
JSON.stringify(error)
|
JSON.stringify(error)
|
||||||
@@ -822,7 +827,13 @@ class ParseLiveQueryServer {
|
|||||||
installationId: client.installationId,
|
installationId: client.installationId,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Client.pushError(parseWebsocket, e.code || 141, e.message || e, false, request.requestId);
|
Client.pushError(
|
||||||
|
parseWebsocket,
|
||||||
|
e.code || Parse.Error.SCRIPT_FAILED,
|
||||||
|
e.message || e,
|
||||||
|
false,
|
||||||
|
request.requestId
|
||||||
|
);
|
||||||
logger.error(
|
logger.error(
|
||||||
`Failed running beforeSubscribe on ${className} for session ${request.sessionToken} with:\n Error: ` +
|
`Failed running beforeSubscribe on ${className} for session ${request.sessionToken} with:\n Error: ` +
|
||||||
JSON.stringify(e)
|
JSON.stringify(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user