1 # GNU Mediagoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011 Free Software Foundation, Inc
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
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/>.
18 from mediagoblin
import storage
21 def test_clean_listy_filepath():
22 expected
= [u
'dir1', u
'dir2', u
'linooks.jpg']
23 assert storage
.clean_listy_filepath(
24 ['dir1', 'dir2', 'linooks.jpg']) == expected
26 expected
= [u
'dir1', u
'foo_.._nasty', u
'linooks.jpg']
27 assert storage
.clean_listy_filepath(
28 ['/dir1/', 'foo/../nasty', 'linooks.jpg']) == expected
30 expected
= [u
'etc', u
'passwd']
31 assert storage
.clean_listy_filepath(
32 ['../../../etc/', 'passwd']) == expected
35 storage
.clean_listy_filepath(
36 ['../../', 'linooks.jpg'])
37 except storage
.InvalidFilepath
:
38 # Yes, this error should be raise
41 assert "success" == "failboat"