diff --git a/tests/test_webinterface.py b/tests/test_webinterface.py new file mode 100644 index 0000000000000000000000000000000000000000..c4f622cdf2e5b4f75f800980b91775bee265c52e --- /dev/null +++ b/tests/test_webinterface.py @@ -0,0 +1,59 @@ +# encoding: utf-8 +# +# ** header v3.0 +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2019 Timm Fitschen (t.fitschen@indiscale.com) +# Copyright (C) 2019 IndiScale GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# ** end header +# +"""Created on 2019-11-12 + +@author: Timm Fitschen (t.fitschen@indiscale.com) +""" +import caosdb as c +from urllib import request +from urllib.error import HTTPError +import ssl +import re +import pytest + +def test_webinterface_version_build(): + url = c.get_config().get("Connection", "url") + + context = ssl.SSLContext() + context.verify_mode = ssl.CERT_NONE + + buildNumber = request.urlopen(url + "webinterface/version/build", + context=context).read().decode("utf8") + assert re.match(r"\d+", buildNumber) + +def test_webinterface(): + url = c.get_config().get("Connection", "url") + + context = ssl.SSLContext() + context.verify_mode = ssl.CERT_NONE + + buildNumber = request.urlopen(url + "webinterface/version/build", + context=context).read().decode("utf8") + + with pytest.raises(HTTPError) as e404: + request.urlopen(url + "webinterface/..", context=context) + assert e404.value.code == 404 + + +