2017-03-06 17:47:56 -06:00
|
|
|
#
|
|
|
|
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
|
|
|
|
#
|
|
|
|
|
|
|
|
"""
|
|
|
|
Test the `session_storage.py` module.
|
|
|
|
"""
|
2017-03-31 03:53:59 -05:00
|
|
|
import pytest
|
|
|
|
|
2017-03-06 17:47:56 -06:00
|
|
|
from ipapython import session_storage
|
|
|
|
|
|
|
|
|
2017-03-31 03:53:59 -05:00
|
|
|
@pytest.mark.skip_ipaclient_unittest
|
2017-12-11 00:48:13 -06:00
|
|
|
@pytest.mark.needs_ipaapi
|
2018-09-26 04:59:50 -05:00
|
|
|
class test_session_storage:
|
2017-03-06 17:47:56 -06:00
|
|
|
"""
|
|
|
|
Test the session storage interface
|
|
|
|
"""
|
|
|
|
|
2019-06-20 09:14:02 -05:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def session_storage_setup(self):
|
2017-03-06 17:47:56 -06:00
|
|
|
# TODO: set up test user and kinit to it
|
|
|
|
# tmpdir = tempfile.mkdtemp(prefix = "tmp-")
|
|
|
|
# os.environ['KRB5CCNAME'] = 'FILE:%s/ccache' % tmpdir
|
|
|
|
self.principal = 'admin'
|
|
|
|
self.key = 'X-IPA-test-session-storage'
|
2017-06-19 12:11:10 -05:00
|
|
|
self.data = b'Test Data'
|
2017-03-06 17:47:56 -06:00
|
|
|
|
|
|
|
def test_01(self):
|
|
|
|
session_storage.store_data(self.principal, self.key, self.data)
|
|
|
|
|
|
|
|
def test_02(self):
|
|
|
|
data = session_storage.get_data(self.principal, self.key)
|
|
|
|
assert(data == self.data)
|
|
|
|
|
|
|
|
def test_03(self):
|
|
|
|
session_storage.remove_data(self.principal, self.key)
|
|
|
|
try:
|
|
|
|
session_storage.get_data(self.principal, self.key)
|
|
|
|
except session_storage.KRB5Error:
|
|
|
|
pass
|