Compare commits
1 Commits
2db018a93e
...
d7127244be
Author | SHA1 | Date |
---|---|---|
Sebastian Lohff | d7127244be |
1
setup.py
1
setup.py
|
@ -12,6 +12,7 @@ setup(
|
||||||
url='http://seba-geek.de/stuff/servefile/',
|
url='http://seba-geek.de/stuff/servefile/',
|
||||||
author='Sebastian Lohff',
|
author='Sebastian Lohff',
|
||||||
author_email='seba@someserver.de',
|
author_email='seba@someserver.de',
|
||||||
|
install_requires=['pyopenssl'],
|
||||||
scripts=['servefile'],
|
scripts=['servefile'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import urllib3
|
||||||
|
|
||||||
# crudly written to learn more about pytest and to have a base for refactoring
|
# crudly written to learn more about pytest and to have a base for refactoring
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def run_servefile():
|
def run_servefile():
|
||||||
instances = []
|
instances = []
|
||||||
|
@ -17,7 +18,7 @@ def run_servefile():
|
||||||
args = [args]
|
args = [args]
|
||||||
print("running with args", args)
|
print("running with args", args)
|
||||||
p = subprocess.Popen(['servefile'] + args, **kwargs)
|
p = subprocess.Popen(['servefile'] + args, **kwargs)
|
||||||
time.sleep(kwargs.get('timeout', 0.1))
|
time.sleep(kwargs.get('timeout', 0.3))
|
||||||
instances.append(p)
|
instances.append(p)
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
@ -171,6 +172,7 @@ def test_serve_directory(run_servefile, datadir):
|
||||||
# download
|
# download
|
||||||
check_download('jup!', '/bar/thisisaverylongfilenamefortestingthatthisstillworksproperly')
|
check_download('jup!', '/bar/thisisaverylongfilenamefortestingthatthisstillworksproperly')
|
||||||
|
|
||||||
|
|
||||||
def test_upload(run_servefile, tmp_path):
|
def test_upload(run_servefile, tmp_path):
|
||||||
data = ('this is my live now\n'
|
data = ('this is my live now\n'
|
||||||
'uploading strings to servers\n'
|
'uploading strings to servers\n'
|
||||||
|
@ -207,17 +209,21 @@ def test_upload(run_servefile, tmp_path):
|
||||||
|
|
||||||
def test_upload_size_limit(run_servefile, tmp_path):
|
def test_upload_size_limit(run_servefile, tmp_path):
|
||||||
uploaddir = tmp_path / 'upload'
|
uploaddir = tmp_path / 'upload'
|
||||||
run_servefile(['-s', '2kb''-u', str(uploaddir)])
|
run_servefile(['-s', '2kb', '-u', str(uploaddir)])
|
||||||
|
|
||||||
# upload file that is too big
|
# upload file that is too big
|
||||||
files = {'file': ('toobig', "x" * 2049)}
|
files = {'file': ('toobig', "x" * 2049)}
|
||||||
r = make_request(method='post', files=files)
|
r = make_request(method='post', files=files)
|
||||||
assert 'Your file was too big' in r.text
|
assert 'Your file was too big' in r.text
|
||||||
assert r.status_code == 200
|
assert r.status_code == 413
|
||||||
assert not (uploaddir / 'toobig').exists()
|
assert not (uploaddir / 'toobig').exists()
|
||||||
|
|
||||||
# upload file that should fit
|
# upload file that should fit
|
||||||
assert False
|
# the size has to be smaller than 2kb, as the sent size also includes mime-headers
|
||||||
|
files = {'file': ('justright', "x" * 1900)}
|
||||||
|
r = make_request(method='post', files=files)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def test_tar_mode(run_servefile, datadir):
|
def test_tar_mode(run_servefile, datadir):
|
||||||
d = {
|
d = {
|
||||||
|
@ -246,10 +252,12 @@ def test_tar_mode(run_servefile, datadir):
|
||||||
def test_tar_compression(run_servefile, datadir):
|
def test_tar_compression(run_servefile, datadir):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_https(run_servefile, datadir):
|
def test_https(run_servefile, datadir):
|
||||||
data = "NOOT NOOT"
|
data = "NOOT NOOT"
|
||||||
p = datadir({'testfile': data}) / 'testfile'
|
p = datadir({'testfile': data}) / 'testfile'
|
||||||
run_servefile(['--ssl', str(p)], stdout=subprocess.PIPE)
|
run_servefile(['--ssl', str(p)])
|
||||||
|
time.sleep(0.2) # time for generating ssl certificates
|
||||||
|
|
||||||
# fingerprint = None
|
# fingerprint = None
|
||||||
# while not fingerprint:
|
# while not fingerprint:
|
||||||
|
@ -263,7 +271,5 @@ def test_https(run_servefile, datadir):
|
||||||
# break
|
# break
|
||||||
|
|
||||||
# assert fingerprint
|
# assert fingerprint
|
||||||
|
urllib3.disable_warnings()
|
||||||
urllib3
|
check_download(data, protocol='https', verify=False)
|
||||||
check_download(protocol='https')
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue