|
|
@@ -391,7 +391,7 @@ describe('ClsiManager', function() {
|
|
|
|
|
|
describe('deleteAuxFiles', function() {
|
|
|
beforeEach(function() {
|
|
|
- this.ClsiManager._makeRequest = sinon.stub().callsArg(2)
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId = sinon.stub().yields(null)
|
|
|
this.DocumentUpdaterHandler.clearProjectState = sinon.stub().callsArg(1)
|
|
|
})
|
|
|
|
|
|
@@ -401,16 +401,21 @@ describe('ClsiManager', function() {
|
|
|
this.project_id,
|
|
|
this.user_id,
|
|
|
{ compileGroup: 'standard' },
|
|
|
+ 'node-1',
|
|
|
this.callback
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should call the delete method in the standard CLSI', function() {
|
|
|
- this.ClsiManager._makeRequest
|
|
|
- .calledWith(this.project_id, {
|
|
|
- method: 'DELETE',
|
|
|
- url: `${this.settings.apis.clsi.url}/project/${this.project_id}/user/${this.user_id}`
|
|
|
- })
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId
|
|
|
+ .calledWith(
|
|
|
+ this.project_id,
|
|
|
+ {
|
|
|
+ method: 'DELETE',
|
|
|
+ url: `${this.settings.apis.clsi.url}/project/${this.project_id}/user/${this.user_id}`
|
|
|
+ },
|
|
|
+ 'node-1'
|
|
|
+ )
|
|
|
.should.equal(true)
|
|
|
})
|
|
|
|
|
|
@@ -888,14 +893,9 @@ describe('ClsiManager', function() {
|
|
|
|
|
|
describe('wordCount', function() {
|
|
|
beforeEach(function() {
|
|
|
- this.ClsiManager._makeRequest = sinon
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId = sinon
|
|
|
.stub()
|
|
|
- .callsArgWith(
|
|
|
- 2,
|
|
|
- null,
|
|
|
- { statusCode: 200 },
|
|
|
- (this.body = { mock: 'foo' })
|
|
|
- )
|
|
|
+ .yields(null, { statusCode: 200 }, (this.body = { mock: 'foo' }))
|
|
|
this.ClsiManager._buildRequest = sinon.stub().callsArgWith(
|
|
|
2,
|
|
|
null,
|
|
|
@@ -912,17 +912,25 @@ describe('ClsiManager', function() {
|
|
|
this.user_id,
|
|
|
false,
|
|
|
{},
|
|
|
+ 'node-1',
|
|
|
this.callback
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should call wordCount with root file', function() {
|
|
|
- this.ClsiManager._makeRequest
|
|
|
- .calledWith(this.project_id, {
|
|
|
- method: 'GET',
|
|
|
- url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
|
|
|
- qs: { file: 'rootfile.text', image: undefined }
|
|
|
- })
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId
|
|
|
+ .calledWith(
|
|
|
+ this.project_id,
|
|
|
+ {
|
|
|
+ method: 'GET',
|
|
|
+ url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
|
|
|
+ qs: {
|
|
|
+ file: 'rootfile.text',
|
|
|
+ image: undefined
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'node-1'
|
|
|
+ )
|
|
|
.should.equal(true)
|
|
|
})
|
|
|
|
|
|
@@ -938,17 +946,22 @@ describe('ClsiManager', function() {
|
|
|
this.user_id,
|
|
|
'main.tex',
|
|
|
{},
|
|
|
+ 'node-2',
|
|
|
this.callback
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should call wordCount with param file', function() {
|
|
|
- this.ClsiManager._makeRequest
|
|
|
- .calledWith(this.project_id, {
|
|
|
- method: 'GET',
|
|
|
- url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
|
|
|
- qs: { file: 'main.tex', image: undefined }
|
|
|
- })
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId
|
|
|
+ .calledWith(
|
|
|
+ this.project_id,
|
|
|
+ {
|
|
|
+ method: 'GET',
|
|
|
+ url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
|
|
|
+ qs: { file: 'main.tex', image: undefined }
|
|
|
+ },
|
|
|
+ 'node-2'
|
|
|
+ )
|
|
|
.should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
@@ -962,17 +975,22 @@ describe('ClsiManager', function() {
|
|
|
this.user_id,
|
|
|
'main.tex',
|
|
|
{},
|
|
|
+ 'node-3',
|
|
|
this.callback
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should call wordCount with file and image', function() {
|
|
|
- this.ClsiManager._makeRequest
|
|
|
- .calledWith(this.project_id, {
|
|
|
- method: 'GET',
|
|
|
- url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
|
|
|
- qs: { file: 'main.tex', image: this.image }
|
|
|
- })
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId
|
|
|
+ .calledWith(
|
|
|
+ this.project_id,
|
|
|
+ {
|
|
|
+ method: 'GET',
|
|
|
+ url: `http://clsi.example.com/project/${this.project_id}/user/${this.user_id}/wordcount`,
|
|
|
+ qs: { file: 'main.tex', image: this.image }
|
|
|
+ },
|
|
|
+ 'node-3'
|
|
|
+ )
|
|
|
.should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
@@ -1008,6 +1026,83 @@ describe('ClsiManager', function() {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ describe('_makeRequestWithClsiServerId', function() {
|
|
|
+ beforeEach(function() {
|
|
|
+ this.response = { statusCode: 200 }
|
|
|
+ this.request.yields(null, this.response)
|
|
|
+ this.opts = {
|
|
|
+ method: 'GET',
|
|
|
+ url: 'http://clsi'
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('with a regular request', function() {
|
|
|
+ it('should process a request with a cookie jar', function(done) {
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId(
|
|
|
+ this.project_id,
|
|
|
+ this.opts,
|
|
|
+ undefined,
|
|
|
+ err => {
|
|
|
+ if (err) return done(err)
|
|
|
+ const args = this.request.args[0]
|
|
|
+ args[0].method.should.equal(this.opts.method)
|
|
|
+ args[0].url.should.equal(this.opts.url)
|
|
|
+ args[0].jar.should.equal(this.jar)
|
|
|
+ expect(args[0].qs).to.not.exist
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should persist the cookie from the response', function(done) {
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId(
|
|
|
+ this.project_id,
|
|
|
+ this.opts,
|
|
|
+ undefined,
|
|
|
+ err => {
|
|
|
+ if (err) return done(err)
|
|
|
+ this.ClsiCookieManager.setServerId
|
|
|
+ .calledWith(this.project_id, this.response)
|
|
|
+ .should.equal(true)
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('with a persistent request', function() {
|
|
|
+ it('should not add a cookie jar', function(done) {
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId(
|
|
|
+ this.project_id,
|
|
|
+ this.opts,
|
|
|
+ 'node-1',
|
|
|
+ err => {
|
|
|
+ if (err) return done(err)
|
|
|
+ const requestOpts = this.request.args[0][0]
|
|
|
+ expect(requestOpts.method).to.equal(this.opts.method)
|
|
|
+ expect(requestOpts.url).to.equal(this.opts.url)
|
|
|
+ expect(requestOpts.jar).to.not.exist
|
|
|
+ expect(requestOpts.qs).to.deep.equal({ clsiserverid: 'node-1' })
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should not persist a cookie on response', function(done) {
|
|
|
+ this.ClsiManager._makeRequestWithClsiServerId(
|
|
|
+ this.project_id,
|
|
|
+ this.opts,
|
|
|
+ 'node-1',
|
|
|
+ err => {
|
|
|
+ if (err) return done(err)
|
|
|
+ expect(this.ClsiCookieManager.setServerId.called).to.equal(false)
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
describe('_makeGoogleCloudRequest', function() {
|
|
|
beforeEach(function() {
|
|
|
this.settings.apis.clsi_new = { url: 'https://compiles.somewhere.test' }
|