summaryrefslogtreecommitdiffstats
path: root/ipatests/test_ipapython/test_session_storage.py
blob: a89fdd97e05e683ce46b485b9beb3b5b3200f09b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#
# Copyright (C) 2017  FreeIPA Contributors see COPYING for license
#

"""
Test the `session_storage.py` module.
"""

from ipapython import session_storage


class test_session_storage(object):
    """
    Test the session storage interface
    """

    def setup(self):
        # 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'
        self.data = 'Test Data'

    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