##// END OF EJS Templates
authn: Test authentication plugin settings POST views.
johbo -
r238:b082c123 default
parent child Browse files
Show More
@@ -1,51 +1,77 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2016-2016 RhodeCode GmbH
3 # Copyright (C) 2016-2016 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21
21
22 import pytest
22 import pytest
23
23
24 from rhodecode.authentication.tests.conftest import (
24 from rhodecode.authentication.tests.conftest import (
25 EnabledAuthPlugin, DisabledAuthPlugin)
25 EnabledAuthPlugin, DisabledAuthPlugin)
26 from rhodecode.config.routing import ADMIN_PREFIX
26 from rhodecode.config.routing import ADMIN_PREFIX
27
27
28
28
29 @pytest.mark.usefixtures('autologin_user', 'app')
29 @pytest.mark.usefixtures('autologin_user', 'app')
30 class TestAuthenticationSettings:
30 class TestAuthenticationSettings:
31
31
32 def test_auth_settings_global_view_get(self, app):
32 def test_auth_settings_global_view_get(self, app):
33 url = '{prefix}/auth/'.format(prefix=ADMIN_PREFIX)
33 url = '{prefix}/auth/'.format(prefix=ADMIN_PREFIX)
34 response = app.get(url)
34 response = app.get(url)
35 assert response.status_code == 200
35 assert response.status_code == 200
36
36
37 def test_plugin_settings_view_get(self, app, auth_plugin):
37 def test_plugin_settings_view_get(self, app, auth_plugin):
38 url = '{prefix}/auth/{name}'.format(
38 url = '{prefix}/auth/{name}'.format(
39 prefix=ADMIN_PREFIX,
39 prefix=ADMIN_PREFIX,
40 name=auth_plugin.name)
40 name=auth_plugin.name)
41 with EnabledAuthPlugin(auth_plugin):
41 with EnabledAuthPlugin(auth_plugin):
42 response = app.get(url)
42 response = app.get(url)
43 assert response.status_code == 200
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 def test_plugin_settings_view_get_404(self, app, auth_plugin):
58 def test_plugin_settings_view_get_404(self, app, auth_plugin):
46 url = '{prefix}/auth/{name}'.format(
59 url = '{prefix}/auth/{name}'.format(
47 prefix=ADMIN_PREFIX,
60 prefix=ADMIN_PREFIX,
48 name=auth_plugin.name)
61 name=auth_plugin.name)
49 with DisabledAuthPlugin(auth_plugin):
62 with DisabledAuthPlugin(auth_plugin):
50 response = app.get(url, status=404)
63 response = app.get(url, status=404)
51 assert response.status_code == 404
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