-
Notifications
You must be signed in to change notification settings - Fork 2k
/
test_util.py
45 lines (37 loc) · 1.25 KB
/
test_util.py
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
# encoding: utf-8
from nose.tools import assert_equal
from pylons.test import pylonsapp
import paste.fixture
from routes import url_for as url_for
import ckan.tests.helpers as helpers
class TestUtil(helpers.FunctionalTestBase):
def test_redirect_ok(self):
app = self._get_test_app()
response = app.get(
url=url_for(controller='util', action='redirect'),
params={'url': '/dataset'},
status=302,
)
assert_equal(response.headers.get('Location'),
'http://test.ckan.net/dataset')
def test_redirect_external(self):
app = self._get_test_app()
response = app.get(
url=url_for(controller='util', action='redirect'),
params={'url': 'http://nastysite.com'},
status=403,
)
def test_redirect_no_params(self):
app = self._get_test_app()
response = app.get(
url=url_for(controller='util', action='redirect'),
params={},
status=400,
)
def test_redirect_no_params_2(self):
app = self._get_test_app()
response = app.get(
url=url_for(controller='util', action='redirect'),
params={'url': ''},
status=400,
)