mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-09 05:56:00 +00:00
decaffeinate: Run post-processing cleanups on AuthorizationManagerTests.coffee and 13 other files
This commit is contained in:
parent
2ca620e7a0
commit
93697a8c5c
14 changed files with 148 additions and 58 deletions
services/real-time/test/unit/coffee
AuthorizationManagerTests.jsChannelManagerTests.jsConnectedUsersManagerTests.jsDocumentUpdaterControllerTests.jsDocumentUpdaterManagerTests.jsDrainManagerTests.jsEventLoggerTests.jsRoomManagerTests.jsSafeJsonParseTest.jsSessionSocketsTests.jsWebApiManagerTests.jsWebsocketControllerTests.jsWebsocketLoadBalancerTests.js
helpers
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
@ -23,7 +29,7 @@ describe('AuthorizationManager', function() {
|
|||
describe("assertClientCanViewProject", function() {
|
||||
it("should allow the readOnly privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "readOnly";
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, (error) => {
|
||||
expect(error).to.be.null;
|
||||
return done();
|
||||
});
|
||||
|
@ -31,7 +37,7 @@ describe('AuthorizationManager', function() {
|
|||
|
||||
it("should allow the readAndWrite privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "readAndWrite";
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, (error) => {
|
||||
expect(error).to.be.null;
|
||||
return done();
|
||||
});
|
||||
|
@ -39,7 +45,7 @@ describe('AuthorizationManager', function() {
|
|||
|
||||
it("should allow the owner privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "owner";
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, (error) => {
|
||||
expect(error).to.be.null;
|
||||
return done();
|
||||
});
|
||||
|
@ -47,7 +53,7 @@ describe('AuthorizationManager', function() {
|
|||
|
||||
return it("should return an error with any other privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "unknown";
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanViewProject(this.client, (error) => {
|
||||
error.message.should.equal("not authorized");
|
||||
return done();
|
||||
});
|
||||
|
@ -57,7 +63,7 @@ describe('AuthorizationManager', function() {
|
|||
describe("assertClientCanEditProject", function() {
|
||||
it("should not allow the readOnly privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "readOnly";
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, (error) => {
|
||||
error.message.should.equal("not authorized");
|
||||
return done();
|
||||
});
|
||||
|
@ -65,7 +71,7 @@ describe('AuthorizationManager', function() {
|
|||
|
||||
it("should allow the readAndWrite privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "readAndWrite";
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, (error) => {
|
||||
expect(error).to.be.null;
|
||||
return done();
|
||||
});
|
||||
|
@ -73,7 +79,7 @@ describe('AuthorizationManager', function() {
|
|||
|
||||
it("should allow the owner privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "owner";
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, (error) => {
|
||||
expect(error).to.be.null;
|
||||
return done();
|
||||
});
|
||||
|
@ -81,7 +87,7 @@ describe('AuthorizationManager', function() {
|
|||
|
||||
return it("should return an error with any other privilegeLevel", function(done) {
|
||||
this.client.ol_context.privilege_level = "unknown";
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, function(error) {
|
||||
return this.AuthorizationManager.assertClientCanEditProject(this.client, (error) => {
|
||||
error.message.should.equal("not authorized");
|
||||
return done();
|
||||
});
|
||||
|
@ -121,9 +127,9 @@ describe('AuthorizationManager', function() {
|
|||
return this.client.ol_context.privilege_level = "readOnly";
|
||||
});
|
||||
|
||||
describe("and not authorised at the document level", () => it("should not allow access", function() {
|
||||
describe("and not authorised at the document level", function() { return it("should not allow access", function() {
|
||||
return this.AuthorizationManager.assertClientCanViewProjectAndDoc(this.client, this.doc_id, err => err.message.should.equal("not authorized"));
|
||||
}));
|
||||
}); });
|
||||
|
||||
describe("and authorised at the document level", function() {
|
||||
beforeEach(function(done) {
|
||||
|
@ -183,9 +189,9 @@ describe('AuthorizationManager', function() {
|
|||
return this.client.ol_context.privilege_level = "readAndWrite";
|
||||
});
|
||||
|
||||
describe("and not authorised at the document level", () => it("should not allow access", function() {
|
||||
describe("and not authorised at the document level", function() { return it("should not allow access", function() {
|
||||
return this.AuthorizationManager.assertClientCanEditProjectAndDoc(this.client, this.doc_id, err => err.message.should.equal("not authorized"));
|
||||
}));
|
||||
}); });
|
||||
|
||||
describe("and authorised at the document level", function() {
|
||||
beforeEach(function(done) {
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
@ -86,7 +92,7 @@ describe('ChannelManager', function() {
|
|||
.onSecondCall().resolves();
|
||||
this.first = this.ChannelManager.subscribe(this.rclient, "applied-ops", "1234567890abcdef");
|
||||
// ignore error
|
||||
this.first.catch((function(){}));
|
||||
this.first.catch((() => {}));
|
||||
expect(this.ChannelManager.getClientMapEntry(this.rclient).get("applied-ops:1234567890abcdef")).to.equal(this.first);
|
||||
|
||||
this.rclient.unsubscribe = sinon.stub().resolves();
|
||||
|
@ -173,7 +179,7 @@ describe('ChannelManager', function() {
|
|||
beforeEach(function(done) {
|
||||
this.rclient.subscribe = sinon.stub().resolves();
|
||||
this.ChannelManager.subscribe(this.rclient, "applied-ops", "1234567890abcdef");
|
||||
let rejectSubscribe = undefined;
|
||||
let rejectSubscribe;
|
||||
this.rclient.unsubscribe = () => new Promise((resolve, reject) => rejectSubscribe = reject);
|
||||
this.ChannelManager.unsubscribe(this.rclient, "applied-ops", "1234567890abcdef");
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
@ -67,7 +75,7 @@ describe("ConnectedUsersManager", function() {
|
|||
};
|
||||
return this.cursorData = { row: 12, column: 9, doc_id: '53c3b8c85fee64000023dc6e' };});
|
||||
|
||||
afterEach(() => tk.reset());
|
||||
afterEach(function() { return tk.reset(); });
|
||||
|
||||
describe("updateUserPosition", function() {
|
||||
beforeEach(function() {
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
@ -28,7 +33,7 @@ describe('EventLogger', function() {
|
|||
return this.message_2 = "message-2";
|
||||
});
|
||||
|
||||
afterEach(() => tk.reset());
|
||||
afterEach(function() { return tk.reset(); });
|
||||
|
||||
return describe('checkEventOrder', function() {
|
||||
|
||||
|
@ -81,7 +86,7 @@ describe('EventLogger', function() {
|
|||
});
|
||||
});
|
||||
|
||||
return describe('after MAX_STALE_TIME_IN_MS', () => it('should flush old entries', function() {
|
||||
return describe('after MAX_STALE_TIME_IN_MS', function() { return it('should flush old entries', function() {
|
||||
let status;
|
||||
this.EventLogger.MAX_EVENTS_BEFORE_CLEAN = 10;
|
||||
this.EventLogger.checkEventOrder(this.channel, this.id_1, this.message_1);
|
||||
|
@ -96,6 +101,6 @@ describe('EventLogger', function() {
|
|||
this.EventLogger.checkEventOrder(this.channel, 'other-1', this.message_2);
|
||||
status = this.EventLogger.checkEventOrder(this.channel, this.id_1, this.message_1);
|
||||
return expect(status).to.be.undefined;
|
||||
}));
|
||||
}); });
|
||||
});
|
||||
});
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
promise/param-names,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
@ -31,7 +38,7 @@ describe('RoomManager', function() {
|
|||
return sinon.spy(this.RoomEvents, 'once');
|
||||
});
|
||||
|
||||
describe("emitOnCompletion", () => describe("when a subscribe errors", function() {
|
||||
describe("emitOnCompletion", function() { return describe("when a subscribe errors", function() {
|
||||
afterEach(function() {
|
||||
return process.removeListener("unhandledRejection", this.onUnhandled);
|
||||
});
|
||||
|
@ -43,7 +50,7 @@ describe('RoomManager', function() {
|
|||
};
|
||||
process.on("unhandledRejection", this.onUnhandled);
|
||||
|
||||
let reject = undefined;
|
||||
let reject;
|
||||
const subscribePromise = new Promise((_, r) => reject = r);
|
||||
const promises = [subscribePromise];
|
||||
const eventName = "project-subscribed-123";
|
||||
|
@ -55,7 +62,7 @@ describe('RoomManager', function() {
|
|||
return it("should keep going", function() {
|
||||
return expect(this.unhandledError).to.not.exist;
|
||||
});
|
||||
}));
|
||||
}); });
|
||||
|
||||
describe("joinProject", function() {
|
||||
|
||||
|
@ -242,7 +249,7 @@ describe('RoomManager', function() {
|
|||
});
|
||||
|
||||
|
||||
return describe("leaveProjectAndDocs", () => describe("when the client is connected to the project and multiple docs", function() {
|
||||
return describe("leaveProjectAndDocs", function() { return describe("when the client is connected to the project and multiple docs", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
this.RoomManager._roomsClientIsIn = sinon.stub().returns([this.project_id, this.doc_id, this.other_doc_id]);
|
||||
|
@ -355,5 +362,5 @@ describe('RoomManager', function() {
|
|||
return this.RoomEvents.emit.called.should.equal(false);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}); });
|
||||
});
|
|
@ -1,3 +1,11 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-useless-escape,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
@ -23,14 +31,14 @@ describe('SafeJsonParse', function() {
|
|||
|
||||
return describe("parse", function() {
|
||||
it("should parse documents correctly", function(done) {
|
||||
return this.SafeJsonParse.parse('{"foo": "bar"}', function(error, parsed) {
|
||||
return this.SafeJsonParse.parse('{"foo": "bar"}', (error, parsed) => {
|
||||
expect(parsed).to.deep.equal({foo: "bar"});
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should return an error on bad data", function(done) {
|
||||
return this.SafeJsonParse.parse('blah', function(error, parsed) {
|
||||
return this.SafeJsonParse.parse('blah', (error, parsed) => {
|
||||
expect(error).to.exist;
|
||||
return done();
|
||||
});
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
@ -41,7 +47,7 @@ describe('SessionSockets', function() {
|
|||
return this.socket = {handshake: {}};});
|
||||
|
||||
it('should return a lookup error', function(done) {
|
||||
return this.checkSocket(this.socket, function(error) {
|
||||
return this.checkSocket(this.socket, (error) => {
|
||||
expect(error).to.exist;
|
||||
expect(error.message).to.equal('could not look up session by key');
|
||||
return done();
|
||||
|
@ -61,7 +67,7 @@ describe('SessionSockets', function() {
|
|||
return this.socket = {handshake: {_signedCookies: {other: 1}}};});
|
||||
|
||||
it('should return a lookup error', function(done) {
|
||||
return this.checkSocket(this.socket, function(error) {
|
||||
return this.checkSocket(this.socket, (error) => {
|
||||
expect(error).to.exist;
|
||||
expect(error.message).to.equal('could not look up session by key');
|
||||
return done();
|
||||
|
@ -88,7 +94,7 @@ describe('SessionSockets', function() {
|
|||
});
|
||||
|
||||
return it('should return a redis error', function(done) {
|
||||
return this.checkSocket(this.socket, function(error) {
|
||||
return this.checkSocket(this.socket, (error) => {
|
||||
expect(error).to.exist;
|
||||
expect(error.message).to.equal('Redis: something went wrong');
|
||||
return done();
|
||||
|
@ -108,7 +114,7 @@ describe('SessionSockets', function() {
|
|||
});
|
||||
|
||||
return it('should return a lookup error', function(done) {
|
||||
return this.checkSocket(this.socket, function(error) {
|
||||
return this.checkSocket(this.socket, (error) => {
|
||||
expect(error).to.exist;
|
||||
expect(error.message).to.equal('could not look up session by key');
|
||||
return done();
|
||||
|
@ -128,14 +134,14 @@ describe('SessionSockets', function() {
|
|||
});
|
||||
|
||||
it('should not return an error', function(done) {
|
||||
return this.checkSocket(this.socket, function(error) {
|
||||
return this.checkSocket(this.socket, (error) => {
|
||||
expect(error).to.not.exist;
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
return it('should return the session', function(done) {
|
||||
return this.checkSocket(this.socket, function(error, s, session) {
|
||||
return this.checkSocket(this.socket, (error, s, session) => {
|
||||
expect(session).to.deep.equal({user: {_id: '123'}});
|
||||
return done();
|
||||
});
|
||||
|
@ -154,14 +160,14 @@ describe('SessionSockets', function() {
|
|||
});
|
||||
|
||||
it('should not return an error', function(done) {
|
||||
return this.checkSocket(this.socket, function(error) {
|
||||
return this.checkSocket(this.socket, (error) => {
|
||||
expect(error).to.not.exist;
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
return it('should return the other session', function(done) {
|
||||
return this.checkSocket(this.socket, function(error, s, session) {
|
||||
return this.checkSocket(this.socket, (error, s, session) => {
|
||||
expect(session).to.deep.equal({user: {_id: 'abc'}});
|
||||
return done();
|
||||
});
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
no-return-assign,
|
||||
no-throw-literal,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
@ -50,7 +58,7 @@ describe('WebsocketController', function() {
|
|||
}
|
||||
});});
|
||||
|
||||
afterEach(() => tk.reset());
|
||||
afterEach(function() { return tk.reset(); });
|
||||
|
||||
describe("joinProject", function() {
|
||||
describe("when authorised", function() {
|
||||
|
@ -81,37 +89,37 @@ describe('WebsocketController', function() {
|
|||
});
|
||||
|
||||
it("should set the privilege level on the client", function() {
|
||||
return this.client.ol_context["privilege_level"].should.equal(this.privilegeLevel);
|
||||
return this.client.ol_context.privilege_level.should.equal(this.privilegeLevel);
|
||||
});
|
||||
it("should set the user's id on the client", function() {
|
||||
return this.client.ol_context["user_id"].should.equal(this.user._id);
|
||||
return this.client.ol_context.user_id.should.equal(this.user._id);
|
||||
});
|
||||
it("should set the user's email on the client", function() {
|
||||
return this.client.ol_context["email"].should.equal(this.user.email);
|
||||
return this.client.ol_context.email.should.equal(this.user.email);
|
||||
});
|
||||
it("should set the user's first_name on the client", function() {
|
||||
return this.client.ol_context["first_name"].should.equal(this.user.first_name);
|
||||
return this.client.ol_context.first_name.should.equal(this.user.first_name);
|
||||
});
|
||||
it("should set the user's last_name on the client", function() {
|
||||
return this.client.ol_context["last_name"].should.equal(this.user.last_name);
|
||||
return this.client.ol_context.last_name.should.equal(this.user.last_name);
|
||||
});
|
||||
it("should set the user's sign up date on the client", function() {
|
||||
return this.client.ol_context["signup_date"].should.equal(this.user.signUpDate);
|
||||
return this.client.ol_context.signup_date.should.equal(this.user.signUpDate);
|
||||
});
|
||||
it("should set the user's login_count on the client", function() {
|
||||
return this.client.ol_context["login_count"].should.equal(this.user.loginCount);
|
||||
return this.client.ol_context.login_count.should.equal(this.user.loginCount);
|
||||
});
|
||||
it("should set the connected time on the client", function() {
|
||||
return this.client.ol_context["connected_time"].should.equal(new Date());
|
||||
return this.client.ol_context.connected_time.should.equal(new Date());
|
||||
});
|
||||
it("should set the project_id on the client", function() {
|
||||
return this.client.ol_context["project_id"].should.equal(this.project_id);
|
||||
return this.client.ol_context.project_id.should.equal(this.project_id);
|
||||
});
|
||||
it("should set the project owner id on the client", function() {
|
||||
return this.client.ol_context["owner_id"].should.equal(this.owner_id);
|
||||
return this.client.ol_context.owner_id.should.equal(this.owner_id);
|
||||
});
|
||||
it("should set the is_restricted_user flag on the client", function() {
|
||||
return this.client.ol_context["is_restricted_user"].should.equal(this.isRestrictedUser);
|
||||
return this.client.ol_context.is_restricted_user.should.equal(this.isRestrictedUser);
|
||||
});
|
||||
it("should call the callback with the project, privilegeLevel and protocolVersion", function() {
|
||||
return this.callback
|
||||
|
@ -1010,7 +1018,7 @@ describe('WebsocketController', function() {
|
|||
});
|
||||
|
||||
describe("after 100ms", function() {
|
||||
beforeEach(done => setTimeout(done, 100));
|
||||
beforeEach(function(done) { return setTimeout(done, 100); });
|
||||
|
||||
it("should send an otUpdateError the client", function() {
|
||||
return this.client.emit.calledWith('otUpdateError').should.equal(true);
|
||||
|
@ -1050,39 +1058,39 @@ describe('WebsocketController', function() {
|
|||
return this.AuthorizationManager.assertClientCanViewProjectAndDoc = sinon.stub();
|
||||
});
|
||||
|
||||
describe("with a read-write client", () => it("should return successfully", function(done) {
|
||||
describe("with a read-write client", function() { return it("should return successfully", function(done) {
|
||||
this.AuthorizationManager.assertClientCanEditProjectAndDoc.yields(null);
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.edit_update, function(error) {
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.edit_update, (error) => {
|
||||
expect(error).to.be.null;
|
||||
return done();
|
||||
});
|
||||
}));
|
||||
}); });
|
||||
|
||||
describe("with a read-only client and an edit op", () => it("should return an error", function(done) {
|
||||
describe("with a read-only client and an edit op", function() { return it("should return an error", function(done) {
|
||||
this.AuthorizationManager.assertClientCanEditProjectAndDoc.yields(new Error("not authorized"));
|
||||
this.AuthorizationManager.assertClientCanViewProjectAndDoc.yields(null);
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.edit_update, function(error) {
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.edit_update, (error) => {
|
||||
expect(error.message).to.equal("not authorized");
|
||||
return done();
|
||||
});
|
||||
}));
|
||||
}); });
|
||||
|
||||
describe("with a read-only client and a comment op", () => it("should return successfully", function(done) {
|
||||
describe("with a read-only client and a comment op", function() { return it("should return successfully", function(done) {
|
||||
this.AuthorizationManager.assertClientCanEditProjectAndDoc.yields(new Error("not authorized"));
|
||||
this.AuthorizationManager.assertClientCanViewProjectAndDoc.yields(null);
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.comment_update, function(error) {
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.comment_update, (error) => {
|
||||
expect(error).to.be.null;
|
||||
return done();
|
||||
});
|
||||
}));
|
||||
}); });
|
||||
|
||||
return describe("with a totally unauthorized client", () => it("should return an error", function(done) {
|
||||
return describe("with a totally unauthorized client", function() { return it("should return an error", function(done) {
|
||||
this.AuthorizationManager.assertClientCanEditProjectAndDoc.yields(new Error("not authorized"));
|
||||
this.AuthorizationManager.assertClientCanViewProjectAndDoc.yields(new Error("not authorized"));
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.comment_update, function(error) {
|
||||
return this.WebsocketController._assertClientCanApplyUpdate(this.client, this.doc_id, this.comment_update, (error) => {
|
||||
expect(error.message).to.equal("not authorized");
|
||||
return done();
|
||||
});
|
||||
}));
|
||||
}); });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/* eslint-disable
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
let MockClient;
|
||||
const sinon = require('sinon');
|
||||
|
||||
|
@ -12,5 +17,6 @@ module.exports = (MockClient = class MockClient {
|
|||
this.id = idCounter++;
|
||||
this.publicId = idCounter++;
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue