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('user-oauth-access-tokens-export-api', function() {
15 fixtureLoader.ensureIntegrationEnvironment('#oauthTokens');
18 if (this._skipFixtureSetup) return;
21 var fixture = fixtureLoader.setup({
23 accessToken: 'web-internal'
26 accessToken: 'web-internal'
29 oAuthAccessToken1: { user: 'user1', client: 'oAuthClient1' },
31 oAuthAccessToken2: { user: 'user1', client: 'oAuthClient2' },
32 oAuthClientNoExport1: {},
33 oAuthAccessTokenNoExport1: { user: 'userNoExport1', client: 'oAuthClientNoExport1' }
36 it('GET /api_web/export/user/:user_id/oauth-access-tokens.ndjson as same user gets data', async () => {
38 .get(`/api_web/export/user/${fixture.user1.id}/oauth-access-tokens.ndjson`)
39 .set('Accept', 'application/x-ndjson,application/json')
40 .set('Authorization', `Bearer ${fixture.user1.accessToken}`)
42 .then(function(result) {
44 result.text.split('\n').length,
46 // 2 + 1 because we defined 2 access tokens explicitely in the fixtures and the other one from the `accessToken: 'web-internal'`
47 'includes 2 + 1 OAuth access tokens (extra newline at the end)'
49 assert(result.text.includes(fixture.oAuthAccessToken1.id), 'includes oAuthAccessToken1');
50 assert(result.text.includes(fixture.oAuthAccessToken2.id), 'includes oAuthAccessToken2');
52 !result.text.includes(fixture.oAuthAccessTokenNoExport1.id),
53 'does not include oAuthAccessTokenNoExport1'