Show More
@@ -1,51 +1,77 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2016-2016 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | |
|
22 | 22 | import pytest |
|
23 | 23 | |
|
24 | 24 | from rhodecode.authentication.tests.conftest import ( |
|
25 | 25 | EnabledAuthPlugin, DisabledAuthPlugin) |
|
26 | 26 | from rhodecode.config.routing import ADMIN_PREFIX |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | @pytest.mark.usefixtures('autologin_user', 'app') |
|
30 | 30 | class TestAuthenticationSettings: |
|
31 | 31 | |
|
32 | 32 | def test_auth_settings_global_view_get(self, app): |
|
33 | 33 | url = '{prefix}/auth/'.format(prefix=ADMIN_PREFIX) |
|
34 | 34 | response = app.get(url) |
|
35 | 35 | assert response.status_code == 200 |
|
36 | 36 | |
|
37 | 37 | def test_plugin_settings_view_get(self, app, auth_plugin): |
|
38 | 38 | url = '{prefix}/auth/{name}'.format( |
|
39 | 39 | prefix=ADMIN_PREFIX, |
|
40 | 40 | name=auth_plugin.name) |
|
41 | 41 | with EnabledAuthPlugin(auth_plugin): |
|
42 | 42 | response = app.get(url) |
|
43 | 43 | assert response.status_code == 200 |
|
44 | 44 | |
|
45 | def test_plugin_settings_view_post(self, app, auth_plugin, csrf_token): | |
|
46 | url = '{prefix}/auth/{name}'.format( | |
|
47 | prefix=ADMIN_PREFIX, | |
|
48 | name=auth_plugin.name) | |
|
49 | params = { | |
|
50 | 'enabled': True, | |
|
51 | 'cache_ttl': 0, | |
|
52 | 'csrf_token': csrf_token, | |
|
53 | } | |
|
54 | with EnabledAuthPlugin(auth_plugin): | |
|
55 | response = app.post(url, params=params) | |
|
56 | assert response.status_code in [200, 302] | |
|
57 | ||
|
45 | 58 | def test_plugin_settings_view_get_404(self, app, auth_plugin): |
|
46 | 59 | url = '{prefix}/auth/{name}'.format( |
|
47 | 60 | prefix=ADMIN_PREFIX, |
|
48 | 61 | name=auth_plugin.name) |
|
49 | 62 | with DisabledAuthPlugin(auth_plugin): |
|
50 | 63 | response = app.get(url, status=404) |
|
51 | 64 | assert response.status_code == 404 |
|
65 | ||
|
66 | def test_plugin_settings_view_post_404(self, app, auth_plugin, csrf_token): | |
|
67 | url = '{prefix}/auth/{name}'.format( | |
|
68 | prefix=ADMIN_PREFIX, | |
|
69 | name=auth_plugin.name) | |
|
70 | params = { | |
|
71 | 'enabled': True, | |
|
72 | 'cache_ttl': 0, | |
|
73 | 'csrf_token': csrf_token, | |
|
74 | } | |
|
75 | with DisabledAuthPlugin(auth_plugin): | |
|
76 | response = app.post(url, params=params, status=404) | |
|
77 | assert response.status_code == 404 |
General Comments 0
You need to be logged in to leave comments.
Login now