Skip to content
Snippets Groups Projects
Verified Commit e15a74fc authored by Daniel Hornung's avatar Daniel Hornung
Browse files

DOC: More documentation, using modern imports.

parent ff08db61
No related branches found
No related tags found
No related merge requests found
Pipeline #58113 passed
...@@ -17,13 +17,14 @@ CaosDB project. ...@@ -17,13 +17,14 @@ CaosDB project.
which points to the `resources` directory here in the pyinttest repository. You can create a which points to the `resources` directory here in the pyinttest repository. You can create a
symlink like that with the following command (adapt paths to match your setting): symlink like that with the following command (adapt paths to match your setting):
`custom$ ln -s ../../../../caosdb-pyinttest/resources debug-scripting-bin` `custom$ ln -s ../../../../caosdb-pyinttest/resources debug-scripting-bin`
- Modify `pycaosdb.ini.template` and save it as `pycaosdb.ini`, taking care of the following points: - Modify `pylinkahead.ini.template` and save it as `pylinkahead.ini`, taking care of the following points:
- Certificates must be valid and be specified in `pycaosdb.ini`. - Certificates must be valid and be specified in `pylinkahead.ini`.
- Server-side scripting paths must be given, otherwise server-side scripting will be omitted. - Server-side scripting paths must be given, otherwise server-side scripting will be omitted.
- The local path `test_server_side_scripting.bin_dir.local` should point to a - The *local* path `test_server_side_scripting.bin_dir.local` should point to the
`linkahead-server/scripting/bin` somwhere. `linkahead-server/scripting/bin` directory in linkahead-server sources.
- The remote path `test_server_side_scripting.bin_dir.server` should probably be something like - The *remote* path `test_server_side_scripting.bin_dir.server` should probably be something
`/opt/caosdb/git/caosdb-server/scripting/bin-debug`. like `/opt/caosdb/git/caosdb-server/scripting/bin-debug`. This is the path as seen by the
server (in most cases inside the docker container).
- Paths for the file tests must exist, or be creatable by the testing script and the server. - Paths for the file tests must exist, or be creatable by the testing script and the server.
- Run the tests with `pytest` or `pytest-3` (depending on your system). - Run the tests with `pytest` or `pytest-3` (depending on your system).
- If you want to run just a single test, you can also select a single test file: - If you want to run just a single test, you can also select a single test file:
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# ** header v3.0 # ** header v3.0
# This file is a part of the CaosDB Project. # This file is a part of the LinkAhead Project.
# #
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
...@@ -33,13 +33,13 @@ import ssl ...@@ -33,13 +33,13 @@ import ssl
import tempfile import tempfile
from http.client import HTTPSConnection from http.client import HTTPSConnection
from caosdb import Info, RecordType from linkahead import Info, RecordType
from caosdb import administration as admin from linkahead import administration as admin
from caosdb import execute_query, get_config, get_connection from linkahead import execute_query, get_config, get_connection
from caosdb.connection.encode import MultipartParam, multipart_encode from linkahead.connection.encode import MultipartParam, multipart_encode
from caosdb.connection.utils import urlencode, urlparse from linkahead.connection.utils import urlencode, urlparse
from caosdb.exceptions import HTTPClientError, HTTPResourceNotFoundError from linkahead.exceptions import HTTPClientError, HTTPResourceNotFoundError
from caosdb.utils.server_side_scripting import run_server_side_script from linkahead.utils.server_side_scripting import run_server_side_script
from lxml import etree from lxml import etree
from pytest import mark, raises from pytest import mark, raises
...@@ -142,6 +142,29 @@ def teardown_module(): ...@@ -142,6 +142,29 @@ def teardown_module():
clean_database() clean_database()
def request(method, headers, path, body=None):
"""Connect without auth-token.
This is clumsy because the pylib is not intended to be used as anonymous user.
"""
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.verify_mode = ssl.CERT_REQUIRED
if hasattr(context, "check_hostname"):
context.check_hostname = True
context.load_verify_locations(get_config().get("Connection", "cacert"))
url = get_config().get("Connection", "url")
fullurl = urlparse(url)
http_con = HTTPSConnection(
str(fullurl.netloc), timeout=200, context=context)
http_con.request(method=method, headers=headers, url=str(fullurl.path) +
path, body=body)
return http_con.getresponse()
def test_call_script_non_existing(): def test_call_script_non_existing():
form = dict() form = dict()
form["call"] = "non_existing_script" form["call"] = "non_existing_script"
...@@ -355,28 +378,6 @@ def test_call_as_anonymous_with_administration_role(): ...@@ -355,28 +378,6 @@ def test_call_as_anonymous_with_administration_role():
assert "exception" not in diagnostics["caosdb"] assert "exception" not in diagnostics["caosdb"]
def request(method, headers, path, body=None):
""" Connect without auth-token. This is clumsy, bc the pylib is not
intended to be used as anonymous user.
"""
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.verify_mode = ssl.CERT_REQUIRED
if hasattr(context, "check_hostname"):
context.check_hostname = True
context.load_verify_locations(get_config().get("Connection", "cacert"))
url = get_config().get("Connection", "url")
fullurl = urlparse(url)
http_con = HTTPSConnection(
str(fullurl.netloc), timeout=200, context=context)
http_con.request(method=method, headers=headers, url=str(fullurl.path) +
path, body=body)
return http_con.getresponse()
def test_anonymous_script_calling_not_permitted(): def test_anonymous_script_calling_not_permitted():
form = dict() form = dict()
form["call"] = "ok" form["call"] = "ok"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment