Verified Commit 7ed75d64 authored by Huste, Tobias (FWCC) - 111645's avatar Huste, Tobias (FWCC) - 111645
Browse files

setup: pin SQLAlchemy-Continuum to < 1.3.5

this version introduces a bug when unit testing the application.
See https://github.com/kvesteri/sqlalchemy-continuum/issues/188 for
details.

use http protocol instead of https when mocking with httpretty. Test
fail beginning with version 0.9.5 of httpretty
parent 2802ce4e
Pipeline #4939 failed with stage
in 28 minutes and 38 seconds
......@@ -73,7 +73,7 @@ def url_validator(value):
tries to determine the filesize of the specified file.
"""
parse_result = urlparse(value)
allowed_protocols = ['https']
allowed_protocols = current_app.config['UPLOADBYURL_ALLOWED_PROTOCOLS']
# check if the used protocol scheme is allowed
if parse_result.scheme not in allowed_protocols:
raise UnsupportedProtocolError()
......
......@@ -43,6 +43,7 @@ tests_require = [
'pytest-cov>=1.8.0',
'pytest-pep8>=1.0.6',
'pytest>=2.8.0',
'SQLAlchemy-Continuum==1.3.4', # FIXME: see issue https://github.com/kvesteri/sqlalchemy-continuum/issues/188
]
extras_require = {
......
......@@ -80,6 +80,11 @@ def base_app(instance_path):
SERVER_NAME='localhost',
TESTING=True,
UPLOADBYURL_NOTIFICATION_ENABLED=False,
UPLOADBYURL_REMOTE_SERVERS={
'foo': {
'deploy_handler': 'invenio_uploadbyurl.utils:deploy_ssh_key',
}
},
UPLOADBYURL_REDISSTORE_URL=os.getenv('UPLOADBYURL_REDISSTORE_URL',
'redis://localhost:6379/0'),
UPLOADBYURL_TIMEOUT=30,
......@@ -90,6 +95,14 @@ def base_app(instance_path):
FlaskCeleryExt(app_)
InvenioDB(app_)
InvenioRecords(app_)
InvenioAccounts(app_)
InvenioAccess(app_)
InvenioAssets(app_)
InvenioCache(app_)
InvenioFilesREST(app_)
InvenioMail(app_)
app_.register_blueprint(accounts_blueprint)
app_.register_blueprint(files_rest_blueprint)
Menu(app_)
......@@ -99,22 +112,6 @@ def base_app(instance_path):
@pytest.yield_fixture()
def app(base_app):
"""Flask application fixture."""
base_app.config.update(
UPLOADBYURL_REMOTE_SERVERS={
'foo': {
'deploy_handler': 'invenio_uploadbyurl.utils:deploy_ssh_key',
}
}
)
InvenioAccounts(base_app)
InvenioAccess(base_app)
InvenioAssets(base_app)
InvenioCache(base_app)
InvenioFilesREST(base_app)
InvenioMail(base_app)
base_app.register_blueprint(accounts_blueprint)
base_app.register_blueprint(files_rest_blueprint)
InvenioUploadByURL(base_app)
base_app.register_blueprint(blueprint)
with base_app.app_context():
......
......@@ -74,7 +74,7 @@ def test_get_api(mock_asyncresult, client, bucket, user):
assert resp.status_code == 200
def test_post_api(client, bucket, user, db):
def test_post_api(app, client, bucket, user, db):
"""Test post request."""
login_user(client, user)
url = url_for('invenio_uploadbyurl.uploadbyurl_api',
......@@ -124,6 +124,11 @@ def test_post_api(client, bucket, user, db):
assert (b'An error occured while connecting to the specified URL.'
in resp.data)
# update allowed protocols in order to not use https
app.config.update(
UPLOADBYURL_ALLOWED_PROTOCOLS=['http', 'https']
)
# set max file size of bucket
bucket.quota_size = 1500
db.session.add(bucket)
......@@ -131,7 +136,7 @@ def test_post_api(client, bucket, user, db):
httpretty.register_uri(
httpretty.HEAD,
'https://test.de/test.zip',
'http://test.de/test.zip',
body='a'*1500,
adding_headers={
'Content-Length': '1500',
......@@ -140,7 +145,7 @@ def test_post_api(client, bucket, user, db):
)
httpretty.register_uri(
httpretty.HEAD,
'https://test.de/test.zip',
'http://test.de/test.zip',
body='a'*1500,
adding_headers={
'Content-Length': '1500',
......@@ -151,7 +156,7 @@ def test_post_api(client, bucket, user, db):
with httpretty.enabled():
url = url_for('invenio_uploadbyurl.uploadbyurl_api',
bucket_id=bucket.id,
url="https://test.de/test.zip",
url="http://test.de/test.zip",
key="test.zip")
resp = client.post(url)
assert resp.status_code == 400
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment