Explain the query is trying to do
[gitter.git] / test / request-web-tests / export / room-export-resource-tests.js
blob132f528aae21f9dc57105950beaf5b52d280c6a1
1 'use strict';
3 process.env.DISABLE_MATRIX_BRIDGE = '1';
4 process.env.DISABLE_API_LISTEN = '1';
5 process.env.DISABLE_API_WEB_LISTEN = '1';
6 process.env.TEST_EXPORT_RATE_LIMIT = 100;
8 const fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
9 const assert = require('assert');
10 const request = require('supertest');
12 const app = require('../../../server/web');
14 describe('room-export-resource', function() {
15   fixtureLoader.ensureIntegrationEnvironment('#oauthTokens');
17   before(function() {
18     if (this._skipFixtureSetup) return;
19   });
21   var fixture = fixtureLoader.setup({
22     user1: {
23       accessToken: 'web-internal'
24     },
25     userNoExport1: {
26       accessToken: 'web-internal'
27     },
28     troupe1: {
29       securityDescriptor: {
30         admins: 'MANUAL',
31         extraAdmins: ['user1']
32       }
33     }
34   });
36   it('GET /api_web/export/rooms/:room_id/messages.ndjson as admin works', function() {
37     return request(app)
38       .get(`/api_web/export/rooms/${fixture.troupe1.id}/messages.ndjson`)
39       .set('Accept', 'application/x-ndjson,application/json')
40       .set('Authorization', `Bearer ${fixture.user1.accessToken}`)
41       .expect(200);
42   });
44   it('GET /api_web/export/rooms/:room_id/messages.ndjson as not admin is forbidden', function() {
45     return request(app)
46       .get(`/api_web/export/rooms/${fixture.troupe1.id}/messages.ndjson`)
47       .set('Accept', 'application/x-ndjson,application/json')
48       .set('Authorization', `Bearer ${fixture.userNoExport1.accessToken}`)
49       .expect(403)
50       .then(function(result) {
51         assert.deepEqual(result.body, { error: 'Forbidden' });
52       });
53   });
54 });