|
|
@@ -6,6 +6,8 @@ const request = require('./helpers/request')
|
|
|
const settings = require('settings-sharelatex')
|
|
|
const { db, ObjectId } = require('../../../app/src/infrastructure/mongojs')
|
|
|
|
|
|
+const expectErrorResponse = require('./helpers/expectErrorResponse')
|
|
|
+
|
|
|
const tryEditorAccess = (user, projectId, test, callback) =>
|
|
|
async.series(
|
|
|
[
|
|
|
@@ -210,10 +212,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
)
|
|
|
},
|
|
|
@@ -267,10 +266,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
)
|
|
|
},
|
|
|
@@ -371,10 +367,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
// token goes nowhere
|
|
|
@@ -395,10 +388,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
@@ -450,10 +440,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.anon,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
@@ -513,10 +500,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.anon,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
// should not allow the user to access read-only token
|
|
|
@@ -537,10 +521,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.anon,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
// should not allow the user to join the project
|
|
|
@@ -595,11 +576,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(response.headers.location).to.match(/\/restricted.*/)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
@@ -681,11 +658,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(response.headers.location).to.match(/\/restricted.*/)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb => {
|
|
|
@@ -794,10 +767,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ (response, body) => {},
|
|
|
cb
|
|
|
)
|
|
|
},
|
|
|
@@ -818,10 +788,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other1,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
)
|
|
|
},
|
|
|
@@ -876,10 +843,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.anon,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
@@ -954,10 +918,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.anon,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
@@ -1010,10 +971,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.anon,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
@@ -1032,10 +990,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.anon,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|
|
|
@@ -1232,10 +1187,7 @@ describe('TokenAccess', function() {
|
|
|
tryEditorAccess(
|
|
|
this.other2,
|
|
|
this.projectId,
|
|
|
- (response, body) => {
|
|
|
- expect(response.statusCode).to.equal(302)
|
|
|
- expect(body).to.match(/.*\/restricted.*/)
|
|
|
- },
|
|
|
+ expectErrorResponse.restricted.html,
|
|
|
cb
|
|
|
),
|
|
|
cb =>
|