summaryrefslogtreecommitdiffstats
path: root/webapp/tests/client_oauth.test.jsx
blob: df2fc665b714c0328c1e6e20f6a4e00491b7d623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

/* eslint-disable no-console */
/* eslint-disable global-require */
/* eslint-disable func-names */
/* eslint-disable prefer-arrow-callback */
/* eslint-disable no-magic-numbers */
/* eslint-disable no-unreachable */

import assert from 'assert';
import TestHelper from './test_helper.jsx';

describe('Client.OAuth', function() {
    this.timeout(100000);

    it('registerOAuthApp', function(done) {
        TestHelper.initBasic(() => {
            TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error

            var app = {};
            app.name = 'test';
            app.homepage = 'homepage';
            app.description = 'desc';
            app.callback_urls = '';

            TestHelper.basicClient().registerOAuthApp(
                app,
                function() {
                    done(new Error('not enabled'));
                },
                function(err) {
                    assert.equal(err.id, 'api.oauth.register_oauth_app.turn_off.app_error');
                    done();
                }
            );
        });
    });

    it('allowOAuth2', function(done) {
        TestHelper.initBasic(() => {
            TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error

            TestHelper.basicClient().allowOAuth2(
                'GET',
                '123456',
                'http://nowhere.com',
                'state',
                'scope',
                function() {
                    done(new Error('not enabled'));
                },
                function(err) {
                    assert.equal(err.id, 'api.oauth.allow_oauth.turn_off.app_error');
                    done();
                }
            );
        });
    });
});