|
|
@@ -1,59 +1,46 @@
|
|
|
-/* eslint-disable
|
|
|
- camelcase,
|
|
|
- max-len,
|
|
|
- no-undef,
|
|
|
- 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
|
|
|
- * DS207: Consider shorter variations of null checks
|
|
|
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
- */
|
|
|
const { expect } = require('chai')
|
|
|
const async = require('async')
|
|
|
const User = require('./helpers/User')
|
|
|
const request = require('./helpers/request')
|
|
|
const settings = require('settings-sharelatex')
|
|
|
|
|
|
-const MockDocstoreApi = require('./helpers/MockDocstoreApi')
|
|
|
-const MockDocUpdaterApi = require('./helpers/MockDocUpdaterApi')
|
|
|
+require('./helpers/MockDocstoreApi')
|
|
|
+require('./helpers/MockDocUpdaterApi')
|
|
|
|
|
|
-const try_read_access = (user, project_id, test, callback) =>
|
|
|
+function tryReadAccess(user, projectId, test, callback) {
|
|
|
async.series(
|
|
|
[
|
|
|
cb =>
|
|
|
- user.request.get(`/project/${project_id}`, (error, response, body) => {
|
|
|
+ user.request.get(`/project/${projectId}`, (error, response, body) => {
|
|
|
if (error != null) {
|
|
|
return cb(error)
|
|
|
}
|
|
|
test(response, body)
|
|
|
- return cb()
|
|
|
+ cb()
|
|
|
}),
|
|
|
cb =>
|
|
|
user.request.get(
|
|
|
- `/project/${project_id}/download/zip`,
|
|
|
+ `/project/${projectId}/download/zip`,
|
|
|
(error, response, body) => {
|
|
|
if (error != null) {
|
|
|
return cb(error)
|
|
|
}
|
|
|
test(response, body)
|
|
|
- return cb()
|
|
|
+ cb()
|
|
|
}
|
|
|
)
|
|
|
],
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const try_settings_write_access = (user, project_id, test, callback) =>
|
|
|
+function trySettingsWriteAccess(user, projectId, test, callback) {
|
|
|
async.series(
|
|
|
[
|
|
|
cb =>
|
|
|
user.request.post(
|
|
|
{
|
|
|
- uri: `/project/${project_id}/settings`,
|
|
|
+ uri: `/project/${projectId}/settings`,
|
|
|
json: {
|
|
|
compiler: 'latex'
|
|
|
}
|
|
|
@@ -63,20 +50,21 @@ const try_settings_write_access = (user, project_id, test, callback) =>
|
|
|
return cb(error)
|
|
|
}
|
|
|
test(response, body)
|
|
|
- return cb()
|
|
|
+ cb()
|
|
|
}
|
|
|
)
|
|
|
],
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const try_admin_access = (user, project_id, test, callback) =>
|
|
|
+function tryAdminAccess(user, projectId, test, callback) {
|
|
|
async.series(
|
|
|
[
|
|
|
cb =>
|
|
|
user.request.post(
|
|
|
{
|
|
|
- uri: `/project/${project_id}/rename`,
|
|
|
+ uri: `/project/${projectId}/rename`,
|
|
|
json: {
|
|
|
newProjectName: 'new-name'
|
|
|
}
|
|
|
@@ -86,13 +74,13 @@ const try_admin_access = (user, project_id, test, callback) =>
|
|
|
return cb(error)
|
|
|
}
|
|
|
test(response, body)
|
|
|
- return cb()
|
|
|
+ cb()
|
|
|
}
|
|
|
),
|
|
|
cb =>
|
|
|
user.request.post(
|
|
|
{
|
|
|
- uri: `/project/${project_id}/settings/admin`,
|
|
|
+ uri: `/project/${projectId}/settings/admin`,
|
|
|
json: {
|
|
|
publicAccessLevel: 'private'
|
|
|
}
|
|
|
@@ -102,26 +90,27 @@ const try_admin_access = (user, project_id, test, callback) =>
|
|
|
return cb(error)
|
|
|
}
|
|
|
test(response, body)
|
|
|
- return cb()
|
|
|
+ cb()
|
|
|
}
|
|
|
)
|
|
|
],
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const try_content_access = function(user, project_id, test, callback) {
|
|
|
+function tryContentAccess(user, projectId, test, callback) {
|
|
|
// The real-time service calls this end point to determine the user's
|
|
|
// permissions.
|
|
|
- let user_id
|
|
|
+ let userId
|
|
|
if (user.id != null) {
|
|
|
- user_id = user.id
|
|
|
+ userId = user.id
|
|
|
} else {
|
|
|
- user_id = 'anonymous-user'
|
|
|
+ userId = 'anonymous-user'
|
|
|
}
|
|
|
- return request.post(
|
|
|
+ request.post(
|
|
|
{
|
|
|
- url: `/project/${project_id}/join`,
|
|
|
- qs: { user_id },
|
|
|
+ url: `/project/${projectId}/join`,
|
|
|
+ qs: { user_id: userId },
|
|
|
auth: {
|
|
|
user: settings.apis.web.user,
|
|
|
pass: settings.apis.web.pass,
|
|
|
@@ -135,26 +124,26 @@ const try_content_access = function(user, project_id, test, callback) {
|
|
|
return callback(error)
|
|
|
}
|
|
|
test(response, body)
|
|
|
- return callback()
|
|
|
+ callback()
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-const expect_read_access = (user, project_id, callback) =>
|
|
|
+function expectReadAccess(user, projectId, callback) {
|
|
|
async.series(
|
|
|
[
|
|
|
cb =>
|
|
|
- try_read_access(
|
|
|
+ tryReadAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) =>
|
|
|
expect(response.statusCode).to.be.oneOf([200, 204]),
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
- try_content_access(
|
|
|
+ tryContentAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) =>
|
|
|
expect(body.privilegeLevel).to.be.oneOf([
|
|
|
'owner',
|
|
|
@@ -166,92 +155,109 @@ const expect_read_access = (user, project_id, callback) =>
|
|
|
],
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const expect_content_write_access = (user, project_id, callback) =>
|
|
|
- try_content_access(
|
|
|
+function expectContentWriteAccess(user, projectId, callback) {
|
|
|
+ tryContentAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) =>
|
|
|
expect(body.privilegeLevel).to.be.oneOf(['owner', 'readAndWrite']),
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const expect_settings_write_access = (user, project_id, callback) =>
|
|
|
- try_settings_write_access(
|
|
|
+function expectSettingsWriteAccess(user, projectId, callback) {
|
|
|
+ trySettingsWriteAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) => expect(response.statusCode).to.be.oneOf([200, 204]),
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const expect_admin_access = (user, project_id, callback) =>
|
|
|
- try_admin_access(
|
|
|
+function expectAdminAccess(user, projectId, callback) {
|
|
|
+ tryAdminAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) => expect(response.statusCode).to.be.oneOf([200, 204]),
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const expect_no_read_access = (user, project_id, options, callback) =>
|
|
|
+function expectNoReadAccess(user, projectId, options, callback) {
|
|
|
async.series(
|
|
|
[
|
|
|
cb =>
|
|
|
- try_read_access(
|
|
|
+ tryReadAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) => {
|
|
|
expect(response.statusCode).to.equal(302)
|
|
|
- return expect(response.headers.location).to.match(
|
|
|
+ expect(response.headers.location).to.match(
|
|
|
new RegExp(options.redirect_to)
|
|
|
)
|
|
|
},
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
- try_content_access(
|
|
|
+ tryContentAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) => expect(body.privilegeLevel).to.be.equal(false),
|
|
|
cb
|
|
|
)
|
|
|
],
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const expect_no_content_write_access = (user, project_id, callback) =>
|
|
|
- try_content_access(
|
|
|
+function expectNoContentWriteAccess(user, projectId, callback) {
|
|
|
+ tryContentAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) =>
|
|
|
expect(body.privilegeLevel).to.be.oneOf([false, 'readOnly']),
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const expect_no_settings_write_access = (user, project_id, options, callback) =>
|
|
|
- try_settings_write_access(
|
|
|
+function expectNoSettingsWriteAccess(user, projectId, options, callback) {
|
|
|
+ trySettingsWriteAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
(response, body) => {
|
|
|
expect(response.statusCode).to.equal(302)
|
|
|
- return expect(response.headers.location).to.match(
|
|
|
+ expect(response.headers.location).to.match(
|
|
|
new RegExp(options.redirect_to)
|
|
|
)
|
|
|
},
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
-const expect_no_admin_access = (user, project_id, options, callback) =>
|
|
|
- try_admin_access(
|
|
|
+function expectNoAdminAccess(user, projectId, callback) {
|
|
|
+ tryAdminAccess(
|
|
|
user,
|
|
|
- project_id,
|
|
|
+ projectId,
|
|
|
+ (response, body) => {
|
|
|
+ expect(response.statusCode).to.equal(403)
|
|
|
+ },
|
|
|
+ callback
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+function expectNoAnonymousAdminAccess(user, projectId, callback) {
|
|
|
+ tryAdminAccess(
|
|
|
+ user,
|
|
|
+ projectId,
|
|
|
(response, body) => {
|
|
|
expect(response.statusCode).to.equal(302)
|
|
|
- return expect(response.headers.location).to.match(
|
|
|
- new RegExp(options.redirect_to)
|
|
|
- )
|
|
|
+ expect(response.headers.location).to.match(/^\/login/)
|
|
|
},
|
|
|
callback
|
|
|
)
|
|
|
+}
|
|
|
|
|
|
describe('Authorization', function() {
|
|
|
beforeEach(function(done) {
|
|
|
@@ -261,18 +267,18 @@ describe('Authorization', function() {
|
|
|
this.other2 = new User()
|
|
|
this.anon = new User()
|
|
|
this.site_admin = new User({ email: 'admin@example.com' })
|
|
|
- return async.parallel(
|
|
|
+ async.parallel(
|
|
|
[
|
|
|
cb => this.owner.login(cb),
|
|
|
cb => this.other1.login(cb),
|
|
|
cb => this.other2.login(cb),
|
|
|
cb => this.anon.getCsrfToken(cb),
|
|
|
cb => {
|
|
|
- return this.site_admin.login(err => {
|
|
|
- if (typeof error !== 'undefined' && error !== null) {
|
|
|
+ this.site_admin.login(err => {
|
|
|
+ if (err != null) {
|
|
|
return cb(err)
|
|
|
}
|
|
|
- return this.site_admin.ensure_admin(cb)
|
|
|
+ this.site_admin.ensure_admin(cb)
|
|
|
})
|
|
|
}
|
|
|
],
|
|
|
@@ -282,114 +288,97 @@ describe('Authorization', function() {
|
|
|
|
|
|
describe('private project', function() {
|
|
|
beforeEach(function(done) {
|
|
|
- return this.owner.createProject(
|
|
|
- 'private-project',
|
|
|
- (error, project_id) => {
|
|
|
- if (error != null) {
|
|
|
- return done(error)
|
|
|
- }
|
|
|
- this.project_id = project_id
|
|
|
- return done()
|
|
|
+ this.owner.createProject('private-project', (error, projectId) => {
|
|
|
+ if (error != null) {
|
|
|
+ return done(error)
|
|
|
}
|
|
|
- )
|
|
|
+ this.projectId = projectId
|
|
|
+ done()
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
it('should allow the owner read access to it', function(done) {
|
|
|
- return expect_read_access(this.owner, this.project_id, done)
|
|
|
+ expectReadAccess(this.owner, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow the owner write access to its content', function(done) {
|
|
|
- return expect_content_write_access(this.owner, this.project_id, done)
|
|
|
+ expectContentWriteAccess(this.owner, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow the owner write access to its settings', function(done) {
|
|
|
- return expect_settings_write_access(this.owner, this.project_id, done)
|
|
|
+ expectSettingsWriteAccess(this.owner, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow the owner admin access to it', function(done) {
|
|
|
- return expect_admin_access(this.owner, this.project_id, done)
|
|
|
+ expectAdminAccess(this.owner, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow another user read access to the project', function(done) {
|
|
|
- return expect_no_read_access(
|
|
|
+ expectNoReadAccess(
|
|
|
this.other1,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow another user write access to its content', function(done) {
|
|
|
- return expect_no_content_write_access(this.other1, this.project_id, done)
|
|
|
+ expectNoContentWriteAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow another user write access to its settings', function(done) {
|
|
|
- return expect_no_settings_write_access(
|
|
|
+ expectNoSettingsWriteAccess(
|
|
|
this.other1,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow another user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.other1,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAdminAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow anonymous user read access to it', function(done) {
|
|
|
- return expect_no_read_access(
|
|
|
+ expectNoReadAccess(
|
|
|
this.anon,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow anonymous user write access to its content', function(done) {
|
|
|
- return expect_no_content_write_access(this.anon, this.project_id, done)
|
|
|
+ expectNoContentWriteAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow anonymous user write access to its settings', function(done) {
|
|
|
- return expect_no_settings_write_access(
|
|
|
+ expectNoSettingsWriteAccess(
|
|
|
this.anon,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow anonymous user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.anon,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAnonymousAdminAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow site admin users read access to it', function(done) {
|
|
|
- return expect_read_access(this.site_admin, this.project_id, done)
|
|
|
+ expectReadAccess(this.site_admin, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow site admin users write access to its content', function(done) {
|
|
|
- return expect_content_write_access(this.site_admin, this.project_id, done)
|
|
|
+ expectContentWriteAccess(this.site_admin, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow site admin users write access to its settings', function(done) {
|
|
|
- return expect_settings_write_access(
|
|
|
- this.site_admin,
|
|
|
- this.project_id,
|
|
|
- done
|
|
|
- )
|
|
|
+ expectSettingsWriteAccess(this.site_admin, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow site admin users admin access to it', function(done) {
|
|
|
- return expect_admin_access(this.site_admin, this.project_id, done)
|
|
|
+ expectAdminAccess(this.site_admin, this.projectId, done)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -397,217 +386,178 @@ describe('Authorization', function() {
|
|
|
beforeEach(function(done) {
|
|
|
this.rw_user = this.other1
|
|
|
this.ro_user = this.other2
|
|
|
- return this.owner.createProject(
|
|
|
- 'private-project',
|
|
|
- (error, project_id) => {
|
|
|
- if (error != null) {
|
|
|
- return done(error)
|
|
|
- }
|
|
|
- this.project_id = project_id
|
|
|
- return this.owner.addUserToProject(
|
|
|
- this.project_id,
|
|
|
- this.ro_user,
|
|
|
- 'readOnly',
|
|
|
- error => {
|
|
|
- if (error != null) {
|
|
|
- return done(error)
|
|
|
- }
|
|
|
- return this.owner.addUserToProject(
|
|
|
- this.project_id,
|
|
|
- this.rw_user,
|
|
|
- 'readAndWrite',
|
|
|
- error => {
|
|
|
- if (error != null) {
|
|
|
- return done(error)
|
|
|
- }
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- )
|
|
|
+ this.owner.createProject('private-project', (error, projectId) => {
|
|
|
+ if (error != null) {
|
|
|
+ return done(error)
|
|
|
}
|
|
|
- )
|
|
|
+ this.projectId = projectId
|
|
|
+ this.owner.addUserToProject(
|
|
|
+ this.projectId,
|
|
|
+ this.ro_user,
|
|
|
+ 'readOnly',
|
|
|
+ error => {
|
|
|
+ if (error != null) {
|
|
|
+ return done(error)
|
|
|
+ }
|
|
|
+ this.owner.addUserToProject(
|
|
|
+ this.projectId,
|
|
|
+ this.rw_user,
|
|
|
+ 'readAndWrite',
|
|
|
+ error => {
|
|
|
+ if (error != null) {
|
|
|
+ return done(error)
|
|
|
+ }
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
it('should allow the read-only user read access to it', function(done) {
|
|
|
- return expect_read_access(this.ro_user, this.project_id, done)
|
|
|
+ expectReadAccess(this.ro_user, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow the read-only user write access to its content', function(done) {
|
|
|
- return expect_no_content_write_access(this.ro_user, this.project_id, done)
|
|
|
+ expectNoContentWriteAccess(this.ro_user, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow the read-only user write access to its settings', function(done) {
|
|
|
- return expect_no_settings_write_access(
|
|
|
+ expectNoSettingsWriteAccess(
|
|
|
this.ro_user,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow the read-only user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.ro_user,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAdminAccess(this.ro_user, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow the read-write user read access to it', function(done) {
|
|
|
- return expect_read_access(this.rw_user, this.project_id, done)
|
|
|
+ expectReadAccess(this.rw_user, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow the read-write user write access to its content', function(done) {
|
|
|
- return expect_content_write_access(this.rw_user, this.project_id, done)
|
|
|
+ expectContentWriteAccess(this.rw_user, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow the read-write user write access to its settings', function(done) {
|
|
|
- return expect_settings_write_access(this.rw_user, this.project_id, done)
|
|
|
+ expectSettingsWriteAccess(this.rw_user, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow the read-write user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.rw_user,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAdminAccess(this.rw_user, this.projectId, done)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('public read-write project', function() {
|
|
|
beforeEach(function(done) {
|
|
|
- return this.owner.createProject(
|
|
|
- 'public-rw-project',
|
|
|
- (error, project_id) => {
|
|
|
- if (error != null) {
|
|
|
- return done(error)
|
|
|
- }
|
|
|
- this.project_id = project_id
|
|
|
- return this.owner.makePublic(this.project_id, 'readAndWrite', done)
|
|
|
+ this.owner.createProject('public-rw-project', (error, projectId) => {
|
|
|
+ if (error != null) {
|
|
|
+ return done(error)
|
|
|
}
|
|
|
- )
|
|
|
+ this.projectId = projectId
|
|
|
+ this.owner.makePublic(this.projectId, 'readAndWrite', done)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
it('should allow a user read access to it', function(done) {
|
|
|
- return expect_read_access(this.other1, this.project_id, done)
|
|
|
+ expectReadAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow a user write access to its content', function(done) {
|
|
|
- return expect_content_write_access(this.other1, this.project_id, done)
|
|
|
+ expectContentWriteAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow a user write access to its settings', function(done) {
|
|
|
- return expect_no_settings_write_access(
|
|
|
+ expectNoSettingsWriteAccess(
|
|
|
this.other1,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow a user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.other1,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAdminAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow an anonymous user read access to it', function(done) {
|
|
|
- return expect_read_access(this.anon, this.project_id, done)
|
|
|
+ expectReadAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow an anonymous user write access to its content', function(done) {
|
|
|
- return expect_content_write_access(this.anon, this.project_id, done)
|
|
|
+ expectContentWriteAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow an anonymous user write access to its settings', function(done) {
|
|
|
- return expect_no_settings_write_access(
|
|
|
+ expectNoSettingsWriteAccess(
|
|
|
this.anon,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow an anonymous user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.anon,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAnonymousAdminAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('public read-only project', function() {
|
|
|
beforeEach(function(done) {
|
|
|
- return this.owner.createProject(
|
|
|
- 'public-ro-project',
|
|
|
- (error, project_id) => {
|
|
|
- if (error != null) {
|
|
|
- return done(error)
|
|
|
- }
|
|
|
- this.project_id = project_id
|
|
|
- return this.owner.makePublic(this.project_id, 'readOnly', done)
|
|
|
+ this.owner.createProject('public-ro-project', (error, projectId) => {
|
|
|
+ if (error != null) {
|
|
|
+ return done(error)
|
|
|
}
|
|
|
- )
|
|
|
+ this.projectId = projectId
|
|
|
+ this.owner.makePublic(this.projectId, 'readOnly', done)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
it('should allow a user read access to it', function(done) {
|
|
|
- return expect_read_access(this.other1, this.project_id, done)
|
|
|
+ expectReadAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow a user write access to its content', function(done) {
|
|
|
- return expect_no_content_write_access(this.other1, this.project_id, done)
|
|
|
+ expectNoContentWriteAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow a user write access to its settings', function(done) {
|
|
|
- return expect_no_settings_write_access(
|
|
|
+ expectNoSettingsWriteAccess(
|
|
|
this.other1,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow a user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.other1,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAdminAccess(this.other1, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should allow an anonymous user read access to it', function(done) {
|
|
|
- return expect_read_access(this.anon, this.project_id, done)
|
|
|
+ expectReadAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow an anonymous user write access to its content', function(done) {
|
|
|
- return expect_no_content_write_access(this.anon, this.project_id, done)
|
|
|
+ expectNoContentWriteAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
|
|
|
it('should not allow an anonymous user write access to its settings', function(done) {
|
|
|
- return expect_no_settings_write_access(
|
|
|
+ expectNoSettingsWriteAccess(
|
|
|
this.anon,
|
|
|
- this.project_id,
|
|
|
+ this.projectId,
|
|
|
{ redirect_to: '/restricted' },
|
|
|
done
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should not allow an anonymous user admin access to it', function(done) {
|
|
|
- return expect_no_admin_access(
|
|
|
- this.anon,
|
|
|
- this.project_id,
|
|
|
- { redirect_to: '/restricted' },
|
|
|
- done
|
|
|
- )
|
|
|
+ expectNoAnonymousAdminAccess(this.anon, this.projectId, done)
|
|
|
})
|
|
|
})
|
|
|
})
|