add login-logout functionality

This commit is contained in:
2025-02-26 13:28:54 +01:00
parent 7affec30ae
commit ffbe63d1a5
5 changed files with 209 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import pytest
from delta_barth.api import common
from delta_barth.constants import HTTP_CONTENT_HEADERS
from delta_barth.errors import UnspecifiedRequestType
from delta_barth.types import HttpRequestTypes
@@ -54,3 +55,32 @@ def test_ping(api_base_url):
with pytest.raises(UnspecifiedRequestType):
resp = common.ping(api_base_url, HttpRequestTypes.POST)
@pytest.mark.api_con_required
def test_login_logout(credentials, api_base_url):
assert HTTP_CONTENT_HEADERS.session_token is None
resp = common.login(
base_url=api_base_url,
user_name=credentials["user"],
password=credentials["pwd"],
database=credentials["db"],
mandant=credentials["mandant"],
)
assert resp.error is None
assert HTTP_CONTENT_HEADERS.session_token is not None
resp = common.logout(
base_url=api_base_url,
)
assert HTTP_CONTENT_HEADERS.session_token is None
assert "DelecoToken" not in HTTP_CONTENT_HEADERS
resp = common.login(
base_url=api_base_url,
user_name=credentials["user"],
password="WRONG_PASSWORD",
database=credentials["db"],
mandant=credentials["mandant"],
)
assert resp.error is not None
assert resp.error.status_code == 409
assert resp.error.message == "Nutzer oder Passwort falsch."