-
Notifications
You must be signed in to change notification settings - Fork 13.8k
chore!: change http code results for ddp over rest #38007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
4a3b4b1
47def35
574aed8
ea7e639
44bc0b6
a2257f2
d03ff97
50dc670
1c767e0
f747ccd
676fab9
f2dac2d
dec5ffb
c828108
fe128b7
d50a169
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -525,7 +525,22 @@ API.v1.addRoute( | |
| if (settings.get('Log_Level') === '2') { | ||
| Meteor._debug(`Exception while invoking method ${method}`, err); | ||
| } | ||
| return API.v1.success(mountResult({ id, error: err })); | ||
|
|
||
| if (err instanceof Meteor.Error) { | ||
| switch (err.error) { | ||
| case 'error-too-many-requests': | ||
| return API.v1.tooManyRequests(mountResult({ id, error: err })); | ||
| case 'unauthorized': | ||
| case 'error-unauthorized': | ||
| return API.v1.unauthorized(mountResult({ id, error: err })); | ||
| case 'forbidden': | ||
| case 'error-forbidden': | ||
| return API.v1.forbidden(mountResult({ id, error: err })); | ||
| default: | ||
| return API.v1.failure(mountResult({ id, error: err })); | ||
| } | ||
| } | ||
| return API.v1.failure(mountResult({ id, error: err })); | ||
| } | ||
| }, | ||
| }, | ||
|
|
@@ -580,7 +595,7 @@ API.v1.addRoute( | |
| if (settings.get('Log_Level') === '2') { | ||
| Meteor._debug(`Exception while invoking method ${method}`, err); | ||
| } | ||
| return API.v1.success(mountResult({ id, error: err })); | ||
| return API.v1.failure(mountResult({ id, error: err })); | ||
|
||
| } | ||
| }, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -166,9 +166,10 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
|
ggazzo marked this conversation as resolved.
|
||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.property('success', true); | ||||||
| expect(res.body).to.have.property('success', false); | ||||||
|
|
||||||
| const data = JSON.parse(res.body.message); | ||||||
| expect(data).to.have.property('error').that.is.an('object'); | ||||||
| expect(data.error).to.have.property('error', 'error-action-not-allowed'); | ||||||
|
|
@@ -576,9 +577,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
|
|
||||||
| const data = JSON.parse(res.body.message); | ||||||
|
|
@@ -734,9 +735,9 @@ describe('Meteor.methods', () => { | |||||
| msg: 'method', | ||||||
| }), | ||||||
| }) | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| const data = JSON.parse(res.body.message); | ||||||
| expect(data).to.have.a.property('error').that.is.an('object'); | ||||||
| expect(data.error).to.have.a.property('error', 'error-not-allowed'); | ||||||
|
|
@@ -903,9 +904,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
|
|
||||||
| const data = JSON.parse(res.body.message); | ||||||
|
|
@@ -1121,9 +1122,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
|
|
||||||
| const data = JSON.parse(res.body.message); | ||||||
|
|
@@ -1301,9 +1302,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
|
|
||||||
| const data = JSON.parse(res.body.message); | ||||||
|
|
@@ -1562,9 +1563,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.include('error-invalid-room'); | ||||||
| }) | ||||||
| .end(done); | ||||||
|
|
@@ -1583,9 +1584,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.include('Match error'); | ||||||
| }) | ||||||
| .end(done); | ||||||
|
|
@@ -2022,9 +2023,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.property('success', true); | ||||||
| expect(res.body).to.have.property('success', false); | ||||||
| const data = JSON.parse(res.body.message); | ||||||
| expect(data).to.not.have.a.property('result').that.is.an('object'); | ||||||
| expect(data).to.have.a.property('error').that.is.an('object'); | ||||||
|
|
@@ -2053,9 +2054,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.property('success', true); | ||||||
| expect(res.body).to.have.property('success', false); | ||||||
| const data = JSON.parse(res.body.message); | ||||||
| expect(data).to.have.a.property('error').that.is.an('object'); | ||||||
| expect(data.error.sanitizedError).to.have.a.property('reason', 'Match failed'); | ||||||
|
|
@@ -2241,9 +2242,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
| const data = JSON.parse(res.body.message); | ||||||
| expect(data).to.have.a.property('msg').that.is.an('string'); | ||||||
|
|
@@ -2264,17 +2265,17 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
| const data = JSON.parse(res.body.message); | ||||||
| expect(data).to.have.a.property('msg').that.is.an('string'); | ||||||
| expect(data.error).to.have.a.property('error', 'error-action-not-allowed'); | ||||||
| }); | ||||||
| }); | ||||||
|
|
||||||
| it('should add a quote attachment to a message', async () => { | ||||||
| it.skip('should add a quote attachment to a message', async () => { | ||||||
| const quotedMsgLink = `${siteUrl}/group/${roomName}?msg=${messageWithMarkdownId}`; | ||||||
| await request | ||||||
| .post(methodCall('updateMessage')) | ||||||
|
|
@@ -2291,6 +2292,7 @@ describe('Meteor.methods', () => { | |||||
| .expect(200) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| // TODO: this test is not testing anything useful | ||||||
|
||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
| }); | ||||||
|
|
||||||
|
|
@@ -2378,7 +2380,7 @@ describe('Meteor.methods', () => { | |||||
| }); | ||||||
| }); | ||||||
|
|
||||||
| it('should remove a quote attachment from a message', async () => { | ||||||
| it.skip('should remove a quote attachment from a message', async () => { | ||||||
| await request | ||||||
| .post(methodCall('updateMessage')) | ||||||
| .set(credentials) | ||||||
|
|
@@ -2534,9 +2536,9 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.a.property('success', true); | ||||||
| expect(res.body).to.have.a.property('success', false); | ||||||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||||||
|
|
||||||
| const data = JSON.parse(res.body.message); | ||||||
|
|
@@ -3098,7 +3100,7 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.property('message').that.is.an('string'); | ||||||
| expect(res.body.message).to.include('error-cant-invite-for-direct-room'); | ||||||
|
|
@@ -3201,7 +3203,7 @@ describe('Meteor.methods', () => { | |||||
| }), | ||||||
| }) | ||||||
| .expect('Content-Type', 'application/json') | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.property('success', true); | ||||||
|
ggazzo marked this conversation as resolved.
Outdated
|
||||||
| const parsedBody = JSON.parse(res.body.message); | ||||||
|
|
@@ -3225,7 +3227,7 @@ describe('Meteor.methods', () => { | |||||
| params: [[{ _id: 'Message_AllowEditing_BlockEditInMinutes', value: { $InfNaN: 0 } }]], | ||||||
| }), | ||||||
| }) | ||||||
| .expect(200) | ||||||
| .expect(400) | ||||||
| .expect((res) => { | ||||||
| expect(res.body).to.have.property('success', true); | ||||||
|
ggazzo marked this conversation as resolved.
Outdated
|
||||||
| expect(res.body).to.have.property('success', true); | |
| expect(res.body).to.have.property('success', false); |
Uh oh!
There was an error while loading. Please reload this page.