##// END OF EJS Templates
test 'files/' redirects...
MinRK -
Show More
@@ -17,11 +17,11 b' class FilesTest(NotebookTestBase):'
17 def test_hidden_files(self):
17 def test_hidden_files(self):
18 not_hidden = [
18 not_hidden = [
19 u'å b',
19 u'å b',
20 pjoin(u'å b/ç. d')
20 u'å b/ç. d',
21 ]
21 ]
22 hidden = [
22 hidden = [
23 u'.å b',
23 u'.å b',
24 pjoin(u'å b/.ç d')
24 u'å b/.ç d',
25 ]
25 ]
26 dirs = not_hidden + hidden
26 dirs = not_hidden + hidden
27
27
@@ -49,3 +49,37 b' class FilesTest(NotebookTestBase):'
49 for foo in ('foo', '.foo'):
49 for foo in ('foo', '.foo'):
50 r = requests.get(url_path_join(url, 'files', d, foo))
50 r = requests.get(url_path_join(url, 'files', d, foo))
51 self.assertEqual(r.status_code, 403)
51 self.assertEqual(r.status_code, 403)
52
53 def test_old_files_redirect(self):
54 """pre-2.0 'files/' prefixed links are properly redirected"""
55 nbdir = self.notebook_dir.name
56 base = self.base_url()
57
58 os.mkdir(pjoin(nbdir, 'files'))
59 os.makedirs(pjoin(nbdir, 'sub', 'files'))
60
61 for prefix in ('', 'sub'):
62 with open(pjoin(nbdir, prefix, 'files', 'f1.txt'), 'w') as f:
63 f.write(prefix + '/files/f1')
64 with open(pjoin(nbdir, prefix, 'files', 'f2.txt'), 'w') as f:
65 f.write(prefix + '/files/f2')
66 with open(pjoin(nbdir, prefix, 'f2.txt'), 'w') as f:
67 f.write(prefix + '/f2')
68 with open(pjoin(nbdir, prefix, 'f3.txt'), 'w') as f:
69 f.write(prefix + '/f3')
70
71 url = url_path_join(base, 'notebooks', prefix, 'files', 'f1.txt')
72 r = requests.get(url)
73 self.assertEqual(r.status_code, 200)
74 self.assertEqual(r.content, prefix + '/files/f1')
75
76 url = url_path_join(base, 'notebooks', prefix, 'files', 'f2.txt')
77 r = requests.get(url)
78 self.assertEqual(r.status_code, 200)
79 self.assertEqual(r.content, prefix + '/files/f2')
80
81 url = url_path_join(base, 'notebooks', prefix, 'files', 'f3.txt')
82 r = requests.get(url)
83 self.assertEqual(r.status_code, 200)
84 self.assertEqual(r.content, prefix + '/f3')
85
General Comments 0
You need to be logged in to leave comments. Login now