##// END OF EJS Templates
try to shutdown at the end of every notebook run...
try to shutdown at the end of every notebook run this line causes noise in the test suite, but if we just ignore it, we'll never get to the bottom of it. It seems to only happen when running 'iptest js', and *not* when running the 'casperjs test' command directly, with a notebookserver that was launched manually.

File last commit:

r13182:dd161051
r13288:f4ebc6b7
Show More
test_files.py
51 lines | 1.5 KiB | text/x-python | PythonLexer
MinRK
test /files/ gives 403 on hidden files
r13175 # coding: utf-8
"""Test the /files/ handler."""
import io
import os
from unicodedata import normalize
pjoin = os.path.join
import requests
from IPython.html.utils import url_path_join
from .launchnotebook import NotebookTestBase
from IPython.utils import py3compat
class FilesTest(NotebookTestBase):
def test_hidden_files(self):
not_hidden = [
u'å b',
pjoin(u'å b/ç. d')
]
hidden = [
u'.å b',
pjoin(u'å b/.ç d')
]
dirs = not_hidden + hidden
nbdir = self.notebook_dir.name
for d in dirs:
MinRK
s/os.path.sep/os.sep/
r13182 path = pjoin(nbdir, d.replace('/', os.sep))
MinRK
test /files/ gives 403 on hidden files
r13175 if not os.path.exists(path):
os.mkdir(path)
MinRK
Windows testing fixes
r13178 with open(pjoin(path, 'foo'), 'w') as f:
f.write('foo')
with open(pjoin(path, '.foo'), 'w') as f:
f.write('.foo')
MinRK
test /files/ gives 403 on hidden files
r13175 url = self.base_url()
for d in not_hidden:
MinRK
s/os.path.sep/os.sep/
r13182 path = pjoin(nbdir, d.replace('/', os.sep))
MinRK
test /files/ gives 403 on hidden files
r13175 r = requests.get(url_path_join(url, 'files', d, 'foo'))
r.raise_for_status()
MinRK
py3k bytes, for crying out loud
r13181 self.assertEqual(r.content, b'foo')
MinRK
test /files/ gives 403 on hidden files
r13175 r = requests.get(url_path_join(url, 'files', d, '.foo'))
self.assertEqual(r.status_code, 403)
for d in hidden:
MinRK
s/os.path.sep/os.sep/
r13182 path = pjoin(nbdir, d.replace('/', os.sep))
MinRK
test /files/ gives 403 on hidden files
r13175 for foo in ('foo', '.foo'):
r = requests.get(url_path_join(url, 'files', d, foo))
self.assertEqual(r.status_code, 403)